go_dreamfactory/modules/entertainment/api_getlist.go
2024-01-09 10:22:18 +08:00

68 lines
1.9 KiB
Go

package entertainment
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
"go_dreamfactory/utils"
"time"
)
//参数校验
func (this *apiComp) GetListCheck(session comm.IUserSession, req *pb.EntertainGetListReq) (errdata *pb.ErrorData) {
return
}
func (this *apiComp) GetList(session comm.IUserSession, req *pb.EntertainGetListReq) (errdata *pb.ErrorData) {
var (
list *pb.DBXXLData
err error
)
list, err = this.module.model.getEntertainmList(session.GetUserId())
if err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
if !utils.IsToday(list.Rtime) {
update := make(map[string]interface{})
list.Rtime = configure.Now().Unix()
list.Playtype = []int32{}
var tmp []int32
for _, v := range this.module.configure.GetGameConsumeIntegral() {
tmp = append(tmp, v.Key) // 配置读取一个玩法
}
for _, v := range comm.GetRandWs(tmp, 2) {
list.Playtype = append(list.Playtype, tmp[v])
}
list.Touxiang = 3 // 需求 默认3 后面可能走配置
update["touxiang"] = list.Touxiang // 每天投降次数清0
update["rtime"] = list.Rtime
update["playtype"] = list.Playtype
endSeasonTime := utils.GetMonthEnd(configure.Now().Unix())
if list.Etime > endSeasonTime {
list.Etime = endSeasonTime
update["etime"] = list.Etime
this.module.ModuleUser.CleanUserMerchantmoney(session)
curMonth := time.Now().Month() // 计算赛季
curYear := time.Now().Year()
preMonth := this.module.service.GetOpentime().Month()
preYear := this.module.service.GetOpentime().Year()
tmp := int(curYear-preYear)*12 + int(curMonth-preMonth)
list.Rounds = int32(tmp)
update["rounds"] = list.Rounds
}
this.module.model.modifyEntertainmList(session.GetUserId(), update)
}
session.SendMsg(string(this.module.GetType()), "getlist", &pb.EntertainGetListResp{
Data: list,
})
return
}