This commit is contained in:
chenbo 2023-09-25 10:27:56 +08:00
parent 9f17ef2957
commit 3a0b20e5aa

View File

@ -92,6 +92,7 @@ class TaskLogic extends BaseLogic
$v_day_count=$v['day_count']; $v_day_count=$v['day_count'];
$v_day_count=$v_day_count+1; $v_day_count=$v_day_count+1;
$time = strtotime(date('Y-m-d')); $time = strtotime(date('Y-m-d'));
Db::startTrans();
$TaskSchedulingPlan_data = [ $TaskSchedulingPlan_data = [
'create_user_id' => 0, 'create_user_id' => 0,
'company_id' => $v['company_id'], 'company_id' => $v['company_id'],
@ -197,8 +198,10 @@ class TaskLogic extends BaseLogic
$task_id = (new Task())->insertGetId($data); $task_id = (new Task())->insertGetId($data);
TaskSchedulingPlan::where('id', $TaskSchedulingPlan['id'])->update(['task_id' => $task_id, 'is_execute' => 1]); TaskSchedulingPlan::where('id', $TaskSchedulingPlan['id'])->update(['task_id' => $task_id, 'is_execute' => 1]);
TaskTemplate::where('id', $v['id'])->inc('day_count')->update(); TaskTemplate::where('id', $v['id'])->inc('day_count')->update();
Db::commit();
return true; return true;
} catch (\Exception $e) { } catch (\Exception $e) {
Db::rollback();
Log::error('定时任务添加失败'.$e->getMessage().'。line'.$e->getLine()); Log::error('定时任务添加失败'.$e->getMessage().'。line'.$e->getLine());
return false; return false;
} }
@ -310,6 +313,7 @@ class TaskLogic extends BaseLogic
$time = strtotime(date('Y-m-d')); $time = strtotime(date('Y-m-d'));
// 任务类型code // 任务类型code
$taskType = (new DictData())->getTownTaskType($taskTemplate['type']); $taskType = (new DictData())->getTownTaskType($taskTemplate['type']);
Db::startTrans();
$TaskSchedulingPlan_data = [ $TaskSchedulingPlan_data = [
'create_user_id' => 0, 'create_user_id' => 0,
'company_id' => $taskTemplate['company_id'], '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]); TaskSchedulingPlan::where('id', $TaskSchedulingPlan['id'])->update(['task_id' => $task_id, 'is_execute' => 1]);
// 任务累计进行天数 +1 // 任务累计进行天数 +1
TaskTemplate::where('id', $taskTemplate['id'])->inc('day_count')->update(); TaskTemplate::where('id', $taskTemplate['id'])->inc('day_count')->update();
Db::commit();
} catch (\Exception $e) { } catch (\Exception $e) {
Db::rollback();
Log::error('定时任务添加失败'.$e->getMessage().'。line'.$e->getLine()); Log::error('定时任务添加失败'.$e->getMessage().'。line'.$e->getLine());
} }
} }
@ -391,16 +397,6 @@ class TaskLogic extends BaseLogic
// 长期金额 // 长期金额
return $tempalte['money_three']; 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;
} }
} }