|
|
@@ -52,7 +52,47 @@ class AutomaticDispatch extends Command
|
|
|
//执行外呼任务
|
|
|
$h = date('H');
|
|
|
if ($h >= 8 && $h <= 22) {
|
|
|
- //$this->startTask();
|
|
|
+ $this->startTask();
|
|
|
+ }
|
|
|
+
|
|
|
+ //异常工单:上门时间超过两小时状态未变更已上门
|
|
|
+ $this->workAnomalous();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 异常工单:上门时间超过两小时状态未变更已上门
|
|
|
+ */
|
|
|
+ protected function workAnomalous()
|
|
|
+ {
|
|
|
+ $size = 100;
|
|
|
+ $startTime = time() - 7200; // 当前时间减去7200秒(2小时)
|
|
|
+ $list = ServiceWork::alias("a")
|
|
|
+ ->leftJoin('service_work_anomalous b','a.id = b.work_id')
|
|
|
+ ->where('a.work_status',3)
|
|
|
+ ->where('a.service_status','<',2)
|
|
|
+ ->where('a.refund_approval',0)
|
|
|
+ ->where('a.work_pay_status',1)
|
|
|
+ ->where('a.appointment_time','<=', $startTime)
|
|
|
+ ->whereNull('b.id')
|
|
|
+ ->field('a.id,a.appointment_time,b.id as anomalous_id')
|
|
|
+ ->order('a.create_time','asc')
|
|
|
+ ->limit($size)
|
|
|
+ ->select()
|
|
|
+ ->toArray();
|
|
|
+ if (!$list) {
|
|
|
+ return ;
|
|
|
+ }
|
|
|
+
|
|
|
+ foreach($list as $item) {
|
|
|
+ try {
|
|
|
+ ServiceWorkAnomalous::create([
|
|
|
+ 'work_id' => $item['id'],
|
|
|
+ 'reason_type' => 3,
|
|
|
+ 'reason' => '上门时间超过两小时状态未变更已上门',
|
|
|
+ ]);
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ Log::write('异常工单:'.$e->getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -68,7 +108,6 @@ class AutomaticDispatch extends Command
|
|
|
$startTime = strtotime(date('Y-m-d 00:00:00'));
|
|
|
$endTime = strtotime(date('Y-m-d 23:59:59'));
|
|
|
|
|
|
- // 获取当前时间的前五分钟时间戳
|
|
|
$list = ServiceWork::where('work_status',0)
|
|
|
->where('service_status',0)
|
|
|
->where('refund_approval',0)
|
|
|
@@ -105,7 +144,6 @@ class AutomaticDispatch extends Command
|
|
|
}
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
- print_r($e->getMessage());
|
|
|
Log::write('自动派单异常:'.$e->getMessage());
|
|
|
}
|
|
|
}
|