e2364f3831
feat(activity): 新增独立奖品发放活动模块
...
新增独立奖品发放活动的后端表结构、服务、管理端接口与小程序领取接口,支持待领取查询、批量加入已处理、删除记录与成本汇总。
2026-05-07 22:09:22 +08:00
6127dc1a35
fix(activity): 允许后台编辑未开始的福利活动
...
中文说明:新增后台专用福利活动详情查询,后台编辑未开始活动时不再复用前台的未开始拦截逻辑,避免后台打开编辑弹窗提示“活动未开始”。
2026-05-03 23:03:52 +08:00
01db44ed50
chore(activity): 补提福利活动接入入口改动
...
补充提交福利活动在主程序、路由和前后端 handler 装配中的接入改动。
确保福利活动能力在服务启动、admin 路由与 app 路由层完整连通。
2026-04-29 17:28:36 +08:00
3db52af4b6
feat(activity): 重构福利活动并支持统一奖池
...
对齐福利活动新库表结构,支持商品、道具卡和优惠券统一建奖、开奖与中奖记录。
同时新增福利活动测试命令行工具,便于模拟消费、参与活动并验证完整开奖链路。
2026-04-29 17:21:11 +08:00
45ea70760b
fix(dashboard): 修复产品动销排行时间范围筛选异常
...
修复产品动销排行接口在时间筛选上的两个问题:
1. parseRange 未处理 all,导致前端传入 all 时实际回落到默认分支,查询结果等同最近 7 天。
2. 产品动销排行原先按 activity_draw_logs.created_at 过滤时间,但销量/营收统计口径基于已支付订单,导致不同时间范围下结果失真,自定义区间与全部区间表现异常。
本次调整内容:
- 为 parseRange 增加 all 分支,返回从较早时间到当前时间的全量区间。
- OperationsProductPerformance 接口改为接收 start/end 参数,支持前端自定义时间范围透传。
- 将产品动销排行的时间过滤从 activity_draw_logs.created_at 改为 COALESCE(orders.paid_at, orders.created_at),并显式限定 orders.status = 2,使筛选口径与销量/营收统计保持一致。
修复后,全部、7天、30天和自定义时间范围将按支付时间维度返回更符合业务语义的产品动销排行结果。
2026-04-25 01:52:19 +08:00
e6e4214df4
fix(dashboard): 按有效抽奖口径修正产品动销排行
...
本次仅调整产品动销排行接口的后端统计逻辑,不改动活动盈亏分析页面与接口。
详细说明:
- 将销量从 activity_draw_logs 总条数改为有效抽奖次数,仅统计 orders.status = 2 的抽奖记录,避免把退款、取消等无效抽奖一并计入。
- 将营收统一改为“有效抽奖次数 × 活动单抽价格(price_draw)”,不再使用总日志数乘单价,确保产品动销排行内部次数与营收口径一致。
- 将成本从 price_snapshot_cents / products.price 的近似标价口径改为 products.cost_price 成本价口径,并继续保留 drop_quantity 与倍数卡 multiplier 的影响,避免利润长期被标价成本压低。
- 将盈亏与利润率统一为 Revenue - Cost 与 Profit / Revenue,使产品动销排行内部的销量、营收、成本、盈亏逻辑自洽。
- 将贡献率从按次数占比调整为按营收占比,更符合“营收贡献率”的业务含义。
本次未处理内容:
- 不修改活动盈亏分析的现有统计口径。
- 不修改前端卡片结构与活动盈亏分析页面。
已核对的业务结论:
- 活动 103 的产品动销排行 4696 次是最近 30 天有效抽奖次数;活动盈亏分析 5960 次是全量历史有效抽奖次数,两边差异来自时间范围而非当前产品动销排行次数公式。
2026-04-24 21:35:36 +08:00
0e202fabd8
fix(dashboard): 统一玩家盈亏分析产出口径
...
将玩家盈亏趋势中的商品产出从当前资产快照估值,
调整为按用户、订单、抽奖日志链路聚合的商品成本口径。
这样可使商品产出与消费看板中的活动产出统计保持一致,
避免同一用户在两个面板中看到不同的商品产出口径。
同时保留积分、道具卡、优惠券三项当前分项展示,
避免接口结构调整后页面字段缺失或被误显示为 0。
2026-04-18 01:15:11 +08:00
5dc9f034c8
fix(dashboard): 修正活动奖品分析成本口径
...
活动奖品分析接口统一使用 products.cost_price 计算 prizeValue、cost 和 totalCost,避免误用售价导致成本统计偏差。
2026-04-14 23:07:32 +08:00
25dacc066a
fix(dashboard): 按订单链路修正用户消费成本统计
...
将玩家消费排行榜和用户消费详情中的产出成本口径从 user_inventory 快照值改为订单抽奖链路成本。
排行榜按 user_id + 活动分类聚合,详情按 user_id + activity_id 聚合,成本统一基于已支付订单对应的 draw log、奖励配置、商品成本价、掉落数量和翻倍道具卡补量规则计算,使列表、详情与活动盈亏页的业务口径保持一致。
2026-04-13 19:23:13 +08:00
c927f46cdd
fix(livestream): 统一直播间盈亏成本口径并消除转赠影响
...
将直播间统计从基于 user_inventory 当前持有状态和 remark 反推成本,改为基于 livestream_draw_logs 中奖事实直接关联 products.cost_price 计算成本。统一 /livestream/activities/:id/stats 与 /livestream/activities/:id/draw_logs 两个接口的营收、退款、成本和净利润口径,避免因转赠、remark 覆盖或订单行缺失导致统计失真,并补充针对转赠、退款、零订单和 product 回退场景的回归测试。
2026-04-12 21:23:36 +08:00
c7a6e1e017
fix(dashboard): 修正销售抽奖趋势自定义日期统计
...
修复 sales_draw_trend 自定义日期按 UTC 解析导致的统计偏差,并统一使用半开区间处理日维度边界,补充上海时区与单日范围回归测试。
2026-04-04 00:06:17 +08:00
6284966d3c
fix(dashboard): add paid amount to sales trend
2026-04-03 18:03:29 +08:00
38edc9f324
fix(user): align profile inventory stats with held assets
...
Count only status=1 inventory in the admin user profile so the profile inventory metrics match the held-assets inventory list semantics.
2026-04-02 23:35:18 +08:00
dd1034dda8
fix(finance): correct activity profit-loss cost aggregation
...
Use handler-specific activity profit/loss rules for the dashboard endpoints, counting cash, coupons, and game pass value against product cost_price. Fix missing extra reward cost aggregation and align activity logs with the same profit calculation semantics.
2026-04-02 22:27:45 +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
46b9555823
feat(fragment): 商品成本价 + 活动奖品单次产出数量
...
- products 表新增 cost_price 字段(成本价/分)
- activity_reward_settings 新增 drop_quantity(单次产出数量,默认1)
和 cost_snapshot_cents(成本价快照)
- 奖品创建/修改时自动快照成本价,drop_quantity 限制 1-100
- 抽奖发放逻辑按 drop_quantity 循环创建多个库存项
- 抽奖结果接口按 drop_quantity 返回多条 item,前端自动合并显示
- 抽奖记录接口返回 drop_quantity 字段
- 商品管理 API 全链路支持 cost_price
2026-03-23 22:26:06 +08:00
win
2a7b731484
feat(finance): implement Phase 1 core P&L service + wire into dashboard
...
- Add internal/service/finance/types.go: AssetType enum, param/result structs
- Add internal/service/finance/service.go: Service interface, read-only ctor
- Add internal/service/finance/query_user.go: QueryUserProfitLoss (4 fan-out scans)
- Add internal/service/finance/query_activity.go: QueryActivityProfitLoss (4 fan-out scans)
- Add internal/service/finance/service_test.go: 22 integration tests (all pass)
- Wire finance.Service into admin handler (admin.go)
- Replace dashboard_activity cost scan with finance.Service call (D-09: value_cents single source of truth)
- Revenue/gamepass/draw-count scans unchanged; response schema fully compatible
Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-21 18:38:33 +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
9cb4aaa511
fix(admin): 修复订单列表source_type=4/5显示未知的问题
...
- source_type=4: 区分购买次卡/次卡抽奖/一番赏
- source_type=5: 区分运费订单/直播间抽奖
2026-03-20 17:45:19 +08:00
win
eaf4af4ba4
Merge remote-tracking branch 'origin/zuncle'
2026-03-19 22:37:56 +08:00
47c36b43cd
feat(fragment): add synthesis flow and fragment restrictions with tests
2026-03-19 16:26:36 +08:00
9f7a7d29fb
fix(admin): 管理端取消订单改为调用 userSvc.CancelOrder,补充优惠券和积分退还逻辑
2026-03-18 21:12:46 +08:00
0722e515c4
feat(shipping): 新增管理端撤销发货功能
...
- 新增 AdminCancelShipping handler,支持批量撤销待发货记录(status=1→5)
- 事务内同步恢复 user_inventory.status=1 并清空 shipping_no
- 在 remark 记录操作人 adminID,保证审计可追溯
- 注册路由 POST /api/admin/shipping/orders/cancel
2026-03-18 20:11:37 +08:00
d1ee319f0e
feat(dashboard): 平台有效资产增加优惠券和次卡价值统计
...
- 新增优惠券总价值统计(关联system_coupons表)
- 新增次卡总价值统计(关联activities表price_draw)
- 使用Raw SQL执行复杂JOIN查询
2026-03-17 19:17:56 +08:00
win
8d1eef2f7f
fix(channel): 修复渠道统计GMV重复计数和商城直购误计入
...
1. 排除商城直购(source_type=1):GMV和成本过滤条件从IN(1,2,3,4)改为IN(2,3,4)
2. 排除次卡免费使用订单(actual_amount=0):避免购买次卡和使用次卡双重计入GMV
- source_type=4 一番赏使用次卡:1578单 44032元重复
- source_type=3 对对碰使用次卡:422单 7042元重复
- 合计去除51074元虚增GMV(29.1%)
3. 成本过滤条件同步修正:source_type IN(2,3,4),total_amount>0
修正后:GMV从175600降至124527元,毛利率从37.4%回到真实的11.8%
2026-03-16 21:41:39 +08:00
2aa7cdbd61
fix(shipping): 使用资产价值快照价格确保发货与分解价格一致
...
修复改价后发货价格与分解价格不一致的问题:
- 发货时优先使用 user_inventory.value_cents 快照价格
- 后台发货列表使用 shipping_records.price 存储的快照价格
- 确保盈亏统计时价格数据准确一致
2026-03-05 17:54:58 +08:00
win
b3b63dcba2
admin
2026-03-05 12:50:06 +08:00
win
e0db8751f3
任务中心的问题
2026-02-27 16:07:12 +08:00
win
46a7253239
fix:订单同步
2026-02-27 00:08:02 +08:00
win
9972427cea
fix: treat livestream pass orders as ticket price
2026-02-24 10:02:11 +08:00
win
8b7af03400
feat(prize): freeze value snapshots across grant redeem refund and reports
2026-02-21 22:16:20 +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
af1c16c7c5
优惠券bug
2026-02-18 23:23:34 +08:00
58baa11a98
fix:优惠券购买次卡bug
2026-02-10 01:17:15 +08:00
e124f8d4ff
优化钱
2026-02-08 17:19:27 +08:00
571cb2f4db
add: 仪表盘
2026-02-04 12:44:37 +08:00
9eea272d69
统计更新
2026-02-03 17:44:02 +08:00
55e22086e8
201
2026-02-01 00:27:38 +08:00
1a8f94d7b8
fix
2026-01-29 19:25:16 +08:00
021ab34c75
add:opencode
2026-01-28 21:36:36 +08:00
6d33cc7fd0
fix:盈亏计算
2026-01-27 01:33:32 +08:00
5ad2f4ace3
feat: 保存当前开发进度 - 直播抽奖验证功能
2026-01-18 01:55:54 +08:00
b21e2db8ef
feat: 添加抖音商品奖励功能,并增强后台用户列表统计数据、邀请人数及道具数量展示。
2026-01-08 10:13:29 +08:00
e3a96e68d8
fix: 修复退款时清理一番赏格位、积分兑换商品库存校验及抖音登录自邀问题。
2026-01-06 01:46:25 +08:00
359ca9121f
chore: 添加定时开奖和抖店同步的调试与信息日志
2026-01-04 22:58:38 +08:00
fb6dc1e434
feat: 新增抖音登录功能、管理端次数卡及套餐管理接口,并引入配置迁移工具。
2026-01-04 01:40:11 +08:00
e8bfff8261
feat: 新增抖音订单、游戏通行证、快照回滚、短信登录及管理后台功能,并优化支付、活动与用户服务模块,同时清理旧文档
2026-01-02 12:38:03 +08:00
4a582997d1
feat: 引入活动抽奖策略槽位选择功能,新增用户库存发货单号字段,并优化支付与活动服务集成。
2025-12-26 18:15:15 +08:00