diff --git a/apps/src/api/legacy/datav.ts b/apps/src/api/legacy/datav.ts index 86cdee2..4c3de51 100644 --- a/apps/src/api/legacy/datav.ts +++ b/apps/src/api/legacy/datav.ts @@ -12,6 +12,7 @@ export interface CountryDashboardMetric { luckyGiftAnchorShare: number | string; luckyGiftPayout: number | string; luckyGiftProfit: number | string; + luckyGiftProfitRate: number | string; luckyGiftTotalFlow: number | string; newUserRecharge: number | string; officialRecharge: number | string; diff --git a/apps/src/views/statistics/datav.vue b/apps/src/views/statistics/datav.vue index 509f744..0d99ea7 100644 --- a/apps/src/views/statistics/datav.vue +++ b/apps/src/views/statistics/datav.vue @@ -72,6 +72,7 @@ const metricColumns = new Set([ 'giftConsume', 'luckyGiftPayout', 'luckyGiftProfit', + 'luckyGiftProfitRate', 'luckyGiftTotalFlow', 'newUserRecharge', 'salaryExchange', @@ -91,6 +92,7 @@ const columns: any[] = [ { align: 'right', dataIndex: 'luckyGiftTotalFlow', key: 'luckyGiftTotalFlow', title: '幸运礼物流水', width: 150 }, { align: 'right', dataIndex: 'luckyGiftPayout', key: 'luckyGiftPayout', title: '幸运礼物返奖', width: 150 }, { align: 'right', dataIndex: 'luckyGiftProfit', key: 'luckyGiftProfit', title: '幸运礼物利润', width: 150 }, + { align: 'right', dataIndex: 'luckyGiftProfitRate', key: 'luckyGiftProfitRate', title: '幸运礼物利润率', width: 160 }, { align: 'right', dataIndex: 'gameTotalFlow', key: 'gameTotalFlow', title: '游戏流水', width: 130 }, { align: 'right', dataIndex: 'gamePayout', key: 'gamePayout', title: '游戏返奖', width: 130 }, { align: 'right', dataIndex: 'gameProfit', key: 'gameProfit', title: '游戏利润', width: 130 }, @@ -104,7 +106,9 @@ const summaryCards = computed(() => { { label: '新增用户', value: formatInteger(item?.countryNewUser) }, { label: '总充值', value: formatAmount(item?.totalRecharge) }, { label: '礼物消耗', value: formatAmount(item?.giftConsume) }, + { label: '幸运礼物流水', value: formatAmount(item?.luckyGiftTotalFlow) }, { label: '幸运礼物利润', value: formatAmount(item?.luckyGiftProfit) }, + { label: '幸运礼物利润率', value: formatPercent(resolveLuckyGiftProfitRate(item)) }, { label: '游戏流水', value: formatAmount(item?.gameTotalFlow) }, { label: '游戏利润', value: formatAmount(item?.gameProfit) }, ]; @@ -201,10 +205,48 @@ function formatAmount(value?: null | number | string) { : '0'; } +function formatPercent(value?: null | number | string) { + const number = Number(value || 0); + return Number.isFinite(number) + ? `${number.toLocaleString('en-US', { + maximumFractionDigits: 2, + minimumFractionDigits: 2, + })}%` + : '0.00%'; +} + +function resolveLuckyGiftProfitRate(record?: null | { + luckyGiftProfit?: number | string; + luckyGiftProfitRate?: number | string; + luckyGiftTotalFlow?: number | string; +}) { + if (!record) { + return 0; + } + if ( + record.luckyGiftProfitRate !== undefined && + record.luckyGiftProfitRate !== null && + record.luckyGiftProfitRate !== '' + ) { + const rate = Number(record.luckyGiftProfitRate); + if (Number.isFinite(rate)) { + return rate; + } + } + const flow = Number(record.luckyGiftTotalFlow || 0); + if (!Number.isFinite(flow) || flow === 0) { + return 0; + } + return (Number(record.luckyGiftProfit || 0) / flow) * 100; +} + function tableCellText(record: Record, key: string) { if (key === 'countryNewUser') { return formatInteger(record.countryNewUser); } + if (key === 'luckyGiftProfitRate') { + return formatPercent(resolveLuckyGiftProfitRate(record)); + } return formatAmount(record[key] as number | string); } @@ -314,7 +356,7 @@ onBeforeUnmount(() => { :data-source="records" :pagination="{ pageSize: 20, showSizeChanger: true }" :row-key="rowKey" - :scroll="{ x: 1900 }" + :scroll="{ x: 2060 }" size="small" >