feat(admin): 新增后台订单列表与详情抽屉
This commit is contained in:
@@ -0,0 +1,157 @@
|
||||
export type TagTone =
|
||||
| 'default'
|
||||
| 'success'
|
||||
| 'processing'
|
||||
| 'error'
|
||||
| 'warning'
|
||||
| 'gold'
|
||||
| 'blue'
|
||||
| 'cyan'
|
||||
| 'orange'
|
||||
| 'red'
|
||||
| 'purple'
|
||||
| 'geekblue'
|
||||
| 'magenta'
|
||||
| 'volcano'
|
||||
| 'green'
|
||||
|
||||
export interface StatusMeta {
|
||||
label: string
|
||||
tone: TagTone
|
||||
}
|
||||
|
||||
export interface StatusOption {
|
||||
label: string
|
||||
value: string
|
||||
}
|
||||
|
||||
function toOptions(map: Record<string, StatusMeta>): StatusOption[] {
|
||||
return Object.entries(map).map(([value, meta]) => ({ value, label: meta.label }))
|
||||
}
|
||||
|
||||
export const orderStatusMap: Record<string, StatusMeta> = {
|
||||
pending_payment: { label: '待支付', tone: 'gold' },
|
||||
pending_handoff: { label: '待交接', tone: 'blue' },
|
||||
renting: { label: '使用中', tone: 'cyan' },
|
||||
overdue: { label: '已逾期', tone: 'volcano' },
|
||||
pending_checkout_confirm: { label: '待号主确认结账', tone: 'orange' },
|
||||
pending_checkout_accept: { label: '待租客确认修正', tone: 'orange' },
|
||||
checkout_disputing: { label: '结账争议中', tone: 'red' },
|
||||
disputing: { label: '申诉中', tone: 'red' },
|
||||
completed: { label: '已完成', tone: 'success' },
|
||||
cancelled: { label: '租客已取消', tone: 'default' },
|
||||
closed: { label: '客服已关闭', tone: 'default' },
|
||||
abnormal: { label: '客服介入', tone: 'magenta' },
|
||||
}
|
||||
|
||||
export const handoffStatusMap: Record<string, StatusMeta> = {
|
||||
none: { label: '未开始', tone: 'default' },
|
||||
pending_owner: { label: '待号主交接', tone: 'blue' },
|
||||
owner_timeout: { label: '号主交接超时', tone: 'volcano' },
|
||||
pending_renter_confirm: { label: '待租客确认', tone: 'blue' },
|
||||
received: { label: '租客已收号', tone: 'cyan' },
|
||||
return_overdue: { label: '归还逾期', tone: 'volcano' },
|
||||
pending_owner_checkout: { label: '待号主确认结账', tone: 'orange' },
|
||||
pending_renter_checkout: { label: '待租客确认修正', tone: 'orange' },
|
||||
checkout_disputed: { label: '结账争议中', tone: 'red' },
|
||||
returned: { label: '已归还', tone: 'success' },
|
||||
owner_return_confirm_timeout: { label: '号主确认结账超时', tone: 'red' },
|
||||
owner_checkout_confirm_timeout: { label: '号主确认结账超时', tone: 'red' },
|
||||
renter_confirm_timeout: { label: '租客确认超时', tone: 'red' },
|
||||
cancelled: { label: '租客已取消', tone: 'default' },
|
||||
admin_closed: { label: '客服已关闭', tone: 'default' },
|
||||
admin_abnormal: { label: '客服介入', tone: 'magenta' },
|
||||
arbitrated: { label: '已仲裁', tone: 'purple' },
|
||||
}
|
||||
|
||||
export const settlementStatusMap: Record<string, StatusMeta> = {
|
||||
unsettled: { label: '未结算', tone: 'default' },
|
||||
pending: { label: '待结算', tone: 'gold' },
|
||||
frozen: { label: '冻结中', tone: 'magenta' },
|
||||
settled: { label: '已结算', tone: 'success' },
|
||||
refunded: { label: '已退款', tone: 'blue' },
|
||||
cancelled: { label: '结算已取消', tone: 'default' },
|
||||
closed: { label: '结算已关闭', tone: 'default' },
|
||||
disputed: { label: '争议中', tone: 'red' },
|
||||
arbitrated: { label: '已仲裁', tone: 'purple' },
|
||||
}
|
||||
|
||||
export const offlineSettlementStatusMap: Record<string, StatusMeta> = {
|
||||
none: { label: '无需线下结算', tone: 'default' },
|
||||
pending: { label: '待确认线下结算', tone: 'gold' },
|
||||
settled: { label: '已确认线下结算', tone: 'success' },
|
||||
}
|
||||
|
||||
export const handoffModeMap: Record<string, StatusMeta> = {
|
||||
owner: { label: '正常订单', tone: 'default' },
|
||||
platform: { label: '平台代管', tone: 'geekblue' },
|
||||
}
|
||||
|
||||
export const settlementModeMap: Record<string, StatusMeta> = {
|
||||
owner_wallet: { label: '号主钱包', tone: 'default' },
|
||||
platform_managed: { label: '平台代管', tone: 'geekblue' },
|
||||
}
|
||||
|
||||
export const checkoutStatusMap: Record<string, StatusMeta> = {
|
||||
submitted: { label: '待确认', tone: 'gold' },
|
||||
countered: { label: '已修正待确认', tone: 'orange' },
|
||||
accepted: { label: '已接受', tone: 'success' },
|
||||
disputed: { label: '争议中', tone: 'red' },
|
||||
settled: { label: '仲裁已结案', tone: 'purple' },
|
||||
}
|
||||
|
||||
export const refundStatusMap: Record<string, StatusMeta> = {
|
||||
none: { label: '未退款', tone: 'default' },
|
||||
pending: { label: '待退款', tone: 'gold' },
|
||||
pending_review: { label: '待客服审核退款', tone: 'orange' },
|
||||
refunding: { label: '退款中', tone: 'processing' },
|
||||
refunded: { label: '已退款', tone: 'success' },
|
||||
failed: { label: '退款失败', tone: 'red' },
|
||||
}
|
||||
|
||||
export function readStatusMeta(map: Record<string, StatusMeta>, value?: string | null): StatusMeta {
|
||||
if (!value) return { label: '—', tone: 'default' }
|
||||
return map[value] ?? { label: value, tone: 'default' }
|
||||
}
|
||||
|
||||
/**
|
||||
* 平台代管订单的交接动作由客服执行,展示文案需要区别于普通号主订单。
|
||||
*/
|
||||
export function handoffStatusMeta(
|
||||
status?: string | null,
|
||||
order?: { handoff_mode?: string; settlement_mode?: string } | null
|
||||
) {
|
||||
const platformManaged =
|
||||
order?.handoff_mode === 'platform' || order?.settlement_mode === 'platform_managed'
|
||||
if (!platformManaged || !status) return readStatusMeta(handoffStatusMap, status)
|
||||
const platformCopy: Record<string, StatusMeta> = {
|
||||
pending_owner: { label: '待客服交接', tone: 'blue' },
|
||||
owner_timeout: { label: '客服交接超时', tone: 'volcano' },
|
||||
pending_owner_checkout: { label: '待客服确认结账', tone: 'orange' },
|
||||
owner_checkout_confirm_timeout: { label: '客服确认结账超时', tone: 'red' },
|
||||
}
|
||||
return platformCopy[status] ?? readStatusMeta(handoffStatusMap, status)
|
||||
}
|
||||
|
||||
export const orderStatusOptions = toOptions(orderStatusMap)
|
||||
|
||||
export const handoffStatusOptions = [
|
||||
'pending_owner',
|
||||
'owner_timeout',
|
||||
'pending_renter_confirm',
|
||||
'received',
|
||||
'return_overdue',
|
||||
'pending_owner_checkout',
|
||||
'pending_renter_checkout',
|
||||
'checkout_disputed',
|
||||
'returned',
|
||||
'admin_closed',
|
||||
'admin_abnormal',
|
||||
].map(value => ({ value, label: handoffStatusMap[value].label }))
|
||||
|
||||
export const handoffModeOptions = toOptions(handoffModeMap)
|
||||
export const settlementStatusOptions = toOptions(settlementStatusMap)
|
||||
export const offlineSettlementStatusOptions = ['pending', 'settled'].map(value => ({
|
||||
value,
|
||||
label: offlineSettlementStatusMap[value].label,
|
||||
}))
|
||||
Reference in New Issue
Block a user