商店购买配置优化
This commit is contained in:
parent
36fbe0b647
commit
3cfefbf017
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user