feat(pdd): 引入拼多多原始订单暂存仓 pdd_raw_orders 与两段式解耦流水线
1. 数据库新增 081_pdd_raw_orders.sql 迁移,创建 pdd_raw_orders 原始暂存表及索引; 2. 新增 pdd-raw-order-repo 仓储,支持原汁原味批量暂存、pending 单据消费、状态回填与重置; 3. 重构 pdd-sync-service 为采集暂存(Staging)与业务进单(Ingestion)两段式解耦流水线,实现断点续传; 4. 管理后台路由接入 raw-orders 原始流水查询及 replay 一键历史单重放 API。
This commit is contained in:
@@ -19,12 +19,69 @@ import { notifyPddCookieExpired } from '../../../services/notification/domain-no
|
||||
import {
|
||||
syncAllPddStores,
|
||||
syncStoreOrders,
|
||||
replayPddRawOrders,
|
||||
} from '../../../services/platforms/pdd/pdd-sync-service.js'
|
||||
import { listPddRawOrders } from '../../../repositories/platforms/pdd-raw-order-repo.js'
|
||||
import { testPddCookie } from '../../../services/platforms/pdd/pdd-client.js'
|
||||
import { createHttpError } from '../../../utils/http.js'
|
||||
|
||||
const router = Router()
|
||||
|
||||
/**
|
||||
* GET /platform-config/pdd/raw-orders
|
||||
* 查询拼多多原始流水暂存记录
|
||||
*/
|
||||
router.get(
|
||||
'/pdd/raw-orders',
|
||||
createJsonHandler(
|
||||
(req) => {
|
||||
const q = req.query as Record<string, string | undefined>
|
||||
return listPddRawOrders({
|
||||
page: q.page ? Number(q.page) : 1,
|
||||
pageSize: q.pageSize ? Number(q.pageSize) : 20,
|
||||
shopId: q.shopId,
|
||||
orderSn: q.orderSn,
|
||||
syncStatus: q.syncStatus,
|
||||
outSkuSn: q.outSkuSn,
|
||||
dateFrom: q.dateFrom,
|
||||
dateTo: q.dateTo,
|
||||
})
|
||||
},
|
||||
{
|
||||
successMessage: 'ok',
|
||||
errorMessage: '查询拼多多暂存订单失败',
|
||||
scope: '[admin/platform-config/pdd/raw-orders]',
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
/**
|
||||
* POST /platform-config/pdd/raw-orders/replay
|
||||
* 一键重置未匹配/失败的暂存单据为 pending 并触发转化入库
|
||||
*/
|
||||
router.post(
|
||||
'/pdd/raw-orders/replay',
|
||||
createJsonHandler(
|
||||
async (req) => {
|
||||
const body = (req.body || {}) as {
|
||||
shopId?: string
|
||||
orderSns?: string[]
|
||||
}
|
||||
return replayPddRawOrders(body)
|
||||
},
|
||||
{
|
||||
successMessage: '已重置暂存订单并触发重放',
|
||||
errorMessage: '重放暂存订单失败',
|
||||
scope: '[admin/platform-config/pdd/raw-orders/replay]',
|
||||
audit: (req) => ({
|
||||
action: 'platform_pdd_raw_orders_replayed',
|
||||
targetType: 'platform_raw_orders',
|
||||
targetId: String((req.body as { shopId?: string })?.shopId || 'all'),
|
||||
}),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
/**
|
||||
* GET /platform-config/pdd
|
||||
* Get complete PDD configuration and store list.
|
||||
|
||||
Reference in New Issue
Block a user