128 lines
5.8 KiB
Go
128 lines
5.8 KiB
Go
package datacenter
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
"time"
|
|
)
|
|
|
|
type IJsonMarshal interface {
|
|
Marshal() []byte //用户ID
|
|
}
|
|
type TopicType string
|
|
|
|
const (
|
|
TopicUserRegister TopicType = "user_register"
|
|
TopicUserVisit TopicType = "user_visit"
|
|
TopicUserOrder TopicType = "user_order"
|
|
TopicUserOrderSuccess TopicType = "user_order_success"
|
|
TopicUserAction TopicType = "user_action"
|
|
)
|
|
|
|
/* 通信协议,第一版*/
|
|
// 新用户注册消息
|
|
type UserRegisterMsg struct {
|
|
UserId int64 `json:"userId" bson:"userId"` // 用户ID
|
|
AppId int32 `json:"appId" bson:"appId"` // appID
|
|
SysType string `json:"sysType" bson:"sysType"` // 操作系统类型 安卓 IOS
|
|
PlatformId string `json:"platformId" bson:"platformId"` // 原始平台流水Id
|
|
DevType string `json:"devType" bson:"devType"` // 设备类型
|
|
Name string `json:"name" bson:"name"` // 名称
|
|
IsDirect bool `json:"isDirect" bson:"isDirect"` // true:是直推用户
|
|
DeviceId string `json:"deviceId" bson:"deviceId"` // 设备Id
|
|
IP string `json:"ip,omitempty" bson:"ip"` // IP
|
|
DistrictCode string `json:"districtCode" bson:"districtCode"` // 渠道码
|
|
InviteCode string `json:"inviteCode" bson:"inviteCode"` // 被邀请码
|
|
RegisterAt time.Time `json:"registerAt,omitempty" bson:"registerAt"` // 注册时间
|
|
UserAgent string `json:"userAgent" bson:"userAgent"` // User-Agent识别
|
|
RegisterTime time.Time `json:"registerTime" bson:"registerTime"` // 注册时间时间
|
|
}
|
|
|
|
var _ IJsonMarshal = &UserRegisterMsg{}
|
|
|
|
func (u *UserRegisterMsg) Marshal() []byte {
|
|
jsonData, err := json.Marshal(u)
|
|
if err != nil {
|
|
log.Fatalf("Failed to marshal JSON: %v", err)
|
|
}
|
|
return jsonData
|
|
}
|
|
|
|
// UserVisitMsg 用户每日第一次访问
|
|
type UserVisitMsg struct {
|
|
UserId int64 `bson:"userId" json:"userId"` // 用户Id
|
|
SumDate time.Time `bson:"sumDate" json:"sumDate"` // 记录时间
|
|
AppId int32 `json:"appId" bson:"appId"` // appID
|
|
SysType string `json:"sysType" bson:"sysType"` // 操作系统类型 安卓 IOS
|
|
DistrictCode string `json:"districtCode" bson:"districtCode"` // 渠道码
|
|
DevType string `json:"devType" bson:"devType"` // 设备类型
|
|
IP string `json:"ip,omitempty" bson:"ip"` // IP
|
|
Version string `json:"version,omitempty" bson:"version"` // APP版本号
|
|
VisitAt time.Time `json:"visitAt,omitempty" bson:"visitAt"` // 访问时间
|
|
}
|
|
|
|
var _ IJsonMarshal = &UserVisitMsg{}
|
|
|
|
func (u *UserVisitMsg) Marshal() []byte {
|
|
jsonData, err := json.Marshal(u)
|
|
if err != nil {
|
|
log.Fatalf("Failed to marshal JSON: %v", err)
|
|
}
|
|
return jsonData
|
|
}
|
|
|
|
// UserOrderMsg 用户订单消息
|
|
type UserOrderMsg struct {
|
|
UserId int64 `json:"userId" bson:"userId"` // 用户ID
|
|
AppId int32 `json:"appId" bson:"appId"` // appID
|
|
PlatformId string `json:"platformId" bson:"platformId"` // 原始平台流水Id
|
|
SysType string `json:"sysType" bson:"sysType"` // 操作系统类型 安卓 IOS
|
|
DistrictCode string `json:"districtCode" bson:"districtCode"` // 渠道码
|
|
DevType string `json:"devType" bson:"devType"` // 设备类型
|
|
ChannelName string `json:"channelName" bson:"channelName"` // 支付渠道名字
|
|
CID string `json:"cid" bson:"cid"` // 渠道id
|
|
Type string `bson:"type" json:"type"` // 充值方式
|
|
RchgUse int64 `json:"rchgUse" bson:"rchgUse"` // 充值用途 1:金币 2:VIP
|
|
Repeat bool `bson:"repeat" json:"repeat"` // 复冲: true 重复充值 false 第一次
|
|
OrderId string `json:"orderId" bson:"orderId"` // 流水id
|
|
Money int64 `json:"money" bson:"money"` // 充值金额 订单金额
|
|
PayMoney int64 `json:"payMoney" bson:"payMoney"` // 实际到账金额 用户实际支付金额
|
|
Status int `json:"status" bson:"status"` // 2付款失败 3付款成功(目前只有成功才发送)
|
|
Rate string `json:"rate" bson:"rate"` // 渠道费率
|
|
SuccessAt time.Time `json:"successAt" bson:"successAt"` // 成功时间
|
|
CreatedAt time.Time `json:"createdAt" bson:"createdAt"` // 创建时间
|
|
}
|
|
|
|
var _ IJsonMarshal = &UserOrderMsg{}
|
|
|
|
func (u *UserOrderMsg) Marshal() []byte {
|
|
jsonData, err := json.Marshal(u)
|
|
if err != nil {
|
|
log.Fatalf("Failed to marshal JSON: %v", err)
|
|
}
|
|
return jsonData
|
|
}
|
|
|
|
// UserChannelEvent 用户渠道统计
|
|
type UserChannelEvent struct {
|
|
UserId int64 `bson:"userId" json:"userId"` // 用户Id
|
|
AppId int32 `json:"appId" bson:"appId"` // appID
|
|
DistrictCode string `json:"districtCode" bson:"districtCode"` // 渠道码
|
|
WatchCount int64 `json:"watchCount,omitempty" bson:"watchCount"` // 观看次数
|
|
WatchTime int64 `json:"watchTime,omitempty" bson:"watchTime"` // 观看时长
|
|
AdClick int64 `json:"adClick,omitempty" bson:"adClick"` // 广告点击
|
|
AppClick int64 `json:"appClick,omitempty" bson:"appClick"` // APP点击
|
|
RegisterAt time.Time `json:"registerAt,omitempty" bson:"registerAt"` // 注册时间
|
|
RequestCount int64 `json:"requestCount,omitempty" bson:"requestCount"` // 请求次数
|
|
}
|
|
|
|
var _ IJsonMarshal = &UserChannelEvent{}
|
|
|
|
func (u *UserChannelEvent) Marshal() []byte {
|
|
jsonData, err := json.Marshal(u)
|
|
if err != nil {
|
|
log.Fatalf("Failed to marshal JSON: %v", err)
|
|
}
|
|
return jsonData
|
|
}
|