40 lines
1.3 KiB
PHP
40 lines
1.3 KiB
PHP
<?php
|
||
|
||
namespace app\job;
|
||
|
||
use app\common\logic\finance\ShareProfit;
|
||
use app\common\model\task\Task;
|
||
use think\queue\Job;
|
||
|
||
/**
|
||
* 任务结算执行的具体逻辑
|
||
*/
|
||
class TaskInformationJob
|
||
{
|
||
|
||
public function fire(Job $job, $data)
|
||
{
|
||
if ($job->attempts() > 3) {
|
||
//通过这个方法可以检查这个任务已经重试了几次了
|
||
}
|
||
$task_id=explode(',',$data['task_id']);
|
||
$task_count=Task::where('id','in',$task_id)->field('director_uid')->with('director_info')->select();
|
||
if(count($task_count)==count($task_id)){
|
||
$name_arr=[];
|
||
foreach ($task_count as $key => $value) {
|
||
$name_arr[$key]=$value['director_info']['nickname'];
|
||
}
|
||
$name=implode('、',$name_arr);
|
||
$arr['money']=$data['template_info']['money'];
|
||
$arr['company_id']=$data['scheduling']['company_id'];
|
||
$arr['msg']='来自任务【'.$data['template_info']['title'].'】,执行人:'.$name.',的任务结算';
|
||
$arr['sn']=$data['sn'];
|
||
$arr['user_id']=$data['user_id'];
|
||
(new ShareProfit())->first($arr);
|
||
}
|
||
|
||
//如果任务执行成功后 记得删除任务,不然这个任务会重复执行,直到达到最大重试次数后失败后,执行failed方法
|
||
$job->delete();
|
||
}
|
||
}
|