98 lines
2.1 KiB
Go
98 lines
2.1 KiB
Go
package model
|
|
|
|
import (
|
|
"mongo.games.com/game/protocol/webapi"
|
|
"time"
|
|
)
|
|
|
|
// 中奖记录
|
|
|
|
var (
|
|
LotteryLogDBName = "log"
|
|
LotteryLogCollName = "log_lottery"
|
|
)
|
|
|
|
type LotteryAward struct {
|
|
Id int64 // 奖品Id
|
|
N int64 // 奖品数量
|
|
}
|
|
|
|
type LotteryShow struct {
|
|
Tp int32 // 1图片 2视频
|
|
Url string // 地址
|
|
ImgUrl string // 缩略图地址
|
|
}
|
|
|
|
type LotteryLog struct {
|
|
Platform string `bson:"-"`
|
|
CId int64 // 抽奖配置Id
|
|
CTime time.Time // 开始时间
|
|
Num int32 // 期数
|
|
SnId int32 // 中奖玩家
|
|
Name string // 中奖玩家昵称
|
|
RoleId int32 // 中奖玩家角色Id
|
|
PlayerNum int64 // 参与人数
|
|
Code string // 中奖码
|
|
CostCard int64 // 消耗房卡
|
|
IsRobot bool // 是否机器人
|
|
Award []*LotteryAward // 奖品
|
|
Price int64 // 奖品价值
|
|
IsMust bool // 是否必中
|
|
ImageURL string // 图片地址
|
|
Ts int64 // 发奖时间
|
|
Media []*LotteryShow // 媒体信息
|
|
}
|
|
|
|
type GetLotteryLogReq struct {
|
|
Platform string
|
|
Num int
|
|
}
|
|
|
|
type GetLotteryLogResp struct {
|
|
LotteryLog []*LotteryLog
|
|
}
|
|
|
|
func GetLotteryLogs(plt string, count int) ([]*LotteryLog, error) {
|
|
if rpcCli == nil {
|
|
return nil, ErrRPClientNoConn
|
|
}
|
|
|
|
req := &GetLotteryLogReq{
|
|
Platform: plt,
|
|
Num: count,
|
|
}
|
|
ret := &GetLotteryLogResp{
|
|
LotteryLog: []*LotteryLog{},
|
|
}
|
|
err := rpcCli.CallWithTimeout("LotteryLogSvc.GetLotteryLogs", req, ret, time.Second*30)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
|
|
return ret.LotteryLog, nil
|
|
}
|
|
|
|
type UpdateLotteryMediaReq struct {
|
|
Platform string
|
|
LogId string
|
|
Media []*webapi.ShowLottery
|
|
}
|
|
|
|
func UpdateLotteryMedia(plt string, logId string, req []*webapi.ShowLottery) error {
|
|
if rpcCli == nil {
|
|
return ErrRPClientNoConn
|
|
}
|
|
|
|
upsertReq := &UpdateLotteryMediaReq{
|
|
Platform: plt,
|
|
LogId: logId,
|
|
Media: req,
|
|
}
|
|
ret := false
|
|
err := rpcCli.CallWithTimeout("LotteryLogSvc.UpdateMedia", upsertReq, &ret, time.Second*30)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|