90 lines
2.9 KiB
Go
90 lines
2.9 KiB
Go
package model
|
||
|
||
import (
|
||
"strconv"
|
||
"time"
|
||
|
||
"mongo.games.com/game/mq"
|
||
)
|
||
|
||
// GenerateOnline 在线统计
|
||
func GenerateOnline(online map[string]int) *RabbitMQData {
|
||
m := map[int]int{} // 平台:真人数
|
||
for k, v := range online {
|
||
i, _ := strconv.Atoi(k)
|
||
m[i] = v
|
||
}
|
||
params := make(map[string]interface{})
|
||
params["Online"] = m
|
||
params["Time"] = time.Now().Unix()
|
||
return NewRabbitMQData(mq.BackOnline, params)
|
||
}
|
||
|
||
// GenerateLogin 玩家登陆事件
|
||
func GenerateLogin(o *PlayerLoginEvent) *RabbitMQData {
|
||
return NewRabbitMQData(mq.BackLogin, o)
|
||
}
|
||
|
||
// GenerateGameEvent 游戏结算事件
|
||
func GenerateGameEvent(o *PlayerGameRecEvent) *RabbitMQData {
|
||
return NewRabbitMQData(mq.BackGameRecord, o)
|
||
}
|
||
|
||
// GenerateSystemFreeGive 系统免费赠送
|
||
func GenerateSystemFreeGive(snid int32, name, platform string, givetype, cointype int32, count int64) *RabbitMQData {
|
||
params := make(map[string]string)
|
||
params["snid"] = strconv.Itoa(int(snid))
|
||
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) *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)
|
||
}
|
||
|
||
//type PlayerGameEntryEvent struct {
|
||
// RecordId string //游戏记录ID
|
||
// SnId int32 //用户ID
|
||
// Platform int32 //平台
|
||
// OS int //0 Windows 1 Android 2 iOS
|
||
// GameId int //游戏id
|
||
// ModeId int //游戏模式
|
||
// Time int64 //入场时间 RFC3339
|
||
// Id int32 //游戏id
|
||
//}
|
||
|
||
// GenerateEnterEvent 玩家或观众进场事件
|
||
//func GenerateEnterEvent(recordId string, snId int32, platform, os string, gameId, modeId int, gameFreeId int32) *RabbitMQData {
|
||
// m := &PlayerGameEntryEvent{
|
||
// RecordId: recordId,
|
||
// SnId: snId,
|
||
// GameId: gameId,
|
||
// ModeId: modeId,
|
||
// Time: time.Now().Unix(),
|
||
// Id: gameFreeId,
|
||
// }
|
||
// pf, err := strconv.Atoi(platform)
|
||
// if err != nil {
|
||
// logger.Error(err)
|
||
// return nil
|
||
// }
|
||
// m.Platform = int32(pf)
|
||
// m.OS = common.DeviceNum[os]
|
||
// return NewRabbitMQData(string(MqNameEnterEvent), m)
|
||
//}
|