fixed 后台在任务运行中删除了任务模板,导致结算出现异常

This commit is contained in:
chenbo 2023-11-24 11:58:58 +08:00
parent 0e7c4434ff
commit 0c54ba8c34

View File

@ -62,14 +62,19 @@ class CronController extends BaseApiController
*/ */
public function settlement(){ public function settlement(){
// $all=TaskSchedulingPlan::where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray(); // $all=TaskSchedulingPlan::where('is_pay',0)->with(['template_info','scheduling'])->select()->toArray();
$all = TaskSchedulingPlan::whereDay('end_time','today') $all = TaskSchedulingPlan::whereDay('end_time','yesterday')
->withJoin(['scheduling'], 'left') ->withJoin(['scheduling'], 'left')
->where('scheduling.company_type', 18) ->where('scheduling.company_type', 18)
->where('is_pay',0) ->where('is_pay',0)
->with(['template_info']) ->with(['template_info'])
->select() ->select()
->toArray(); ->toArray();
foreach($all as $k=>$v){ foreach($all as $k=>$v){
// 任务运行中,后台删除了任务模板
if (empty($v['template_info'])) {
continue;
}
queue(TaskInformationJob::class,$v); queue(TaskInformationJob::class,$v);
} }
Log::info('小组服务公司定时任务结算执行成功'.date('Y-m-d H:i:s')); Log::info('小组服务公司定时任务结算执行成功'.date('Y-m-d H:i:s'));
@ -128,6 +133,10 @@ class CronController extends BaseApiController
->select() ->select()
->toArray(); ->toArray();
foreach($taskSchedulingPlanList as $taskSchedulingPlan){ foreach($taskSchedulingPlanList as $taskSchedulingPlan){
// 任务运行中,后台删除了任务模板
if (empty($taskSchedulingPlan['template_info'])) {
continue;
}
queue(VillageTaskSettlementJob::class, $taskSchedulingPlan); queue(VillageTaskSettlementJob::class, $taskSchedulingPlan);
} }
Log::info('村管理公司定时任务结算执行-结束'.date('Y-m-d H:i:s')); Log::info('村管理公司定时任务结算执行-结束'.date('Y-m-d H:i:s'));
@ -185,6 +194,10 @@ class CronController extends BaseApiController
->select() ->select()
->toArray(); ->toArray();
foreach($taskSchedulingPlanList as $taskSchedulingPlan){ foreach($taskSchedulingPlanList as $taskSchedulingPlan){
// 任务运行中,后台删除了任务模板
if (empty($taskSchedulingPlan['template_info'])) {
continue;
}
// 解耦 三个角色分开结算,避免某个角色的结算逻辑出现异常,导致整个镇农科公司的任务结算都终止 // 解耦 三个角色分开结算,避免某个角色的结算逻辑出现异常,导致整个镇农科公司的任务结算都终止
$taskTemplateInfo = $taskSchedulingPlan['template_info']; $taskTemplateInfo = $taskSchedulingPlan['template_info'];
// 负责人任务结算 // 负责人任务结算