上传协议

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

@ -15,15 +15,17 @@ func (this *apiComp) ExchangeCheck(session comm.IUserSession, req *pb.WTaskExcha
// /获取系统公告 // /获取系统公告
func (this *apiComp) Exchange(session comm.IUserSession, req *pb.WTaskExchangeReq) (errdata *pb.ErrorData) { func (this *apiComp) Exchange(session comm.IUserSession, req *pb.WTaskExchangeReq) (errdata *pb.ErrorData) {
var ( var (
info *pb.DBWTask info *pb.DBWTask
conf *cfg.GameWorldDealData confs []*cfg.GameWorldDealData
err error need []*cfg.Gameatn
money []*cfg.Gameatn
err error
) )
if errdata = this.ExchangeCheck(session, req); errdata != nil { if errdata = this.ExchangeCheck(session, req); errdata != nil {
return 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{ errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound, Code: pb.ErrorCode_ConfigNoFound,
Title: pb.ErrorCode_ConfigNoFound.ToString(), Title: pb.ErrorCode_ConfigNoFound.ToString(),
@ -41,23 +43,28 @@ func (this *apiComp) Exchange(session comm.IUserSession, req *pb.WTaskExchangeRe
return return
} }
if info.Exchange[req.Eid] >= conf.Buy { for i, v := range req.Eid {
errdata = &pb.ErrorData{ if info.Exchange[v] >= confs[i].Buy {
Code: pb.ErrorCode_ReqParameterError, errdata = &pb.ErrorData{
Title: pb.ErrorCode_ReqParameterError.ToString(), Code: pb.ErrorCode_ReqParameterError,
Message: err.Error(), Title: pb.ErrorCode_ReqParameterError.ToString(),
Message: err.Error(),
}
return
} }
need = append(need, confs[i].Item...)
money = append(need, confs[i].Money...)
info.Exchange[v]++
}
if errdata = this.module.ConsumeRes(session, need, true); errdata != nil {
return return
} }
if errdata = this.module.ConsumeRes(session, conf.Item, true); errdata != nil { if errdata = this.module.DispenseRes(session, money, true); errdata != nil {
return return
} }
if errdata = this.module.DispenseRes(session, conf.Money, true); errdata != nil {
return
}
info.Exchange[req.Eid]++
if err = this.module.modelwtask.Change(session.GetUserId(), map[string]interface{}{ if err = this.module.modelwtask.Change(session.GetUserId(), map[string]interface{}{
"exchange": info.Exchange, "exchange": info.Exchange,
}); err != nil { }); err != nil {

View File

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

View File

@ -1057,7 +1057,7 @@ type WTaskExchangeReq struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields 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() { func (x *WTaskExchangeReq) Reset() {
@ -1092,11 +1092,11 @@ func (*WTaskExchangeReq) Descriptor() ([]byte, []int) {
return file_wtask_wtask_msg_proto_rawDescGZIP(), []int{19} return file_wtask_wtask_msg_proto_rawDescGZIP(), []int{19}
} }
func (x *WTaskExchangeReq) GetEid() int32 { func (x *WTaskExchangeReq) GetEid() []int32 {
if x != nil { if x != nil {
return x.Eid return x.Eid
} }
return 0 return nil
} }
//世界任务兑换物品 请求 //世界任务兑换物品 请求
@ -1105,7 +1105,7 @@ type WTaskExchangeResp struct {
sizeCache protoimpl.SizeCache sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields 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"` //奖励 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} return file_wtask_wtask_msg_proto_rawDescGZIP(), []int{20}
} }
func (x *WTaskExchangeResp) GetEid() int32 { func (x *WTaskExchangeResp) GetEid() []int32 {
if x != nil { if x != nil {
return x.Eid return x.Eid
} }
return 0 return nil
} }
func (x *WTaskExchangeResp) GetAward() []*UserAssets { 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, 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, 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, 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, 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, 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, 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, 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, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,