perf(customs): request only tax refund orders

This commit is contained in:
2026-10-02 14:45:09 +08:00
parent c3a213d039
commit c06c105836
4 changed files with 49 additions and 14 deletions
@@ -1,9 +1,28 @@
import assert from 'node:assert/strict'
import { readFileSync } from 'node:fs'
import test from 'node:test'
import ts from 'typescript'
const source = readFileSync(new URL('./unifiedOrders.ts', import.meta.url), 'utf8')
test('forwards optional tax mode and pagination through the current GET endpoint', async () => {
const calls = []
const code = ts.transpileModule(source, { compilerOptions: { module: ts.ModuleKind.CommonJS } }).outputText
const api = {}
new Function('require', 'exports', code)(id => {
assert.equal(id, '@/api/http')
return { apiRequest: async config => { calls.push(config); return { records: [] } } }
}, api)
await api.getMerchantUnifiedOrders({ page: 2, size: 200, taxMode: 'TAX_REFUND' })
await api.getMerchantUnifiedOrders({ taxMode: 'BUY_DECLARATION' })
await api.getMerchantUnifiedOrders()
assert.deepEqual(calls, [
{ method: 'GET', url: '/merchant/v1/orders', params: { page: 2, size: 200, taxMode: 'TAX_REFUND' } },
{ method: 'GET', url: '/merchant/v1/orders', params: { page: 1, size: 200, taxMode: 'BUY_DECLARATION' } },
{ method: 'GET', url: '/merchant/v1/orders', params: { page: 1, size: 200 } },
])
})
test('keeps the merchant unified-order boundary and one-click palletization status', () => {
assert.match(source, /const unifiedOrderBaseUrl = '\/merchant\/v1\/orders'/)
assert.match(source, /ApiUnifiedOrderMainStatus[\s\S]*?'WAIT_PALLETIZE'/)
@@ -141,6 +141,7 @@ export interface MerchantUnifiedOrderDetail {
}
export interface MerchantUnifiedOrderQuery {
taxMode?: ApiTaxMode
keyword?: string
fbaCode?: string
orderNo?: string