quguofeng 1 rok temu
rodzic
commit
e655e9c32f

+ 4 - 0
application/api/controller/User.php

@@ -235,11 +235,15 @@ class User extends Api
         if(!$apply)$this->error('数据异常');
         if($type==1){
             $apply->save(['status'=>1]);
+            //发送微信模板消息
+            Apply::wxApplyMessage($this->auth->id,$apply['uid'],Date('Y-m-d H:i:s'),'同意认识申请');
             $this->success('已同意',$apply);
         }elseif($type==2){
             $grain = $apply['grain']*0.5;
             UserModel::money($grain,$apply['uid'],'拒绝认识申请,退还狗粮');
             $apply->save(['status'=>2,'refund_grain'=>$grain]);
+            //发送微信模板消息
+            Apply::wxApplyMessage($this->auth->id,input('nid'),Date('Y-m-d H:i:s'),'拒绝认识申请');
             $this->success('已拒绝',$apply);
         }
 

+ 39 - 0
application/common/model/Apply.php

@@ -110,4 +110,43 @@ class Apply extends Model
         $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,'http://'.$_SERVER['HTTP_HOST'].$url);
     }
+    /**
+     * 微信模板消息通知(申请通过、被拒、过期)
+     */
+    public static function wxApplyMessage($uid,$nid,$time,$appeal){
+        $user_name = User::get(['id'=>$uid])['username'];
+        $user_info = User::get(['id'=>$nid]);
+        $data = [
+            'thing7'=>[
+                'value'=>$user_name
+            ],
+            'time4'=>[
+                'value'=>$time
+            ],
+            'thing3'=>[
+                'value'=>$appeal
+            ],
+        ];
+        (new \app\api\controller\Common())->sendWechatMessage($user_info['open_id'],'VJNwruW2tQp4bG0K1gg_-HJ4vaougj6fELLED2OYcrI',$data,'http://'.$_SERVER['HTTP_HOST'].'/h5/#/pages/xiaoxi/my-shenqing');
+    }
+    /**
+     * 微信模板消息通知(申请认识)
+     */
+    public static function wxKnowMessage($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,'http://'.$_SERVER['HTTP_HOST'].$url);
+    }
 }