|
|
0e202fabd8
|
fix(dashboard): 统一玩家盈亏分析产出口径
将玩家盈亏趋势中的商品产出从当前资产快照估值,
调整为按用户、订单、抽奖日志链路聚合的商品成本口径。
这样可使商品产出与消费看板中的活动产出统计保持一致,
避免同一用户在两个面板中看到不同的商品产出口径。
同时保留积分、道具卡、优惠券三项当前分项展示,
避免接口结构调整后页面字段缺失或被误显示为 0。
|
2026-04-18 01:15:11 +08:00 |
|
|
|
58fd926b46
|
fix(finance): 统一收益统计口径,修复多处数据计算错误
1. Revenue 口径统一为 actual_amount(真实现金到账)
- 优惠券(discount_amount)和积分(points_amount)是平台免费发放的营销补贴,
不算收入,改为展示字段
- 涉及: profit_metrics.go, dashboard_spending.go, users_profit_loss.go,
dashboard_user_spending.go, activity_rankings_admin.go
2. Cost 口径统一为奖品库存价值
- 删除 finance service 中的积分成本扫描(Step 3)和优惠券成本扫描(Step 4)
- 之前优惠券同时算在收入和成本两侧,导致利润被人为压低
- 涉及: query_user.go, query_activity.go
3. 统一 value_cents fallback chain
- finance service 改为与排行榜一致的三级回退:
COALESCE(NULLIF(value_cents,0), price_snapshot_cents, products.price, 0)
- 涉及: query_user.go, query_activity.go
4. 活动盈亏收入统一到 finance service
- 删除 dashboard_activity.go 自有的 revenue SQL(含比例分摊逻辑)
- 收入和成本统一由 finance.Service.QueryActivityProfitLoss() 提供
- 修复日志明细 profit:道具卡倍率改用 ComputePrizeCostWithMultiplier
5. finance service 新增展示字段
- ProfitLossDetail 增加 CouponDiscount, PointsDiscount, GamePassValue
- 不参与 Revenue/Cost/Profit 计算,仅供前端展示营销补贴明细
6. 修复对对碰次卡订单 discount_amount 数据污染
- matching_game_app.go 次卡下单时 DiscountAmount 错误设为活动全价
- 改为 0(次卡支付不涉及优惠券)
- 附带历史数据修复 migration SQL
7. 排除已分解奖品的成本重复计算
- 用户可以把奖品分解成积分再兑换新商品,导致同一份价值被计算两次
- 所有库存查询增加排除条件: status=3 且 remark 含 redeemed_points 或 batch_redeemed
- 涉及 6 个文件的库存成本/资产查询
8. 排行榜详情抽屉限定活动范围
- prize 查询增加 activity_id > 0 过滤,排除积分兑换/转入/合成等非活动产出
- 使排行榜与其详情抽屉口径一致
修改文件(12个):
- internal/service/finance/profit_metrics.go
- internal/service/finance/query_user.go
- internal/service/finance/query_activity.go
- internal/service/finance/types.go
- internal/api/admin/dashboard_activity.go
- internal/api/admin/dashboard_spending.go
- internal/api/admin/dashboard_user_spending.go
- internal/api/admin/users_profit_loss.go
- internal/api/admin/users_profile.go
- internal/api/admin/activity_rankings_admin.go
- internal/api/activity/matching_game_app.go
- migrations/20260325_fix_matching_gamepass_discount.sql
|
2026-03-26 00:01:17 +08:00 |
|
|
|
5b34972ee3
|
fix(dashboard): 盈亏分析CAST修复+视角改为平台视角(A-B)
1. CAST修复:
MySQL的 / 运算符返回DECIMAL类型,GORM无法将DECIMAL扫描进int64,
导致商品产出静默返回0。添加 CAST(... AS SIGNED) 与排行榜对齐。
2. 视角统一:
盈亏分析原为用户视角(B-A),排行榜为平台视角(A-B),同一用户
一个显示+¥12,130(用户赚了),一个显示-¥12,127(平台亏了),
造成管理员困惑。
修改:
- 净盈亏: Value-Cost → Cost-Value (A-B,平台盈利为正)
- 盈亏比: Value/Cost → Cost/Value (A/B,>1表示平台盈利)
- 趋势图每个数据点同步调整
|
2026-03-20 21:18:02 +08:00 |
|
|
|
fe3141e2b5
|
fix(dashboard): 盈亏分析商品产出对齐排行榜计算口径
问题:
盈亏分析(GetUserProfitLossTrend)和用户画像(GetUserProfile)中的
"商品产出"与玩家消费排行榜(DashboardPlayerSpendingLeaderboard)
计算口径不一致,导致同一用户的商品产出差异巨大。
排行榜显示用户9110商品产出¥16,913.40,盈亏分析显示¥0.00。
差异点:
1. status条件: 盈亏用 status=1(仅待发货),排行榜用 status IN (1,3)
2. 价格回退链: 盈亏缺少 price_snapshot_cents 回退层级
3. 道具卡倍率: 盈亏未计算 reward_multiplier_x1000
4. void排除: 盈亏未排除 remark 含 void 的作废项
修复:
- users_profit_loss.go: 商品产出查询完全对齐排行榜公式
- users_profile.go: 库存价值查询同步对齐
- 公式: COALESCE(value_cents, snapshot_cents, price, 0)
* GREATEST(COALESCE(multiplier, 1000), 1000) / 1000
- 条件: status IN (1,3) AND remark NOT LIKE '%void%'
|
2026-03-20 21:02:21 +08:00 |
|
|
|
ddd66bf4e9
|
fix(dashboard): 修复盈亏分析商品产出只统计待发货库存的bug
问题:
盈亏分析(GetUserProfitLossTrend)和用户画像(GetUserProfile)中的
"商品产出"查询条件为 `ui.status = 1`,只统计了待发货/库存中的商品,
已发货/已兑换(status=3)的商品被完全排除。
示例:用户9110实际累计获得874件商品(价值¥16,279.40),但因为大部分
已发货(status=3),盈亏分析只显示商品产出¥12.50,全资产产出严重偏低。
而 dashboard_user_spending.go 中的同类查询正确使用了
`status IN (1, 3)`,说明此处是遗漏。
修复:
- users_profit_loss.go: 当前资产快照查询改为 `status IN (1, 3)`
- users_profile.go: 库存统计查询改为 `status IN (1, 3)`
- 与 dashboard_user_spending.go 的计算口径对齐
|
2026-03-20 20:39:50 +08:00 |
|
win
|
46a7253239
|
fix:订单同步
|
2026-02-27 00:08:02 +08:00 |
|
win
|
7e8a2ebb52
|
feat: Add user spending dashboard, update database schema, and refine various API endpoints and service logic.
|
2026-02-21 21:33:19 +08:00 |
|
|
|
6d33cc7fd0
|
fix:盈亏计算
|
2026-01-27 01:33:32 +08:00 |
|
|
|
b21e2db8ef
|
feat: 添加抖音商品奖励功能,并增强后台用户列表统计数据、邀请人数及道具数量展示。
|
2026-01-08 10:13:29 +08:00 |
|
|
|
e3a96e68d8
|
fix: 修复退款时清理一番赏格位、积分兑换商品库存校验及抖音登录自邀问题。
|
2026-01-06 01:46:25 +08:00 |
|
|
|
fb6dc1e434
|
feat: 新增抖音登录功能、管理端次数卡及套餐管理接口,并引入配置迁移工具。
|
2026-01-04 01:40:11 +08:00 |
|
|
|
e8bfff8261
|
feat: 新增抖音订单、游戏通行证、快照回滚、短信登录及管理后台功能,并优化支付、活动与用户服务模块,同时清理旧文档
|
2026-01-02 12:38:03 +08:00 |
|