商店购买配置优化

This commit is contained in:
meixiongfeng 2022-11-30 12:21:37 +08:00
parent 36fbe0b647
commit 3cfefbf017
2 changed files with 29 additions and 1 deletions

View File

@ -30,13 +30,18 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.HeroBuyReq) (code pb
update map[string]interface{}
price []int32 // 购买所需的价钱
totalCost float32 // 购买打折系数
udata *pb.DBUser
)
update = make(map[string]interface{})
if code = this.BuyCheck(session, req); code != pb.ErrorCode_Success {
return
}
if udata = this.module.ModuleUser.GetUser(session.GetUserId()); udata == nil {
code = pb.ErrorCode_SystemError
return
}
if conf, err = this.module.configure.GetShopItemsConfigure(req.BuyType); err != nil { // 找配置
if conf, err = this.module.configure.GetShopItemsConfigureByGroups(req.BuyType, udata); err != nil { // 找配置
code = pb.ErrorCode_ConfigNoFound
return
}

View File

@ -3,6 +3,7 @@ package hero
import (
"fmt"
"go_dreamfactory/modules"
"go_dreamfactory/pb"
"go_dreamfactory/sys/configure"
cfg "go_dreamfactory/sys/configure/structs"
@ -463,3 +464,25 @@ func (this *configureComp) GetShopItemsConfigure(key int32) (result *cfg.GameSho
}
return
}
func (this *configureComp) GetShopItemsConfigureByGroups(groupid int32, user *pb.DBUser) (result *cfg.GameShopitemData, err error) {
var (
v interface{}
table *cfg.GameShopitem
)
if v, err = this.GetConfigure(game_shopitem); err != nil {
this.module.Errorf("err:%v", err)
return
} else {
table = v.(*cfg.GameShopitem)
for _, v := range table.GetDataMap() {
if v.Id == groupid &&
user.Lv >= v.Lvmin &&
user.Lv <= v.Lvmax &&
user.Vip >= v.Vip {
result = v
return
}
}
}
return
}