102 lines
2.4 KiB
Go
102 lines
2.4 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
var (
|
|
LotteryDataDBName = "log"
|
|
LotteryDataCollName = "log_lotterydata"
|
|
)
|
|
|
|
// LotteryData 单个抽奖活动的状态
|
|
type LotteryData struct {
|
|
Platform string `bson:"-"`
|
|
CId int64 // 抽奖配置id
|
|
StartTs int64 // 开始时间
|
|
EndTs int64 // 结束时间
|
|
WinTs int64 // 发奖时间
|
|
Reward []*ItemInfo // 奖励
|
|
Price int64 // 价值,美分
|
|
TotalCode int64 // 总开奖码数
|
|
RobotCodeNum int64 // 机器人开奖码数
|
|
ImageURL string // 图片地址
|
|
|
|
Code int // 抽奖码序号
|
|
PlayerIndex int // 玩家序号
|
|
RobotIndex int // 机器人序号
|
|
IsSend bool // 是否发奖
|
|
PlayerNum int32 // 参与人数
|
|
CostCard int64 // 所有消耗房卡数量
|
|
Format string // 兑奖码格式
|
|
CustomAward int64 // 竞技馆奖品价值
|
|
RobotCodeCount int // 机器人已发放开奖码数量
|
|
Num int // 期数
|
|
Codes []int // 开奖码
|
|
|
|
SnId int32 // 玩家ID
|
|
Name string // 玩家名字
|
|
RoleId int32 // 玩家角色ID
|
|
WinCostCard int64 // 中奖玩家消耗房卡数量
|
|
WinCode string // 中奖码
|
|
IsRobot bool // 是否机器人中奖
|
|
}
|
|
|
|
type GetLotteryDataReq struct {
|
|
Platform string
|
|
}
|
|
|
|
type GetLotteryDataResp struct {
|
|
Data []*LotteryData
|
|
}
|
|
|
|
func GetLotteryData(plt string) (ret []*LotteryData, err error) {
|
|
if rpcCli == nil {
|
|
return nil, ErrRPClientNoConn
|
|
}
|
|
|
|
req := &GetLotteryDataReq{
|
|
Platform: plt,
|
|
}
|
|
resp := &GetLotteryDataResp{}
|
|
err = rpcCli.CallWithTimeout("LotteryDataSvc.Get", req, resp, time.Second*30)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return resp.Data, nil
|
|
}
|
|
|
|
type UpsertLotteryDataReq struct {
|
|
Platform string
|
|
Data []*LotteryData
|
|
}
|
|
|
|
func UpsertLotteryData(plt string, data []*LotteryData) (err error) {
|
|
if rpcCli == nil {
|
|
return
|
|
}
|
|
|
|
req := &UpsertLotteryDataReq{
|
|
Platform: plt,
|
|
Data: data,
|
|
}
|
|
ret := false
|
|
return rpcCli.CallWithTimeout("LotteryDataSvc.Upsert", req, &ret, time.Second*30)
|
|
}
|
|
|
|
type DelLotteryDataReq struct {
|
|
Platform string
|
|
CId int64
|
|
}
|
|
|
|
func DelLotteryData(plt string, cId int64) (err error) {
|
|
if rpcCli == nil {
|
|
return
|
|
}
|
|
|
|
req := &DelLotteryDataReq{
|
|
Platform: plt,
|
|
CId: cId,
|
|
}
|
|
ret := false
|
|
return rpcCli.CallWithTimeout("LotteryDataSvc.Del", req, &ret, time.Second*30)
|
|
}
|