liuyuanhang 4 anni fa
parent
commit
15d0c12ff0

+ 3 - 3
app/Helpers/functions.php

xqd
@@ -592,11 +592,11 @@ if (!function_exists('send_wechat_message_to_docter')) {
 
 // 医生端发送公众号模板消息方法
 if (!function_exists('send_wechatSubscription_message')) {
-    function send_wechatSubscription_message($type, $arr)
+    function send_wechatSubscription_message($type, $arr,$message=['wechatSubscription_template','docter_wechat_small_program'])
     {
         try {
-            $app = Factory::miniProgram(config('config.docter_wechat_small_program'));
-            $data = config('config.wechatSubscription_template')[$type];
+            $app = Factory::miniProgram(config('config.'.$message[1]));
+            $data = config('config.'.$message[0])[$type];
             $json = json_encode($data, JSON_UNESCAPED_UNICODE);
             $json = vsprintf($json, $arr);
             $data = json_decode($json, true);

+ 33 - 5
app/Http/Controllers/Api/V2/PatientController.php

xqd xqd xqd xqd xqd xqd xqd
@@ -71,7 +71,7 @@ class PatientController extends AuthController
             }
 
             if (isset($req['comStatus']) && $req['comStatus'] == '0') {
-                $comstatus = [1, 2, 3,7];
+                $comstatus = [ 2, 3,7];
                 $where[] = [function ($query) use ($comstatus) {
                     $query->whereIn('order_status', $comstatus);//处理中
                 }];
@@ -93,7 +93,7 @@ class PatientController extends AuthController
                 $where['product_type'] = 1;//电话咨询
             }
             if (isset($req['processing']) && $req['processing'] == 0) {
-                $status = [1, 2, 3];
+                $status = [2, 3];
                 $where[] = [function ($query) use ($status) {
                     $query->whereIn('order_status', $status);//处理中
                 }];
@@ -262,6 +262,7 @@ class PatientController extends AuthController
             $unlok = (new Commons())->unLokPhone($finds['xphone'], $finds['subs_id']);
             Axb::where(['subs_id' => $finds['subs_id']])->delete();
         }
+        $this->ReceivingReminderOK($find['id']);
 
         return out();
 
@@ -891,7 +892,6 @@ class PatientController extends AuthController
                     $Order['created_at'],
                     '',
                 ]);
-                var_dump($send);
             }
         }
     }
@@ -923,7 +923,7 @@ class PatientController extends AuthController
                     $type,
                     date('Y-m-d H:i',$Order['receiving_time']),
                     $Order['order_patient']['phone'],
-                ]);
+                ],['wechat_official_message_template','wechat_small_program']);
             }
         }
     }
@@ -947,7 +947,7 @@ class PatientController extends AuthController
                     $list['organization']['name'],
                     $list['docter']['name'],
                     $user['nickname'],
-                ]);
+                ],['wechat_official_message_template','wechat_small_program']);
             }
         }
     }
@@ -1058,5 +1058,33 @@ class PatientController extends AuthController
         }
     }
 
+    /**
+     * 完成订单
+     * @param $order_id
+     */
+    public function ReceivingReminderOK($order_id){
+        $Order = Order::with(['orderPatient','user'])->where(['id'=>$order_id])->first();
+        $type = '';
+        if ($Order['product_type']==1){
+            $type = '电话咨询';
+        }elseif ($Order['product_type']==2){
+            $type = '图文咨询 ';
+        }elseif ($Order['product_type']==3){
+            $type = '门诊预约';
+        }
+        if ($Order){
+            if ($Order['user']['openid']){
+                $send = send_wechatSubscription_message('receiving_reminderok',[
+                    $Order['user']['openid'],
+                    "pages/index",
+                    $Order['order_sn'],
+                    $type,
+                    date('Y-m-d H:i',$Order['receiving_time']),
+                    $Order['order_patient']['phone'],
+                ],['wechat_official_message_template','wechat_small_program']);
+            }
+        }
+    }
+
 
 }

+ 33 - 0
config/config.php

xqd
@@ -879,6 +879,39 @@ return [
                 ]
             ],
         ],
+        // 医生完成订单提醒
+        'receiving_reminderok'=>[
+            'touser' => '%s',
+            'mp_template_msg' => [
+                'appid' => env('OFFICIAL_WECHAT_APPID'),
+                'template_id' => 'grtzjXaIQNMTI-UoxY8cakzVna4q65s6qqZFbW67rIk',
+                'url' => '',
+                'miniprogram' => [
+                    'appid' => env('WECHAT_APPID', 'wx6131f74e623bf6bf'),
+                    'page' => '%s',
+                ],
+                'data' => [
+                    'first' => [
+                        'value' => '尊敬的用户,你的咨询订单服务已完成!',
+                    ]
+                    ,'keyword1' => [
+                        'value' => '%s',
+                    ],
+                    'keyword2' => [
+                        'value' => '%s',
+                    ],
+                    'keyword3' => [
+                        'value' => '%s',
+                    ],
+                    'keyword4' => [
+                        'value' => '%s',
+                    ],
+                    'remark' => [
+                        'value' => '点击进入小程序查看详情!',
+                    ],
+                ]
+            ],
+        ],
         // 消息回复提醒
         'reply_reminder'=>[
             'touser' => '%s',