quguofeng 1 year ago
parent
commit
1f954867ff
2 changed files with 22 additions and 9 deletions
  1. 2 0
      application/api/controller/Index.php
  2. 20 9
      application/common/model/Apply.php

+ 2 - 0
application/api/controller/Index.php

@@ -345,6 +345,8 @@ class Index extends Api
                     ];
                     LikeMutually::create($like_mutually2);
                 }
+                //发送微信模板消息
+                Apply::wxUnlockMessage($uid,input('id'),Date('Y-m-d H:i:s'),'喜欢你',2);
                 $this->success('已喜欢');
             }else{
                 $this->error('系统异常');

+ 20 - 9
application/common/model/Apply.php

@@ -90,13 +90,24 @@ class Apply extends Model
         ];
         (new \app\api\controller\Common())->sendWechatMessage($user_info['open_id'],'KOWDFd4MsuxROCPCLNZF5k5LHzM_-o-WoEI2NpfQYx0',$data,'https://'.$_SERVER['HTTP_HOST'].'/h5/#/pages/xiaoxi/look-me');
     }
-
-
-
-
-
-
-
-
-
+    /**
+     * 微信模板消息通知(喜欢我,解锁照片,解锁资料)$url_type(1:解锁照片/资料,2:喜欢)
+     */
+    public static function wxUnlockMessage($uid,$nid,$time,$appeal,$url_type){
+        $user_name = User::get(['id'=>$uid])['username'];
+        $user_info = User::get(['id'=>$nid]);
+        $data = [
+            'thing2'=>[
+                'value'=>$user_name
+            ],
+            'time8'=>[
+                'value'=>$time
+            ],
+            'phrase10'=>[
+                'value'=>$appeal
+            ],
+        ];
+        $url = $url_type == 1?'/h5/#/pages/xiaoxi/look-me':'/h5/#/pages/xiaoxi/like-me';
+        (new \app\api\controller\Common())->sendWechatMessage($user_info['open_id'],'VJNwruW2tQp4bG0K1gg_-HJ4vaougj6fELLED2OYcrI',$data,'https://'.$_SERVER['HTTP_HOST'].$url);
+    }
 }