接口调整

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 {
// 创建一个新的特权卡
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)
// 检查特权 参数 计费点 返回值 是否有特权

View File

@ -369,7 +369,7 @@ func (this *ModuleBase) DispenseRes(session comm.IUserSession, res []*cfg.Gameat
}
if len(vip) > 0 { //卡片资源
for k := range vip {
code = this.ModulePrivilege.CreatePrivilegeCard(session, k)
code, _ = this.ModulePrivilege.Delivery(session, k)
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 {
return
}
code = this.module.CreatePrivilegeCard(session, req.CID)
code, _ = this.module.Delivery(session, req.CID)
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 (
bFind bool
)
conf, err := this.configure.GetPrivilegeCard(cId)
if err != nil {
return pb.ErrorCode_ConfigNoFound
code = pb.ErrorCode_ConfigNoFound
return
}
// 是不是购买过
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 {
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})
return

View File

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

View File

@ -124,3 +124,17 @@ func (this *configureComp) GetMaxDifficultyByBossID(bossId int32) int32 {
}
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
}