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

34 lines
686 B
Go
Executable File

package main
import (
"context"
"flag"
"fmt"
"bindbox-game/configs"
"bindbox-game/internal/repository/mysql"
"bindbox-game/internal/repository/mysql/dao"
)
func main() {
flag.Parse()
// 初始化配置
configs.Init()
// 初始化数据库
db, err := mysql.New()
if err != nil {
panic(err)
}
// 查询ID为22的优惠券
coupon, err := dao.Use(db.GetDbR()).SystemCoupons.WithContext(context.Background()).Where(dao.Use(db.GetDbR()).SystemCoupons.ID.Eq(22)).First()
if err != nil {
fmt.Printf("Error querying coupon 22: %v\n", err)
return
}
fmt.Printf("Coupon 22: Name=%s, Status=%d, ShowInMiniapp=%d\n", coupon.Name, coupon.Status, coupon.ShowInMiniapp)
}