| xqd
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
|
|
+use App\Http\Controllers\Api\V2\PatientController;
|
|
|
use App\Models\DocterOrganization;
|
|
|
use App\Models\Order;
|
|
|
use App\Models\SystemConfig;
|
| xqd
@@ -47,7 +48,7 @@ class overTimeOrder extends Command
|
|
|
}
|
|
|
if($type == 'orderOut'){
|
|
|
//订单超时
|
|
|
- $this->overTimeOrers();
|
|
|
+ $this->clinicOverTimeOrders();
|
|
|
dd('订单超时检查执行时间'.date('Y-m-d H:i:s'));
|
|
|
} else if($type == 'appiontOut'){
|
|
|
//预约超时
|
| xqd
@@ -61,32 +62,44 @@ class overTimeOrder extends Command
|
|
|
} else if($type == 'orderCancel'){
|
|
|
$this->orderCancel();
|
|
|
dd('订单接单超时检查执行时间'.date('Y-m-d H:i:s'));
|
|
|
+ }else if ($type = 'orderComplete'){
|
|
|
+ // 图文||电话订单自动完成
|
|
|
+ $this->timeOrdersComplete();
|
|
|
+ }else if ($type = "todayReminder"){
|
|
|
+ // 明日预约提醒
|
|
|
+ $this->TodayReminder();
|
|
|
}
|
|
|
dd('ok');
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 确认超时提醒 当天的预约订单,医生还未点击完成的订单,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']]);
|
|
|
+ * Notes:确认超时提醒 当天的预约订单,医生还未点击完成的订单,23:00给医生发送提醒
|
|
|
+ * Author: 白猫!
|
|
|
+ * DateTime: 2021/3/4 17:45
|
|
|
+ * @param array $params
|
|
|
+ */
|
|
|
+ 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']]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 签约失效提醒
|
|
|
- * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
|
|
- * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
|
- * @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
+ * Notes:签约失效提醒
|
|
|
+ * Author: 白猫!
|
|
|
+ * DateTime: 2021/3/4 17:59
|
|
|
*/
|
|
|
public function InvalidThenReminder(){
|
|
|
$list = DocterOrganization::with('docter','organization')->get();
|
| xqd
@@ -102,10 +115,9 @@ class overTimeOrder extends Command
|
|
|
|
|
|
|
|
|
/**
|
|
|
- * 认证到期提醒
|
|
|
- * @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
|
|
- * @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
|
|
- * @throws \GuzzleHttp\Exception\GuzzleException
|
|
|
+ * Notes: 认证到期提醒
|
|
|
+ * Author: 白猫!
|
|
|
+ * DateTime: 2021/3/4 18:00
|
|
|
*/
|
|
|
public function OutThenReminder(){
|
|
|
$list = DocterOrganization::with('docter','organization')->get();
|
| xqd
@@ -119,42 +131,88 @@ class overTimeOrder extends Command
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 有医生接单的情况
|
|
|
- * 订单超时自动完成 电话 图文 门诊(定时)
|
|
|
+ * Notes:明日预约提醒 (定时)
|
|
|
+ * Author: 白猫!
|
|
|
+ * DateTime: 2021/3/4 17:54
|
|
|
+ */
|
|
|
+ public function TodayReminder(){
|
|
|
+ $list = Order::with('docter','orderPatient','organization')->get();
|
|
|
+ if($list){
|
|
|
+ foreach ($list as $k=>$v){
|
|
|
+ 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']:'',
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Notes:图文电话超时自动完成!
|
|
|
+ * Author: 白猫!
|
|
|
+ * DateTime: 2021/3/4 17:44
|
|
|
*/
|
|
|
- public function overTimeOrers(){
|
|
|
+ public function timeOrdersComplete(){
|
|
|
+// $user = $this->user;
|
|
|
+// $docter_id = $user['id'];
|
|
|
+ $patient = new PatientController();
|
|
|
$config_chat = SystemConfig::get('docter_config','chat_complete_time');
|
|
|
$config_phone = SystemConfig::get('docter_config','phone_complete_time');
|
|
|
-
|
|
|
// 换算为秒
|
|
|
- $config_chat = intval($config_chat)*60;
|
|
|
- $config_phone = intval($config_phone)*60;
|
|
|
-
|
|
|
+ $config_chat = $config_chat*60;
|
|
|
+ $config_phone = $config_phone*60;
|
|
|
$inOrder = Order::with('orderPatient')->where(['order_status'=>3,'payment_status'=>2])->get();
|
|
|
$catNewIds = [];
|
|
|
- $menNewIds = [];
|
|
|
foreach ($inOrder as $k=>$v){
|
|
|
-
|
|
|
if ($v['product_type']==1){
|
|
|
- if ((time()-intval($v['receiving_time']))>=$config_phone){
|
|
|
+ if ((time()-$v['receiving_time'])>=$config_chat){
|
|
|
$catNewIds[$k] = $v['id'];
|
|
|
+ $patient->ReceivingReminderOK($v['id']);
|
|
|
}
|
|
|
}else if($v['product_type']==2){
|
|
|
- if ((time()-$v['receiving_time'])>=$config_chat){
|
|
|
- echo $v->order_sn.PHP_EOL;
|
|
|
+ if ((time()-$v['receiving_time'])>=$config_phone){
|
|
|
$catNewIds[$k] = $v['id'];
|
|
|
- }
|
|
|
- }else if($v['product_type']==3){
|
|
|
- if ((time()-$v['receiving_time'])>=(1*60*60*24)){
|
|
|
- $menNewIds[$k] = $v['id'];
|
|
|
+ $patient->ReceivingReminderOK($v['id']);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
-// echo '图文订单'.count($catNewIds).'个 ---'.'门诊订单'.count($menNewIds).'个';
|
|
|
- if ($catNewIds || $menNewIds){
|
|
|
+ if ($catNewIds){
|
|
|
// 操作图文和电话订单为已完成
|
|
|
Order::whereIn('id',$catNewIds)->update(['order_status'=>4]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Notes:门诊24小时后未确认超时
|
|
|
+ * Author: 白猫!
|
|
|
+ * DateTime: 2021/3/4 17:48
|
|
|
+ */
|
|
|
+ public function clinicOverTimeOrders(){
|
|
|
+ $inOrder = Order::with('orderPatient')->where(['order_status'=>3,'payment_status'=>2])->get();
|
|
|
+ $menNewIds = [];
|
|
|
+
|
|
|
+ foreach ($inOrder as $k=>$v){
|
|
|
+ if($v['product_type']==3 || $v['product_type']==4 || $v['product_type']==5){
|
|
|
+// if ((time()-$v['receiving_time'])>=(1*60*60*24)){
|
|
|
+ $menNewIds[$k] = $v['id'];
|
|
|
+ $this->AppointReminder($v['id']);
|
|
|
+// }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if ($menNewIds){
|
|
|
// 操作门诊订单为已超时
|
|
|
Order::whereIn('id',$menNewIds)->update(['order_status'=>6]);
|
|
|
}
|