attempts() > 1) { // //通过这个方法可以检查这个任务已经重试了几次了 // } $company = Company::where('id', $data['company_id'])->field('id,deposit,company_money,user_id,day_count,company_type,province,city,area,street,village,brigade')->find(); // 可能要判断预存金是否满足 $arr['status'] = 0; //信息更新 if ($data['template_info']['type'] == 31) { if ($data['template_info']['information_count'] < $data['template_info']['information_day_count']) { Log::info('任务结算失败,信息更新未达到要求:' . json_encode($data)); return false; } $name = '小组队长'; $arr['status'] = 1; } elseif //交易金额 ($data['template_info']['type'] == 33) { $shang_date_total_price = App(RemoteController::class)->shang_date_total_price($company); if ($shang_date_total_price == false) { Log::info('任务结算失败,交易金额未达到要求:' . json_encode($data)); return false; } $name = $shang_date_total_price['name']; $arr['status'] = $shang_date_total_price['arr']['status']; } else { $task_count = Task::where('id', $data['task_id'])->field('director_uid')->where('status', 3)->with('director_info')->find(); if (empty($task_count)) { Log::error('列105 任务结算失败,task_count为空:' . json_encode($data)); return false; } $name = $task_count['director_info']['nickname']; $arr['status'] = 1; } try { $arr['money'] = $data['template_info']['money']; $arr['company_id'] = $data['scheduling']['company_id']; $arr['msg'] = '来自任务【' . $data['template_info']['title'] . '】,完成人:' . $name . ',的任务结算'; $arr['proportion_one'] = $data['template_info']['proportion_one']; $arr['proportion_two'] = $data['template_info']['proportion_two']; $arr['sn'] = $data['sn']; $arr['id'] = $data['id']; } catch (\Exception $e) { Log::error('列122 任务结算失败:' . $e->getMessage() . json_encode($data)); return false; } (new ShareProfit())->first($arr, $company); //如果任务执行成功后 记得删除任务,不然这个任务会重复执行,直到达到最大重试次数后失败后,执行failed方法 $job->delete(); } public function failed($data) { Log::error('任务结算失败' . $data); // ...任务达到最大重试次数后,失败了 } }