// +---------------------------------------------------------------------- namespace app\jobs\haichao; use app\haichao\HaichaoJstServices; use crmeb\basic\BaseJobs; use crmeb\traits\QueueTrait; use think\facade\Log; class JstAfterSalePushJob extends BaseJobs { use QueueTrait; public static function queueName() { return (string)env('QUEUE_LISTEN_NAME', 'CRMEB_PRO'); } public function create(int $refundId, int $times = 0): bool { Log::info('jst.after_sale.create.job_start ' . json_encode([ 'refund_id' => $refundId, 'times' => $times ], JSON_UNESCAPED_UNICODE)); try { HaichaoJstServices::getServices()->afterSaleCreatePush($refundId); } catch (\Throwable $e) { Log::error('jst.after_sale.create.job_error ' . json_encode([ 'refund_id' => $refundId, 'times' => $times, 'msg' => $e->getMessage(), ], JSON_UNESCAPED_UNICODE)); if ($times < 3) { self::dispatchSece(10 * ($times + 1), 'create', [$refundId, $times + 1]); } } return true; } public function cancel(int $refundId, int $times = 0): bool { Log::info('jst.after_sale.cancel.job_start ' . json_encode([ 'refund_id' => $refundId, 'times' => $times ], JSON_UNESCAPED_UNICODE)); try { HaichaoJstServices::getServices()->afterSaleCancelPush($refundId); } catch (\Throwable $e) { Log::error('jst.after_sale.cancel.job_error ' . json_encode([ 'refund_id' => $refundId, 'times' => $times, 'msg' => $e->getMessage(), ], JSON_UNESCAPED_UNICODE)); if ($times < 3) { self::dispatchSece(10 * ($times + 1), 'cancel', [$refundId, $times + 1]); } } return true; } public function refunded(int $refundId, int $times = 0): bool { Log::info('jst.after_sale.refunded.job_start ' . json_encode([ 'refund_id' => $refundId, 'times' => $times ], JSON_UNESCAPED_UNICODE)); try { HaichaoJstServices::getServices()->afterSaleRefundedPush($refundId); } catch (\Throwable $e) { Log::error('jst.after_sale.refunded.job_error ' . json_encode([ 'refund_id' => $refundId, 'times' => $times, 'msg' => $e->getMessage(), ], JSON_UNESCAPED_UNICODE)); if ($times < 3) { self::dispatchSece(10 * ($times + 1), 'refunded', [$refundId, $times + 1]); } } return true; } }