1234567891011121314151617181920212223242526272829303132333435 |
- <?php
- namespace app\jobs;
- use think\queue\Job;
- use think\facade\Console;
- class Crmimportjob
- {
- public function fire(Job $job, $queuedata)
- {
- //业务处理代码
- $is_done = $this->jobDone($queuedata);
- if($is_done){
- $job->delete();
- }
- if ($job->attempts() > 3) {
- //通过这个方法可以检查这个任务已经重试了几次了
- $job->delete();
- }
- }
- public function failed($queuedata)
- {
- // ...任务达到最大重试次数后,失败了
- }
- private function jobDone($queuedata){
- $output = Console::call('crmresimport',[(string)$queuedata['employee_id'],(string)$queuedata['root_id'],(string)$queuedata['org_id']]);
- return $output->fetch();
-
- }
- }
|