用户抓包(fxdd.dgjapp.com/NewOrder/List,dbname 空)返回 6 单抖店待发货, oms 拉取却是 0 单。逐个参数复刻后定位到 Filter 操作符写错: - 平台订单页发的是 `Filters[1][Contract]=%3D`(即单个 `=`) - OMS 发的是 `Contract: '=='`,抖店老分区(dzh93a8yur84Y3Yln2ha9RbPovVMhBTc) 直接回 `Success=false`「服务器繁忙,请稍会儿再试」 - 该错误被 `isFilterUnsupportedError` 当成「分区不支持过滤」→ 退化时间窗全量拉取 - 而平台**全量列表不返回待发货单**(实测 30 天 698/710 行全是 sended/success/close), 于是 6 单待发货怎么都拉不到,且被记成「拉取成功 0 单」 修复与验证: - `fetchOrderPage` 的 ErpState 过滤改为 `Contract: '='`(与浏览器一致); 实测三个分区均生效:抖店-186 → 6 单、精选平台四区 → 6 单、新系统区 → 0 单; `UpFxUserId` 的 `in` 过滤同样正常 - 修后 shop 19 一次拉单:18 单待处理(DYXD 12 / TB 4 / PDD 2), 其中 6 单 `875172835889885066` 等真抖店单已落 order_status_pending - 退化兜底分支补 warn:平台全量列表不含待发货单,命中兜底时要能看出可能漏单 - 单测 `dgjOrderQuery.test.js`:断言过滤条件为 `CreateTime:between | ErpState:= | UpFxUserId:in` - 文档更正 4.2.1 节:抓包是 `Contract=`,并记录本次踩坑与三分区对照表 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
65 lines
2.4 KiB
JavaScript
65 lines
2.4 KiB
JavaScript
'use strict';
|
|
|
|
const { assert } = require('egg-mock/bootstrap');
|
|
const DgjService = require('../../../app/lib/printPlatform/dgj');
|
|
|
|
describe('lib/printPlatform/dgj 订单查询报文口径', () => {
|
|
/**
|
|
* 造一个只用于报文断言的服务实例
|
|
* @return {Object} 店管家服务实例
|
|
*/
|
|
function buildService() {
|
|
return new DgjService({
|
|
platform: { code: 'dgj', name: '店管家', url: 'fxdd.dgjapp.com', fetch_waybill_no: 1 },
|
|
account: { id: 1, account: 'tester', password: 'pwd', token: 'token', cookie: '' },
|
|
});
|
|
}
|
|
|
|
it('ErpState 过滤的 Contract 必须是单个等号(写成 == 抖店老分区会回「服务器繁忙」)', async () => {
|
|
const service = buildService();
|
|
let captured = null;
|
|
service.request = async (url, options) => {
|
|
captured = new URLSearchParams(options.body);
|
|
return { status: 200, json: { Success: true, Data: { Rows: [], Total: 0 } }, text: '', setCookies: [] };
|
|
};
|
|
|
|
await service.fetchOrderPage('fxdd.dgjapp.com', {
|
|
traceId: 'trace',
|
|
dbname: 'dzh93a8yur84Y3Yln2ha9RbPovVMhBTc',
|
|
startTime: new Date('2026-10-09T00:00:00+08:00'),
|
|
endTime: new Date('2026-11-07T23:59:59+08:00'),
|
|
pageIndex: 1,
|
|
erpState: 'waitsellersend',
|
|
merchantFxUserId: '953516',
|
|
});
|
|
|
|
const contracts = [];
|
|
for (let index = 0; index < 5; index += 1) {
|
|
const name = captured.get(`Filters[${index}][Name]`);
|
|
if (!name) break;
|
|
contracts.push(`${name}:${captured.get(`Filters[${index}][Contract]`)}`);
|
|
}
|
|
console.log('过滤条件:', contracts.join(' | '));
|
|
assert.deepStrictEqual(contracts, [ 'CreateTime:between', 'ErpState:=', 'UpFxUserId:in' ]);
|
|
});
|
|
|
|
it('不传状态时只带时间窗', async () => {
|
|
const service = buildService();
|
|
let captured = null;
|
|
service.request = async (url, options) => {
|
|
captured = new URLSearchParams(options.body);
|
|
return { status: 200, json: { Success: true, Data: { Rows: [], Total: 0 } }, text: '', setCookies: [] };
|
|
};
|
|
await service.fetchOrderPage('fxali.dgjapp.com', {
|
|
traceId: 'trace',
|
|
dbname: '',
|
|
startTime: new Date('2026-11-01T00:00:00+08:00'),
|
|
endTime: new Date('2026-11-07T00:00:00+08:00'),
|
|
pageIndex: 1,
|
|
});
|
|
assert.strictEqual(captured.get('Filters[1][Name]'), null);
|
|
assert.strictEqual(captured.get('Filters[0][Contract]'), 'between');
|
|
assert.strictEqual(captured.get('PageSize'), '500');
|
|
});
|
|
});
|