This commit is contained in:
mkm 2023-08-16 11:13:31 +08:00
parent eba96151f6
commit ff1bbc4733
4 changed files with 41 additions and 63 deletions

View File

@ -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'])

View File

@ -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;
@ -72,51 +73,7 @@ class TaskLogic extends BaseLogic
{
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;
// }
$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'];
}
$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;
}
}
}
//任务金额
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 随机生成信息更新任务

View File

@ -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()
{

@ -1 +1 @@
Subproject commit 1294ea49ff9ecc4532821f8798304816cbf8dd74
Subproject commit 9acc82cd23d807280ddd29df2117e7890094d049