From eb887198e90687b58f66cdafbac5ba055d091436 Mon Sep 17 00:00:00 2001 From: zzw <1464003642@qq.com> Date: Fri, 28 Aug 2026 15:05:44 +0800 Subject: [PATCH] feat: sale info --- README.md | 2 +- pkg/utils/status.go | 2 +- rpc/sale/pb/sale.pb.go | 504 ++++++++++++++++-- rpc/sale/pb/sale_grpc.pb.go | 40 ++ rpc/sale/sale.pb | Bin 16510 -> 17526 bytes rpc/sale/sale.proto | 44 ++ .../internal/logic/decryptMobileLogic.go | 5 + services/chore/internal/logic/testLogic.go | 53 +- services/sale/internal/dao/sale.go | 55 +- services/sale/internal/logic/helper.go | 28 + .../sale/internal/logic/infoInternalLogic.go | 91 ++++ services/sale/internal/logic/infoLogic.go | 13 +- services/sale/internal/server/saleServer.go | 6 + services/sale/saleClient/sale.go | 11 + 14 files changed, 762 insertions(+), 92 deletions(-) create mode 100644 services/sale/internal/logic/infoInternalLogic.go diff --git a/README.md b/README.md index 881089a..aab12ee 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ D:\Git\bin\bash.exe rpc/scripts/gen-rpc.sh order rpc/scripts/gen-rpc.sh order ``` -加一个服务需要在bff/etc/bff.yaml 加 Upstreams ,docker.compose.prod.yaml 加服务,nacos 加配置,Dockerfile 文件 +加一个服务需要在bff/etc/bff.yaml 加 Upstreams ,docker.compose.prod.yaml 加服务,nacos 加配置,增加 etc/order.yaml 配置文件,Dockerfile 文件 ## 如何加一个新服务 diff --git a/pkg/utils/status.go b/pkg/utils/status.go index 8c8a6ff..fac08bd 100644 --- a/pkg/utils/status.go +++ b/pkg/utils/status.go @@ -104,6 +104,7 @@ var ( // 参数类 ErrorReasonParams = Status{Code: 10001, Msg: "原因不能为空"} + ErrorMobileError = Status{Code: 10009, Msg: "手机号格式错误"} // ErrorNotFund 数据类 ErrorFormatDataError = Status{Code: 11010, Msg: "格式化数据出错"} @@ -122,7 +123,6 @@ var ( ErrorJwtExpired = NewError(10005, "jwt过期") ErrorMissingProjectId = NewError(10006, "缺少权限项目ID") ErrorMissingIdentification = NewError(10007, "缺少权限标识") - ErrorMobileError = NewError(10009, "手机号不对") ErrorEncryptMissingKey = NewError(10010, "加密密钥错误") ErrorDecryptAesError = NewError(10012, "解密失败") ErrorEncryptAesKeyError = NewError(10013, "AESKey失败") diff --git a/rpc/sale/pb/sale.pb.go b/rpc/sale/pb/sale.pb.go index 874cd8a..09fbd81 100644 --- a/rpc/sale/pb/sale.pb.go +++ b/rpc/sale/pb/sale.pb.go @@ -838,6 +838,378 @@ func (x *InfoReq) GetId() int64 { return 0 } +type Region struct { + state protoimpl.MessageState `protogen:"open.v1"` + Province string `protobuf:"bytes,1,opt,name=province,proto3" json:"province,omitempty"` + City string `protobuf:"bytes,2,opt,name=city,proto3" json:"city,omitempty"` + District string `protobuf:"bytes,3,opt,name=district,proto3" json:"district,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *Region) Reset() { + *x = Region{} + mi := &file_sale_sale_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *Region) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Region) ProtoMessage() {} + +func (x *Region) ProtoReflect() protoreflect.Message { + mi := &file_sale_sale_proto_msgTypes[10] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Region.ProtoReflect.Descriptor instead. +func (*Region) Descriptor() ([]byte, []int) { + return file_sale_sale_proto_rawDescGZIP(), []int{10} +} + +func (x *Region) GetProvince() string { + if x != nil { + return x.Province + } + return "" +} + +func (x *Region) GetCity() string { + if x != nil { + return x.City + } + return "" +} + +func (x *Region) GetDistrict() string { + if x != nil { + return x.District + } + return "" +} + +type GroupItem struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *GroupItem) Reset() { + *x = GroupItem{} + mi := &file_sale_sale_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *GroupItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*GroupItem) ProtoMessage() {} + +func (x *GroupItem) ProtoReflect() protoreflect.Message { + mi := &file_sale_sale_proto_msgTypes[11] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use GroupItem.ProtoReflect.Descriptor instead. +func (*GroupItem) Descriptor() ([]byte, []int) { + return file_sale_sale_proto_rawDescGZIP(), []int{11} +} + +func (x *GroupItem) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *GroupItem) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type InfoData struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + SaleId int64 `protobuf:"varint,2,opt,name=sale_id,json=saleId,proto3" json:"sale_id,omitempty"` + Mobile string `protobuf:"bytes,3,opt,name=mobile,proto3" json:"mobile,omitempty"` + OriginMobile string `protobuf:"bytes,4,opt,name=origin_mobile,json=originMobile,proto3" json:"origin_mobile,omitempty"` + Name string `protobuf:"bytes,5,opt,name=name,proto3" json:"name,omitempty"` + IdCardFront string `protobuf:"bytes,6,opt,name=id_card_front,json=idCardFront,proto3" json:"id_card_front,omitempty"` + IdCardBack string `protobuf:"bytes,7,opt,name=id_card_back,json=idCardBack,proto3" json:"id_card_back,omitempty"` + BusinessLicense string `protobuf:"bytes,8,opt,name=business_license,json=businessLicense,proto3" json:"business_license,omitempty"` + Region *Region `protobuf:"bytes,9,opt,name=region,proto3" json:"region,omitempty"` + ProvinceId int64 `protobuf:"varint,10,opt,name=province_id,json=provinceId,proto3" json:"province_id,omitempty"` + CityId int64 `protobuf:"varint,11,opt,name=city_id,json=cityId,proto3" json:"city_id,omitempty"` + DistrictId int64 `protobuf:"varint,12,opt,name=district_id,json=districtId,proto3" json:"district_id,omitempty"` + TerritoryId int64 `protobuf:"varint,13,opt,name=territory_id,json=territoryId,proto3" json:"territory_id,omitempty"` + TerritoryName string `protobuf:"bytes,14,opt,name=territory_name,json=territoryName,proto3" json:"territory_name,omitempty"` + GroupId int64 `protobuf:"varint,15,opt,name=group_id,json=groupId,proto3" json:"group_id,omitempty"` + Address string `protobuf:"bytes,16,opt,name=address,proto3" json:"address,omitempty"` + Status uint32 `protobuf:"varint,17,opt,name=status,proto3" json:"status,omitempty"` + Avatar string `protobuf:"bytes,18,opt,name=avatar,proto3" json:"avatar,omitempty"` + Account string `protobuf:"bytes,19,opt,name=account,proto3" json:"account,omitempty"` + Type uint32 `protobuf:"varint,20,opt,name=type,proto3" json:"type,omitempty"` + Sex uint32 `protobuf:"varint,21,opt,name=sex,proto3" json:"sex,omitempty"` + BirthDate string `protobuf:"bytes,22,opt,name=birth_date,json=birthDate,proto3" json:"birth_date,omitempty"` + Reason string `protobuf:"bytes,23,opt,name=reason,proto3" json:"reason,omitempty"` + AdminId int64 `protobuf:"varint,24,opt,name=admin_id,json=adminId,proto3" json:"admin_id,omitempty"` + AdminName string `protobuf:"bytes,25,opt,name=admin_name,json=adminName,proto3" json:"admin_name,omitempty"` + CreateTime string `protobuf:"bytes,26,opt,name=create_time,json=createTime,proto3" json:"create_time,omitempty"` + UpdateTime string `protobuf:"bytes,27,opt,name=update_time,json=updateTime,proto3" json:"update_time,omitempty"` + Group *GroupItem `protobuf:"bytes,28,opt,name=group,proto3" json:"group,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *InfoData) Reset() { + *x = InfoData{} + mi := &file_sale_sale_proto_msgTypes[12] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *InfoData) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*InfoData) ProtoMessage() {} + +func (x *InfoData) ProtoReflect() protoreflect.Message { + mi := &file_sale_sale_proto_msgTypes[12] + if x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use InfoData.ProtoReflect.Descriptor instead. +func (*InfoData) Descriptor() ([]byte, []int) { + return file_sale_sale_proto_rawDescGZIP(), []int{12} +} + +func (x *InfoData) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *InfoData) GetSaleId() int64 { + if x != nil { + return x.SaleId + } + return 0 +} + +func (x *InfoData) GetMobile() string { + if x != nil { + return x.Mobile + } + return "" +} + +func (x *InfoData) GetOriginMobile() string { + if x != nil { + return x.OriginMobile + } + return "" +} + +func (x *InfoData) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *InfoData) GetIdCardFront() string { + if x != nil { + return x.IdCardFront + } + return "" +} + +func (x *InfoData) GetIdCardBack() string { + if x != nil { + return x.IdCardBack + } + return "" +} + +func (x *InfoData) GetBusinessLicense() string { + if x != nil { + return x.BusinessLicense + } + return "" +} + +func (x *InfoData) GetRegion() *Region { + if x != nil { + return x.Region + } + return nil +} + +func (x *InfoData) GetProvinceId() int64 { + if x != nil { + return x.ProvinceId + } + return 0 +} + +func (x *InfoData) GetCityId() int64 { + if x != nil { + return x.CityId + } + return 0 +} + +func (x *InfoData) GetDistrictId() int64 { + if x != nil { + return x.DistrictId + } + return 0 +} + +func (x *InfoData) GetTerritoryId() int64 { + if x != nil { + return x.TerritoryId + } + return 0 +} + +func (x *InfoData) GetTerritoryName() string { + if x != nil { + return x.TerritoryName + } + return "" +} + +func (x *InfoData) GetGroupId() int64 { + if x != nil { + return x.GroupId + } + return 0 +} + +func (x *InfoData) GetAddress() string { + if x != nil { + return x.Address + } + return "" +} + +func (x *InfoData) GetStatus() uint32 { + if x != nil { + return x.Status + } + return 0 +} + +func (x *InfoData) GetAvatar() string { + if x != nil { + return x.Avatar + } + return "" +} + +func (x *InfoData) GetAccount() string { + if x != nil { + return x.Account + } + return "" +} + +func (x *InfoData) GetType() uint32 { + if x != nil { + return x.Type + } + return 0 +} + +func (x *InfoData) GetSex() uint32 { + if x != nil { + return x.Sex + } + return 0 +} + +func (x *InfoData) GetBirthDate() string { + if x != nil { + return x.BirthDate + } + return "" +} + +func (x *InfoData) GetReason() string { + if x != nil { + return x.Reason + } + return "" +} + +func (x *InfoData) GetAdminId() int64 { + if x != nil { + return x.AdminId + } + return 0 +} + +func (x *InfoData) GetAdminName() string { + if x != nil { + return x.AdminName + } + return "" +} + +func (x *InfoData) GetCreateTime() string { + if x != nil { + return x.CreateTime + } + return "" +} + +func (x *InfoData) GetUpdateTime() string { + if x != nil { + return x.UpdateTime + } + return "" +} + +func (x *InfoData) GetGroup() *GroupItem { + if x != nil { + return x.Group + } + return nil +} + type ItemsReq struct { state protoimpl.MessageState `protogen:"open.v1"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` @@ -852,7 +1224,7 @@ type ItemsReq struct { func (x *ItemsReq) Reset() { *x = ItemsReq{} - mi := &file_sale_sale_proto_msgTypes[10] + mi := &file_sale_sale_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -864,7 +1236,7 @@ func (x *ItemsReq) String() string { func (*ItemsReq) ProtoMessage() {} func (x *ItemsReq) ProtoReflect() protoreflect.Message { - mi := &file_sale_sale_proto_msgTypes[10] + mi := &file_sale_sale_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -877,7 +1249,7 @@ func (x *ItemsReq) ProtoReflect() protoreflect.Message { // Deprecated: Use ItemsReq.ProtoReflect.Descriptor instead. func (*ItemsReq) Descriptor() ([]byte, []int) { - return file_sale_sale_proto_rawDescGZIP(), []int{10} + return file_sale_sale_proto_rawDescGZIP(), []int{13} } func (x *ItemsReq) GetName() string { @@ -933,7 +1305,7 @@ type StatusReq struct { func (x *StatusReq) Reset() { *x = StatusReq{} - mi := &file_sale_sale_proto_msgTypes[11] + mi := &file_sale_sale_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -945,7 +1317,7 @@ func (x *StatusReq) String() string { func (*StatusReq) ProtoMessage() {} func (x *StatusReq) ProtoReflect() protoreflect.Message { - mi := &file_sale_sale_proto_msgTypes[11] + mi := &file_sale_sale_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -958,7 +1330,7 @@ func (x *StatusReq) ProtoReflect() protoreflect.Message { // Deprecated: Use StatusReq.ProtoReflect.Descriptor instead. func (*StatusReq) Descriptor() ([]byte, []int) { - return file_sale_sale_proto_rawDescGZIP(), []int{11} + return file_sale_sale_proto_rawDescGZIP(), []int{14} } func (x *StatusReq) GetId() int64 { @@ -1065,7 +1437,51 @@ const file_sale_sale_proto_rawDesc = "" + "idCardBack\x12)\n" + "\x10business_license\x18\x15 \x01(\tR\x0fbusinessLicense\"\x19\n" + "\aInfoReq\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"\x94\x01\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"T\n" + + "\x06Region\x12\x1a\n" + + "\bprovince\x18\x01 \x01(\tR\bprovince\x12\x12\n" + + "\x04city\x18\x02 \x01(\tR\x04city\x12\x1a\n" + + "\bdistrict\x18\x03 \x01(\tR\bdistrict\"/\n" + + "\tGroupItem\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\"\xbf\x06\n" + + "\bInfoData\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x17\n" + + "\asale_id\x18\x02 \x01(\x03R\x06saleId\x12\x16\n" + + "\x06mobile\x18\x03 \x01(\tR\x06mobile\x12#\n" + + "\rorigin_mobile\x18\x04 \x01(\tR\foriginMobile\x12\x12\n" + + "\x04name\x18\x05 \x01(\tR\x04name\x12\"\n" + + "\rid_card_front\x18\x06 \x01(\tR\vidCardFront\x12 \n" + + "\fid_card_back\x18\a \x01(\tR\n" + + "idCardBack\x12)\n" + + "\x10business_license\x18\b \x01(\tR\x0fbusinessLicense\x12$\n" + + "\x06region\x18\t \x01(\v2\f.sale.RegionR\x06region\x12\x1f\n" + + "\vprovince_id\x18\n" + + " \x01(\x03R\n" + + "provinceId\x12\x17\n" + + "\acity_id\x18\v \x01(\x03R\x06cityId\x12\x1f\n" + + "\vdistrict_id\x18\f \x01(\x03R\n" + + "districtId\x12!\n" + + "\fterritory_id\x18\r \x01(\x03R\vterritoryId\x12%\n" + + "\x0eterritory_name\x18\x0e \x01(\tR\rterritoryName\x12\x19\n" + + "\bgroup_id\x18\x0f \x01(\x03R\agroupId\x12\x18\n" + + "\aaddress\x18\x10 \x01(\tR\aaddress\x12\x16\n" + + "\x06status\x18\x11 \x01(\rR\x06status\x12\x16\n" + + "\x06avatar\x18\x12 \x01(\tR\x06avatar\x12\x18\n" + + "\aaccount\x18\x13 \x01(\tR\aaccount\x12\x12\n" + + "\x04type\x18\x14 \x01(\rR\x04type\x12\x10\n" + + "\x03sex\x18\x15 \x01(\rR\x03sex\x12\x1d\n" + + "\n" + + "birth_date\x18\x16 \x01(\tR\tbirthDate\x12\x16\n" + + "\x06reason\x18\x17 \x01(\tR\x06reason\x12\x19\n" + + "\badmin_id\x18\x18 \x01(\x03R\aadminId\x12\x1d\n" + + "\n" + + "admin_name\x18\x19 \x01(\tR\tadminName\x12\x1f\n" + + "\vcreate_time\x18\x1a \x01(\tR\n" + + "createTime\x12\x1f\n" + + "\vupdate_time\x18\x1b \x01(\tR\n" + + "updateTime\x12%\n" + + "\x05group\x18\x1c \x01(\v2\x0f.sale.GroupItemR\x05group\"\x94\x01\n" + "\bItemsReq\x12\x12\n" + "\x04name\x18\x01 \x01(\tR\x04name\x12\x12\n" + "\x04page\x18\x02 \x01(\rR\x04page\x12\x1b\n" + @@ -1076,7 +1492,7 @@ const file_sale_sale_proto_rawDesc = "" + "\tStatusReq\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" + "\x06status\x18\x02 \x01(\rR\x06status\x12\x16\n" + - "\x06reason\x18\x03 \x01(\tR\x06reason2\xbf\x06\n" + + "\x06reason\x18\x03 \x01(\tR\x06reason2\xee\x06\n" + "\x04Sale\x12S\n" + "\n" + "GroupItems\x12\x13.sale.GroupItemsReq\x1a\x0e.sale.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\x12\x15/admin/v3/sales/group\x12U\n" + @@ -1088,7 +1504,8 @@ const file_sale_sale_proto_rawDesc = "" + "\rNamesInternal\x12\x0e.sale.NamesReq\x1a\x0f.sale.NamesData\x12E\n" + "\x06Create\x12\x0f.sale.CreateReq\x1a\x0e.sale.Response\"\x1a\x82\xd3\xe4\x93\x02\x14:\x01*\"\x0f/admin/v3/sales\x12A\n" + "\x04Edit\x12\r.sale.EditReq\x1a\x0e.sale.Response\"\x1a\x82\xd3\xe4\x93\x02\x14:\x01*\x1a\x0f/admin/v3/sales\x12F\n" + - "\x04Info\x12\r.sale.InfoReq\x1a\x0e.sale.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\x12\x14/admin/v3/sales/info\x12C\n" + + "\x04Info\x12\r.sale.InfoReq\x1a\x0e.sale.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\x12\x14/admin/v3/sales/info\x12-\n" + + "\fInfoInternal\x12\r.sale.InfoReq\x1a\x0e.sale.InfoData\x12C\n" + "\x05Items\x12\x0e.sale.ItemsReq\x1a\x0e.sale.Response\"\x1a\x82\xd3\xe4\x93\x02\x14:\x01*\x12\x0f/admin/v3/sales\x12L\n" + "\x06Status\x12\x0f.sale.StatusReq\x1a\x0e.sale.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\x1a\x16/admin/v3/sales/statusB\x18Z\x16lone-services/rpc/saleb\x06proto3" @@ -1104,7 +1521,7 @@ func file_sale_sale_proto_rawDescGZIP() []byte { return file_sale_sale_proto_rawDescData } -var file_sale_sale_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_sale_sale_proto_msgTypes = make([]protoimpl.MessageInfo, 15) var file_sale_sale_proto_goTypes = []any{ (*Response)(nil), // 0: sale.Response (*GroupEmptyReq)(nil), // 1: sale.GroupEmptyReq @@ -1116,38 +1533,45 @@ var file_sale_sale_proto_goTypes = []any{ (*CreateReq)(nil), // 7: sale.CreateReq (*EditReq)(nil), // 8: sale.EditReq (*InfoReq)(nil), // 9: sale.InfoReq - (*ItemsReq)(nil), // 10: sale.ItemsReq - (*StatusReq)(nil), // 11: sale.StatusReq + (*Region)(nil), // 10: sale.Region + (*GroupItem)(nil), // 11: sale.GroupItem + (*InfoData)(nil), // 12: sale.InfoData + (*ItemsReq)(nil), // 13: sale.ItemsReq + (*StatusReq)(nil), // 14: sale.StatusReq } var file_sale_sale_proto_depIdxs = []int32{ 5, // 0: sale.NamesData.items:type_name -> sale.NameItem - 2, // 1: sale.Sale.GroupItems:input_type -> sale.GroupItemsReq - 3, // 2: sale.Sale.GroupCreate:input_type -> sale.GroupCreateReq - 1, // 3: sale.Sale.GroupNames:input_type -> sale.GroupEmptyReq - 1, // 4: sale.Sale.Types:input_type -> sale.GroupEmptyReq - 4, // 5: sale.Sale.Names:input_type -> sale.NamesReq - 4, // 6: sale.Sale.NamesInternal:input_type -> sale.NamesReq - 7, // 7: sale.Sale.Create:input_type -> sale.CreateReq - 8, // 8: sale.Sale.Edit:input_type -> sale.EditReq - 9, // 9: sale.Sale.Info:input_type -> sale.InfoReq - 10, // 10: sale.Sale.Items:input_type -> sale.ItemsReq - 11, // 11: sale.Sale.Status:input_type -> sale.StatusReq - 0, // 12: sale.Sale.GroupItems:output_type -> sale.Response - 0, // 13: sale.Sale.GroupCreate:output_type -> sale.Response - 0, // 14: sale.Sale.GroupNames:output_type -> sale.Response - 0, // 15: sale.Sale.Types:output_type -> sale.Response - 0, // 16: sale.Sale.Names:output_type -> sale.Response - 6, // 17: sale.Sale.NamesInternal:output_type -> sale.NamesData - 0, // 18: sale.Sale.Create:output_type -> sale.Response - 0, // 19: sale.Sale.Edit:output_type -> sale.Response - 0, // 20: sale.Sale.Info:output_type -> sale.Response - 0, // 21: sale.Sale.Items:output_type -> sale.Response - 0, // 22: sale.Sale.Status:output_type -> sale.Response - 12, // [12:23] is the sub-list for method output_type - 1, // [1:12] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 10, // 1: sale.InfoData.region:type_name -> sale.Region + 11, // 2: sale.InfoData.group:type_name -> sale.GroupItem + 2, // 3: sale.Sale.GroupItems:input_type -> sale.GroupItemsReq + 3, // 4: sale.Sale.GroupCreate:input_type -> sale.GroupCreateReq + 1, // 5: sale.Sale.GroupNames:input_type -> sale.GroupEmptyReq + 1, // 6: sale.Sale.Types:input_type -> sale.GroupEmptyReq + 4, // 7: sale.Sale.Names:input_type -> sale.NamesReq + 4, // 8: sale.Sale.NamesInternal:input_type -> sale.NamesReq + 7, // 9: sale.Sale.Create:input_type -> sale.CreateReq + 8, // 10: sale.Sale.Edit:input_type -> sale.EditReq + 9, // 11: sale.Sale.Info:input_type -> sale.InfoReq + 9, // 12: sale.Sale.InfoInternal:input_type -> sale.InfoReq + 13, // 13: sale.Sale.Items:input_type -> sale.ItemsReq + 14, // 14: sale.Sale.Status:input_type -> sale.StatusReq + 0, // 15: sale.Sale.GroupItems:output_type -> sale.Response + 0, // 16: sale.Sale.GroupCreate:output_type -> sale.Response + 0, // 17: sale.Sale.GroupNames:output_type -> sale.Response + 0, // 18: sale.Sale.Types:output_type -> sale.Response + 0, // 19: sale.Sale.Names:output_type -> sale.Response + 6, // 20: sale.Sale.NamesInternal:output_type -> sale.NamesData + 0, // 21: sale.Sale.Create:output_type -> sale.Response + 0, // 22: sale.Sale.Edit:output_type -> sale.Response + 0, // 23: sale.Sale.Info:output_type -> sale.Response + 12, // 24: sale.Sale.InfoInternal:output_type -> sale.InfoData + 0, // 25: sale.Sale.Items:output_type -> sale.Response + 0, // 26: sale.Sale.Status:output_type -> sale.Response + 15, // [15:27] is the sub-list for method output_type + 3, // [3:15] is the sub-list for method input_type + 3, // [3:3] is the sub-list for extension type_name + 3, // [3:3] is the sub-list for extension extendee + 0, // [0:3] is the sub-list for field type_name } func init() { file_sale_sale_proto_init() } @@ -1161,7 +1585,7 @@ func file_sale_sale_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_sale_sale_proto_rawDesc), len(file_sale_sale_proto_rawDesc)), NumEnums: 0, - NumMessages: 12, + NumMessages: 15, NumExtensions: 0, NumServices: 1, }, diff --git a/rpc/sale/pb/sale_grpc.pb.go b/rpc/sale/pb/sale_grpc.pb.go index 0f2a681..9ca8042 100644 --- a/rpc/sale/pb/sale_grpc.pb.go +++ b/rpc/sale/pb/sale_grpc.pb.go @@ -28,6 +28,7 @@ const ( Sale_Create_FullMethodName = "/sale.Sale/Create" Sale_Edit_FullMethodName = "/sale.Sale/Edit" Sale_Info_FullMethodName = "/sale.Sale/Info" + Sale_InfoInternal_FullMethodName = "/sale.Sale/InfoInternal" Sale_Items_FullMethodName = "/sale.Sale/Items" Sale_Status_FullMethodName = "/sale.Sale/Status" ) @@ -47,6 +48,8 @@ type SaleClient interface { Create(ctx context.Context, in *CreateReq, opts ...grpc.CallOption) (*Response, error) Edit(ctx context.Context, in *EditReq, opts ...grpc.CallOption) (*Response, error) Info(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*Response, error) + // 服务间调用:销售详情(含分组;mobile 脱敏,origin_mobile 为加密串) + InfoInternal(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*InfoData, error) Items(ctx context.Context, in *ItemsReq, opts ...grpc.CallOption) (*Response, error) Status(ctx context.Context, in *StatusReq, opts ...grpc.CallOption) (*Response, error) } @@ -149,6 +152,16 @@ func (c *saleClient) Info(ctx context.Context, in *InfoReq, opts ...grpc.CallOpt return out, nil } +func (c *saleClient) InfoInternal(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*InfoData, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(InfoData) + err := c.cc.Invoke(ctx, Sale_InfoInternal_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *saleClient) Items(ctx context.Context, in *ItemsReq, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) @@ -184,6 +197,8 @@ type SaleServer interface { Create(context.Context, *CreateReq) (*Response, error) Edit(context.Context, *EditReq) (*Response, error) Info(context.Context, *InfoReq) (*Response, error) + // 服务间调用:销售详情(含分组;mobile 脱敏,origin_mobile 为加密串) + InfoInternal(context.Context, *InfoReq) (*InfoData, error) Items(context.Context, *ItemsReq) (*Response, error) Status(context.Context, *StatusReq) (*Response, error) mustEmbedUnimplementedSaleServer() @@ -223,6 +238,9 @@ func (UnimplementedSaleServer) Edit(context.Context, *EditReq) (*Response, error func (UnimplementedSaleServer) Info(context.Context, *InfoReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method Info not implemented") } +func (UnimplementedSaleServer) InfoInternal(context.Context, *InfoReq) (*InfoData, error) { + return nil, status.Error(codes.Unimplemented, "method InfoInternal not implemented") +} func (UnimplementedSaleServer) Items(context.Context, *ItemsReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method Items not implemented") } @@ -412,6 +430,24 @@ func _Sale_Info_Handler(srv interface{}, ctx context.Context, dec func(interface return interceptor(ctx, in, info, handler) } +func _Sale_InfoInternal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(InfoReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(SaleServer).InfoInternal(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Sale_InfoInternal_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(SaleServer).InfoInternal(ctx, req.(*InfoReq)) + } + return interceptor(ctx, in, info, handler) +} + func _Sale_Items_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ItemsReq) if err := dec(in); err != nil { @@ -491,6 +527,10 @@ var Sale_ServiceDesc = grpc.ServiceDesc{ MethodName: "Info", Handler: _Sale_Info_Handler, }, + { + MethodName: "InfoInternal", + Handler: _Sale_InfoInternal_Handler, + }, { MethodName: "Items", Handler: _Sale_Items_Handler, diff --git a/rpc/sale/sale.pb b/rpc/sale/sale.pb index 767894e4751b0990b20b2e75f7b38bc8beb7c952..776acd0a6ed6d2281e2b956c4b117f8613478a67 100644 GIT binary patch delta 944 zcmZWoJ#Q015S8utZ10`zuz<5M210No8VrgQhy;kQ2xN&+oYJ4xcZ*qJ@0q=Igez0h z-~T{}h?<&zK|@P}M2VQ4J)44V-d`t;ga~%OdZa#7uhJuK_zeL=+Vi zh+ZenRLikcQ4!w20s}`LV+z($wS`pk$9H>u4<)`#o^qW$)2T9ahXgW-V!+Xe$8T6I z|9)@pxQ@d1Xr4(Wvh0P7g~|l&6HntLSpx+AelV~_4%~FZB1W$ge>G*>4#^jXy+=MI zKvQQFRY@O-#+XwTUb_e9eD|@(QQ&6+eKJe8;xp+ z!G)0;PZA9suuV)|K|9sVa5K-?IS4di+K4RAPhmfrQA{WhI>pO4oh!r67gjMsJ7cq$ z33dUE@J%;KB@^%1MWpPLUM6HDwRs&S+z8e|iv}`q4#Iv{3!bHlZDFWDwmF_mVad=O zTSBN3LJvSdcVOvacxv0u5*eHe%s2*5BO)W=0=gI{jyeIxE@3{i utils.NumberZero { + var group dao.SaleGroupNameItem + if err := (model.SaleGroupModel{}.Init().GetOne(modelbase.Params{ + Eq: map[string]string{"id": strconv.FormatInt(info.GroupId, 10)}, + }, &group)); err != nil { + return nil, err + } + if group.Id > utils.NumberZero { + info.Group = &group + } + } + return &info, nil +} + func maskSaleNameItems(items []dao.SaleNameItem) { for i := range items { mobile, err := utils.DecryptPhone(items[i].Mobile) diff --git a/services/sale/internal/logic/infoInternalLogic.go b/services/sale/internal/logic/infoInternalLogic.go new file mode 100644 index 0000000..98a963b --- /dev/null +++ b/services/sale/internal/logic/infoInternalLogic.go @@ -0,0 +1,91 @@ +package logic + +import ( + "context" + + "lone-services/pkg/utils" + "lone-services/pkg/validate" + sale "lone-services/rpc/sale/pb" + "lone-services/services/sale/internal/dao" + "lone-services/services/sale/internal/svc" + "lone-services/services/sale/validator" + + "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +type InfoInternalLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewInfoInternalLogic(ctx context.Context, svcCtx *svc.ServiceContext) *InfoInternalLogic { + return &InfoInternalLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *InfoInternalLogic) InfoInternal(in *sale.InfoReq) (*sale.InfoData, error) { + var req validator.InfoValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return nil, status.Error(codes.InvalidArgument, msg) + } + + info, err := querySaleInfo(req.Id) + if err != nil { + l.Errorf("sale InfoInternal: %v", err) + return nil, status.Error(codes.Internal, utils.Fail.Msg) + } + if info == nil { + return nil, status.Error(codes.NotFound, utils.ErrorNotFund.Msg) + } + + return toSaleInfoData(info), nil +} + +func toSaleInfoData(info *dao.SaleInfo) *sale.InfoData { + data := &sale.InfoData{ + Id: info.Id, + SaleId: info.SaleId, + Mobile: info.Mobile, + OriginMobile: info.OriginMobile, + Name: info.Name, + IdCardFront: info.IdCardFront, + IdCardBack: info.IdCardBack, + BusinessLicense: info.BusinessLicense, + Region: &sale.Region{ + Province: info.Region.Province, + City: info.Region.City, + District: info.Region.District, + }, + ProvinceId: info.ProvinceId, + CityId: info.CityId, + DistrictId: info.DistrictId, + TerritoryId: info.TerritoryId, + TerritoryName: info.TerritoryName, + GroupId: info.GroupId, + Address: info.Address, + Status: uint32(info.Status), + Avatar: info.Avatar, + Account: info.Account, + Type: uint32(info.Type), + Sex: uint32(info.Sex), + BirthDate: info.BirthDate, + Reason: info.Reason, + AdminId: info.AdminId, + AdminName: info.AdminName, + CreateTime: info.CreateTime.String(), + UpdateTime: info.UpdateTime.String(), + } + if info.Group != nil { + data.Group = &sale.GroupItem{ + Id: info.Group.Id, + Name: info.Group.Name, + } + } + return data +} diff --git a/services/sale/internal/logic/infoLogic.go b/services/sale/internal/logic/infoLogic.go index aa46ae5..87ee1f6 100644 --- a/services/sale/internal/logic/infoLogic.go +++ b/services/sale/internal/logic/infoLogic.go @@ -2,14 +2,10 @@ package logic import ( "context" - "strconv" - "lone-services/pkg/modelbase" "lone-services/pkg/utils" "lone-services/pkg/validate" sale "lone-services/rpc/sale/pb" - "lone-services/services/sale/internal/dao" - "lone-services/services/sale/internal/model" "lone-services/services/sale/internal/svc" "lone-services/services/sale/validator" @@ -36,16 +32,13 @@ func (l *InfoLogic) Info(in *sale.InfoReq) (*sale.Response, error) { return outResponse(utils.ErrorParams, msg), nil } - var info dao.SaleInfo - if err := (model.SaleModel{}.Init().GetOne(modelbase.Params{ - Eq: map[string]string{"id": strconv.FormatInt(req.Id, 10)}, - }, &info)); err != nil { + info, err := querySaleInfo(req.Id) + if err != nil { l.Errorf("sale info: %v", err) return failResponse(utils.Fail), nil } - if info.Id < utils.NumberOne { + if info == nil { return failResponse(utils.ErrorNotFund), nil } - maskSaleMobile(&info) return okResponse(info), nil } diff --git a/services/sale/internal/server/saleServer.go b/services/sale/internal/server/saleServer.go index 2e1b92d..572683a 100644 --- a/services/sale/internal/server/saleServer.go +++ b/services/sale/internal/server/saleServer.go @@ -70,6 +70,12 @@ func (s *SaleServer) Info(ctx context.Context, in *sale.InfoReq) (*sale.Response return l.Info(in) } +// 服务间调用:销售详情(含分组;mobile 脱敏,origin_mobile 为加密串) +func (s *SaleServer) InfoInternal(ctx context.Context, in *sale.InfoReq) (*sale.InfoData, error) { + l := logic.NewInfoInternalLogic(ctx, s.svcCtx) + return l.InfoInternal(in) +} + func (s *SaleServer) Items(ctx context.Context, in *sale.ItemsReq) (*sale.Response, error) { l := logic.NewItemsLogic(ctx, s.svcCtx) return l.Items(in) diff --git a/services/sale/saleClient/sale.go b/services/sale/saleClient/sale.go index aa77181..2700ee3 100644 --- a/services/sale/saleClient/sale.go +++ b/services/sale/saleClient/sale.go @@ -18,12 +18,15 @@ type ( EditReq = sale.EditReq GroupCreateReq = sale.GroupCreateReq GroupEmptyReq = sale.GroupEmptyReq + GroupItem = sale.GroupItem GroupItemsReq = sale.GroupItemsReq + InfoData = sale.InfoData InfoReq = sale.InfoReq ItemsReq = sale.ItemsReq NameItem = sale.NameItem NamesData = sale.NamesData NamesReq = sale.NamesReq + Region = sale.Region Response = sale.Response StatusReq = sale.StatusReq @@ -39,6 +42,8 @@ type ( Create(ctx context.Context, in *CreateReq, opts ...grpc.CallOption) (*Response, error) Edit(ctx context.Context, in *EditReq, opts ...grpc.CallOption) (*Response, error) Info(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*Response, error) + // 服务间调用:销售详情(含分组;mobile 脱敏,origin_mobile 为加密串) + InfoInternal(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*InfoData, error) Items(ctx context.Context, in *ItemsReq, opts ...grpc.CallOption) (*Response, error) Status(ctx context.Context, in *StatusReq, opts ...grpc.CallOption) (*Response, error) } @@ -101,6 +106,12 @@ func (m *defaultSale) Info(ctx context.Context, in *InfoReq, opts ...grpc.CallOp return client.Info(ctx, in, opts...) } +// 服务间调用:销售详情(含分组;mobile 脱敏,origin_mobile 为加密串) +func (m *defaultSale) InfoInternal(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*InfoData, error) { + client := sale.NewSaleClient(m.cli.Conn()) + return client.InfoInternal(ctx, in, opts...) +} + func (m *defaultSale) Items(ctx context.Context, in *ItemsReq, opts ...grpc.CallOption) (*Response, error) { client := sale.NewSaleClient(m.cli.Conn()) return client.Items(ctx, in, opts...)