game_sync/model/rabbit_mq.go

83 lines
3.1 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package model
import (
"strconv"
"time"
"mongo.games.com/game/mq"
)
// GenerateOnline 在线统计
func GenerateOnline(online map[string]map[string]int) *mq.RabbitMQData {
params := make(map[string]interface{})
params["Online"] = online
params["Time"] = time.Now().Unix()
return NewRabbitMQData(mq.BackOnline, params)
}
func GenerateOnlineGame(online map[string]map[string]map[string]map[int]map[int]int) *mq.RabbitMQData {
params := make(map[string]interface{})
params["Online"] = online
params["Time"] = time.Now().Unix()
return NewRabbitMQData(mq.BackOnlineGame, params)
}
// GenerateLogin 玩家登陆事件
func GenerateLogin(o *PlayerLoginEvent) *mq.RabbitMQData {
return NewRabbitMQData(mq.BackLogin, o)
}
type SystemFreeGive struct {
Snid int32 `json:"snid,omitempty"`
Channel string `json:"Channel,omitempty"`
AppChannel string `json:"AppChannel,omitempty"`
ChannelId string `json:"ChannelId,omitempty"`
Platform string `json:"platform,omitempty"`
Name string `json:"name,omitempty"`
GiveWay int32 `json:"givetype,omitempty"`
GiveType int32 `json:"cointype,omitempty"`
Count int64 `json:"count,omitempty"`
Ts int64 `json:"ts,omitempty"`
ItemId int32 `json:"itemid,omitempty"`
}
// GenerateSystemFreeGive 系统免费赠送
func GenerateSystemFreeGive(snid int32, name, platform, channel string, givetype, cointype int32, count int64) *mq.RabbitMQData {
params := make(map[string]string)
params["snid"] = strconv.Itoa(int(snid))
params["Channel"] = channel
params["name"] = name
params["platform"] = platform
params["givetype"] = strconv.Itoa(int(givetype)) //0创号赠送 1签到赠送转盘、签到、累签 2商城观看视频赠送 3破产补助 4vip领取
params["cointype"] = strconv.Itoa(int(cointype)) //货币类型 0金币 1钻石
params["count"] = strconv.Itoa(int(count))
params["ts"] = strconv.Itoa(int(time.Now().Unix()))
return NewRabbitMQData(mq.BackSystemFreeGive, params)
}
// GeneratePhoneLottery 手机抽奖统计
func GeneratePhoneLottery(snid int32, platform string, items string, lotteryType, count, countType, score int) *mq.RabbitMQData {
params := make(map[string]string)
params["Snid"] = strconv.Itoa(int(snid))
params["Platform"] = platform
params["LotteryType"] = strconv.Itoa(lotteryType) //1-抽奖获得 2-兑换 3-抽奖次数
params["Items"] = items
params["Score"] = strconv.Itoa(score) //兑换消耗积分
params["CountType"] = strconv.Itoa(countType) //1-首次登录 2-玩游戏 3-输赢送 4-充值送 5-初始送
params["Count"] = strconv.Itoa(count)
params["Ts"] = strconv.Itoa(int(time.Now().Unix()))
return NewRabbitMQData(mq.BackPhoneLottery, params)
}
// GenerateActivityLog 活动参与log
// childType 1-点击行为 2-兑换行为
func GenerateActivityLog(snid int32, platform string, typeId, childType int32) *mq.RabbitMQData {
params := make(map[string]string)
params["Snid"] = strconv.Itoa(int(snid))
params["Platform"] = platform
params["TypeId"] = strconv.Itoa(int(typeId))
params["ChildType"] = strconv.Itoa(int(childType))
params["Ts"] = strconv.FormatInt(time.Now().Unix(), 10)
return NewRabbitMQData(mq.BackActivityLog, params)
}