130 lines
2.6 KiB
Go
130 lines
2.6 KiB
Go
package model
|
|
|
|
import "time"
|
|
|
|
var (
|
|
LotteryCodeDBName = "log"
|
|
LotteryCodeCollName = "log_lotterycode"
|
|
)
|
|
|
|
// 玩家抽奖活动开奖码
|
|
|
|
type LotteryCode struct {
|
|
Platform string `bson:"-"`
|
|
SnId int32 // 玩家id
|
|
CId int64 // 抽奖配置id
|
|
StartTs int64 // 抽奖开始时间
|
|
Code string // 开奖码
|
|
Index int // 开奖码序号
|
|
}
|
|
|
|
type UpsertLotteryCodeReq struct {
|
|
Platform string
|
|
Item *LotteryCode
|
|
}
|
|
|
|
// UpsertLotteryCode 记录玩家抽奖活动开奖码
|
|
func UpsertLotteryCode(plt string, item *LotteryCode) (err error) {
|
|
if rpcCli == nil {
|
|
return ErrRPClientNoConn
|
|
}
|
|
|
|
req := &UpsertLotteryCodeReq{
|
|
Platform: plt,
|
|
Item: item,
|
|
}
|
|
ret := false
|
|
|
|
err = rpcCli.CallWithTimeout("LotteryCodeSvc.Upsert", req, &ret, time.Second*30)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return nil
|
|
}
|
|
|
|
type GetLotteryCodeReq struct {
|
|
Platform string
|
|
Code string
|
|
CId int64
|
|
StartTs int64
|
|
}
|
|
|
|
type GetLotteryCodeResp struct {
|
|
Item *LotteryCode
|
|
}
|
|
|
|
// GetLotteryCode 获取玩家抽奖活动开奖码
|
|
func GetLotteryCode(plt string, code string, cid int64, startTs int64) (*LotteryCode, error) {
|
|
if rpcCli == nil {
|
|
return nil, ErrRPClientNoConn
|
|
}
|
|
|
|
req := &GetLotteryCodeReq{
|
|
Platform: plt,
|
|
Code: code,
|
|
CId: cid,
|
|
StartTs: startTs,
|
|
}
|
|
ret := &GetLotteryCodeResp{}
|
|
|
|
err := rpcCli.CallWithTimeout("LotteryCodeSvc.Get", req, ret, time.Second*30)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ret.Item, nil
|
|
}
|
|
|
|
// GetLotteryCodeJoinNumReq 获取参与人数
|
|
type GetLotteryCodeJoinNumReq struct {
|
|
Platform string
|
|
CId int64
|
|
StartTs int64
|
|
}
|
|
|
|
// GetLotteryCodeJoinNum 获取参与人数
|
|
func GetLotteryCodeJoinNum(plt string, cid int64, startTs int64) (int, error) {
|
|
if rpcCli == nil {
|
|
return 0, ErrRPClientNoConn
|
|
}
|
|
req := &GetLotteryCodeJoinNumReq{
|
|
Platform: plt,
|
|
CId: cid,
|
|
StartTs: startTs,
|
|
}
|
|
ret := 0
|
|
err := rpcCli.CallWithTimeout("LotteryCodeSvc.GetJoinNum", req, &ret, time.Second*30)
|
|
if err != nil {
|
|
return 0, err
|
|
}
|
|
return ret, nil
|
|
}
|
|
|
|
// GetLotteryCodeRandomReq 获取随机开奖码
|
|
type GetLotteryCodeRandomReq struct {
|
|
Platform string
|
|
CId int64
|
|
StartTs int64
|
|
Index int
|
|
Tp int
|
|
}
|
|
|
|
// GetLotteryCodeRandom 获取随机开奖码
|
|
func GetLotteryCodeRandom(plt string, cid int64, startTs int64, tp, index int) (*LotteryCode, error) {
|
|
if rpcCli == nil {
|
|
return nil, ErrRPClientNoConn
|
|
}
|
|
req := &GetLotteryCodeRandomReq{
|
|
Platform: plt,
|
|
CId: cid,
|
|
StartTs: startTs,
|
|
Index: index,
|
|
Tp: tp,
|
|
}
|
|
ret := &GetLotteryCodeResp{}
|
|
err := rpcCli.CallWithTimeout("LotteryCodeSvc.GetRandom", req, ret, time.Second*30)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ret.Item, nil
|
|
}
|