mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 17:49:19 +08:00
refactor: 调整订单表
This commit is contained in:
@@ -3,11 +3,25 @@
|
||||
*/
|
||||
import type { OrderItemVO, OrderVO } from '#/api/ecommerce/order';
|
||||
|
||||
/** 实付/商家实收(兼容 receivedAmount 别名) */
|
||||
/** 买家实付 */
|
||||
export function getOrderPayAmount(
|
||||
order: Pick<OrderVO.Info, 'payAmount'>,
|
||||
): number {
|
||||
return Number(order.payAmount ?? 0);
|
||||
}
|
||||
|
||||
/** 商家实收(缺省时回退实付,兼容旧数据) */
|
||||
export function getOrderReceivedAmount(
|
||||
order: Pick<OrderVO.Info, 'payAmount' | 'receivedAmount'>,
|
||||
): number {
|
||||
return Number(order.payAmount ?? order.receivedAmount ?? 0);
|
||||
return Number(order.receivedAmount ?? order.payAmount ?? 0);
|
||||
}
|
||||
|
||||
/** 平台服务费 */
|
||||
export function getOrderServiceFee(
|
||||
order: Pick<OrderVO.Info, 'serviceFee'>,
|
||||
): number {
|
||||
return Number(order.serviceFee ?? 0);
|
||||
}
|
||||
|
||||
/** 首行明细(列表/卡片单行展示) */
|
||||
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* 电商平台展示:与后端 PlatformCode 枚举对齐,覆盖全部预置平台。
|
||||
* 文案以字典 API / 后端 platformLabel 为准;色板仅前端展示用。
|
||||
*/
|
||||
|
||||
export type PlatformTagColor =
|
||||
| 'blue'
|
||||
| 'cyan'
|
||||
| 'default'
|
||||
| 'error'
|
||||
| 'geekblue'
|
||||
| 'gold'
|
||||
| 'green'
|
||||
| 'lime'
|
||||
| 'magenta'
|
||||
| 'orange'
|
||||
| 'processing'
|
||||
| 'purple'
|
||||
| 'red'
|
||||
| 'success'
|
||||
| 'volcano'
|
||||
| 'warning';
|
||||
|
||||
export interface PlatformDisplayMeta {
|
||||
code: string;
|
||||
/** 默认中文名(字典未加载时回退) */
|
||||
label: string;
|
||||
color: PlatformTagColor;
|
||||
}
|
||||
|
||||
/** 与 PlatformCode 一一对应;未知 code 走 fallback */
|
||||
const PLATFORM_META: Record<string, PlatformDisplayMeta> = {
|
||||
taobao: { code: 'taobao', label: '淘宝', color: 'orange' },
|
||||
jd: { code: 'jd', label: '京东', color: 'red' },
|
||||
pdd: { code: 'pdd', label: '拼多多', color: 'volcano' },
|
||||
douyin: { code: 'douyin', label: '抖音', color: 'magenta' },
|
||||
kuaishou: { code: 'kuaishou', label: '快手', color: 'gold' },
|
||||
xiaohongshu: { code: 'xiaohongshu', label: '小红书', color: 'error' },
|
||||
tmall: { code: 'tmall', label: '天猫', color: 'red' },
|
||||
vip: { code: 'vip', label: '唯品会', color: 'purple' },
|
||||
suning: { code: 'suning', label: '苏宁', color: 'blue' },
|
||||
'1688': { code: '1688', label: '1688', color: 'cyan' },
|
||||
};
|
||||
|
||||
export function getPlatformMeta(code?: null | string): PlatformDisplayMeta | null {
|
||||
if (!code || !code.trim()) return null;
|
||||
const key = code.trim().toLowerCase();
|
||||
return PLATFORM_META[key] ?? null;
|
||||
}
|
||||
|
||||
export function getPlatformTagColor(code?: null | string): PlatformTagColor {
|
||||
return getPlatformMeta(code)?.color ?? 'default';
|
||||
}
|
||||
|
||||
/** 展示名:优先后端/字典 label,再本地映射,最后原 code */
|
||||
export function getPlatformLabel(
|
||||
code?: null | string,
|
||||
preferredLabel?: null | string,
|
||||
): string {
|
||||
if (preferredLabel && preferredLabel.trim()) return preferredLabel.trim();
|
||||
const meta = getPlatformMeta(code);
|
||||
if (meta) return meta.label;
|
||||
if (code && code.trim()) return code.trim();
|
||||
return '未关联平台';
|
||||
}
|
||||
|
||||
export function listBuiltinPlatformMetas(): PlatformDisplayMeta[] {
|
||||
return Object.values(PLATFORM_META);
|
||||
}
|
||||
Reference in New Issue
Block a user