Browse Source

图文电话,接单超时命令

whj 4 years ago
parent
commit
42e337a7db
1 changed files with 33 additions and 1 deletions
  1. 33 1
      app/Console/Commands/overTimeOrder.php

+ 33 - 1
app/Console/Commands/overTimeOrder.php

xqd xqd xqd
@@ -42,7 +42,7 @@ class overTimeOrder extends Command
     public function handle()
     {
         $type = $this->argument('type');
-        if(!in_array($type,['orderOut','appiontOut','thenOut','thenLose'])){
+        if(!in_array($type,['orderOut','appiontOut','thenOut','thenLose','orderCancel'])){
             dd('请输入正确的参数');
         }
         if($type == 'orderOut'){
@@ -58,6 +58,9 @@ class overTimeOrder extends Command
         }else if($type == 'thenLose'){
             //认证失效
             $this->InvalidThenReminder();
+        } else if($type == 'orderCancel'){
+            $this->orderCancel();
+            dd('订单接单超时检查执行时间'.date('Y-m-d H:i:s'));
         }
         dd('ok');
     }
@@ -155,4 +158,33 @@ class overTimeOrder extends Command
             Order::whereIn('id',$menNewIds)->update(['order_status'=>6]);
         }
     }
+
+    /**
+     * 订单接单超时自动取消(定时)
+     */
+    public function orderCancel(){
+
+        $config_chat =  SystemConfig::get('docter_config','chat_cancel_time');
+        $config_phone =  SystemConfig::get('docter_config','phone_cancel_time');
+
+        // 换算为秒
+        $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();
+        foreach ($inOrder as $k=>$v){
+            if ($v['product_type']==1){
+                if ((time()-$v['receiving_time'])>=$config_phone){
+                    $catNewIds[$k] = $v['id'];
+                    Order::orderCancel($v['id'],'接单超时取消');
+                }
+            }else if($v['product_type']==2){
+                if ((time()-$v['receiving_time'])>=$config_chat){
+                    Order::orderCancel($v['id'],'接单超时取消');
+                    $catNewIds[$k] = $v['id'];
+                }
+            }
+        }
+    }
 }