package statcenter import ( "time" "videoweb/pub/pubdef" "github.com/shopspring/decimal" ) type KFKTopic string const ( STAT_APPID int32 = pubdef.AppId USER_REG KFKTopic = "user_register" // 用户注册 USER_RECH KFKTopic = "user_recharge" // 用户充值(成功) USER_RECH_ALL KFKTopic = "user_recharge_all" // 全部充值订单 USER_ACCE KFKTopic = "user_access" // 用户访问 USER_BINDING KFKTopic = "user_binding" // 用户绑定(邮箱/正式注册) USER_INVITE KFKTopic = "user_invite" // 用户邀请绑定 VipJob KFKTopic = "vip" // VIP 购买(兼容旧任务) RechargeAll KFKTopic = "rechargeAll" // 全部充值(兼容旧任务名) RegisterLightJob KFKTopic = "registerLight" // H5 轻量注册 ConsumeRecordJob KFKTopic = "consume_record" // 产品消费流水 CardSellJob KFKTopic = "card_sell" // 会员卡销售流水 AI_SELL_JOB KFKTopic = "ai_sell" // AI 消费(本项目无此业务) ) const ( StatVipCard = iota // 会员卡 StatValueAddSer // 增值/其他消费 StatVideoUnlock // 视频解锁 ) const ( CurrencyTypeGold = iota // 金币 CurrencyTypeCash // 现金 ) // StatcenterSyncReq 统计中心增量同步请求 type StatcenterSyncReq struct { Job string `json:"job" bson:"job"` // 同步任务类型 UserId uint64 `json:"userId" bson:"userId"` // 用户(注册) PlatformId string `json:"platformId" bson:"platformId"` // 原始平台Id(访问/流水) SuccessTime time.Time `json:"successTime"` // 游标时间(购买会员、提现、充值) MaxSize int64 `json:"maxSize" bson:"maxSize"` // 最大条数 } // StatcenterSyncResp 统计中心增量同步响应 type StatcenterSyncResp struct { Code int `json:"code"` // 200正常 其他异常 Msg string `json:"msg"` // 错误消息 Job string `json:"job" bson:"job"` // 类型 VisitList []UserVisitMsg `json:"visitList"` // 日活记录(旧字段,兼容) AccessList []UserVisitMsg `json:"accessList"` // 日活记录 RegisterList []UserRegisterMsg `json:"registerList"` // 注册记录 BindingList []UserBindingMsg `json:"bindingList"` // 用户绑定记录 InviteList []UserInviteBindMsg `json:"inviteList"` // 邀请绑定 ConsumeList []ConsumeRecordMsg `json:"consumeList"` // 消费流水 RechargeList []UserRechargeMsg `json:"rechargeList"` // 充值记录 AllRechargeList []UserRechargeMsg `json:"allRechargeList"` // 全部支付订单 VipList []UserBuyVIPMsg `json:"buyVipList"` // VIP购买记录 CardSellList []CardSellMsg `json:"cardSellList"` // 会员卡销售流水 AiSellList []AiSellMsg `json:"aiSellList"` // AI销售流水 } // 用户访问消息 type UserVisitMsg struct { UserId uint64 `json:"userId" bson:"userId"` // 用户ID PlatformId string `json:"platformId" bson:"platformId"` // 原始平台流水Id AppId int32 `json:"appId" bson:"appId"` // appID SysType string `json:"sysType" bson:"sysType"` // 操作系统类型 安卓 IOS DevType string `json:"devType,omitempty" bson:"devType"` // 设备型号 IP string `json:"ip,omitempty" bson:"ip"` // IP Version string `json:"version,omitempty" bson:"version"` // APP版本号 DevID string `json:"devID,omitempty" bson:"devID"` // 设备ID VisitAt time.Time `json:"visitAt,omitempty" bson:"visitAt"` // 访问时间 IsDirect bool `json:"isDirect,omitempty"` // true:是直推用户 DistrictCode string `json:"districtCode,omitempty"` // 渠道码 RegisterTime time.Time `json:"registerTime,omitempty"` // 用户注册时间 } // 用户注册消息 type UserRegisterMsg struct { UserId uint64 `json:"userId" bson:"userId" binding:"required"` // 用户ID AppId int32 `json:"appId" bson:"appId" binding:"required"` // appID SysType string `json:"sysType" bson:"sysType" binding:"required"` // 操作系统类型 安卓 IOS PlatformId string `json:"platformId" bson:"platformId"` // 原始平台流水Id DevType string `json:"devType" bson:"devType"` // 设备类型 Mobile string `json:"mobile" bson:"mobile"` // 手机号 IP string `json:"ip,omitempty" bson:"ip"` // IP Name string `json:"name" bson:"name"` // 名称 IsDirect bool `json:"isDirect" bson:"isDirect" binding:"required"` // true:是直推用户 DistrictCode string `json:"districtCode" bson:"districtCode" ` // 渠道码 PromSeqe string `json:"promSeqe,omitempty" bson:"promSeqe"` // 全名代理 PromCode string `json:"promCode,omitempty" bson:"promCode"` // 推广序列 PUC string `json:"puc" bson:"puc"` // 应用中心推广 RegisterTime time.Time `json:"registerTime,omitempty" bson:"registerTime" binding:"required"` // 注册时间 } // UserBindingMsg 用户绑定(本项目对应邮箱正式注册) type UserBindingMsg struct { UserId uint64 `json:"userId"` // 用户ID AppId int32 `json:"appId"` // appID PlatformId string `json:"platformId"` // 原始平台流水Id SysType string `json:"sysType"` // 操作系统类型 DevType string `json:"devType"` // 设备类型 Mobile string `json:"mobile"` // 手机号/绑定账号(本项目填邮箱) BindingTime *time.Time `json:"bindingTime"` // 绑定时间 } // UserInviteBindMsg 邀请绑定 type UserInviteBindMsg struct { UserId uint64 `json:"userId" bson:"userId" binding:"required"` AppId int32 `json:"appId" bson:"appId" binding:"required"` ParentPromCode string `json:"parentPromCode,omitempty" bson:"promSeqe"` InviteTime time.Time `json:"inviteTime,omitempty" bson:"inviteTime" binding:"required"` } // ConsumeRecordMsg 消费流水 type ConsumeRecordMsg struct { AppID int32 `json:"appID" bson:"appID"` UID uint64 `json:"uid" bson:"uid"` Type int `json:"type" bson:"type"` // 消费类型 CurrencyType int `json:"currencyType" bson:"currencyType"` // 0金币 1人民币 Money decimal.Decimal `json:"money" bson:"money"` // 人民币 元 Amount decimal.Decimal `json:"amount" bson:"amount"` // 金币 Uniq string `json:"uniq" bson:"uniq"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` } // AiSellMsg AI 销售流水 type AiSellMsg struct { AppID int32 `json:"appID" bson:"appID"` UID uint64 `json:"uid" bson:"uid"` UniqID string `json:"uniqID" bson:"uniqID"` Amount int64 `json:"amount" bson:"amount"` TranType string `json:"tranType" bson:"tranType"` SysType string `json:"sysType" bson:"sysType"` DevType string `json:"devType" bson:"devType"` CurrencyType string `json:"currencyType" bson:"currencyType"` TranCreatedAt time.Time `json:"tranCreatedAt" bson:"tranCreatedAt"` IsRepurchase string `json:"isRepurchase" bson:"isRepurchase"` } // CardSellMsg 会员卡销售流水 type CardSellMsg struct { AppID int32 `json:"appID" bson:"appID"` UID uint64 `json:"uid" bson:"uid"` UniqID string `json:"uniqID" bson:"uniqID"` Amount int64 `json:"amount" bson:"amount"` TranTypeInt int64 `json:"tranTypeInt" bson:"tranTypeInt"` TranType string `json:"tranType" bson:"tranType"` SysType string `json:"sysType" bson:"sysType"` CurrencyType int `json:"currencyType" bson:"currencyType"` // 0金币 1现金 TranCreatedAt time.Time `json:"tranCreatedAt" bson:"tranCreatedAt"` Product Product `json:"product" bson:"product"` } // Product 售卡产品信息 type Product struct { ID string `json:"id"` Name string `json:"name"` DiscountedPrice int64 `json:"discountedPrice"` } // 用户充值消息 type UserRechargeMsg struct { UserId uint64 `json:"userId" bson:"userId" binding:"required"` AppId int32 `json:"appId" bson:"appId" binding:"required"` PlatformId string `json:"platformId" bson:"platformId"` SysType string `json:"sysType" bson:"sysType" binding:"required"` DevType string `json:"devType" bson:"devType"` ChannelName string `json:"channelName" bson:"channelName"` CID string `json:"cid" bson:"cid"` Type string `bson:"type" json:"type"` OrderId string `json:"orderId" bson:"orderId" binding:"required"` OID string `json:"oid" bson:"oid"` Money int64 `json:"money" bson:"money" binding:"required"` PayMoney int64 `json:"payMoney" bson:"payMoney" binding:"required"` Status int `json:"status" bson:"status"` Rate string `json:"rate"` SuccessAt time.Time `json:"successAt,omitempty" bson:"successAt"` PaymentAt time.Time `json:"paymentAt"` ProductType int `json:"productType" bson:"productType"` ChanShareMod int `json:"chanShareMod" bson:"chanShareMod"` IsNewOrOldUser bool `json:"isNewOrOldUser" bson:"isNewOrOldUser"` CreatedAt time.Time `json:"createdAt" bson:"createdAt"` DistrictCode string `json:"districtCode" bson:"districtCode"` RegisterTime time.Time `json:"registerTime,omitempty" bson:"registerTime"` } type BuyVIPType int64 const ( BuyVIPTypeMoney BuyVIPType = 0 + iota // 现金 BuyVIPTypeGold // 金币 ) // 用户购买VIP type UserBuyVIPMsg struct { AppId int32 `json:"appId" bson:"appId"` UID uint64 `json:"uid" bson:"uid"` PlatformId string `json:"platformId" bson:"platformId"` Name string `json:"name" bson:"name"` Money int64 `json:"money" bson:"money"` Amount int64 `json:"amount" bson:"amount"` BuyVIPType BuyVIPType `json:"buyVIPType" bson:"buyVIPType"` OID string `json:"oid" bson:"oid"` DeviceType string `json:"deviceType" bson:"deviceType"` Status int `json:"status" bson:"status"` SuccessAt time.Time `json:"successTime"` IsDirect bool `json:"isDirect" bson:"isDirect"` DistrictCode string `json:"districtCode" bson:"districtCode"` PromCode string `json:"promCode" bson:"promCode"` } // MapOrderStatusToStat 将本项目订单状态映射为统计中心约定:2失败 3成功 func MapOrderStatusToStat(status pubdef.VipOrderStatus) int { switch status { case pubdef.VipOrderSuccess: return 3 case pubdef.VipOrderFailed: return 2 default: return int(status) } }