Files
douba_shop/app/jobs/haichao/JstAfterSalePushJob.php
Karlcarlo 7e422335e4 feat(haichao): 新增聚水潭ERP集成功能
- 新增聚水潭回调接口及事件处理机制
- 添加聚水潭商品、订单、售后同步任务
- 实现聚水潭订单推送及售后状态同步
- 新增手动同步聚水潭商品功能
- 在各路由组添加聚水潭中间件支持
2026-04-01 11:55:18 +08:00

91 lines
3.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2026 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
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;
}
}