Browse Source

问诊订单,计划任务

lizhen_gitee 10 tháng trước cách đây
mục cha
commit
263274d29c

+ 9 - 1
application/api/controller/Notify.php

@@ -161,11 +161,20 @@ class Notify extends Api
         $nowtime = time();
 
         //逻辑开始
+        $wenzhen_order = Db::name('wenzhen_order')->where('id',$orderInfo['table_id'])->lock(true)->find();
+        if($wenzhen_order['status'] != 0 && $wenzhen_order['status'] != 3 ){
+            Db::rollback();
+            return false;
+        }
         $order_update = [
             'pay_out_trade_no' => $out_trade_no,
             'pay_type' => $orderInfo['pay_type'],
             'pay_time' => $nowtime,
             'status'   => 10,
+
+            'cancel_time'   => 0,
+            'cancel_reason' => '',
+            'finish_time'   => 0,
         ];
         $update_rs = Db::name('wenzhen_order')->where('id',$orderInfo['table_id'])->update($order_update);
         if($update_rs===false)
@@ -187,7 +196,6 @@ class Notify extends Api
 
 
         //发送im消息给医生
-        $wenzhen_order = Db::name('wenzhen_order')->where('id',$orderInfo['table_id'])->find();
         if($wenzhen_order['order_type'] == 1){
             $tenim = new Tenim();
             $message = [

+ 3 - 3
application/extra/site.php

@@ -91,9 +91,9 @@ return array (
 5、本服务不支持取消订单,选择后将不能取消及退单,请确认后再选择
 6、以上服务条款最终解释权归在线问诊平台所有。',
   'nopay_order_autocancel_minute' => '10',
-  'accept_videoorder_autofinish_minute' => '10',
-  'payorder_noaccept_autocancel_minute' => '10',
-  'accept_textorder_autofinish_minute' => '48',
+  'payorder_noaccept_autotuizhen_minute' => '10',
+  'firstvideo_videoorder_autofinish_minute' => '10',
+  'accept_textorder_autofinish_minute' => '2880',
   'index_jiuyipeizhen' => '/uploads/20240428/85e048031609eb5fcb29d0b901a5c82c.png',
   'index_hulipeihu' => '/uploads/20240428/85e048031609eb5fcb29d0b901a5c82c.png',
 );

+ 48 - 5
application/index/controller/Plantask.php

@@ -8,19 +8,62 @@ use think\Cache;
 
 class Plantask extends Controller
 {
-    //未支付订单N分钟后自动取消
+    //未支付订单,下单N分钟后自动取消
     public function auto_cancel_nopay_order(){
+        $nowtime  = time();
+        $second   = config('site.nopay_order_autocancel_minute') * 60;
+        $lasttime = $nowtime - $second;
+
+        //dump(datetime($lasttime));exit;
+        Db::name('wenzhen_order')->where('status',0)->where('createtime','lt',$lasttime)->update([
+            'status'        => 3,
+            'cancel_time'   => $nowtime,
+            'cancel_reason' => '超时未支付',
+            'finish_time'   => $nowtime,
+        ]);
+    }
 
+    //待接诊订单,医生不操作,支付N分钟后,自动退珍
+    public function auto_tuizhen_noaccept_order(){
+        $nowtime  = time();
+        $second   = config('site.payorder_noaccept_autotuizhen_minute') * 60;
+        $lasttime = $nowtime - $second;
+
+        //dump(datetime($lasttime));exit;
+        Db::name('wenzhen_order')->where('status',10)->where('pay_time','lt',$lasttime)->update([
+            'status'        => 16,
+            'cancel_time'   => $nowtime,
+            'cancel_reason' => '超时未接诊',
+            'finish_time'   => $nowtime,
+            //待退款
+            'refund_status'   => 1,
+        ]);
+
+        //不仅改状态,还要自动退款,放到队列处理
     }
 
-    //自动取消未接诊订单
-    public function auto_cancel_noaccept_order(){
+    //视频订单,已拨打,通话N分钟后,自动结束
+    public function auto_finish_firstvideo_videoorder(){
+        $nowtime  = time();
+        $second   = config('site.firstvideo_videoorder_autofinish_minute') * 60;
+        $lasttime = $nowtime - $second;
 
+        Db::name('wenzhen_order')->where('status',25)->where('ordertype',2)->where('video_time','lt',$lasttime)->update([
+            'status'        => 30,
+            'finish_time'   => $nowtime,
+        ]);
     }
 
-    //视频订单接诊后,并第一次拨打N分钟自动结束
-    public function auto_finish_accept_videoorder(){
+    //图文订单,已接诊,接诊N分钟后,自动结束
+    public function auto_finish_accept_textorder(){
+        $nowtime  = time();
+        $second   = config('site.accept_textorder_autofinish_minute') * 60;
+        $lasttime = $nowtime - $second;
 
+        Db::name('wenzhen_order')->where('status',20)->where('ordertype',1)->where('accept_time','lt',$lasttime)->update([
+            'status'        => 30,
+            'finish_time'   => $nowtime,
+        ]);
     }
 
 /////////////////////////////////////////////////////////////////////////