上传商店协议和商品中心协议

This commit is contained in:
liwei1dao 2023-10-30 09:44:09 +08:00
parent cbad03e203
commit 5f6b164aaf
4 changed files with 39 additions and 36 deletions

View File

@ -31,6 +31,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (errdata
record *pb.UserShopData
need []*cfg.Gameatn
give []*cfg.Gameatn
award []*pb.UserAtno
tasks []*pb.BuriedParam = make([]*pb.BuriedParam, 0)
)
if errdata = this.BuyCheck(session, req); errdata != nil {
@ -147,13 +148,19 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (errdata
this.module.modelShop.Change(session.GetUserId(), map[string]interface{}{filed: record})
if !conf.Preview {
if errdata = this.module.DispenseRes(session, give, true); errdata != nil {
if errdata, award = this.module.DispenseAtno(session, give, true); errdata != nil {
return
}
} else {
if errdata = this.module.equip.AddEquipment(session, record.Preview[req.Gid].Equipment); errdata != nil {
return
}
award = []*pb.UserAtno{{
A: comm.EquipmentType,
T: record.Preview[req.Gid].Equipment.CId,
N: 1,
O: record.Preview[req.Gid].Equipment.Id,
}}
}
//随机任务
@ -227,7 +234,7 @@ func (this *apiComp) Buy(session comm.IUserSession, req *pb.ShopBuyReq) (errdata
}
}
session.SendMsg(string(this.module.GetType()), "buy", &pb.ShopBuyResp{IsSucc: true})
session.SendMsg(string(this.module.GetType()), "buy", &pb.ShopBuyResp{Award: award})
if len(tasks) > 0 {
go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) {
this.module.ModuleBuried.TriggerBuried(session, tasks...)

View File

@ -26,7 +26,7 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.ShopCenterReceiv
user *pb.DBUser
drop int32
items []*cfg.Gameatn
award []*pb.UserAssets
award []*pb.UserAtno
ok bool
err error
)
@ -154,17 +154,10 @@ func (this *apiComp) Receive(session comm.IUserSession, req *pb.ShopCenterReceiv
}
return
}
if errdata = this.module.DispenseRes(session, items, true); errdata != nil {
if errdata, award = this.module.DispenseAtno(session, items, true); errdata != nil {
return
}
award = make([]*pb.UserAssets, 0)
for _, v := range items {
award = append(award, &pb.UserAssets{
A: v.A,
T: v.T,
N: v.N,
})
}
if err = this.module.modelshop.Change(session.GetUserId(), map[string]interface{}{
"item": info.Item,
}); err != nil {

View File

@ -330,7 +330,7 @@ type ShopBuyResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
IsSucc bool `protobuf:"varint,1,opt,name=IsSucc,proto3" json:"IsSucc"` //是否成功
Award []*UserAtno `protobuf:"bytes,3,rep,name=award,proto3" json:"award"` //奖励
}
func (x *ShopBuyResp) Reset() {
@ -365,11 +365,11 @@ func (*ShopBuyResp) Descriptor() ([]byte, []int) {
return file_shop_shop_msg_proto_rawDescGZIP(), []int{4}
}
func (x *ShopBuyResp) GetIsSucc() bool {
func (x *ShopBuyResp) GetAward() []*UserAtno {
if x != nil {
return x.IsSucc
return x.Award
}
return false
return nil
}
var File_shop_shop_msg_proto protoreflect.FileDescriptor
@ -422,10 +422,11 @@ var file_shop_shop_msg_proto_rawDesc = []byte{
0x79, 0x70, 0x65, 0x52, 0x08, 0x53, 0x68, 0x6f, 0x70, 0x54, 0x79, 0x70, 0x65, 0x12, 0x10, 0x0a,
0x03, 0x67, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x67, 0x69, 0x64, 0x12,
0x16, 0x0a, 0x06, 0x42, 0x75, 0x79, 0x4e, 0x75, 0x6d, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52,
0x06, 0x42, 0x75, 0x79, 0x4e, 0x75, 0x6d, 0x22, 0x25, 0x0a, 0x0b, 0x53, 0x68, 0x6f, 0x70, 0x42,
0x75, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x49, 0x73, 0x53, 0x75, 0x63, 0x63,
0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x06, 0x49, 0x73, 0x53, 0x75, 0x63, 0x63, 0x42, 0x06,
0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x06, 0x42, 0x75, 0x79, 0x4e, 0x75, 0x6d, 0x22, 0x2e, 0x0a, 0x0b, 0x53, 0x68, 0x6f, 0x70, 0x42,
0x75, 0x79, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1f, 0x0a, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x18,
0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x74, 0x6e, 0x6f,
0x52, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -450,6 +451,7 @@ var file_shop_shop_msg_proto_goTypes = []interface{}{
(*UserAssets)(nil), // 5: UserAssets
(*DB_Equipment)(nil), // 6: DB_Equipment
(ShopType)(0), // 7: ShopType
(*UserAtno)(nil), // 8: UserAtno
}
var file_shop_shop_msg_proto_depIdxs = []int32{
5, // 0: ShopItem.Items:type_name -> UserAssets
@ -459,11 +461,12 @@ var file_shop_shop_msg_proto_depIdxs = []int32{
7, // 4: ShopGetListResp.sType:type_name -> ShopType
0, // 5: ShopGetListResp.Goods:type_name -> ShopItem
7, // 6: ShopBuyReq.ShopType:type_name -> ShopType
7, // [7:7] is the sub-list for method output_type
7, // [7:7] is the sub-list for method input_type
7, // [7:7] is the sub-list for extension type_name
7, // [7:7] is the sub-list for extension extendee
0, // [0:7] is the sub-list for field type_name
8, // 7: ShopBuyResp.award:type_name -> UserAtno
8, // [8:8] is the sub-list for method output_type
8, // [8:8] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name
8, // [8:8] is the sub-list for extension extendee
0, // [0:8] is the sub-list for field type_name
}
func init() { file_shop_shop_msg_proto_init() }

View File

@ -165,9 +165,9 @@ type ShopCenterReceiveResp struct {
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Fid int32 `protobuf:"varint,1,opt,name=fid,proto3" json:"fid"` //基金id
Pid int32 `protobuf:"varint,2,opt,name=pid,proto3" json:"pid"` //进度id
Award []*UserAssets `protobuf:"bytes,3,rep,name=award,proto3" json:"award"` //奖励
Fid int32 `protobuf:"varint,1,opt,name=fid,proto3" json:"fid"` //基金id
Pid int32 `protobuf:"varint,2,opt,name=pid,proto3" json:"pid"` //进度id
Award []*UserAtno `protobuf:"bytes,3,rep,name=award,proto3" json:"award"` //奖励
}
func (x *ShopCenterReceiveResp) Reset() {
@ -216,7 +216,7 @@ func (x *ShopCenterReceiveResp) GetPid() int32 {
return 0
}
func (x *ShopCenterReceiveResp) GetAward() []*UserAssets {
func (x *ShopCenterReceiveResp) GetAward() []*UserAtno {
if x != nil {
return x.Award
}
@ -239,14 +239,14 @@ var file_shopcenter_shopcenter_msg_proto_rawDesc = []byte{
0x68, 0x6f, 0x70, 0x43, 0x65, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65,
0x52, 0x65, 0x71, 0x12, 0x10, 0x0a, 0x03, 0x66, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05,
0x52, 0x03, 0x66, 0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01,
0x28, 0x05, 0x52, 0x03, 0x70, 0x69, 0x64, 0x22, 0x5e, 0x0a, 0x15, 0x53, 0x68, 0x6f, 0x70, 0x43,
0x28, 0x05, 0x52, 0x03, 0x70, 0x69, 0x64, 0x22, 0x5c, 0x0a, 0x15, 0x53, 0x68, 0x6f, 0x70, 0x43,
0x65, 0x6e, 0x74, 0x65, 0x72, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70,
0x12, 0x10, 0x0a, 0x03, 0x66, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x03, 0x66,
0x69, 0x64, 0x12, 0x10, 0x0a, 0x03, 0x70, 0x69, 0x64, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52,
0x03, 0x70, 0x69, 0x64, 0x12, 0x21, 0x0a, 0x05, 0x61, 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, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62,
0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x03, 0x70, 0x69, 0x64, 0x12, 0x1f, 0x0a, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x18, 0x03, 0x20,
0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41, 0x74, 0x6e, 0x6f, 0x52, 0x05,
0x61, 0x77, 0x61, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -268,11 +268,11 @@ var file_shopcenter_shopcenter_msg_proto_goTypes = []interface{}{
(*ShopCenterReceiveReq)(nil), // 2: ShopCenterReceiveReq
(*ShopCenterReceiveResp)(nil), // 3: ShopCenterReceiveResp
(*DBShopCenter)(nil), // 4: DBShopCenter
(*UserAssets)(nil), // 5: UserAssets
(*UserAtno)(nil), // 5: UserAtno
}
var file_shopcenter_shopcenter_msg_proto_depIdxs = []int32{
4, // 0: ShopCenterInfoResp.info:type_name -> DBShopCenter
5, // 1: ShopCenterReceiveResp.award:type_name -> UserAssets
5, // 1: ShopCenterReceiveResp.award:type_name -> UserAtno
2, // [2:2] is the sub-list for method output_type
2, // [2:2] is the sub-list for method input_type
2, // [2:2] is the sub-list for extension type_name