fix: calculate dashboard summary profit rate

This commit is contained in:
zhx 2026-05-24 14:08:31 +08:00
parent 854048d6e8
commit b7f674b097

View File

@ -761,6 +761,10 @@ function resolveLuckyGiftProfitRate(record?: null | {
if (!record) { if (!record) {
return 0; return 0;
} }
const flow = toAmount(record.luckyGiftTotalFlow);
if (flow !== 0) {
return (toAmount(record.luckyGiftProfit) / flow) * 100;
}
if ( if (
record.luckyGiftProfitRate !== undefined && record.luckyGiftProfitRate !== undefined &&
record.luckyGiftProfitRate !== null && record.luckyGiftProfitRate !== null &&
@ -771,11 +775,7 @@ function resolveLuckyGiftProfitRate(record?: null | {
return rate; return rate;
} }
} }
const flow = Number(record.luckyGiftTotalFlow || 0); return 0;
if (!Number.isFinite(flow) || flow === 0) {
return 0;
}
return (Number(record.luckyGiftProfit || 0) / flow) * 100;
} }
function resolveMetricRate(record: Record<string, any>, key: string) { function resolveMetricRate(record: Record<string, any>, key: string) {