上传协议

This commit is contained in:
liwei 2023-07-27 16:39:24 +08:00
parent f9fefeaba5
commit 0f85389b6e
3 changed files with 41 additions and 29 deletions

View File

@ -16,14 +16,16 @@ func (this *apiComp) ExchangeCheck(session comm.IUserSession, req *pb.WTaskExcha
func (this *apiComp) Exchange(session comm.IUserSession, req *pb.WTaskExchangeReq) (errdata *pb.ErrorData) {
var (
info *pb.DBWTask
conf *cfg.GameWorldDealData
confs []*cfg.GameWorldDealData
need []*cfg.Gameatn
money []*cfg.Gameatn
err error
)
if errdata = this.ExchangeCheck(session, req); errdata != nil {
return
}
if conf, err = this.module.configure.getGameWorldDeal(req.Eid); err != nil {
if confs, err = this.module.configure.getGameWorldDeal(req.Eid); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(),
@ -41,7 +43,8 @@ func (this *apiComp) Exchange(session comm.IUserSession, req *pb.WTaskExchangeRe
return
}
if info.Exchange[req.Eid] >= conf.Buy {
for i, v := range req.Eid {
if info.Exchange[v] >= confs[i].Buy {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ReqParameterError,
Title: pb.ErrorCode_ReqParameterError.ToString(),
@ -49,15 +52,19 @@ func (this *apiComp) Exchange(session comm.IUserSession, req *pb.WTaskExchangeRe
}
return
}
need = append(need, confs[i].Item...)
money = append(need, confs[i].Money...)
info.Exchange[v]++
}
if errdata = this.module.ConsumeRes(session, conf.Item, true); errdata != nil {
if errdata = this.module.ConsumeRes(session, need, true); errdata != nil {
return
}
if errdata = this.module.DispenseRes(session, conf.Money, true); errdata != nil {
if errdata = this.module.DispenseRes(session, money, true); errdata != nil {
return
}
info.Exchange[req.Eid]++
if err = this.module.modelwtask.Change(session.GetUserId(), map[string]interface{}{
"exchange": info.Exchange,
}); err != nil {

View File

@ -239,19 +239,24 @@ func (this *configureComp) getGameSearchitemBox(id int32) (conf *cfg.GameSearchi
return
}
func (this *configureComp) getGameWorldDeal(id int32) (conf *cfg.GameWorldDealData, err error) {
func (this *configureComp) getGameWorldDeal(ids []int32) (confs []*cfg.GameWorldDealData, err error) {
var (
v interface{}
conf *cfg.GameWorldDealData
ok bool
)
if v, err = this.GetConfigure(game_worlddeal); err != nil {
return
} else {
confs = make([]*cfg.GameWorldDealData, 0)
for _, id := range ids {
if conf, ok = v.(*cfg.GameWorldDeal).GetDataMap()[id]; !ok {
err = comm.NewNotFoundConfErr(modulename, gameWorldTask, id)
err = comm.NewNotFoundConfErr(modulename, gameWorldTask, v)
this.module.Errorf("err:%v", err)
return
}
confs = append(confs, conf)
}
}
return

View File

@ -1057,7 +1057,7 @@ type WTaskExchangeReq struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Eid int32 `protobuf:"varint,1,opt,name=eid,proto3" json:"eid"`
Eid []int32 `protobuf:"varint,1,rep,packed,name=eid,proto3" json:"eid"`
}
func (x *WTaskExchangeReq) Reset() {
@ -1092,11 +1092,11 @@ func (*WTaskExchangeReq) Descriptor() ([]byte, []int) {
return file_wtask_wtask_msg_proto_rawDescGZIP(), []int{19}
}
func (x *WTaskExchangeReq) GetEid() int32 {
func (x *WTaskExchangeReq) GetEid() []int32 {
if x != nil {
return x.Eid
}
return 0
return nil
}
//世界任务兑换物品 请求
@ -1105,7 +1105,7 @@ type WTaskExchangeResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Eid int32 `protobuf:"varint,1,opt,name=eid,proto3" json:"eid"`
Eid []int32 `protobuf:"varint,1,rep,packed,name=eid,proto3" json:"eid"`
Award []*UserAssets `protobuf:"bytes,2,rep,name=award,proto3" json:"award"` //奖励
}
@ -1141,11 +1141,11 @@ func (*WTaskExchangeResp) Descriptor() ([]byte, []int) {
return file_wtask_wtask_msg_proto_rawDescGZIP(), []int{20}
}
func (x *WTaskExchangeResp) GetEid() int32 {
func (x *WTaskExchangeResp) GetEid() []int32 {
if x != nil {
return x.Eid
}
return 0
return nil
}
func (x *WTaskExchangeResp) GetAward() []*UserAssets {
@ -1265,10 +1265,10 @@ var file_wtask_wtask_msg_proto_rawDesc = []byte{
0x77, 0x61, 0x72, 0x64, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65,
0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x22, 0x24,
0x0a, 0x10, 0x57, 0x54, 0x61, 0x73, 0x6b, 0x45, 0x78, 0x63, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x52,
0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52,
0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x69, 0x64, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x52,
0x03, 0x65, 0x69, 0x64, 0x22, 0x48, 0x0a, 0x11, 0x57, 0x54, 0x61, 0x73, 0x6b, 0x45, 0x78, 0x63,
0x68, 0x61, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x10, 0x0a, 0x03, 0x65, 0x69, 0x64,
0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x65, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x05, 0x61,
0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x52, 0x03, 0x65, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x05, 0x61,
0x77, 0x61, 0x72, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65,
0x72, 0x41, 0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x42, 0x06,
0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,