统一订单单状态模型

This commit is contained in:
yml2213
2026-07-31 17:02:19 +08:00
parent 677bdbbc1c
commit 04130e5ec8
19 changed files with 300 additions and 345 deletions
+20 -14
View File
@@ -131,10 +131,10 @@ export default function Dashboard() {
</Col>
<Col xs={24} sm={12} lg={8}>
<MetricCard
title="待履约订单"
value={stats?.pending_order_count ?? 0}
title="待发货订单"
value={stats?.paid_order_count ?? 0}
icon={<ClockCircleOutlined />}
color={(stats?.pending_order_count ?? 0) > 0 ? '#cf1322' : undefined}
color={(stats?.paid_order_count ?? 0) > 0 ? '#cf1322' : undefined}
/>
</Col>
</Row>
@@ -162,26 +162,32 @@ export default function Dashboard() {
<Card title="订单状态">
<Space direction="vertical" size="middle" style={{ width: '100%' }}>
<StatusLine
label="已成功"
value={stats?.succeeded_order_count ?? 0}
total={stats?.order_count ?? 0}
color="#52c41a"
/>
<StatusLine
label="待履约"
label="待支付"
value={stats?.pending_order_count ?? 0}
total={stats?.order_count ?? 0}
color="#faad14"
/>
<StatusLine
label="履约中"
value={stats?.processing_order_count ?? 0}
label="待发货"
value={stats?.paid_order_count ?? 0}
total={stats?.order_count ?? 0}
color="#1677ff"
/>
<StatusLine
label="已失败"
value={stats?.failed_order_count ?? 0}
label="发货中"
value={stats?.delivering_order_count ?? 0}
total={stats?.order_count ?? 0}
color="#13c2c2"
/>
<StatusLine
label="已交付"
value={stats?.delivered_order_count ?? 0}
total={stats?.order_count ?? 0}
color="#52c41a"
/>
<StatusLine
label="发货失败"
value={stats?.ship_failed_order_count ?? 0}
total={stats?.order_count ?? 0}
color="#ff4d4f"
/>
+14 -26
View File
@@ -41,18 +41,12 @@ import type {
WalletLedgerEntry,
} from '../types'
const fulfillmentStatusMap: Record<string, { color: string; text: string }> = {
pending: { color: 'orange', text: '待履约' },
processing: { color: 'cyan', text: '履约中' },
succeeded: { color: 'green', text: '已成功' },
failed: { color: 'red', text: '已失败' },
cancelled: { color: 'default', text: '已取消' },
}
const paymentStatusMap: Record<string, { color: string; text: string }> = {
const orderStatusMap: Record<string, { color: string; text: string }> = {
pending: { color: 'orange', text: '待支付' },
paid: { color: 'blue', text: '已支付' },
refunded: { color: 'purple', text: '已退款' },
paid: { color: 'blue', text: '待发货' },
delivering: { color: 'cyan', text: '发货中' },
delivered: { color: 'green', text: '已交付' },
ship_failed: { color: 'red', text: '发货失败' },
cancelled: { color: 'default', text: '已取消' },
}
@@ -78,8 +72,8 @@ const eventOptions = [
]
const testOrderStatusOptions = [
{ value: 'pending', label: '已支付,可发货' },
{ value: 'failed', label: '发货失败,可重试' },
{ value: 'paid', label: '已支付,可发货' },
{ value: 'ship_failed', label: '发货失败,可重试' },
]
type MerchantCenterTab = 'products' | 'orders' | 'wallet' | 'api' | 'callbacks' | 'members'
@@ -347,7 +341,7 @@ export default function MerchantCenter({ fixedTab, title = '商户中心' }: Mer
testOrderForm.setFieldsValue({
buyer_reference: '测试买家',
note: '联调测试订单',
fulfillment_status: 'pending',
order_status: 'paid',
})
setTestOrderOpen(true)
setTestOrderProductsLoading(true)
@@ -374,7 +368,7 @@ export default function MerchantCenter({ fixedTab, title = '商户中心' }: Mer
sku: values.sku,
buyer_reference: values.buyer_reference,
note: values.note,
fulfillment_status: values.fulfillment_status,
order_status: values.order_status,
})
setTestOrderOpen(false)
setTestOrderResult(result)
@@ -494,8 +488,7 @@ export default function MerchantCenter({ fixedTab, title = '商户中心' }: Mer
{ title: '基础金额', dataIndex: 'base_amount', width: 88, render: money },
{ title: '手续费', dataIndex: 'service_fee_amount', width: 82, render: money },
{ title: '扣款合计', dataIndex: 'amount', width: 88, render: money },
{ title: '支付', dataIndex: 'payment_status', width: 76, render: paymentStatusTag },
{ title: '履约', dataIndex: 'fulfillment_status', width: 86, render: fulfillmentStatusTag },
{ title: '状态', dataIndex: 'order_status', width: 92, render: orderStatusTag },
{ title: '上游单号', dataIndex: 'provider_order_no', width: 120, ellipsis: true, render: (v) => v || '-' },
{
title: '链接有效期',
@@ -791,7 +784,7 @@ export default function MerchantCenter({ fixedTab, title = '商户中心' }: Mer
<Form.Item name="buyer_reference" label="买家名称" rules={[{ max: 128 }]}>
<Input />
</Form.Item>
<Form.Item name="fulfillment_status" label="可发货状态" rules={[{ required: true }]}>
<Form.Item name="order_status" label="订单状态" rules={[{ required: true }]}>
<Select options={testOrderStatusOptions} />
</Form.Item>
<Form.Item name="note" label="备注" rules={[{ max: 512 }]}>
@@ -1004,14 +997,9 @@ function productOptionLabel(item: MerchantProduct) {
return name === item.sku ? item.sku : `${name} / ${item.sku}`
}
function paymentStatusTag(value: string) {
const item = paymentStatusMap[value] || { color: 'default', text: value }
return <Tag color={item.color}>{item.text}</Tag>
}
function fulfillmentStatusTag(value: string) {
const item = fulfillmentStatusMap[value] || { color: 'default', text: value }
return <Tag color={item.color}>{item.text}</Tag>
function orderStatusTag(value: string) {
const item = orderStatusMap[value] || { color: 'default', text: value }
return <Tag color={item.color}>{item.text}</Tag>
}
function ledgerTypeTag(value: string) {
+2 -16
View File
@@ -7,7 +7,6 @@ import {
endpoints,
errorCodes,
orderStatusTable,
paymentStatusTable,
} from '../openapi/endpoints'
import { endpointSections, type EndpointSpec } from '../openapi/types'
@@ -453,7 +452,7 @@ function EndpointSection({ spec }: { spec: EndpointSpec }) {
function StatusSection() {
return (
<SectionWrap id="status" title="状态说明">
<Card className="api-docs__card" size="small" title="履约状态 fulfillment_status 与 can_fulfill">
<Card className="api-docs__card" size="small" title="订单状态 order_status 与 can_fulfill">
<Table
className="api-docs__table"
size="small"
@@ -473,19 +472,6 @@ function StatusSection() {
]}
/>
</Card>
<Card className="api-docs__card" size="small" title="支付状态 payment_status">
<Table
className="api-docs__table"
size="small"
pagination={false}
rowKey="name"
dataSource={paymentStatusTable}
columns={[
{ title: '状态', dataIndex: 'name', width: 140, render: (v) => <Text code>{v}</Text> },
{ title: '说明', dataIndex: 'desc' },
]}
/>
</Card>
<Alert
className="api-docs__alert"
type="info"
@@ -501,7 +487,7 @@ POST /orders 下单(client_order_no 幂等)
发货平台查询订单并执行发货
发货平台通过上游回调更新 fulfillment_status
发货平台通过上游回调更新 order_status
GET /orders/{order_no} 轮询,或接收 order.fulfillment.updated 回调`}</pre>
}