接口调整

This commit is contained in:
meixiongfeng 2022-12-22 18:57:58 +08:00
parent 0b83a213b3
commit 28c6133a99
6 changed files with 39 additions and 14 deletions

View File

@ -279,7 +279,7 @@ type (
} }
IPrivilege interface { IPrivilege interface {
// 创建一个新的特权卡 // 创建一个新的特权卡
CreatePrivilegeCard(session IUserSession, cId string) (code pb.ErrorCode) Delivery(session IUserSession, pId string) (code pb.ErrorCode, items []*pb.UserAssets)
// 续费特权卡 // 续费特权卡
RenewPrivilegeCard(session IUserSession, cId string) (code pb.ErrorCode) RenewPrivilegeCard(session IUserSession, cId string) (code pb.ErrorCode)
// 检查特权 参数 计费点 返回值 是否有特权 // 检查特权 参数 计费点 返回值 是否有特权

View File

@ -369,7 +369,7 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameat
} }
if len(vip) > 0 { //卡片资源 if len(vip) > 0 { //卡片资源
for k := range vip { for k := range vip {
code = this.ModulePrivilege.CreatePrivilegeCard(session, k) code, _ = this.ModulePrivilege.Delivery(session, k)
this.Debugf("发放月卡资源: %v [%v]", k, code) this.Debugf("发放月卡资源: %v [%v]", k, code)
} }

View File

@ -21,6 +21,6 @@ func (this *apiComp) BuyYueka(session comm.IUserSession, req *pb.PrivilegeBuyYue
if code = this.BuyYuekaCheck(session, req); code != pb.ErrorCode_Success { if code = this.BuyYuekaCheck(session, req); code != pb.ErrorCode_Success {
return return
} }
code = this.module.CreatePrivilegeCard(session, req.CID) code, _ = this.module.Delivery(session, req.CID)
return return
} }

View File

@ -66,14 +66,15 @@ func (this *Privilege) EventUserOffline(session comm.IUserSession) {
} }
// 购买了一个新的特权 // 购买了一个新的特权
func (this *Privilege) CreatePrivilegeCard(session comm.IUserSession, cId string) (code pb.ErrorCode) { func (this *Privilege) Delivery(session comm.IUserSession, cId string) (code pb.ErrorCode, items []*pb.UserAssets) {
var ( var (
bFind bool bFind bool
) )
conf, err := this.configure.GetPrivilegeCard(cId) conf, err := this.configure.GetPrivilegeCard(cId)
if err != nil { if err != nil {
return pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
return
} }
// 是不是购买过 // 是不是购买过
list, err := this.modelPrivilege.getPrivilegeList(session.GetUserId()) list, err := this.modelPrivilege.getPrivilegeList(session.GetUserId())
@ -168,6 +169,13 @@ func (this *Privilege) CreatePrivilegeCard(session comm.IUserSession, cId string
if code = this.DispenseRes(session, conf.DisposableReward, true); code != pb.ErrorCode_Success { if code = this.DispenseRes(session, conf.DisposableReward, true); code != pb.ErrorCode_Success {
return return
} }
for _, v := range conf.DisposableReward {
items = append(items, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N,
})
}
// 推送 // 推送
session.SendMsg(string(this.GetType()), PrivilegeBuyYuekaResp, &pb.PrivilegeBuyYuekaResp{Data: list}) session.SendMsg(string(this.GetType()), PrivilegeBuyYuekaResp, &pb.PrivilegeBuyYuekaResp{Data: list})
return return

View File

@ -27,6 +27,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code
curCount int32 // 当前门票数量 curCount int32 // 当前门票数量
szcostRes []*cfg.Gameatn // 购买累计消耗 szcostRes []*cfg.Gameatn // 购买累计消耗
addCount int32 //获得数量 addCount int32 //获得数量
PrivilegeBuyCount int32 // 特权购买次数
) )
mapData = make(map[string]interface{}, 0) mapData = make(map[string]interface{}, 0)
code = this.BuyCheck(session, req) code = this.BuyCheck(session, req)
@ -49,6 +50,8 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code
} else { } else {
curByCount = list.BuyCount curByCount = list.BuyCount
} }
PrivilegeBuyCount = this.module.ModulePrivilege.GetCountByPrivilegeId(session.GetUserId(), comm.PrivilegeType3)
conf := this.module.configure.GetGlobalConf() conf := this.module.configure.GetGlobalConf()
if conf == nil { if conf == nil {
code = pb.ErrorCode_ConfigNoFound code = pb.ErrorCode_ConfigNoFound
@ -92,7 +95,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code
mapData["recoveryTime"] = list.RecoveryTime // 更新刷新时间 mapData["recoveryTime"] = list.RecoveryTime // 更新刷新时间
curByCount += req.Count // 当前需要购买的数量 curByCount += req.Count // 当前需要购买的数量
if this.configure.GetMaxBuyChallengeCount() < curByCount { if this.configure.GetMaxBuyChallengeCount()+PrivilegeBuyCount < curByCount {
code = pb.ErrorCode_VikingBuyMaxCount code = pb.ErrorCode_VikingBuyMaxCount
return return
} }
@ -101,8 +104,8 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.VikingBuyReq) (code
for i := list.BuyCount + 1; i <= curByCount; i++ { for i := list.BuyCount + 1; i <= curByCount; i++ {
_cfg := this.configure.GetBuyChallengeCount(i) _cfg := this.configure.GetBuyChallengeCount(i)
if _cfg == nil { if _cfg == nil {
code = pb.ErrorCode_VikingBuyMaxCount // 取最后一条
return _cfg = this.configure.GetLastBuyChallenge()
} }
szcostRes = append(szcostRes, _cfg.Need...) szcostRes = append(szcostRes, _cfg.Need...)
} }

View File

@ -124,3 +124,17 @@ func (this *configureComp) GetMaxDifficultyByBossID(bossId int32) int32 {
} }
return 0 return 0
} }
// 获取最后一条数据
func (this *configureComp) GetLastBuyChallenge() (data *cfg.GameVikingChallengeData) {
if v, err := this.GetConfigure(game_challenge); err == nil {
if configure, ok := v.(*cfg.GameVikingChallenge); ok && len(configure.GetDataList()) > 0 {
data = configure.GetDataList()[len(configure.GetDataList())-1]
return
}
} else {
log.Errorf("get game_challenge conf err:%v", err)
}
return
}