上传商店装备价格
This commit is contained in:
parent
78b87913c0
commit
d1ca1a5e94
@ -23,15 +23,18 @@ func (this *apiComp) BuyCheck(session comm.IUserSession, req *pb.ShopBuyReq) (er
|
|||||||
// /获取用户商品列表
|
// /获取用户商品列表
|
||||||
func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (errdata *pb.ErrorData) {
|
func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (errdata *pb.ErrorData) {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
conf *cfg.GameShopitemData
|
conf *cfg.GameShopitemData
|
||||||
shopData *pb.DBShop
|
shopData *pb.DBShop
|
||||||
good *pb.UserShopGood
|
good *pb.UserShopGood
|
||||||
filed string
|
filed string
|
||||||
record *pb.UserShopData
|
record *pb.UserShopData
|
||||||
need []*cfg.Gameatn
|
need []*cfg.Gameatn
|
||||||
give []*cfg.Gameatn
|
give []*cfg.Gameatn
|
||||||
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
|
||||||
|
equi *pb.DB_Equipment
|
||||||
|
equiconf *cfg.GameEquipData
|
||||||
|
equibuyconf *cfg.GameShopBuyequiCosData
|
||||||
)
|
)
|
||||||
if errdata = this.BuyCheck(session, req); errdata != nil {
|
if errdata = this.BuyCheck(session, req); errdata != nil {
|
||||||
return
|
return
|
||||||
@ -141,8 +144,31 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (errdata
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
good.Buy += req.BuyNum
|
good.Buy += req.BuyNum
|
||||||
if errdata = this.module.ConsumeRes(session, need, true); errdata != nil {
|
if !conf.Preview {
|
||||||
return
|
if errdata = this.module.ConsumeRes(session, need, true); errdata != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
} else { //装备价格采用计算价格
|
||||||
|
equi = record.Preview[req.Gid]
|
||||||
|
if equiconf, err = this.module.configure.getGameEquipData(equi.CId); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if equibuyconf, err = this.module.configure.getShopBuyequiCosData(equiconf.InitLv, equi.Lv); err != nil {
|
||||||
|
errdata = &pb.ErrorData{
|
||||||
|
Code: pb.ErrorCode_ConfigNoFound,
|
||||||
|
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||||
|
Message: err.Error(),
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if errdata = this.module.ConsumeRes(session, equibuyconf.Suittype, true); errdata != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.module.modelShop.Change(session.GetUserId(), map[string]interface{}{filed: record})
|
this.module.modelShop.Change(session.GetUserId(), map[string]interface{}{filed: record})
|
||||||
if !conf.Preview {
|
if !conf.Preview {
|
||||||
|
@ -10,8 +10,10 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
game_shop = "game_shop.json"
|
game_shop = "game_shop.json"
|
||||||
game_shopitem = "game_shopitem.json"
|
game_shopitem = "game_shopitem.json"
|
||||||
|
game_shopbuyequicos = "game_shopbuyequicos.json"
|
||||||
|
game_equip = "game_equip.json" //装备信息表
|
||||||
)
|
)
|
||||||
|
|
||||||
// /背包配置管理组件
|
// /背包配置管理组件
|
||||||
@ -26,6 +28,8 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
|
|||||||
this.module = module.(*Shop)
|
this.module = module.(*Shop)
|
||||||
this.LoadConfigure(game_shop, cfg.NewGameShop)
|
this.LoadConfigure(game_shop, cfg.NewGameShop)
|
||||||
this.LoadConfigure(game_shopitem, cfg.NewGameShopitem)
|
this.LoadConfigure(game_shopitem, cfg.NewGameShopitem)
|
||||||
|
this.LoadConfigure(game_shopbuyequicos, cfg.NewGameShopBuyequiCos)
|
||||||
|
this.LoadConfigure(game_equip, cfg.NewGameEquip)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,3 +122,43 @@ func (this *configureComp) GetShopItemsConfigureByIds(keys ...int32) (result []*
|
|||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 获取装备套装配置
|
||||||
|
func (this *configureComp) getShopBuyequiCosData(intlv, lv int32) (conf *cfg.GameShopBuyequiCosData, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(game_shopbuyequicos); err != nil {
|
||||||
|
this.module.Errorf("err:%v", err)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
for _, v := range v.(*cfg.GameShopBuyequiCos).GetDataList() {
|
||||||
|
if v.InitLv == intlv && v.UpLv == lv {
|
||||||
|
conf = v
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_shopbuyequicos, fmt.Sprintf("intlv:%d lv:%d", intlv, lv))
|
||||||
|
this.module.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取装备配置数据
|
||||||
|
func (this *configureComp) getGameEquipData(equipmentId string) (configure *cfg.GameEquipData, err error) {
|
||||||
|
var (
|
||||||
|
v interface{}
|
||||||
|
ok bool
|
||||||
|
)
|
||||||
|
if v, err = this.GetConfigure(game_equip); err != nil {
|
||||||
|
this.module.Errorf("err:%v", err)
|
||||||
|
return
|
||||||
|
} else {
|
||||||
|
if configure, ok = v.(*cfg.GameEquip).GetDataMap()[equipmentId]; !ok {
|
||||||
|
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_equip, equipmentId)
|
||||||
|
this.module.Errorln(err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user