diff --git a/src/lib/a5/data.test.ts b/src/lib/a5/data.test.ts index 6edc591..e04aecf 100644 --- a/src/lib/a5/data.test.ts +++ b/src/lib/a5/data.test.ts @@ -15,6 +15,12 @@ describe('A5 launch', () => { }) }) describe('A5 responses', () => { + it('uses the backend id as the order number, independently of payment identifiers', () => { + expect(adaptA5Order({ id: 42, order_id: 'legacy', transaction_id: 'payment-123', out_trade_no: 'merchant-456' })) + .toMatchObject({ order_id: '42', transaction_id: 'payment-123', out_trade_no: 'merchant-456' }) + expect(adaptA5Order({ id: 43 }).order_id).toBe('43') + expect(adaptA5Order({ transaction_id: 'payment-only' }).order_id).toBe('') + }) it('accepts numeric or string success codes, rejects failed HTTP and business responses', () => { expect(unwrapA5Response(200, '{"code":"0","data":[]}').data).toEqual([]) expect(() => unwrapA5Response(404, { code: 0 })).toThrow() diff --git a/src/pages/complaint/index.tsx b/src/pages/complaint/index.tsx index 702d65e..47929d7 100644 --- a/src/pages/complaint/index.tsx +++ b/src/pages/complaint/index.tsx @@ -132,8 +132,8 @@ export default function ComplaintPage ({ services }: { services?: ComplaintServi - 交易ID - {order?.out_trade_no || '-'} + {services ? '订单编号' : '交易ID'} + {(services ? order?.order_id : order?.out_trade_no) || '-'} 交易时间 diff --git a/src/pages/index/index.tsx b/src/pages/index/index.tsx index 48c63db..18429c0 100644 --- a/src/pages/index/index.tsx +++ b/src/pages/index/index.tsx @@ -179,8 +179,9 @@ export default function Index ({ a5 = false }: { a5?: boolean }) { a5={a5} order={order} onCopy={() => { - if (!order.transaction_id) return - Taro.setClipboardData({ data: String(order.transaction_id) }) + const number = a5 ? order.order_id : order.transaction_id + if (!number) return + Taro.setClipboardData({ data: String(number) }) }} onViewDetail={() => setDetailOrder(order)} onResubmit={() => openOrderPage('/pages/resubmit/index', order)} @@ -226,6 +227,7 @@ function OrderCard ({ onResubmit: () => void onComplaint: () => void }) { + const number = a5 ? order.order_id : order.transaction_id const status = (a5 && A5_STATUSES[order.process_status]) || getStatusMeta(order.process_status, order.process_status_name) const actions = a5 ? { complaint: true, submit: true, detail: order.process_status === '2' } : getOrderCardActions(order) @@ -242,9 +244,9 @@ function OrderCard ({ - 交易单号: - {order.transaction_id || '-'} - {order.transaction_id ? ( + {a5 ? '订单编号:' : '交易单号:'} + {number || '-'} + {number ? ( ) : null}