zxhxx 3 years ago
parent
commit
12b6385b43
1 changed files with 26 additions and 1 deletions
  1. 26 1
      application/api/controller/Rescue.php

+ 26 - 1
application/api/controller/Rescue.php

@@ -3,7 +3,9 @@ namespace app\api\controller;
 use app\common\controller\Api;
 use app\common\model\Sos;
 use app\common\model\SosBill;
+use app\common\model\UserRelation;
 use liuniu\UtilService;
+use liuniu\WechatTempleService;
 use think\Request;
 use \app\common\model\Rescue as RescueModel;
 class Rescue extends Api
@@ -109,12 +111,35 @@ class Rescue extends Api
             [
                 ['status',1],
                 ['process_remark',''],
+                ['from','weixin'],
+                ['re_url',''],
 
             ],$request
         );
         $where['processtime'] = time();
-
         SosBill::where('id',input('id',0))->update($where);
+        $info = SosBill::find(input('id',0));
+        switch ($where['status'])
+        {
+            case  1:
+                $temp = WechatTempleService::SUPPAORTER_REPLY;
+                $res_user = Rescue::where('user_id',$this->auth->getUserinfo()['id'])->find();
+                $data['first'] = "你发起求救已受理,救员者正在赶来";
+                $data['keyword1'] = $res_user['phone'];
+                $data['keyword2'] = $res_user['address'];
+                $data['keyword3'] = date("Y-m-d H:i:s");
+                $data['remark'] =$where['process_remark'];
+                break;
+            case 2:
+                $temp = WechatTempleService::REQUEXST_REFUSE;
+                $data['first'] = "你发起求救已拒绝";
+                $data['keyword1'] = $where['process_remark'];
+                $data['keyword2'] = date("Y-m-d H:i:s");
+                $data['keyword3'] = "求救";
+                $data['remark'] ="";
+                break;
+        }
+        WechatTempleService::sendTemplate($this->cid,UserRelation::userIdToOpenId($info['user_id']),$temp,$data,$where['re_url']);
         $this->success('处理完成');
     }
     public function sos_del(Request $request)