feat: 补齐数据大盘京东 CPS 与金币展示
改了什么:数据大盘总收入/CPS 收入纳入京东 CPS;京东 CPS 卡片展示有效/无效订单;刷新按钮改为同步全部 CPS 订单;ARPU 展示产品确认的昨日活跃用户分母;激励视频金币展示真实值并标注已计入领券奖励。 验证方式:npx tsc --noEmit;浏览器验证 /dashboard 已显示京东 CPS、ARPU 分母和激励视频金币。
This commit is contained in:
@@ -381,19 +381,25 @@ export default function DashboardPage() {
|
||||
const regularTaskCoinTotal =
|
||||
periodData?.coins.regular_task_coin_total ??
|
||||
((signinCoinTotal ?? 0) + (signinBoostCoinTotal ?? 0) + (taskCoinTotal ?? 0));
|
||||
const cpsCommissionCents = data?.cps.meituan_commission_cents;
|
||||
const cpsAvailable = data?.cps.available === true;
|
||||
const meituanCpsCommissionCents = data?.cps.meituan_commission_cents;
|
||||
const jdCpsCommissionCents = data?.cps.jd_commission_cents;
|
||||
const totalCpsCommissionCents = cpsAvailable
|
||||
? (meituanCpsCommissionCents ?? 0) + (jdCpsCommissionCents ?? 0)
|
||||
: null;
|
||||
const totalRevenueYuan =
|
||||
adReport?.total_revenue_yuan == null && (!cpsAvailable || cpsCommissionCents == null)
|
||||
adReport?.total_revenue_yuan == null && totalCpsCommissionCents == null
|
||||
? null
|
||||
: (adReport?.total_revenue_yuan ?? 0) + (cpsAvailable ? (cpsCommissionCents ?? 0) / 100 : 0);
|
||||
: (adReport?.total_revenue_yuan ?? 0) + ((totalCpsCommissionCents ?? 0) / 100);
|
||||
const yesterdayTrendPoint = periodData?.trend?.[periodData.trend.length - 1];
|
||||
const yesterdayActiveUsers = yesterdayTrendPoint?.active_users ?? null;
|
||||
const arpuYuan =
|
||||
totalRevenueYuan == null || yesterdayActiveUsers == null || yesterdayActiveUsers <= 0
|
||||
? null
|
||||
: totalRevenueYuan / yesterdayActiveUsers;
|
||||
const cpsRevenueText = cpsAvailable ? fmtCents(cpsCommissionCents) : '--';
|
||||
const cpsRevenueText = cpsAvailable ? fmtCents(totalCpsCommissionCents) : '--';
|
||||
const meituanCpsRevenueText = cpsAvailable ? fmtCents(meituanCpsCommissionCents) : '--';
|
||||
const jdCpsRevenueText = cpsAvailable ? fmtCents(jdCpsCommissionCents) : '--';
|
||||
const cpsHitRate = !cpsAvailable || data?.cps.meituan_hit_rate == null ? '--' : pct(data.cps.meituan_hit_rate);
|
||||
const retentionValue =
|
||||
periodData?.users.retention_rate == null
|
||||
@@ -464,7 +470,7 @@ export default function DashboardPage() {
|
||||
return <Alert type="error" showIcon message={overviewError ?? '数据大盘加载失败'} />;
|
||||
}
|
||||
|
||||
const syncMeituanCps = async () => {
|
||||
const syncCpsOrders = async () => {
|
||||
setCpsSyncing(true);
|
||||
try {
|
||||
const resp = await api.post<{
|
||||
@@ -476,12 +482,13 @@ export default function DashboardPage() {
|
||||
params: {
|
||||
date_from: range.start.format('YYYY-MM-DD'),
|
||||
date_to: range.end.format('YYYY-MM-DD'),
|
||||
platform: 'all',
|
||||
},
|
||||
});
|
||||
message.success(`已同步 ${resp.data.fetched} 单`);
|
||||
setRefreshKey((v) => v + 1);
|
||||
} catch {
|
||||
message.error('美团订单刷新失败');
|
||||
message.error('CPS 订单刷新失败');
|
||||
} finally {
|
||||
setCpsSyncing(false);
|
||||
}
|
||||
@@ -597,7 +604,7 @@ export default function DashboardPage() {
|
||||
<h3>变现</h3>
|
||||
<span>
|
||||
{cpsAvailable
|
||||
? (adError ? '广告收益接口当前后端不可用,美团 CPS 已接入' : '广告收益与美团 CPS 已接入')
|
||||
? (adError ? '广告收益接口当前后端不可用,美团/京东 CPS 已接入' : '广告收益与美团/京东 CPS 已接入')
|
||||
: (adError ? '广告收益接口当前后端不可用,订单/佣金数据待接' : '广告收益已接入,订单/佣金数据待接')}
|
||||
</span>
|
||||
</div>
|
||||
@@ -620,33 +627,33 @@ export default function DashboardPage() {
|
||||
<RevenueCard
|
||||
title="CPS 收入"
|
||||
value={cpsRevenueText}
|
||||
meta={[{ label: '来源', value: cpsAvailable ? '美团已接,淘宝/京东暂空' : '订单/佣金待接' }]}
|
||||
meta={[{ label: '来源', value: cpsAvailable ? '美团、京东已接;淘宝暂未接入' : '订单/佣金待接' }]}
|
||||
/>
|
||||
<RevenueCard
|
||||
title="ARPU"
|
||||
value={adLoading ? '--' : fmtYuan(arpuYuan)}
|
||||
meta={[
|
||||
{ label: '口径', value: '收入 / 活跃用户' },
|
||||
{ label: 'ARPPU', value: '待确认付费用户口径' },
|
||||
{ label: '口径', value: '总收入 / 昨日活跃用户' },
|
||||
{ label: '分母', value: yesterdayActiveUsers == null ? '--' : `${fmtInt(yesterdayActiveUsers)} 人` },
|
||||
]}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="sub-label cps-sub-label">
|
||||
<span>CPS 收益</span>
|
||||
<button type="button" onClick={syncMeituanCps} disabled={cpsSyncing}>
|
||||
{cpsSyncing ? '刷新中' : '刷新美团订单'}
|
||||
<button type="button" onClick={syncCpsOrders} disabled={cpsSyncing}>
|
||||
{cpsSyncing ? '刷新中' : '刷新 CPS 订单'}
|
||||
</button>
|
||||
</div>
|
||||
<div className="grid g4">
|
||||
<RevenueCard
|
||||
title="总 CPS 收益"
|
||||
value={cpsRevenueText}
|
||||
meta={[{ label: '来源', value: cpsAvailable ? '美团订单佣金,淘宝/京东暂空' : '订单/佣金待接' }]}
|
||||
meta={[{ label: '来源', value: cpsAvailable ? '美团+京东订单佣金,淘宝暂未接入' : '订单/佣金待接' }]}
|
||||
/>
|
||||
<RevenueCard
|
||||
title="美团 CPS"
|
||||
value={cpsRevenueText}
|
||||
value={meituanCpsRevenueText}
|
||||
meta={[
|
||||
{ label: '订单量', value: cpsAvailable ? fmtInt(data?.cps.meituan_order_count) : '待订单数据' },
|
||||
{
|
||||
@@ -658,8 +665,16 @@ export default function DashboardPage() {
|
||||
]}
|
||||
accent="yellow"
|
||||
/>
|
||||
<RevenueCard title="淘宝 CPS" value="--" meta={[{ label: '状态', value: '后续接入后填写' }]} accent="red" />
|
||||
<RevenueCard title="京东 CPS" value="--" meta={[{ label: '状态', value: '后续接入后填写' }]} accent="red" />
|
||||
<RevenueCard title="淘宝 CPS" value="--" meta={[{ label: '状态', value: '暂未接入' }]} accent="red" />
|
||||
<RevenueCard
|
||||
title="京东 CPS"
|
||||
value={jdCpsRevenueText}
|
||||
meta={[
|
||||
{ label: '有效订单', value: cpsAvailable ? fmtInt(data?.cps.jd_order_count) : '待订单数据' },
|
||||
{ label: '无效订单', value: cpsAvailable ? fmtInt(data?.cps.jd_invalid_count ?? 0) : '待订单数据' },
|
||||
]}
|
||||
accent="red"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="sub-label">广告收益</div>
|
||||
@@ -719,7 +734,7 @@ export default function DashboardPage() {
|
||||
value={fmtInt(comparisonRewardCoinTotal)}
|
||||
status="比价相关发放"
|
||||
/>
|
||||
<StatCard title="激励视频金币" value="--" status="并入领券奖励" />
|
||||
<StatCard title="激励视频金币" value={fmtInt(periodData?.coins.reward_video_coin_total)} status="已计入领券奖励" />
|
||||
<StatCard
|
||||
title="常规任务金币"
|
||||
value={fmtInt(regularTaskCoinTotal)}
|
||||
|
||||
@@ -536,6 +536,11 @@ export interface DashboardOverview {
|
||||
meituan_miss_count: number;
|
||||
meituan_unknown_rate_count: number;
|
||||
meituan_hit_rate: number | null;
|
||||
jd_order_count?: number;
|
||||
jd_commission_cents?: number;
|
||||
jd_actual_commission_cents?: number;
|
||||
jd_estimated_commission_cents?: number;
|
||||
jd_invalid_count?: number;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user