78 lines
1.5 KiB
Go
78 lines
1.5 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// 玩家对于每个抽奖活动的状态
|
|
|
|
var (
|
|
LotteryDBName = "user"
|
|
LotteryCollName = "user_lottery"
|
|
)
|
|
|
|
type Lottery struct {
|
|
SnId int32 // 玩家id
|
|
CId int64 // 抽奖配置Id
|
|
Code []string // 抽奖码
|
|
StartTs int64 // 抽奖时间
|
|
CostCard int64 // 消耗房卡
|
|
ReCostCard int // 不足获取抽奖码时消耗房卡记录
|
|
}
|
|
|
|
type GetLotteryReq struct {
|
|
Platform string
|
|
SnId int32
|
|
CId int64
|
|
StartTs int64
|
|
}
|
|
|
|
type GetLotteryResp struct {
|
|
Lottery []*Lottery
|
|
}
|
|
|
|
// GetLottery 获取玩家对于每个抽奖活动的状态
|
|
// plt 平台
|
|
// snid 玩家id
|
|
// cid 抽奖配置Id
|
|
// startTs 活动开始时间范围,大于这个时间的活动
|
|
func GetLottery(plt string, snid int32, cid, startTs int64) (ret []*Lottery, err error) {
|
|
if rpcCli == nil {
|
|
return nil, ErrRPClientNoConn
|
|
}
|
|
|
|
req := &GetLotteryReq{
|
|
Platform: plt,
|
|
SnId: snid,
|
|
CId: cid,
|
|
StartTs: startTs,
|
|
}
|
|
resp := &GetLotteryResp{}
|
|
|
|
err = rpcCli.CallWithTimeout("LotterySvc.Get", req, resp, time.Second*30)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return resp.Lottery, nil
|
|
}
|
|
|
|
type UpsertLotteryReq struct {
|
|
Platform string
|
|
Lottery []*Lottery
|
|
}
|
|
|
|
func UpsertLottery(plt string, item ...*Lottery) (err error) {
|
|
if rpcCli == nil {
|
|
return ErrRPClientNoConn
|
|
}
|
|
|
|
req := &UpsertLotteryReq{
|
|
Platform: plt,
|
|
Lottery: item,
|
|
}
|
|
|
|
var ret bool
|
|
err = rpcCli.CallWithTimeout("LotterySvc.Upsert", req, &ret, time.Second*30)
|
|
return
|
|
}
|