更新
This commit is contained in:
parent
fa520f572d
commit
9669673fec
@ -4,10 +4,6 @@ namespace app\job;
|
||||
|
||||
use app\common\logic\task\TaskLogic;
|
||||
use think\queue\Job;
|
||||
use app\common\model\Company;
|
||||
use app\common\model\task\Task;
|
||||
use app\common\model\task_scheduling\TaskScheduling;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
|
||||
/**
|
||||
* 任务下发执行的具体逻辑
|
||||
@ -15,12 +11,12 @@ use app\common\model\task_template\TaskTemplate;
|
||||
class TaskAdd
|
||||
{
|
||||
|
||||
public function fire(Job $job, $v)
|
||||
public function fire(Job $job, $data)
|
||||
{
|
||||
if ($job->attempts() > 3) {
|
||||
//通过这个方法可以检查这个任务已经重试了几次了
|
||||
}
|
||||
// TaskLogic::CronAdd($v);
|
||||
TaskLogic::CronAdd($data['data'],$data['data_two']);
|
||||
//如果任务执行成功后 记得删除任务,不然这个任务会重复执行,直到达到最大重试次数后失败后,执行failed方法
|
||||
$job->delete();
|
||||
}
|
||||
|
@ -10,12 +10,14 @@ use app\common\model\Company;
|
||||
use app\common\model\task_template\TaskTemplate;
|
||||
use app\common\logic\task\TaskLogic;
|
||||
use app\common\model\task_scheduling\TaskScheduling;
|
||||
class TaskCron extends Task{
|
||||
|
||||
class TaskCron extends Task
|
||||
{
|
||||
|
||||
public function configure()
|
||||
{
|
||||
$this->daily(); //设置任务的周期,每天执行一次,更多的方法可以查看源代码,都有注释
|
||||
// $this->everyMinute();
|
||||
// $this->everyMinute();//每分钟
|
||||
}
|
||||
/**
|
||||
* 执行任务
|
||||
@ -40,62 +42,19 @@ class TaskCron extends Task{
|
||||
}
|
||||
$company_id = [];
|
||||
foreach ($plan_all as $k => $v) {
|
||||
foreach($v['template'] as $kkk=>$vvv){
|
||||
if ($v['types'] == 1 ||$vvv['types'] == 3) {
|
||||
if ($v['company_info'] && $v['company_info']['day_count'] <=$vvv['stage_day_one']) {
|
||||
$res=$this->stage_inspection($v['template'],'moeny','一');
|
||||
if($res==false){
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$res=$this->stage_inspection($v['template'],'money_two','二');
|
||||
if($res==false){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} elseif ($v['types'] == 2) {
|
||||
if ($v['company_info']['day_count'] <=$vvv['stage_day_one']) {
|
||||
$res=$this->stage_inspection($v['template'],'moeny','一');
|
||||
if($res==false){
|
||||
return false;
|
||||
}
|
||||
} elseif ($v['company_info']['day_count'] <=$vvv['stage_day_two']) {
|
||||
$res=$this->stage_inspection($v['template'],'money_two','二');
|
||||
if($res==false){
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$res=$this->stage_inspection($v['template'],'money_three','三');
|
||||
if($res==false){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ( $v['company_info']['day_count'] <=$vvv['stage_day_one']) {
|
||||
$res=$this->stage_inspection($v['template'],'money_three','三');
|
||||
if($res==false){
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$res=$this->stage_inspection($v['template'],'money_two','二');
|
||||
if($res==false){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($v['template'] as $kk => $vv) {
|
||||
TaskLogic::CronAdd($vv,$v);
|
||||
queue(TaskAdd::class,['data'=>$vv,'data_two'=>$v]);
|
||||
}
|
||||
}
|
||||
$company_id[] = $v['company_id'];
|
||||
}
|
||||
Company::where('id', 'in', $company_id)->inc('day_count')->update();
|
||||
TaskScheduling::where('id', 'in', $plan_ids)->update(['cron_time' => time()]);
|
||||
Log::error('定时任务下发执行成功' . date('Y-m-d H:i:s'));
|
||||
//...具体的任务执行
|
||||
}
|
||||
|
||||
public function stage_inspection($v,$moeny_type='moeny',$title='一'){
|
||||
public function stage_inspection($v, $moeny_type = 'moeny', $title = '一')
|
||||
{
|
||||
$count_moeny = 0;
|
||||
foreach ($v['template'] as $kkkk => $vvvv) {
|
||||
$count_moeny += $vvvv[$moeny_type];
|
||||
@ -107,3 +66,53 @@ class TaskCron extends Task{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// foreach($plan_all as $k=>$v){
|
||||
// foreach($v['template'] as $kkk=>$vvv){
|
||||
// if ($v['types'] == 1 ||$vvv['types'] == 3) {
|
||||
// if ($v['company_info'] && $v['company_info']['day_count'] <=$vvv['stage_day_one']) {
|
||||
// $res=$this->stage_inspection($v['template'],'moeny','一');
|
||||
// if($res==false){
|
||||
// return false;
|
||||
// }
|
||||
// } else {
|
||||
// $res=$this->stage_inspection($v['template'],'money_two','二');
|
||||
// if($res==false){
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// } elseif ($v['types'] == 2) {
|
||||
// if ($v['company_info']['day_count'] <=$vvv['stage_day_one']) {
|
||||
// $res=$this->stage_inspection($v['template'],'moeny','一');
|
||||
// if($res==false){
|
||||
// return false;
|
||||
// }
|
||||
// } elseif ($v['company_info']['day_count'] <=$vvv['stage_day_two']) {
|
||||
// $res=$this->stage_inspection($v['template'],'money_two','二');
|
||||
// if($res==false){
|
||||
// return false;
|
||||
// }
|
||||
// } else {
|
||||
// $res=$this->stage_inspection($v['template'],'money_three','三');
|
||||
// if($res==false){
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// if ( $v['company_info']['day_count'] <=$vvv['stage_day_one']) {
|
||||
// $res=$this->stage_inspection($v['template'],'money_three','三');
|
||||
// if($res==false){
|
||||
// return false;
|
||||
// }
|
||||
// } else {
|
||||
// $res=$this->stage_inspection($v['template'],'money_two','二');
|
||||
// if($res==false){
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// foreach($v['template'] as $kk=>$vv){
|
||||
// TaskLogic::CronAdd($vv,$v);
|
||||
// }
|
||||
// $company_id[]=$v['company_id'];
|
||||
// }
|
@ -12,7 +12,7 @@ class TaskSettlementCron extends Task{
|
||||
public function configure()
|
||||
{
|
||||
$this->daily(); //设置任务的周期,每天执行一次,更多的方法可以查看源代码,都有注释
|
||||
// $this->everyMinute();
|
||||
// $this->everyMinute();//每分钟
|
||||
}
|
||||
/**
|
||||
* 任务结算
|
||||
|
Loading…
x
Reference in New Issue
Block a user