package model import ( "active/tools" "fmt" "git.jiaxianghudong.com/webs/pkg/ali" "time" ) //SendSlsPacket 插入日志 type SendSlsPacket struct { AppID int32 `json:"app_id"` ChannelID int32 `json:"channel_id"` ProductID int `json:"product_id"` Region string `json:"region"` DataID int `json:"dataid"` Value int `json:"value"` InvNum int `json:"inv_num"` HelperID int `json:"helper_id"` UserID uint32 `json:"user_id"` NewSmallGameUser int `json:"new_small_game_user"` OpType int `json:"op_type"` ActType int `json:"act_type"` Ext string `json:"ext"` Ext1 string `json:"ext_1"` IP string WxOpenId string `json:"wx_open_id"` } //SendSlsLog 插入阿里日志 func (this *SendSlsPacket) SendSlsLog() { data := map[string]string{ "app_id": fmt.Sprintf("%d", this.AppID), "channel_id": fmt.Sprintf("%d", this.ChannelID), "product_id": fmt.Sprintf("%d", GetProductID(this.AppID)), "region": this.Region, "dataid": fmt.Sprintf("%d", this.DataID), "value": fmt.Sprintf("%d", this.Value), "inv_num": fmt.Sprintf("%d", this.InvNum), "user_id": fmt.Sprintf("%d", this.UserID), "helper_id": fmt.Sprintf("%d", this.HelperID), "new_small_game_user": fmt.Sprintf("%d", FromSmallGame(int(this.ChannelID))), "op_type": fmt.Sprintf("%d", this.OpType), "act_type": fmt.Sprintf("%d", this.ActType), "time": time.Now().Format("2006-01-02 15:04:05"), "ext": fmt.Sprintf("%v", this.Ext), "ext1": fmt.Sprintf("%v", this.Ext1), "wx_open_id": fmt.Sprintf("%v", this.WxOpenId), } ali.SendLog("redpack_activity", this.IP, data) } //FromSmallGame 来源小游戏 func FromSmallGame(ChannelID int) int { if tools.InIntArray(ChannelID, []int{818, 821, 820, 851}) { return 1 } return 0 } //GetProductID 获取产品ID func GetProductID(appID int32) int32 { //偶数变基数 if appID%2 == 0 { return appID - 1 } return appID } //GetPlatformID 获取平台ID func GetPlatformID(platFromName string) int { if platFromName == "ios" { return 11 } return 12 }