上传门票接口
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)
|
AddItems(session IUserSession, items map[string]int32, bPush bool) (change []*pb.DB_UserItemData, code pb.ErrorCode)
|
||||||
///清理道具
|
///清理道具
|
||||||
CleanItems(session IUserSession) (code pb.ErrorCode)
|
CleanItems(session IUserSession) (code pb.ErrorCode)
|
||||||
///购买统一入场卷
|
///购买统一入场券
|
||||||
BuyUnifiedTicket(session IUserSession, buynum int32) (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) {
|
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 {
|
if code = this.RefreshUnifiedTicketCheck(session, req); code != pb.ErrorCode_Success {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if user = this.module.ModuleUser.GetUser(session.GetUserId()); user == nil {
|
if code = this.module.modelItems.recoverTicket(session); code != pb.ErrorCode_Success {
|
||||||
code = pb.ErrorCode_CacheReadError
|
|
||||||
return
|
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{})
|
session.SendMsg(string(this.module.GetType()), "refreshunifiedticket", &pb.ItemsRefreshUnifiedTicketResp{})
|
||||||
return
|
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) {
|
func (this *ModelItemsComp) buyTicket(session comm.IUserSession, buy int32) (info *pb.DBUserExpand, code pb.ErrorCode) {
|
||||||
var (
|
var (
|
||||||
user *pb.DBUser
|
|
||||||
need *cfg.Gameatn
|
need *cfg.Gameatn
|
||||||
needs []*cfg.Gameatn
|
needs []*cfg.Gameatn
|
||||||
maxbuy, vipbuy int
|
maxbuy, vipbuy int
|
||||||
err error
|
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 {
|
if info, err = this.module.ModuleUser.GetUserExpand(session.GetUserId()); err != nil {
|
||||||
code = pb.ErrorCode_CacheReadError
|
code = pb.ErrorCode_CacheReadError
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
this.module.modelItems.recoverTicket(session, user, info)
|
this.module.modelItems.recoverTicket(session)
|
||||||
if maxbuy, err = this.module.configure.GetchallengeDataCount(); err != nil {
|
if maxbuy, err = this.module.configure.GetchallengeDataCount(); err != nil {
|
||||||
code = pb.ErrorCode_ConfigNoFound
|
code = pb.ErrorCode_ConfigNoFound
|
||||||
return
|
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 (
|
var (
|
||||||
|
user *pb.DBUser
|
||||||
|
info *pb.DBUserExpand
|
||||||
duration time.Duration
|
duration time.Duration
|
||||||
ticket int32
|
ticket int32
|
||||||
ticketNum 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() {
|
if time.Unix(info.Lasttimeunifiedticket, 0).Day() < configure.Now().Day() {
|
||||||
info.Lasttimeunifiedticket = configure.Now().Unix()
|
info.Lasttimeunifiedticket = configure.Now().Unix()
|
||||||
info.Buyunifiedticket = 0
|
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()
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//购买门票道具
|
||||||
|
func (this *Items) RecoverTicket(session comm.IUserSession) (code pb.ErrorCode) {
|
||||||
|
code = this.modelItems.recoverTicket(session)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
//Evens--------------------------------------------------------------------------------------------------------------------------------
|
//Evens--------------------------------------------------------------------------------------------------------------------------------
|
||||||
//推送道具变化消息
|
//推送道具变化消息
|
||||||
func (this *Items) itemsChangePush(session comm.IUserSession, items []*pb.DB_UserItemData) (err error) {
|
func (this *Items) itemsChangePush(session comm.IUserSession, items []*pb.DB_UserItemData) (err error) {
|
||||||
|
@ -7,8 +7,6 @@ import (
|
|||||||
"go_dreamfactory/modules"
|
"go_dreamfactory/modules"
|
||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
|
||||||
"math"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"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) {
|
func (this *modelUserMF) recoverTicket(session comm.IUserSession, info *pb.DBUserMFantasy) {
|
||||||
var (
|
// var (
|
||||||
duration time.Duration
|
// duration time.Duration
|
||||||
ticket int32
|
// ticket int32
|
||||||
ticketNum int32
|
// ticketNum int32
|
||||||
)
|
// )
|
||||||
if time.Unix(info.LastTrigger, 0).Day() < configure.Now().Day() {
|
if time.Unix(info.LastTrigger, 0).Day() < configure.Now().Day() {
|
||||||
info.TriggerNum = 0
|
info.TriggerNum = 0
|
||||||
info.LastTrigger = configure.Now().Unix()
|
info.LastTrigger = configure.Now().Unix()
|
||||||
info.BuyNum = 0
|
// 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()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
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