feat(haichao): 新增聚水潭ERP集成功能
- 新增聚水潭回调接口及事件处理机制 - 添加聚水潭商品、订单、售后同步任务 - 实现聚水潭订单推送及售后状态同步 - 新增手动同步聚水潭商品功能 - 在各路由组添加聚水潭中间件支持
This commit is contained in:
@@ -22,10 +22,12 @@ use app\services\product\shipping\ShippingTemplatesServices;
|
||||
use app\services\product\sku\StoreProductAttrServices;
|
||||
use app\services\product\sku\StoreProductAttrValueServices;
|
||||
use app\services\product\sku\StoreProductRuleServices;
|
||||
use app\jobs\product\ProductSyncErp;
|
||||
use crmeb\services\FileService;
|
||||
use crmeb\services\SpreadsheetExcelService;
|
||||
use crmeb\services\UploadService;
|
||||
use think\annotation\Inject;
|
||||
use think\facade\Log;
|
||||
|
||||
/**
|
||||
* Class StoreProduct
|
||||
@@ -992,6 +994,39 @@ class StoreProduct extends AuthController
|
||||
return $this->success('已加入消息队列进行同步');
|
||||
}
|
||||
|
||||
public function sync_jst_product()
|
||||
{
|
||||
[$spuStr, $sync] = $this->request->postMore([
|
||||
['spu_str', ""],
|
||||
['sync', 0]
|
||||
], true);
|
||||
if (!$spuStr) {
|
||||
return $this->fail('请输入ERP商品SPU');
|
||||
}
|
||||
$spus = array_unique(array_filter(explode(',', $spuStr)));
|
||||
$traceId = uniqid('jst_', true);
|
||||
Log::info('admin.manual.jst.product.sync.dispatch', [
|
||||
'trace_id' => $traceId,
|
||||
'admin_id' => $this->adminId,
|
||||
'admin_type' => $this->adminType,
|
||||
'supplier_id' => $this->supplierId,
|
||||
'client_ip' => $this->request->ip(),
|
||||
'count' => count($spus),
|
||||
'spus' => $spus
|
||||
]);
|
||||
if ($sync) {
|
||||
foreach ($spus as $spu) {
|
||||
(new ProductSyncErp())->productFromErp($spu, (int)$this->supplierId);
|
||||
}
|
||||
return $this->success('同步完成');
|
||||
} else {
|
||||
foreach ($spus as $spu) {
|
||||
ProductSyncErp::dispatchDo('productFromErp', [$spu, (int)$this->supplierId]);
|
||||
}
|
||||
return $this->success('正在同步中,请稍后查看');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品批量操作
|
||||
* @param StoreProductBatchProcessServices $batchProcessServices
|
||||
|
||||
@@ -39,6 +39,8 @@ use Joypack\Tencent\Map\Bundle\LocationOption;
|
||||
use app\Request;
|
||||
use crmeb\services\CacheService;
|
||||
use crmeb\services\UploadService;
|
||||
use think\facade\Log;
|
||||
use think\Response;
|
||||
|
||||
/**
|
||||
* 公共类
|
||||
@@ -131,6 +133,22 @@ class PublicController
|
||||
return app('json')->success($data);
|
||||
}
|
||||
|
||||
public function jstCallback(Request $request)
|
||||
{
|
||||
$data = json_decode((string)$request->getContent(), true);
|
||||
if (!is_array($data)) {
|
||||
$data = $request->param();
|
||||
}
|
||||
$actionCode = $data['action_code'] ?? ($request->param('action_code') ?: '');
|
||||
Log::info('jst.api.callback ' . $actionCode);
|
||||
if ($actionCode === 'business_sku_syn') (new \app\haichao\callback\event\JstProductEvent())->event($request);
|
||||
if ($actionCode === 'sync_shipped') (new \app\haichao\callback\event\JstOrderPostEvent())->event($request);
|
||||
if ($actionCode === 'orderPost') (new \app\haichao\callback\event\JstOrderPostEvent())->event($request);
|
||||
if ($actionCode === 'orderRefund') (new \app\haichao\callback\event\JstOrderRefundEvent())->event($request);
|
||||
if ($actionCode === 'trade_after_sale') (new \app\haichao\callback\event\JstTradeEvent())->event($request);
|
||||
return Response::create(['code' => 0, 'msg' => 'ok'], 'json');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取个人中心菜单
|
||||
* @param Request $request
|
||||
|
||||
Reference in New Issue
Block a user