diff --git a/app/adminapi/lists/task_template/TaskTemplateLists.php b/app/adminapi/lists/task_template/TaskTemplateLists.php index 0f117879d..f22440d3d 100644 --- a/app/adminapi/lists/task_template/TaskTemplateLists.php +++ b/app/adminapi/lists/task_template/TaskTemplateLists.php @@ -55,7 +55,6 @@ class TaskTemplateLists extends BaseAdminDataLists implements ListsSearchInterfa public function lists(): array { return TaskTemplate::where($this->searchWhere) - ->field(['id', 'title', 'admin_id', 'money', 'type', 'status', 'content','stage_day_one','proportion_one','stage_day_two','proportion_two']) ->with(['admin','data_type']) ->limit($this->limitOffset, $this->limitLength) ->order(['id' => 'desc']) diff --git a/app/common/logic/task/TaskLogic.php b/app/common/logic/task/TaskLogic.php index 430b9492d..0cdc73b2b 100644 --- a/app/common/logic/task/TaskLogic.php +++ b/app/common/logic/task/TaskLogic.php @@ -19,6 +19,7 @@ use app\common\model\task\Task; use app\common\logic\BaseLogic; use app\common\model\informationg\UserInformationg; use app\common\model\task_scheduling_plan\TaskSchedulingPlan; +use app\common\model\task_template\TaskTemplate; use think\facade\Db; use think\facade\Log; @@ -71,52 +72,8 @@ class TaskLogic extends BaseLogic public static function CronAdd(array $v): bool { if ($v['template_info'] != null) { - try{ - if ($v['template_info']['type'] == 31) { - $res = self::random_informationg($v['scheduling']['company_id']); - if(!$res){ - return true; - } - $task_id=[]; - foreach ($res as $key => $value) { - $extend['informationg']['arr'] = $value['id']; - $extend['informationg']['arr_count'] = 1; - $extend['informationg']['create_user_id'] = $value['create_user_id']; - $extend['informationg']['update'] = 0; - $extend['informationg']['update_count'] = 0; - $arr = [ - 'template_id' => $v['template_id'], - 'scheduling_plan_id' => $v['id'], - 'company_id' => $v['scheduling']['company_id'], - 'director_uid' => $value['create_user_id'], - 'title' => $v['template_info']['title'], - 'money' => $v['template_info']['money'], - 'type' => $v['template_info']['type'], - 'content' => $v['template_info']['content'], - 'start_time' => strtotime($v['start_time']), - 'end_time' => strtotime($v['end_time']), - "extend" => json_encode($extend), - 'create_time' => time(), - 'update_time' => time(), - ]; - $data = $arr; - if($v['company']&& $v['company']['day_count']>$v['template_info']['stage_day_one']){ - $data['proportion']=$v['template_info']['proportion_two']; - }else{ - $data['proportion']=$v['template_info']['proportion_one']; - } - $task_id[] = (new Task())->insertGetId($data); - } - TaskSchedulingPlan::where('id', $v['id'])->update(['task_id' => implode(',', $task_id), 'is_execute' => 1]); - return true; - } else { - // foreach ($res as $key => $value) { - // $extend['informationg']['arr']=$value['id']; - // $extend['informationg']['arr_count']=1; - // $extend['informationg']['create_user_id']=$value['create_user_id']; - // $extend['informationg']['update']=0; - // $extend['informationg']['update_count']=0; - // } + try { + $arr = [ 'template_id' => $v['template_id'], 'scheduling_plan_id' => $v['id'], @@ -132,26 +89,48 @@ class TaskLogic extends BaseLogic 'update_time' => time(), ]; $data = $arr; - if($v['company']&& $v['company']['day_count']>$v['template_info']['stage_day_one']){ - $data['proportion']=$v['template_info']['proportion_two']; - }else{ - $data['proportion']=$v['template_info']['proportion_one']; - } - if($v['template_info']['type'] == 32){ - $data['director_uid']=$v['company']['user_id']; + $data['money'] = self::task_money($v); + if ($v['template_info']['type'] == 32) { + $data['director_uid'] = $v['company']['user_id']; } $task_id = (new Task())->insertGetId($data); TaskSchedulingPlan::where('id', $v['id'])->update(['task_id' => $task_id, 'is_execute' => 1]); + return true; + } catch (\Exception $e) { + Log::error('定时任务添加失败', [$e->getMessage()]); + return false; } - return true; - }catch(\Exception $e){ - Log::error('定时任务添加失败',[$e->getMessage()]); - return false; } - } - } - + //任务金额 + private static function task_money($v) + { + if ($v['template_info']['types'] == 1 || $v['template_info']['types'] == 3) { + if ($v['company'] && $v['company']['day_count'] <= $v['template_info']['stage_day_one']) { + return $v['template_info']['money']; + } else { + return $v['template_info']['money_two']; + } + } elseif ($v['template_info']['types'] == 2) { + if ($v['company'] && $v['company']['day_count'] <= $v['template_info']['stage_day_one']) { + return $v['template_info']['money']; + } elseif ($v['company'] && $v['company']['day_count'] <= $v['template_info']['stage_day_two']) { + return $v['template_info']['money_two']; + } else { + return $v['template_info']['money_three']; + } + } else { + if ($v['company'] && $v['company']['day_count'] <= $v['template_info']['stage_day_one']) { + $a = $v['template_info']['money']; + } else { + $a = $v['template_info']['money_two']; + } + if($v['company'] && $v['company']['day_count']>=$v['template_info']['stage_day_two']){ + TaskTemplate::where('id',$v['template_id'])->update(['status'=>0]); + } + return $a; + } + } /** * @notes 随机生成信息更新任务 diff --git a/app/common/model/task_scheduling_plan/TaskSchedulingPlan.php b/app/common/model/task_scheduling_plan/TaskSchedulingPlan.php index 6c34cb626..7995a0545 100644 --- a/app/common/model/task_scheduling_plan/TaskSchedulingPlan.php +++ b/app/common/model/task_scheduling_plan/TaskSchedulingPlan.php @@ -48,7 +48,7 @@ class TaskSchedulingPlan extends BaseModel } public function templateInfo() { - return $this->hasOne(TaskTemplate::class, 'id', 'template_id'); + return $this->hasOne(TaskTemplate::class, 'id', 'template_id')->where('status',1); } public function company() { diff --git a/vendor/ebaoquan/junziqian_sdk b/vendor/ebaoquan/junziqian_sdk index 1294ea49f..9acc82cd2 160000 --- a/vendor/ebaoquan/junziqian_sdk +++ b/vendor/ebaoquan/junziqian_sdk @@ -1 +1 @@ -Subproject commit 1294ea49ff9ecc4532821f8798304816cbf8dd74 +Subproject commit 9acc82cd23d807280ddd29df2117e7890094d049