| xqd
@@ -170,21 +170,68 @@ class overTimeOrder extends Command
|
|
|
// 换算为秒
|
|
|
$config_chat = intval($config_chat)*60;
|
|
|
$config_phone = intval($config_phone)*60;
|
|
|
- echo $config_phone.'---'.$config_chat;
|
|
|
|
|
|
- $inOrder = Order::with('orderPatient')->where('product_type','<',3)->where(['order_status'=>2,'payment_status'=>2])->get();
|
|
|
+ $inOrder = Order::with('orderPatient')->with('orderUser')->with('docter')->where('product_type','<',3)->where(['order_status'=>2,'payment_status'=>2])->get();
|
|
|
foreach ($inOrder as $k=>$v){
|
|
|
if ($v['product_type']==1){
|
|
|
- if ((time()-$v['receiving_time'])>=$config_phone){
|
|
|
+ if ((time()-strtotime($v['create_at']))>=$config_phone){
|
|
|
$catNewIds[$k] = $v['id'];
|
|
|
- Order::orderCancel($v['id'],'接单超时取消');
|
|
|
+ $res = Order::orderCancel($v['id'],'医生超时未接单自动取消');
|
|
|
+ //取消成功才发送消息
|
|
|
+ if($res){
|
|
|
+ $this->cancelUserMsg($v);
|
|
|
+ $this->cancelDocterMsg($v);
|
|
|
+ }
|
|
|
}
|
|
|
}else if($v['product_type']==2){
|
|
|
- if ((time()-$v['receiving_time'])>=$config_chat){
|
|
|
- Order::orderCancel($v['id'],'接单超时取消');
|
|
|
- $catNewIds[$k] = $v['id'];
|
|
|
+ if ((time()-strtotime($v['create_at']))>=$config_chat){
|
|
|
+ $res = Order::orderCancel($v['id'],'医生超时未接单自动取消');
|
|
|
+ //取消成功才发送消息
|
|
|
+ if($res){
|
|
|
+ $this->cancelUserMsg($v);
|
|
|
+ $this->cancelDocterMsg($v);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ public function cancelUserMsg($order)
|
|
|
+ {
|
|
|
+ $openid = $order->orderUser->openid;
|
|
|
+ $pt = Order::getProductType();
|
|
|
+ $type = $pt[$order->product_type];
|
|
|
+ $msgArr = [
|
|
|
+ $openid,
|
|
|
+ $order->order_sn,
|
|
|
+ $type,
|
|
|
+ ($order->payment_amount/100),
|
|
|
+ $order->created_at,
|
|
|
+ $order->orderPatient->name,
|
|
|
+ $order->docter->name.'医生',
|
|
|
+ '医生超时未接单自动取消',
|
|
|
+ '订单状态:已退款 ',
|
|
|
+ ];
|
|
|
+ $minArr = [$openid,$order->order_sn,$type,'医生超时未接单自动取消'];
|
|
|
+ send_wechat_message(7,$msgArr,$minArr);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function cancelDocterMsg($order)
|
|
|
+ {
|
|
|
+ $openid = $order->docter->openid;
|
|
|
+// $openid = 'oflME5eixHMij2TIVyy52WbfaQvA';
|
|
|
+ $pt = Order::getProductType();
|
|
|
+ $type = $pt[$order->product_type];
|
|
|
+ $msgArr = [
|
|
|
+ $openid,
|
|
|
+ '',
|
|
|
+ $order->docter->name,
|
|
|
+ $order->order_sn,
|
|
|
+ $type,
|
|
|
+ ($order->payment_amount/100).'元',
|
|
|
+ $order->created_at,
|
|
|
+ '医生超时未接单自动取消',
|
|
|
+ ];
|
|
|
+ send_wechatSubscription_message('cancel_reminder',$msgArr);
|
|
|
+ }
|
|
|
}
|