上传门票接口
This commit is contained in:
parent
f01345db2b
commit
2e93abd69d
@ -37,8 +37,10 @@ type (
|
||||
AddItems(session IUserSession, items map[string]int32, bPush bool) (change []*pb.DB_UserItemData, code pb.ErrorCode)
|
||||
///清理道具
|
||||
CleanItems(session IUserSession) (code pb.ErrorCode)
|
||||
///购买统一入场卷
|
||||
///购买统一入场券
|
||||
BuyUnifiedTicket(session IUserSession, buynum int32) (code pb.ErrorCode)
|
||||
///刷新恢复入场券
|
||||
RecoverTicket(session IUserSession) (code pb.ErrorCode)
|
||||
}
|
||||
|
||||
//英雄
|
||||
|
@ -15,23 +15,12 @@ func (this *apiComp) RefreshUnifiedTicketCheck(session comm.IUserSession, req *p
|
||||
|
||||
//购买
|
||||
func (this *apiComp) RefreshUnifiedTicket(session comm.IUserSession, req *pb.ItemsRefreshUnifiedTicketReq) (code pb.ErrorCode, data proto.Message) {
|
||||
var (
|
||||
user *pb.DBUser
|
||||
info *pb.DBUserExpand
|
||||
err error
|
||||
)
|
||||
if code = this.RefreshUnifiedTicketCheck(session, req); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil {
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
if code = this.module.modelItems.recoverTicket(session); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
if info, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
return
|
||||
}
|
||||
this.module.modelItems.recoverTicket(session, user, info)
|
||||
session.SendMsg(string(this.module.GetType()), "refreshunifiedticket", &pb.ItemsRefreshUnifiedTicketResp{})
|
||||
return
|
||||
}
|
||||
|
@ -464,21 +464,16 @@ func (this *ModelItemsComp) addItemToUserPack(uid string, items []*pb.DB_UserIte
|
||||
//购买门票
|
||||
func (this *ModelItemsComp) buyTicket(session comm.IUserSession, buy int32) (info *pb.DBUserExpand, code pb.ErrorCode) {
|
||||
var (
|
||||
user *pb.DBUser
|
||||
need *cfg.Gameatn
|
||||
needs []*cfg.Gameatn
|
||||
maxbuy, vipbuy int
|
||||
err error
|
||||
)
|
||||
if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil {
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
return
|
||||
}
|
||||
if info, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
return
|
||||
}
|
||||
this.module.modelItems.recoverTicket(session, user, info)
|
||||
this.module.modelItems.recoverTicket(session)
|
||||
if maxbuy, err = this.module.configure.GetchallengeDataCount(); err != nil {
|
||||
code = pb.ErrorCode_ConfigNoFound
|
||||
return
|
||||
@ -514,12 +509,23 @@ func (this *ModelItemsComp) buyTicket(session comm.IUserSession, buy int32) (inf
|
||||
}
|
||||
|
||||
///回复门票
|
||||
func (this *ModelItemsComp) recoverTicket(session comm.IUserSession, user *pb.DBUser, info *pb.DBUserExpand) {
|
||||
func (this *ModelItemsComp) recoverTicket(session comm.IUserSession) (code pb.ErrorCode) {
|
||||
var (
|
||||
user *pb.DBUser
|
||||
info *pb.DBUserExpand
|
||||
duration time.Duration
|
||||
ticket int32
|
||||
ticketNum int32
|
||||
err error
|
||||
)
|
||||
if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil {
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
return
|
||||
}
|
||||
if info, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
|
||||
code = pb.ErrorCode_CacheReadError
|
||||
return
|
||||
}
|
||||
if time.Unix(info.Lasttimeunifiedticket, 0).Day() < configure.Now().Day() {
|
||||
info.Lasttimeunifiedticket = configure.Now().Unix()
|
||||
info.Buyunifiedticket = 0
|
||||
@ -538,4 +544,5 @@ func (this *ModelItemsComp) recoverTicket(session comm.IUserSession, user *pb.DB
|
||||
info.Recovertimeunifiedticket = time.Unix(info.Recovertimeunifiedticket, 0).Add(time.Duration(ticketNum) * time.Minute).Unix()
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -181,6 +181,12 @@ func (this *Items) BuyUnifiedTicket(session comm.IUserSession, buynum int32) (co
|
||||
return
|
||||
}
|
||||
|
||||
//购买门票道具
|
||||
func (this *Items) RecoverTicket(session comm.IUserSession) (code pb.ErrorCode) {
|
||||
code = this.modelItems.recoverTicket(session)
|
||||
return
|
||||
}
|
||||
|
||||
//Evens--------------------------------------------------------------------------------------------------------------------------------
|
||||
//推送道具变化消息
|
||||
func (this *Items) itemsChangePush(session comm.IUserSession, items []*pb.DB_UserItemData) (err error) {
|
||||
|
@ -7,8 +7,6 @@ import (
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
@ -73,27 +71,28 @@ func (this *modelUserMF) updateUserInfo(info *pb.DBUserMFantasy) (err error) {
|
||||
}
|
||||
|
||||
func (this *modelUserMF) recoverTicket(session comm.IUserSession, info *pb.DBUserMFantasy) {
|
||||
var (
|
||||
duration time.Duration
|
||||
ticket int32
|
||||
ticketNum int32
|
||||
)
|
||||
// var (
|
||||
// duration time.Duration
|
||||
// ticket int32
|
||||
// ticketNum int32
|
||||
// )
|
||||
if time.Unix(info.LastTrigger, 0).Day() < configure.Now().Day() {
|
||||
info.TriggerNum = 0
|
||||
info.LastTrigger = configure.Now().Unix()
|
||||
info.BuyNum = 0
|
||||
}
|
||||
global := this.module.configure.GetGlobalConf()
|
||||
ticket = int32(this.module.ModuleItems.QueryItemAmount(info.Uid, comm.MoonFantasyTicket))
|
||||
if ticket < global.DreamlandFightnum && info.Lastrtickettime > 0 {
|
||||
duration = configure.Now().Sub(time.Unix(info.Lastrtickettime, 0))
|
||||
ticketNum = int32(math.Floor(duration.Minutes() / float64(global.ArenaTicketRecoveryTime)))
|
||||
if ticketNum > 0 {
|
||||
if ticketNum+ticket > global.ArenaTicketMax {
|
||||
ticketNum = global.ArenaTicketMax - ticket
|
||||
}
|
||||
this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{A: comm.ItemType, T: comm.MoonFantasyTicket, N: ticketNum}}, true)
|
||||
info.Lastrtickettime = time.Unix(info.Lastrtickettime, 0).Add(time.Duration(ticketNum) * time.Minute).Unix()
|
||||
}
|
||||
// info.BuyNum = 0
|
||||
}
|
||||
this.module.ModuleItems.RecoverTicket(session)
|
||||
// global := this.module.configure.GetGlobalConf()
|
||||
// ticket = int32(this.module.ModuleItems.QueryItemAmount(info.Uid, comm.MoonFantasyTicket))
|
||||
// if ticket < global.DreamlandFightnum && info.Lastrtickettime > 0 {
|
||||
// duration = configure.Now().Sub(time.Unix(info.Lastrtickettime, 0))
|
||||
// ticketNum = int32(math.Floor(duration.Minutes() / float64(global.ArenaTicketRecoveryTime)))
|
||||
// if ticketNum > 0 {
|
||||
// if ticketNum+ticket > global.ArenaTicketMax {
|
||||
// ticketNum = global.ArenaTicketMax - ticket
|
||||
// }
|
||||
// this.module.DispenseRes(session, []*cfg.Gameatn{&cfg.Gameatn{A: comm.ItemType, T: comm.MoonFantasyTicket, N: ticketNum}}, true)
|
||||
// info.Lastrtickettime = time.Unix(info.Lastrtickettime, 0).Add(time.Duration(ticketNum) * time.Minute).Unix()
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user