上传商城代码
This commit is contained in:
parent
9c3c1ab798
commit
260842c0d5
@ -112,6 +112,8 @@ type (
|
||||
AddNewEquipments(session IUserSession, cIds map[string]uint32, bPush bool) (code pb.ErrorCode)
|
||||
//创建装备
|
||||
NewEquipment(uid, cid string) (code pb.ErrorCode, equip *pb.DB_Equipment)
|
||||
//添加装备
|
||||
AddEquipment(equip *pb.DB_Equipment) (code pb.ErrorCode)
|
||||
}
|
||||
IMainline interface {
|
||||
// 修改章节信息
|
||||
|
@ -140,6 +140,28 @@ func (this *modelEquipmentComp) AddEquipments(session comm.IUserSession, cIds ma
|
||||
return
|
||||
}
|
||||
|
||||
func (this *modelEquipmentComp) addEquipment(equip *pb.DB_Equipment) (err error) {
|
||||
var (
|
||||
model *db.DBModel
|
||||
)
|
||||
if this.module.IsCross() {
|
||||
if model, err = this.module.GetDBNoduleByUid(equip.UId, this.TableName, this.Expired); err != nil {
|
||||
this.module.Errorln(err)
|
||||
} else {
|
||||
if err = model.AddList(equip.UId, equip.Id, equip); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if err = this.AddList(equip.UId, equip.Id, equip); err != nil {
|
||||
this.module.Errorf("err:%v", err)
|
||||
return
|
||||
}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//删除装备
|
||||
func (this *modelEquipmentComp) DelEquipments(uId string, eIds []string) (change []*pb.DB_Equipment, err error) {
|
||||
var (
|
||||
|
@ -145,6 +145,18 @@ func (this *Equipment) NewEquipment(uid, cid string) (code pb.ErrorCode, equip *
|
||||
return
|
||||
}
|
||||
|
||||
//创建新的装备
|
||||
func (this *Equipment) AddEquipment(equip *pb.DB_Equipment) (code pb.ErrorCode) {
|
||||
var (
|
||||
err error
|
||||
)
|
||||
if err = this.modelEquipment.addEquipment(equip); err != nil {
|
||||
code = pb.ErrorCode_DBError
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
//Evens--------------------------------------------------------------------------------------------------------------------------------
|
||||
//推送道具变化消息
|
||||
func (this *Equipment) equipmentsChangePush(session comm.IUserSession, items []*pb.DB_Equipment) (err error) {
|
||||
|
@ -62,14 +62,6 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (code pb
|
||||
if code = this.module.ConsumeRes(session, need, true); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
if !conf.Preview {
|
||||
if code = this.module.DispenseRes(session, give, true); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
switch req.ShopType {
|
||||
case pb.ShopType_GoldShop:
|
||||
filed = "goldShop"
|
||||
@ -103,6 +95,15 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (code pb
|
||||
}
|
||||
record.Buy[req.GoodsId] += req.BuyNum
|
||||
this.module.modelShop.Change(session.GetUserId(), map[string]interface{}{filed: record})
|
||||
if !conf.Preview {
|
||||
if code = this.module.DispenseRes(session, give, true); code != pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
} else {
|
||||
if code = this.module.equip.AddEquipment(record.Preview[req.GoodsId]); code == pb.ErrorCode_Success {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
//随机任务
|
||||
this.module.ModuleRtask.SendToRtask(session, comm.Rtype64, 1)
|
||||
|
Loading…
Reference in New Issue
Block a user