From 3a0b20e5aabfacbbba1014c38e0e092ec1238f02 Mon Sep 17 00:00:00 2001 From: chenbo <709206448@qq.com> Date: Mon, 25 Sep 2023 10:27:56 +0800 Subject: [PATCH] fixed --- app/common/logic/task/TaskLogic.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index ad643f5d7..a752ad993 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -92,6 +92,7 @@ class TaskLogic extends BaseLogic $v_day_count=$v['day_count']; $v_day_count=$v_day_count+1; $time = strtotime(date('Y-m-d')); + Db::startTrans(); $TaskSchedulingPlan_data = [ 'create_user_id' => 0, 'company_id' => $v['company_id'], @@ -197,8 +198,10 @@ class TaskLogic extends BaseLogic $task_id = (new Task())->insertGetId($data); TaskSchedulingPlan::where('id', $TaskSchedulingPlan['id'])->update(['task_id' => $task_id, 'is_execute' => 1]); TaskTemplate::where('id', $v['id'])->inc('day_count')->update(); + Db::commit(); return true; } catch (\Exception $e) { + Db::rollback(); Log::error('定时任务添加失败'.$e->getMessage().'。line:'.$e->getLine()); return false; } @@ -310,6 +313,7 @@ class TaskLogic extends BaseLogic $time = strtotime(date('Y-m-d')); // 任务类型code $taskType = (new DictData())->getTownTaskType($taskTemplate['type']); + Db::startTrans(); $TaskSchedulingPlan_data = [ 'create_user_id' => 0, 'company_id' => $taskTemplate['company_id'], @@ -352,7 +356,9 @@ class TaskLogic extends BaseLogic TaskSchedulingPlan::where('id', $TaskSchedulingPlan['id'])->update(['task_id' => $task_id, 'is_execute' => 1]); // 任务累计进行天数 +1 TaskTemplate::where('id', $taskTemplate['id'])->inc('day_count')->update(); + Db::commit(); } catch (\Exception $e) { + Db::rollback(); Log::error('定时任务添加失败'.$e->getMessage().'。line:'.$e->getLine()); } } @@ -391,16 +397,6 @@ class TaskLogic extends BaseLogic // 长期金额 return $tempalte['money_three']; } - } else { - if ($v_day_count <= $tempalte['stage_day_one']) { - $a = $tempalte['money']; - } else { - $a = $tempalte['money_two']; - } - if ($v_day_count >= $tempalte['stage_day_two']) { - TaskTemplate::where('id', $tempalte['id'])->update(['status' => 0]); - } - return $a; } }