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): StatusOption[] { return Object.entries(map).map(([value, meta]) => ({ value, label: meta.label })) } export const orderStatusMap: Record = { 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 = { 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 = { 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 = { none: { label: '无需线下结算', tone: 'default' }, pending: { label: '待确认线下结算', tone: 'gold' }, settled: { label: '已确认线下结算', tone: 'success' }, } export const handoffModeMap: Record = { owner: { label: '正常订单', tone: 'default' }, platform: { label: '平台代管', tone: 'geekblue' }, } export const settlementModeMap: Record = { owner_wallet: { label: '号主钱包', tone: 'default' }, platform_managed: { label: '平台代管', tone: 'geekblue' }, } export const checkoutStatusMap: Record = { submitted: { label: '待确认', tone: 'gold' }, countered: { label: '已修正待确认', tone: 'orange' }, accepted: { label: '已接受', tone: 'success' }, disputed: { label: '争议中', tone: 'red' }, settled: { label: '仲裁已结案', tone: 'purple' }, } export const refundStatusMap: Record = { 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, 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 = { 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, })) export const userStatusMap: Record = { active: { label: '正常', tone: 'success' }, frozen: { label: '已冻结', tone: 'red' }, disabled: { label: '已禁用', tone: 'default' }, } export const realnameStatusMap: Record = { unverified: { label: '未实名', tone: 'default' }, pending: { label: '认证中', tone: 'gold' }, verified: { label: '已实名', tone: 'success' }, rejected: { label: '认证失败', tone: 'red' }, } export const riskStatusMap: Record = { normal: { label: '正常', tone: 'success' }, watch: { label: '观察', tone: 'gold' }, restricted: { label: '受限', tone: 'orange' }, blocked: { label: '已拦截', tone: 'red' }, } export const userStatusOptions = toOptions(userStatusMap) export const realnameStatusOptions = toOptions(realnameStatusMap) export const riskStatusOptions = toOptions(riskStatusMap) export const withdrawalStatusMap: Record = { pending: { label: '待审核', tone: 'gold' }, processing: { label: '待打款', tone: 'blue' }, completed: { label: '已完成', tone: 'success' }, rejected: { label: '已驳回', tone: 'red' }, cancelled: { label: '已取消', tone: 'default' }, } export const withdrawalStatusOptions = toOptions(withdrawalStatusMap) export const financeStatusMap: Record = { normal: { label: '正常', tone: 'success' }, refund_pending: { label: '退款中', tone: 'blue' }, refund_failed: { label: '退款失败', tone: 'red' }, settlement_diff: { label: '结算差异', tone: 'orange' }, offline_settlement_pending: { label: '待线下结算', tone: 'gold' }, } export const announcementStatusMap: Record = { draft: { label: '草稿', tone: 'default' }, published: { label: '已发布', tone: 'success' }, archived: { label: '已归档', tone: 'default' }, } export const announcementCategoryMap: Record = { notice: '通知', tutorial: '教程', rule: '规则', faq: '常见问题', } export const announcementStatusOptions = Object.entries(announcementStatusMap).map( ([value, meta]) => ({ value, label: meta.label }) ) export const announcementCategoryOptions = Object.entries(announcementCategoryMap).map( ([value, label]) => ({ value, label }) ) export const auditActorTypeMap: Record = { admin: '管理员', user: '用户', system: '系统', } export const auditBizTypeMap: Record = { order: '订单', listing: '商品', dispute: '申诉', admin_user: '用户资料', admin: '后台账号', system_config: '系统配置', payment_config: '支付配置', manual_disbursement: '人工打款', operating_expense: '运营支出', pickup: '线下提号', pickup_shop: '提号店铺', distribution: '分销', announcement: '公告', } export const auditActionMap: Record = { 'order.admin_close': '后台关闭订单', 'order.admin_seal': '订单封存', 'order.deposit_hold': '冻结押金', 'order.deposit_release': '释放押金', 'order.force_handoff': '强制交接', 'order.mark_abnormal': '标记异常订单', 'order.offline_settlement': '线下结算', 'order.platform_handoff': '平台代交接', 'order.platform_checkout_confirm': '平台代确认结账', 'order.platform_checkout_counter': '平台修正结账', 'order.platform_checkout_dispute': '平台发起结账争议', 'order.reset_checkout_confirm': '重置结账确认', 'order.reset_handoff': '重置交接状态', 'order.reset_renter_confirm': '重置租客确认', 'order.reset_return_overdue': '重置归还逾期', 'listing.adjust_external': '调整外部同步', 'listing.adjust_review_price': '调整审核价', 'listing.admin_offline': '后台下架商品', 'listing.mark_abnormal': '标记异常商品', 'listing.transfer_owner': '转移商品归属', 'listing.update_screenshots': '更新商品截图', 'dispute.admin_create': '代建申诉', 'dispute.arbitrate': '提交仲裁', 'admin_user.freeze': '冻结用户', 'admin_user.unfreeze': '解冻用户', 'admin_user.set_deposit_free_quota': '设置免押额度', 'admin_user.adjust_growth_points': '调整成长值', 'admin_user.manual_realname': '人工实名', 'admin_user.revoke_realname': '撤销实名', 'admin_user.wallet_adjust': '调整钱包余额', 'system_config.create': '新增系统配置', 'system_config.update': '更新系统配置', 'payment_config.create': '新增支付配置', 'payment_config.update': '更新支付配置', 'payment_config.delete': '删除支付配置', 'payment_config.export': '导出支付配置', 'payment_config.import': '导入支付配置', 'payment_config.view_secret': '查看支付密钥', 'manual_disbursement_create': '新建人工打款', 'manual_disbursement_void': '作废人工打款', 'operating_expense_create': '登记运营支出', 'operating_expense_void': '作废运营支出', 'pickup_create': '创建线下提号', 'pickup_cancel': '取消线下提号', 'pickup_complete': '完成线下提号', 'pickup_profit_update': '更新提号利润', 'pickup_offline_settlement': '提号线下结算', 'pickup_financial_adjustment_create': '新建提号财务调整', 'pickup_financial_adjustment_settle': '结算提号财务调整', 'pickup_shop_create': '新增提号店铺', 'pickup_shop_update': '更新提号店铺', 'pickup_shop_delete': '删除提号店铺', 'pickup_shop_map_historical': '关联历史捡漏店铺', 'pickup_shop_unmap_historical': '解除历史捡漏店铺', 'pickup_third_party_order_no_update': '更新第三方单号', 'distribution_financial_snapshot_create': '生成分销财务快照', 'auth.token_version.bump': '刷新登录令牌版本', } export const auditActionOptions = Object.entries(auditActionMap).map(([value, label]) => ({ value, label, })) export const auditBizTypeOptions = Object.entries(auditBizTypeMap).map(([value, label]) => ({ value, label, })) export const systemConfigCategoryMap: Record = { chat: '聊天与群组', distribution: '分销', handoff: '交接与超时', integration: '第三方集成', listing: '商品发布', mobile: '移动端首页', order: '订单', profile: '个人中心', renter: '租客成长', sms: '短信', } export const systemConfigCategoryOptions = Object.entries(systemConfigCategoryMap).map( ([value, label]) => ({ value, label }) ) export function systemConfigCategory(key: string) { return key.split('.')[0] || 'other' } export function systemConfigCategoryLabel(key: string) { const category = systemConfigCategory(key) return systemConfigCategoryMap[category] ?? category } export const distributionSiteStatusMap: Record = { active: { label: '运营中', tone: 'success' }, disabled: { label: '已停用', tone: 'default' }, } export const distributionSiteStatusOptions = toOptions(distributionSiteStatusMap) export const distributionMemberTypeMap: Record = { operator: '运营', finance: '财务', customer_service: '客服', } export const announcementModeMap: Record = { inherit: '继承主站公告', own_only: '仅本站公告', } export const financeDisbursementSourceMap: Record = { platform_managed: '平台代管', pickup: '线下提号', pickup_adjustment: '提号调整', withdrawal: '钱包提现', manual_offline: '线下出款', } export const financeDisbursementStatusMap: Record = { review_pending: { label: '待审核', tone: 'gold' }, payment_pending: { label: '待打款', tone: 'blue' }, paid: { label: '已打款', tone: 'success' }, rejected: { label: '已驳回', tone: 'red' }, cancelled: { label: '已取消', tone: 'default' }, voided: { label: '已作废', tone: 'default' }, } export const financeDisbursementStatusOptions = Object.entries(financeDisbursementStatusMap).map( ([value, meta]) => ({ value, label: meta.label }) ) export const financeDisbursementSourceOptions = Object.entries(financeDisbursementSourceMap).map( ([value, label]) => ({ value, label }) ) export const manualDisbursementCategoryMap: Record = { user_compensation: '用户补偿', seller_supplement: '卖家补款', operating_expense: '运营支出', channel_fee: '渠道费用', duoduo_deposit_refund: '多多退押金', other: '其他', custom: '自定义分类', } export const manualDisbursementCategoryOptions = Object.entries(manualDisbursementCategoryMap).map( ([value, label]) => ({ value, label }) ) export const operatingExpenseStatusMap: Record = { paid: { label: '已记账', tone: 'success' }, voided: { label: '已作废', tone: 'default' }, } export const operatingExpenseStatusOptions = Object.entries(operatingExpenseStatusMap).map( ([value, meta]) => ({ value, label: meta.label }) )