feat: add lucky gift profit rate to dashboard
This commit is contained in:
parent
4470a95a91
commit
ccf7520107
@ -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;
|
||||
|
||||
@ -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<string, any>, 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"
|
||||
>
|
||||
<template #bodyCell="{ column, record }">
|
||||
@ -413,7 +455,7 @@ onBeforeUnmount(() => {
|
||||
.summary-grid {
|
||||
display: grid;
|
||||
gap: 12px;
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.summary-card {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user