|
@@ -55,26 +55,36 @@ class AutomaticDispatch extends Command
|
|
|
$this->startTask();
|
|
$this->startTask();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- //异常工单:上门时间超过两小时状态未变更已上门
|
|
|
|
|
|
|
+ //异常工单:已过预约时间工程师未确认上门
|
|
|
$this->workAnomalous();
|
|
$this->workAnomalous();
|
|
|
|
|
+
|
|
|
|
|
+ //异常工单:上门时间超过两小时工单未确认完成
|
|
|
|
|
+ $this->unFinishedWorkAnomalous();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 异常工单:上门时间超过两小时状态未变更已上门
|
|
|
|
|
|
|
+ * 异常工单:已过预约时间工程师未确认上门
|
|
|
*/
|
|
*/
|
|
|
protected function workAnomalous()
|
|
protected function workAnomalous()
|
|
|
{
|
|
{
|
|
|
$size = 100;
|
|
$size = 100;
|
|
|
- $startTime = time() - 7200; // 当前时间减去7200秒(2小时)
|
|
|
|
|
|
|
+ $startTime = strtotime(date('Y-m-d 00:00:00'));
|
|
|
|
|
+ $endTime = time(); // 当前时间戳
|
|
|
|
|
+
|
|
|
$list = ServiceWork::alias("a")
|
|
$list = ServiceWork::alias("a")
|
|
|
->leftJoin('service_work_anomalous b','a.id = b.work_id')
|
|
->leftJoin('service_work_anomalous b','a.id = b.work_id')
|
|
|
->where('a.work_status',3)
|
|
->where('a.work_status',3)
|
|
|
->where('a.service_status','<',2)
|
|
->where('a.service_status','<',2)
|
|
|
->where('a.refund_approval',0)
|
|
->where('a.refund_approval',0)
|
|
|
->where('a.work_pay_status',1)
|
|
->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')
|
|
|
|
|
|
|
+ ->where('a.appointment_time','between', [$startTime, $endTime])
|
|
|
|
|
+ ->whereNotExists(function($query) {
|
|
|
|
|
+ $query->table('la_service_work_anomalous c')
|
|
|
|
|
+ ->whereRaw('a.id = c.work_id')
|
|
|
|
|
+ ->where('c.reason_type', 3);
|
|
|
|
|
+ })
|
|
|
|
|
+ ->field('a.id,a.appointment_time,b.id as anomalous_id,b.reason_type')
|
|
|
|
|
+ ->group('a.id')
|
|
|
->order('a.create_time','asc')
|
|
->order('a.create_time','asc')
|
|
|
->limit($size)
|
|
->limit($size)
|
|
|
->select()
|
|
->select()
|
|
@@ -88,7 +98,50 @@ class AutomaticDispatch extends Command
|
|
|
ServiceWorkAnomalous::create([
|
|
ServiceWorkAnomalous::create([
|
|
|
'work_id' => $item['id'],
|
|
'work_id' => $item['id'],
|
|
|
'reason_type' => 3,
|
|
'reason_type' => 3,
|
|
|
- 'reason' => '上门时间超过两小时状态未变更已上门',
|
|
|
|
|
|
|
+ 'reason' => '已过预约时间工程师未确认上门',
|
|
|
|
|
+ ]);
|
|
|
|
|
+ } catch (\Exception $e) {
|
|
|
|
|
+ Log::write('异常工单:'.$e->getMessage());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 异常工单:上门时间超过两小时工单未确认完成
|
|
|
|
|
+ */
|
|
|
|
|
+ protected function unFinishedWorkAnomalous()
|
|
|
|
|
+ {
|
|
|
|
|
+ $size = 100;
|
|
|
|
|
+ $startTime = strtotime(date('Y-m-d 00:00:00'));
|
|
|
|
|
+ $endTime = time() - 7200; // 当前时间减去7200秒(2小时)
|
|
|
|
|
+ $list = ServiceWork::alias("a")
|
|
|
|
|
+ ->leftJoin('service_work_anomalous b','a.id = b.work_id')
|
|
|
|
|
+ ->where('a.work_status', '>=', 4)
|
|
|
|
|
+ ->where('a.service_status','<',3)
|
|
|
|
|
+ ->where('a.refund_approval',0)
|
|
|
|
|
+ ->where('a.work_pay_status',1)
|
|
|
|
|
+ ->where('a.appointment_time','between', [$startTime, $endTime])
|
|
|
|
|
+ ->whereNotExists(function($query) {
|
|
|
|
|
+ $query->table('la_service_work_anomalous c')
|
|
|
|
|
+ ->whereRaw('a.id = c.work_id')
|
|
|
|
|
+ ->where('c.reason_type', 4);
|
|
|
|
|
+ })
|
|
|
|
|
+ ->field('a.id,a.appointment_time,b.id as anomalous_id')
|
|
|
|
|
+ ->group('a.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' => 4,
|
|
|
|
|
+ 'reason' => '上门时间超过两小时工单未确认完成',
|
|
|
]);
|
|
]);
|
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
|
Log::write('异常工单:'.$e->getMessage());
|
|
Log::write('异常工单:'.$e->getMessage());
|