liuyuanhang 4 лет назад
Родитель
Сommit
a13c166407
3 измененных файлов с 39 добавлено и 29 удалено
  1. 3 3
      app/Helpers/functions.php
  2. 35 25
      app/Http/Controllers/Api/V2/PatientController.php
  3. 1 1
      config/config.php

+ 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,$message=['wechatSubscription_template','docter_wechat_small_program'])
+    function send_wechatSubscription_message($type, $arr,$message='docter_wechat_small_program')
     {
         try {
-            $app = Factory::miniProgram(config('config.'.$message[1]));
-            $data = config('config.'.$message[0])[$type];
+            $app = Factory::miniProgram(config('config.'.$message));
+            $data = config('config.wechatSubscription_template')[$type];
             $json = json_encode($data, JSON_UNESCAPED_UNICODE);
             $json = vsprintf($json, $arr);
             $data = json_decode($json, true);

+ 35 - 25
app/Http/Controllers/Api/V2/PatientController.php

xqd xqd xqd xqd xqd xqd xqd xqd xqd xqd
@@ -253,6 +253,8 @@ class PatientController extends AuthController
             DB::rollBack();
             return out('', 500, $e->getMessage());
         }
+        $this->ReceivingReminderOK($find['id']);
+
 
         $axbwhere['docter_id'] = $user['id'];
         $axbwhere['user_id'] = $find['user_id'];
@@ -262,7 +264,6 @@ 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();
 
@@ -750,14 +751,17 @@ class PatientController extends AuthController
             if ($v['product_type']==1){
                 if ((time()-$v['receiving_time'])>=$config_chat){
                     $catNewIds[$k] = $v['id'];
+                    $this->ReceivingReminderOK($v['id']);
                 }
             }else if($v['product_type']==2){
                 if ((time()-$v['receiving_time'])>=$config_phone){
                     $catNewIds[$k] = $v['id'];
+                    $this->ReceivingReminderOK($v['id']);
                 }
             }else if($v['product_type']==3){
                 if ((time()-$v['receiving_time'])>=(1*60*60*24)){
                     $menNewIds[$k] = $v['id'];
+                    $this->AppointReminder($v['id']);
                 }
             }
 
@@ -849,18 +853,24 @@ class PatientController extends AuthController
     /**
      * 	确认超时提醒 当天的预约订单,医生还未点击完成的订单,23:00给医生发送提醒
      */
-    public function AppointReminder(){
-
-        $beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
-        $endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
-        $Order = Order::with(['orderPatient','docter','user'])->where(['order_status'=>3,'payment_status'=>2,'product_type'=>3])->whereBetween('receiving_time',[$beginToday,$endToday])->get();
-        foreach ($Order as $k=>$v){
-            if ($v['docter']){
-                if ($v['docter']['openid']){
-                    $send = send_wechatSubscription_message('appoint_reminder',[$v['docter']['openid'], "pages/index/index",$v['order_sn'],$v['user']['nickname'],$v['user']['phone'],$v['created_at']]);
+    public function AppointReminder($id=''){
+        if (!empty($id)){
+            $Order = Order::with(['orderPatient','docter','user'])->where(['id'=>$id,'order_status'=>3,'payment_status'=>2])->first();
+            $send = send_wechatSubscription_message('appoint_reminder',[$Order['docter']['openid'], "pages/index/index",$Order['order_sn'],$Order['user']['nickname'],$Order['user']['phone'],$Order['created_at']]);
+        }else{
+            $beginToday=mktime(0,0,0,date('m'),date('d'),date('Y'));
+            $endToday=mktime(0,0,0,date('m'),date('d')+1,date('Y'))-1;
+            $Order = Order::with(['orderPatient','docter','user'])->where(['order_status'=>3,'payment_status'=>2,'product_type'=>3])->whereBetween('receiving_time',[$beginToday,$endToday])->get();
+            foreach ($Order as $k=>$v){
+                if ($v['docter']){
+                    if ($v['docter']['openid']){
+                        $send = send_wechatSubscription_message('appoint_reminder',[$v['docter']['openid'], "pages/index/index",$v['order_sn'],$v['user']['nickname'],$v['user']['phone'],$v['created_at']]);
+                    }
                 }
             }
         }
+
+
     }
 
     /**
@@ -891,7 +901,7 @@ class PatientController extends AuthController
                     $type,
                     $Order['total_amount'],
                     $Order['created_at'],
-                    '',
+                    '医生取消订单',
                 ]);
             }
         }
@@ -924,7 +934,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']);
+                ],'wechat_small_program');
             }
         }
     }
@@ -948,7 +958,7 @@ class PatientController extends AuthController
                     $list['organization']['name'],
                     $list['docter']['name'],
                     $user['nickname'],
-                ],['wechat_official_message_template','wechat_small_program']);
+                ],'wechat_small_program');
             }
         }
     }
@@ -973,7 +983,7 @@ class PatientController extends AuthController
         }
         if ($list){
             if ($openid){
-                $send = send_wechatSubscription_message('schedule_reminder',[$openid,  "pages/index/index", $type, 'A社区']);
+                $send = send_wechatSubscription_message('schedule_reminder',[$openid,  "pages/index/index", $type, '社区']);
             }
         }
     }
@@ -1035,25 +1045,25 @@ class PatientController extends AuthController
 
 
     /**
-     * 明日预约提醒(未完成)
+     * 明日预约提醒  8点跑定时
      * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
      * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
      * @throws \GuzzleHttp\Exception\GuzzleException
      */
     public function TodayReminder(){
-        $list = DocterOrganization::with('docter','organization')->get();
+        $list = Order::with('docter','orderPatient','organization')->get();
         if($list){
             foreach ($list as $k=>$v){
-                if ($v['docter']['openid']&& time()>=strtotime($v['authentication_end_time'])){
-                    $send = send_wechatSubscription_message('schedule_reminder', [
-                        '医生id',
+                if ($v['docter']['openid']&& date('Y-m-d',$v['order_patient']['appoint_start_time'])==date("Y-m-d",strtotime("+1 day"))){
+                    $send = send_wechatSubscription_message('today_reminder', [
+                        $v['docter']['openid'],
                         "pages/index/index",
-                        '小刘',
-                        '类型',
-                        '人数',
-                        '医院',
+                        $v['docter']['name'],
+                        date("Y-m-d",strtotime("+1 day")),
+                        "门诊预约",
+                        count($list),
+                        !empty($v['organization']['name'])?$v['organization']['name']:'',
                     ]);
-
                 }
             }
         }
@@ -1082,7 +1092,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']);
+                ],'wechat_small_program');
             }
         }
     }

+ 1 - 1
config/config.php

xqd
@@ -958,7 +958,7 @@ return [
                         'value' => '尊敬的%s,您明天有新的门诊预约订单待处理!',
                     ]
                     ,'keyword1' => [
-                        'value' => '签约失效提醒',
+                        'value' => '%s',
                     ],
                     'keyword2' => [
                         'value' => '%s',