zxhxx 3 anni fa
parent
commit
bfb497a25c
2 ha cambiato i file con 13 aggiunte e 1 eliminazioni
  1. 2 0
      application/api/controller/Rescue.php
  2. 11 1
      application/common/model/Sos.php

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

@@ -66,6 +66,8 @@ class Rescue extends Api
                 ['longitude',''],
                 ['rescuers_id',0],
                 ['rescuers_user_id',0],
+                ['from','wiexin'],
+                ['re_url',''],
             ],$request
         );
         if($where['rescuers_id']==0) $this->error('选择救授人员');

+ 11 - 1
application/common/model/Sos.php

@@ -3,6 +3,7 @@
 namespace app\common\model;
 
 use liuniu\BaseModel;
+use liuniu\WechatTempleService;
 use think\Exception;
 use think\Model;
 
@@ -52,9 +53,18 @@ class Sos extends BaseModel
             $res = self::create($where);
             $user_phone = User::where('id', $where['user_id'])->value('mobile');
             $rescue_phone = User::where('id', $where['rescuers_user_id'])->value('mobile');
-            $rescuers_id = Rescue::where('uid',$where['rescuers_user_id'])->value('id');
+            $rescuers_id = Rescue::where('user_id',$where['rescuers_user_id'])->value('id');
             $res1 = SosBill::income($where['cid'], $where['user_id'], $res['id'], $rescuers_id,$where['rescuers_user_id'], $where['latitude'], $where['longitude'], $user_phone, $rescue_phone,$where['address']);
             //tudo 模板信息
+            if($where['form'] == "weixin") {
+                $data['first'] = "有人向你发起求救";
+                $data['keyword1'] = $user_phone;
+                $data['keyword2'] = $where['address'];
+                $data['keyword3'] = date("Y-m-d H:i:s");
+                $data['keyword4'] = "";
+                $data['remark'] ="详细请点信息";
+                WechatTempleService::sendTemplate($where['cid'], UserRelation::userIdToOpenId('rescuers_user_id'), WechatTempleService::EMERGANCY_RESCUE,$data,$where['re_url']);
+            }
             if($res && $res1)
             {
                 self::commitTrans();