diff --git a/rpc/sale/pb/sale.pb.go b/rpc/sale/pb/sale.pb.go index cadbb9f..a5dde50 100644 --- a/rpc/sale/pb/sale.pb.go +++ b/rpc/sale/pb/sale.pb.go @@ -83,18 +83,23 @@ func (x *Response) GetData() string { } type ApiSaleAddReq struct { - state protoimpl.MessageState `protogen:"open.v1"` - Mobile string `protobuf:"bytes,1,opt,name=Mobile,proto3" json:"Mobile,omitempty"` - Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` - District string `protobuf:"bytes,3,opt,name=District,proto3" json:"District,omitempty"` - Address string `protobuf:"bytes,4,opt,name=Address,proto3" json:"Address,omitempty"` - Account string `protobuf:"bytes,5,opt,name=Account,proto3" json:"Account,omitempty"` - Credentials string `protobuf:"bytes,6,opt,name=Credentials,proto3" json:"Credentials,omitempty"` - Sex int32 `protobuf:"varint,7,opt,name=Sex,proto3" json:"Sex,omitempty"` - BirthDate string `protobuf:"bytes,8,opt,name=BirthDate,proto3" json:"BirthDate,omitempty"` - Type int32 `protobuf:"varint,9,opt,name=Type,proto3" json:"Type,omitempty"` - unknownFields protoimpl.UnknownFields - sizeCache protoimpl.SizeCache + state protoimpl.MessageState `protogen:"open.v1"` + Mobile string `protobuf:"bytes,1,opt,name=mobile,proto3" json:"mobile,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + BusinessLicense string `protobuf:"bytes,3,opt,name=business_license,json=businessLicense,proto3" json:"business_license,omitempty"` + Address string `protobuf:"bytes,4,opt,name=address,proto3" json:"address,omitempty"` + Account string `protobuf:"bytes,5,opt,name=account,proto3" json:"account,omitempty"` + Credentials string `protobuf:"bytes,6,opt,name=credentials,proto3" json:"credentials,omitempty"` + Sex int32 `protobuf:"varint,7,opt,name=sex,proto3" json:"sex,omitempty"` + BirthDate string `protobuf:"bytes,8,opt,name=birth_date,json=birthDate,proto3" json:"birth_date,omitempty"` + Type int32 `protobuf:"varint,9,opt,name=type,proto3" json:"type,omitempty"` + IdCardFront string `protobuf:"bytes,10,opt,name=idCard_front,json=idCardFront,proto3" json:"idCard_front,omitempty"` + IdCardBack string `protobuf:"bytes,11,opt,name=idCard_back,json=idCardBack,proto3" json:"idCard_back,omitempty"` + ProvinceId int64 `protobuf:"varint,12,opt,name=province_id,json=provinceId,proto3" json:"province_id,omitempty"` + CityId int64 `protobuf:"varint,13,opt,name=city_id,json=cityId,proto3" json:"city_id,omitempty"` + DistrictId int64 `protobuf:"varint,14,opt,name=district_id,json=districtId,proto3" json:"district_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache } func (x *ApiSaleAddReq) Reset() { @@ -141,9 +146,9 @@ func (x *ApiSaleAddReq) GetName() string { return "" } -func (x *ApiSaleAddReq) GetDistrict() string { +func (x *ApiSaleAddReq) GetBusinessLicense() string { if x != nil { - return x.District + return x.BusinessLicense } return "" } @@ -190,6 +195,41 @@ func (x *ApiSaleAddReq) GetType() int32 { return 0 } +func (x *ApiSaleAddReq) GetIdCardFront() string { + if x != nil { + return x.IdCardFront + } + return "" +} + +func (x *ApiSaleAddReq) GetIdCardBack() string { + if x != nil { + return x.IdCardBack + } + return "" +} + +func (x *ApiSaleAddReq) GetProvinceId() int64 { + if x != nil { + return x.ProvinceId + } + return 0 +} + +func (x *ApiSaleAddReq) GetCityId() int64 { + if x != nil { + return x.CityId + } + return 0 +} + +func (x *ApiSaleAddReq) GetDistrictId() int64 { + if x != nil { + return x.DistrictId + } + return 0 +} + type ApiLowerSaleItemsReq struct { state protoimpl.MessageState `protogen:"open.v1"` Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"` @@ -1702,17 +1742,27 @@ const file_sale_sale_proto_rawDesc = "" + "\bResponse\x12\x12\n" + "\x04code\x18\x01 \x01(\x05R\x04code\x12\x10\n" + "\x03msg\x18\x02 \x01(\tR\x03msg\x12\x12\n" + - "\x04data\x18\x03 \x01(\tR\x04data\"\xf1\x01\n" + + "\x04data\x18\x03 \x01(\tR\x04data\"\xa0\x03\n" + "\rApiSaleAddReq\x12\x16\n" + - "\x06Mobile\x18\x01 \x01(\tR\x06Mobile\x12\x12\n" + - "\x04Name\x18\x02 \x01(\tR\x04Name\x12\x1a\n" + - "\bDistrict\x18\x03 \x01(\tR\bDistrict\x12\x18\n" + - "\aAddress\x18\x04 \x01(\tR\aAddress\x12\x18\n" + - "\aAccount\x18\x05 \x01(\tR\aAccount\x12 \n" + - "\vCredentials\x18\x06 \x01(\tR\vCredentials\x12\x10\n" + - "\x03Sex\x18\a \x01(\x05R\x03Sex\x12\x1c\n" + - "\tBirthDate\x18\b \x01(\tR\tBirthDate\x12\x12\n" + - "\x04Type\x18\t \x01(\x05R\x04Type\"f\n" + + "\x06mobile\x18\x01 \x01(\tR\x06mobile\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\x12)\n" + + "\x10business_license\x18\x03 \x01(\tR\x0fbusinessLicense\x12\x18\n" + + "\aaddress\x18\x04 \x01(\tR\aaddress\x12\x18\n" + + "\aaccount\x18\x05 \x01(\tR\aaccount\x12 \n" + + "\vcredentials\x18\x06 \x01(\tR\vcredentials\x12\x10\n" + + "\x03sex\x18\a \x01(\x05R\x03sex\x12\x1d\n" + + "\n" + + "birth_date\x18\b \x01(\tR\tbirthDate\x12\x12\n" + + "\x04type\x18\t \x01(\x05R\x04type\x12!\n" + + "\fidCard_front\x18\n" + + " \x01(\tR\vidCardFront\x12\x1f\n" + + "\vidCard_back\x18\v \x01(\tR\n" + + "idCardBack\x12\x1f\n" + + "\vprovince_id\x18\f \x01(\x03R\n" + + "provinceId\x12\x17\n" + + "\acity_id\x18\r \x01(\x03R\x06cityId\x12\x1f\n" + + "\vdistrict_id\x18\x0e \x01(\x03R\n" + + "districtId\"f\n" + "\x14ApiLowerSaleItemsReq\x12\x12\n" + "\x04page\x18\x01 \x01(\x05R\x04page\x12\x12\n" + "\x04size\x18\x02 \x01(\x05R\x04size\x12\x12\n" + @@ -1849,7 +1899,7 @@ const file_sale_sale_proto_rawDesc = "" + "\x0eNamesByIdsData\x12*\n" + "\x05items\x18\x01 \x03(\v2\x14.sale.NamesByIdsItemR\x05items\"\n" + "\n" + - "\bEmptyReq2\xde\t\n" + + "\bEmptyReq2\x90\t\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" + @@ -1866,8 +1916,7 @@ const file_sale_sale_proto_rawDesc = "" + "\x06Status\x12\x0f.sale.StatusReq\x1a\x0e.sale.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\x1a\x16/admin/v3/sales/status\x12O\n" + "\n" + "ApiSaleAdd\x12\x13.sale.ApiSaleAddReq\x1a\x0e.sale.Response\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\x1a\x11/api/v3/sales/add\x12_\n" + - "\x11ApiLowerSaleItems\x12\x1a.sale.ApiLowerSaleItemsReq\x1a\x0e.sale.Response\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\x1a\x13/api/v3/sales/lower\x12L\n" + - "\vApiSaleInfo\x12\x0e.sale.EmptyReq\x1a\x0e.sale.Response\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\x1a\x12/api/v3/sales/info\x12-\n" + + "\x11ApiLowerSaleItems\x12\x1a.sale.ApiLowerSaleItemsReq\x1a\x0e.sale.Response\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\x1a\x13/api/v3/sales/lower\x12-\n" + "\fInfoInternal\x12\r.sale.InfoReq\x1a\x0e.sale.InfoData\x125\n" + "\fInfoByUserId\x12\x15.sale.InfoByUserIdReq\x1a\x0e.sale.InfoData\x127\n" + "\n" + @@ -1928,29 +1977,27 @@ var file_sale_sale_proto_depIdxs = []int32{ 17, // 14: sale.Sale.Status:input_type -> sale.StatusReq 1, // 15: sale.Sale.ApiSaleAdd:input_type -> sale.ApiSaleAddReq 2, // 16: sale.Sale.ApiLowerSaleItems:input_type -> sale.ApiLowerSaleItemsReq - 21, // 17: sale.Sale.ApiSaleInfo:input_type -> sale.EmptyReq - 11, // 18: sale.Sale.InfoInternal:input_type -> sale.InfoReq - 12, // 19: sale.Sale.InfoByUserId:input_type -> sale.InfoByUserIdReq - 18, // 20: sale.Sale.NamesByIds:input_type -> sale.NamesByIdsReq - 0, // 21: sale.Sale.GroupItems:output_type -> sale.Response - 0, // 22: sale.Sale.GroupCreate:output_type -> sale.Response - 0, // 23: sale.Sale.GroupNames:output_type -> sale.Response - 0, // 24: sale.Sale.Types:output_type -> sale.Response - 0, // 25: sale.Sale.Names:output_type -> sale.Response - 8, // 26: sale.Sale.NamesInternal:output_type -> sale.NamesData - 0, // 27: sale.Sale.Create:output_type -> sale.Response - 0, // 28: sale.Sale.Edit:output_type -> sale.Response - 0, // 29: sale.Sale.Info:output_type -> sale.Response - 0, // 30: sale.Sale.Items:output_type -> sale.Response - 0, // 31: sale.Sale.Status:output_type -> sale.Response - 0, // 32: sale.Sale.ApiSaleAdd:output_type -> sale.Response - 0, // 33: sale.Sale.ApiLowerSaleItems:output_type -> sale.Response - 0, // 34: sale.Sale.ApiSaleInfo:output_type -> sale.Response - 15, // 35: sale.Sale.InfoInternal:output_type -> sale.InfoData - 15, // 36: sale.Sale.InfoByUserId:output_type -> sale.InfoData - 20, // 37: sale.Sale.NamesByIds:output_type -> sale.NamesByIdsData - 21, // [21:38] is the sub-list for method output_type - 4, // [4:21] is the sub-list for method input_type + 11, // 17: sale.Sale.InfoInternal:input_type -> sale.InfoReq + 12, // 18: sale.Sale.InfoByUserId:input_type -> sale.InfoByUserIdReq + 18, // 19: sale.Sale.NamesByIds:input_type -> sale.NamesByIdsReq + 0, // 20: sale.Sale.GroupItems:output_type -> sale.Response + 0, // 21: sale.Sale.GroupCreate:output_type -> sale.Response + 0, // 22: sale.Sale.GroupNames:output_type -> sale.Response + 0, // 23: sale.Sale.Types:output_type -> sale.Response + 0, // 24: sale.Sale.Names:output_type -> sale.Response + 8, // 25: sale.Sale.NamesInternal:output_type -> sale.NamesData + 0, // 26: sale.Sale.Create:output_type -> sale.Response + 0, // 27: sale.Sale.Edit:output_type -> sale.Response + 0, // 28: sale.Sale.Info:output_type -> sale.Response + 0, // 29: sale.Sale.Items:output_type -> sale.Response + 0, // 30: sale.Sale.Status:output_type -> sale.Response + 0, // 31: sale.Sale.ApiSaleAdd:output_type -> sale.Response + 0, // 32: sale.Sale.ApiLowerSaleItems:output_type -> sale.Response + 15, // 33: sale.Sale.InfoInternal:output_type -> sale.InfoData + 15, // 34: sale.Sale.InfoByUserId:output_type -> sale.InfoData + 20, // 35: sale.Sale.NamesByIds:output_type -> sale.NamesByIdsData + 20, // [20:36] is the sub-list for method output_type + 4, // [4:20] is the sub-list for method input_type 4, // [4:4] is the sub-list for extension type_name 4, // [4:4] is the sub-list for extension extendee 0, // [0:4] is the sub-list for field type_name diff --git a/rpc/sale/pb/sale_grpc.pb.go b/rpc/sale/pb/sale_grpc.pb.go index e738ca6..8f9f48d 100644 --- a/rpc/sale/pb/sale_grpc.pb.go +++ b/rpc/sale/pb/sale_grpc.pb.go @@ -32,7 +32,6 @@ const ( Sale_Status_FullMethodName = "/sale.Sale/Status" Sale_ApiSaleAdd_FullMethodName = "/sale.Sale/ApiSaleAdd" Sale_ApiLowerSaleItems_FullMethodName = "/sale.Sale/ApiLowerSaleItems" - Sale_ApiSaleInfo_FullMethodName = "/sale.Sale/ApiSaleInfo" Sale_InfoInternal_FullMethodName = "/sale.Sale/InfoInternal" Sale_InfoByUserId_FullMethodName = "/sale.Sale/InfoByUserId" Sale_NamesByIds_FullMethodName = "/sale.Sale/NamesByIds" @@ -58,7 +57,6 @@ type SaleClient interface { // ********************API************************ ApiSaleAdd(ctx context.Context, in *ApiSaleAddReq, opts ...grpc.CallOption) (*Response, error) ApiLowerSaleItems(ctx context.Context, in *ApiLowerSaleItemsReq, opts ...grpc.CallOption) (*Response, error) - ApiSaleInfo(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*Response, error) // 销售详情 InfoInternal(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*InfoData, error) // 按 user_id 查销售详情(内部) @@ -205,16 +203,6 @@ func (c *saleClient) ApiLowerSaleItems(ctx context.Context, in *ApiLowerSaleItem return out, nil } -func (c *saleClient) ApiSaleInfo(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*Response, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(Response) - err := c.cc.Invoke(ctx, Sale_ApiSaleInfo_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - 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) @@ -265,7 +253,6 @@ type SaleServer interface { // ********************API************************ ApiSaleAdd(context.Context, *ApiSaleAddReq) (*Response, error) ApiLowerSaleItems(context.Context, *ApiLowerSaleItemsReq) (*Response, error) - ApiSaleInfo(context.Context, *EmptyReq) (*Response, error) // 销售详情 InfoInternal(context.Context, *InfoReq) (*InfoData, error) // 按 user_id 查销售详情(内部) @@ -321,9 +308,6 @@ func (UnimplementedSaleServer) ApiSaleAdd(context.Context, *ApiSaleAddReq) (*Res func (UnimplementedSaleServer) ApiLowerSaleItems(context.Context, *ApiLowerSaleItemsReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method ApiLowerSaleItems not implemented") } -func (UnimplementedSaleServer) ApiSaleInfo(context.Context, *EmptyReq) (*Response, error) { - return nil, status.Error(codes.Unimplemented, "method ApiSaleInfo not implemented") -} func (UnimplementedSaleServer) InfoInternal(context.Context, *InfoReq) (*InfoData, error) { return nil, status.Error(codes.Unimplemented, "method InfoInternal not implemented") } @@ -588,24 +572,6 @@ func _Sale_ApiLowerSaleItems_Handler(srv interface{}, ctx context.Context, dec f return interceptor(ctx, in, info, handler) } -func _Sale_ApiSaleInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(EmptyReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(SaleServer).ApiSaleInfo(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Sale_ApiSaleInfo_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(SaleServer).ApiSaleInfo(ctx, req.(*EmptyReq)) - } - 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 { @@ -719,10 +685,6 @@ var Sale_ServiceDesc = grpc.ServiceDesc{ MethodName: "ApiLowerSaleItems", Handler: _Sale_ApiLowerSaleItems_Handler, }, - { - MethodName: "ApiSaleInfo", - Handler: _Sale_ApiSaleInfo_Handler, - }, { MethodName: "InfoInternal", Handler: _Sale_InfoInternal_Handler, diff --git a/rpc/sale/sale.pb b/rpc/sale/sale.pb index e09f58a..735aa55 100644 Binary files a/rpc/sale/sale.pb and b/rpc/sale/sale.pb differ diff --git a/rpc/sale/sale.proto b/rpc/sale/sale.proto index c5e09a5..630d2c3 100644 --- a/rpc/sale/sale.proto +++ b/rpc/sale/sale.proto @@ -82,12 +82,6 @@ service Sale { body: "*" }; } - rpc ApiSaleInfo(EmptyReq) returns (Response) { - option (google.api.http) = { - put: "/api/v3/sales/info" - body: "*" - }; - } // 销售详情 rpc InfoInternal(InfoReq) returns (InfoData); @@ -104,17 +98,23 @@ message Response { } message ApiSaleAddReq { - string Mobile = 1; - string Name = 2; - string District = 3; - string Address = 4; - string Account = 5; - string Credentials = 6; - int32 Sex = 7; - string BirthDate = 8; - int32 Type = 9; + string mobile = 1; + string name = 2; + string business_license = 3; + string address = 4; + string account = 5; + string credentials = 6; + int32 sex = 7; + string birth_date = 8; + int32 type = 9; + string idCard_front = 10; + string idCard_back = 11; + int64 province_id = 12; + int64 city_id = 13; + int64 district_id = 14; } + message ApiLowerSaleItemsReq { int32 page = 1; int32 size = 2; diff --git a/services/sale/internal/dao/sale.go b/services/sale/internal/dao/sale.go index 1329f8b..b069c2b 100644 --- a/services/sale/internal/dao/sale.go +++ b/services/sale/internal/dao/sale.go @@ -15,6 +15,7 @@ const ( SaleStatusEnabled uint8 = 1 // 开启 SaleStatusDisabled uint8 = 2 // 禁用 + ) type RegionNames struct { @@ -63,8 +64,11 @@ type SaleCreate struct { BusinessLicense string `gorm:"column:business_license" json:"business_license"` Region RegionNames `gorm:"column:region;type:json" json:"region"` ProvinceId int64 `gorm:"column:province_id" json:"province_id"` + ProvinceName string `json:"province_name" gorm:"province_name"` CityId int64 `gorm:"column:city_id" json:"city_id"` + CityName string `json:"city_name" gorm:"city_name"` DistrictId int64 `gorm:"column:district_id" json:"district_id"` + DistrictName string `json:"district_name" gorm:"district_name"` TerritoryId int64 `gorm:"column:territory_id" json:"territory_id"` TerritoryName string `gorm:"column:territory_name" json:"territory_name"` GroupId int64 `gorm:"column:group_id" json:"group_id"` @@ -90,8 +94,11 @@ type SaleInfo struct { BusinessLicense string `gorm:"column:business_license" json:"business_license"` Region RegionNames `gorm:"column:region;type:json" json:"region"` ProvinceId int64 `gorm:"column:province_id" json:"province_id"` + ProvinceName string `json:"province_name" gorm:"province_name"` CityId int64 `gorm:"column:city_id" json:"city_id"` + CityName string `json:"city_name" gorm:"city_name"` DistrictId int64 `gorm:"column:district_id" json:"district_id"` + DistrictName string `json:"district_name" gorm:"district_name"` TerritoryId int64 `gorm:"column:territory_id" json:"territory_id"` TerritoryName string `gorm:"column:territory_name" json:"territory_name"` GroupId int64 `gorm:"column:group_id" json:"group_id"` @@ -132,3 +139,30 @@ type SaleTypeOption struct { Value uint8 `json:"value"` Label string `json:"label"` } + +type APiSaleInfo struct { + Id int `gorm:"column:id;type:int(11);primary_key;AUTO_INCREMENT" json:"id"` + SaleId int `gorm:"column:sale_id;type:int(11);default:0;comment:父级销售;NOT NULL" json:"sale_id"` + Mobile string `gorm:"column:mobile;type:char(60);comment:手机号,也是登录账号;NOT NULL" json:"mobile"` + Name string `gorm:"column:name;type:varchar(256);comment:姓名或公司名;NOT NULL" json:"name"` + IdCardFront string `gorm:"column:id_card_front" json:"id_card_front"` + IdCardBack string `gorm:"column:id_card_back" json:"id_card_back"` + BusinessLicense string `gorm:"column:business_license" json:"business_license"` + Region RegionNames `gorm:"column:region;type:json" json:"region"` + ProvinceId int64 `gorm:"column:province_id" json:"province_id"` + ProvinceName string `gorm:"column:province_name;type:varchar(255);comment:身份名;NOT NULL" json:"province_name"` + CityId int64 `gorm:"column:city_id" json:"city_id"` + CityName string `json:"city_name" gorm:"city_name"` + DistrictId int64 `gorm:"column:district_id" json:"district_id"` + DistrictName string `json:"district_name" gorm:"district_name"` + TerritoryId int64 `gorm:"column:territory_id" json:"territory_id"` + TerritoryName string `gorm:"column:territory_name" json:"territory_name"` + Address string `gorm:"column:address;type:varchar(255);comment:地址" json:"address"` + Account string `gorm:"column:account;type:varchar(255);comment:账户信息" json:"account"` + Status uint8 `gorm:"column:status;type:tinyint(1);default:9;comment:9是待处理 1是已通过 2是未通过,3为禁用;NOT NULL" json:"status"` + Avatar string `gorm:"column:avatar;type:varchar(255);comment:头像" json:"avatar"` + Type uint8 `gorm:"column:type;type:tinyint(1);default:1;comment:类型,默认为1.1为公司销售,2为公司代理,3为个人代理" json:"type"` + Sex uint8 `gorm:"column:sex;type:tinyint(1);default:3;comment:性别,1男,2女,3未知" json:"sex"` + BirthDate string `gorm:"column:birth_date;type:char(12);comment:生日" json:"birth_date"` + Reason string `gorm:"column:reason;type:varchar(255);comment:理由" json:"reason"` +} diff --git a/services/sale/internal/logic/apiLowerSaleItemsLogic.go b/services/sale/internal/logic/apiLowerSaleItemsLogic.go index 213bf6e..fb5d6d5 100644 --- a/services/sale/internal/logic/apiLowerSaleItemsLogic.go +++ b/services/sale/internal/logic/apiLowerSaleItemsLogic.go @@ -2,9 +2,15 @@ package logic import ( "context" - + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" "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" + "strconv" "github.com/zeromicro/go-zero/core/logx" ) @@ -24,7 +30,55 @@ func NewApiLowerSaleItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) } func (l *ApiLowerSaleItemsLogic) ApiLowerSaleItems(in *sale.ApiLowerSaleItemsReq) (*sale.Response, error) { - // todo: add your logic here and delete this line + var req validator.ApiSalesItemsValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return outResponse(utils.ErrorParams, msg), nil + } - return &sale.Response{}, nil + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return failResponse(utils.ErrorNoLoginInfo), nil + } + + var info []dao.APiSaleInfo + w := modelbase.Params{ + Page: int(in.Page), + Size: int(in.Size), + Order: "id desc", + Eq: map[string]string{"sale_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen)}, + In: map[string][]string{ + "status": { + utils.StringStatusOk, + utils.StatusForbiddenString, + strconv.Itoa(int(utils.StatusWaitPass))}, + }, + } + + if in.Type > utils.NumberZero { + if in.Type == utils.NumberNine { + w.In["type"] = []string{strconv.Itoa(int(dao.SaleTypeAgentCorp)), strconv.Itoa(int(dao.SaleTypeAgentPerson))} + } else { + w.Eq["type"] = strconv.Itoa(int(in.Type)) + } + } + + w.Like = make(map[string]string) + if len(in.Name) > utils.NumberZero { + w.Like["name LIKE ? "] = "%%" + in.Name + "%%" + } + + items, err := model.SaleModel{}.Init().Page(w, &info) + if err != nil { + l.Logger.Error(err) + return failResponse(utils.Fail), nil + } + for key, v := range info { + mobile, aErr := utils.Crypto{}.AESDecryptECB(v.Mobile) + if aErr == nil { + info[key].Mobile = mobile + } + } + + items.Items = info + return okResponse(items), nil } diff --git a/services/sale/internal/logic/apiSaleAddLogic.go b/services/sale/internal/logic/apiSaleAddLogic.go index 15770aa..bbe911a 100644 --- a/services/sale/internal/logic/apiSaleAddLogic.go +++ b/services/sale/internal/logic/apiSaleAddLogic.go @@ -2,11 +2,20 @@ package logic import ( "context" + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + "lone-services/services/sale/internal/dao" + "lone-services/services/sale/internal/model" + "lone-services/services/sale/validator" + "strconv" "lone-services/rpc/sale/pb" "lone-services/services/sale/internal/svc" "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" ) type ApiSaleAddLogic struct { @@ -25,7 +34,131 @@ func NewApiSaleAddLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApiSal // API func (l *ApiSaleAddLogic) ApiSaleAdd(in *sale.ApiSaleAddReq) (*sale.Response, error) { - // todo: add your logic here and delete this line + var req validator.ApiCreateValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return outResponse(utils.ErrorParams, msg), nil + } + if msg := validateSaleTypeRules(uint32(req.Type), req.Account, req.BusinessLicense); msg != utils.StringEmpty { + return outResponse(utils.ErrorParams, msg), nil + } - return &sale.Response{}, nil + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return failResponse(utils.ErrorNoLoginInfo), nil + } + + if err := checkSaleIdentityCreatable(l.ctx, l.svcCtx.UserSvcName, req.Mobile); err != nil { + l.Errorf("sale check identity: %v", err) + if st, ok := status.FromError(err); ok && st.Code() == codes.AlreadyExists { + return failResponse(utils.ErrorDataIsExist), nil + } + if msg, ok := userRPCError(err); ok { + return outResponse(utils.Fail, msg), nil + } + return failResponse(utils.Fail), nil + } + + encryptMobile, encErr := utils.EncryptPhone(req.Mobile) + if encErr != nil { + l.Errorf("sale create encrypt mobile: %v", encErr) + return failResponse(utils.ErrorEncryptAesError), nil + } + + m := model.SaleModel{}.Init() + var existing dao.SaleStatusUpdate + if err := m.GetOne(modelbase.Params{ + Eq: map[string]string{"mobile": encryptMobile}, + }, &existing); err != nil { + l.Errorf("sale create check mobile: %v", err) + return failResponse(utils.Fail), nil + } + if existing.Id > utils.NumberZero { + return failResponse(utils.ErrorDataIsExist), nil + } + + names, nErr := fetchRegionNames(l.ctx, l.svcCtx.ChoreSvcName, in.ProvinceId, req.ProvinceId, req.CityId, req.DistrictId) + if nErr != nil { + l.Errorf("sale regions: %v", nErr) + return failResponse(utils.Fail), nil + } + territoryName := names[in.ProvinceId] + if territoryName == utils.StringEmpty { + return outResponse(utils.ErrorParams, "请选择地域"), nil + } + province := names[in.ProvinceId] + if province == utils.StringEmpty { + return outResponse(utils.ErrorParams, "请选择省份"), nil + } + city := names[in.CityId] + if city == utils.StringEmpty { + return outResponse(utils.ErrorParams, "请选择城市"), nil + } + district := names[in.DistrictId] + if district == utils.StringEmpty { + return outResponse(utils.ErrorParams, "请选择区县"), nil + } + + birthDate, bErr := utils.ParseDateOnly(in.BirthDate) + if bErr != nil { + return outResponse(utils.ErrorParams, "生日格式不正确"), nil + } + + data := dao.SaleCreate{ + SaleId: adminInfo.ID, + Mobile: encryptMobile, + Name: in.Name, + IdCardFront: in.IdCardFront, + IdCardBack: in.IdCardBack, + BusinessLicense: in.BusinessLicense, + Region: buildRegion(province, city, district), + ProvinceId: in.ProvinceId, + ProvinceName: province, + CityId: in.CityId, + CityName: city, + DistrictId: in.DistrictId, + DistrictName: district, + TerritoryId: in.ProvinceId, + TerritoryName: territoryName, + GroupId: adminInfo.GroupId, + Address: in.Address, + Status: utils.StatusWaitPass, + Account: in.Account, + Type: uint8(in.Type), + Sex: uint8(in.Sex), + BirthDate: birthDate, + } + m.Begin() + + if err := m.Create(&data); err != nil { + m.Rollback() + l.Errorf("sale create: %v", err) + return failResponse(utils.Fail), nil + } + + password := utils.GetRandString(utils.NumberFive) + identity, idErr := ensureSaleIdentity(l.ctx, l.svcCtx.UserSvcName, in.Mobile, password, data.Id) + if idErr != nil { + m.Rollback() + l.Errorf("sale ensure identity: %v", idErr) + return failResponse(utils.ErrorInternalServer), nil + } + if identity.GetUserId() < utils.NumberOne || identity.GetMobile() == utils.StringEmpty { + m.Rollback() + l.Error("sale rollback after empty identity") + return failResponse(utils.Fail), nil + } + + if _, err := m.Edit(modelbase.Params{ + Eq: map[string]string{"id": strconv.FormatInt(data.Id, utils.NumberTen)}, + }, map[string]interface{}{ + "user_id": identity.GetUserId(), + "mobile": identity.GetMobile(), + }); err != nil { + l.Errorf("sale bind user_id: %v", err) + m.Rollback() + return failResponse(utils.Fail), nil + } + m.Commit() + + return okResponse(nil), nil } diff --git a/services/sale/internal/logic/apiSaleInfoLogic.go b/services/sale/internal/logic/apiSaleInfoLogic.go deleted file mode 100644 index a7e6eb0..0000000 --- a/services/sale/internal/logic/apiSaleInfoLogic.go +++ /dev/null @@ -1,30 +0,0 @@ -package logic - -import ( - "context" - - "lone-services/rpc/sale/pb" - "lone-services/services/sale/internal/svc" - - "github.com/zeromicro/go-zero/core/logx" -) - -type ApiSaleInfoLogic struct { - ctx context.Context - svcCtx *svc.ServiceContext - logx.Logger -} - -func NewApiSaleInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApiSaleInfoLogic { - return &ApiSaleInfoLogic{ - ctx: ctx, - svcCtx: svcCtx, - Logger: logx.WithContext(ctx), - } -} - -func (l *ApiSaleInfoLogic) ApiSaleInfo(in *sale.EmptyReq) (*sale.Response, error) { - // todo: add your logic here and delete this line - - return &sale.Response{}, nil -} diff --git a/services/sale/internal/logic/createLogic.go b/services/sale/internal/logic/createLogic.go index 9c0827b..06d02f4 100644 --- a/services/sale/internal/logic/createLogic.go +++ b/services/sale/internal/logic/createLogic.go @@ -112,8 +112,11 @@ func (l *CreateLogic) Create(in *sale.CreateReq) (*sale.Response, error) { BusinessLicense: req.BusinessLicense, Region: buildRegion(province, city, district), ProvinceId: req.ProvinceId, + ProvinceName: province, CityId: req.CityId, + CityName: city, DistrictId: req.DistrictId, + DistrictName: district, TerritoryId: req.TerritoryId, TerritoryName: territoryName, GroupId: req.GroupId, diff --git a/services/sale/internal/server/saleServer.go b/services/sale/internal/server/saleServer.go index 35e1ac2..1dce902 100644 --- a/services/sale/internal/server/saleServer.go +++ b/services/sale/internal/server/saleServer.go @@ -91,11 +91,6 @@ func (s *SaleServer) ApiLowerSaleItems(ctx context.Context, in *sale.ApiLowerSal return l.ApiLowerSaleItems(in) } -func (s *SaleServer) ApiSaleInfo(ctx context.Context, in *sale.EmptyReq) (*sale.Response, error) { - l := logic.NewApiSaleInfoLogic(ctx, s.svcCtx) - return l.ApiSaleInfo(in) -} - // 销售详情 func (s *SaleServer) InfoInternal(ctx context.Context, in *sale.InfoReq) (*sale.InfoData, error) { l := logic.NewInfoInternalLogic(ctx, s.svcCtx) diff --git a/services/sale/run.toml b/services/sale/run.toml deleted file mode 100644 index 6f83ec6..0000000 --- a/services/sale/run.toml +++ /dev/null @@ -1,59 +0,0 @@ -[base] - login_out_time=43200 #api接口超时时间分 - login_refresh_out_time=83200 - name = "sale-service" - listenOn = "0.0.0.0:10300" - mode = "dev" -[log] - path = "logs" - serviceName = "sale-service" - mode = "file" - encoding = "plain" - level = "info" - keepDays = 7 - maxSize = 50 - maxBackups = 5 - compress = false - -[oss] - accessKeyId = "LTAI5t7U8KvxSiPE5auwQUuu" - accessKeySecret = "xjfgbQQRpL4TcIspNuClg6bYADa3pk" - roleArn = "acs:ram::1663896742753915:role/oss-upload" - roleSessionName = "oss-upload" - region = "oss-cn-hangzhou" - bucketName = "lone-images" - endpoint = "https://oss-accelerate.aliyuncs.com" - host = "https://images.ailuowan.com" - dir = "upload/" - expireSeconds = 3600 - -[mysql] - host = '39.106.171.204' - port = 33066 - user = 'root' - password = 'MOLXRZNOU4Y4' - database = 'dms-sale' - charset = 'utf8mb4' - prefix = '' - debug = true -[mysql_read] - host = '39.106.171.204' - port = 33066 - user = 'root' - password = 'MOLXRZNOU4Y4' - database = 'dms-sale' - charset = 'utf8mb4' - prefix = '' - -[redis] - host = '39.106.171.204' - password = 'lLMLcuPpzSj' - port = 6379 - db = 0 - -[encrypt] - data_key = "u2t9T3luZtoRfhBstkFN6TiIMW38BA8a" - -[services] - chore = "chore-service" - user = "user-service" \ No newline at end of file diff --git a/services/sale/saleClient/sale.go b/services/sale/saleClient/sale.go index 0b681db..e452bbc 100644 --- a/services/sale/saleClient/sale.go +++ b/services/sale/saleClient/sale.go @@ -54,7 +54,6 @@ type ( // API ApiSaleAdd(ctx context.Context, in *ApiSaleAddReq, opts ...grpc.CallOption) (*Response, error) ApiLowerSaleItems(ctx context.Context, in *ApiLowerSaleItemsReq, opts ...grpc.CallOption) (*Response, error) - ApiSaleInfo(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*Response, error) // 销售详情 InfoInternal(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*InfoData, error) // 按 user_id 查销售详情(内部) @@ -142,11 +141,6 @@ func (m *defaultSale) ApiLowerSaleItems(ctx context.Context, in *ApiLowerSaleIte return client.ApiLowerSaleItems(ctx, in, opts...) } -func (m *defaultSale) ApiSaleInfo(ctx context.Context, in *EmptyReq, opts ...grpc.CallOption) (*Response, error) { - client := sale.NewSaleClient(m.cli.Conn()) - return client.ApiSaleInfo(ctx, in, opts...) -} - // 销售详情 func (m *defaultSale) InfoInternal(ctx context.Context, in *InfoReq, opts ...grpc.CallOption) (*InfoData, error) { client := sale.NewSaleClient(m.cli.Conn()) diff --git a/services/sale/validator/validator.go b/services/sale/validator/validator.go index acbbfc6..f1aba7d 100644 --- a/services/sale/validator/validator.go +++ b/services/sale/validator/validator.go @@ -243,3 +243,41 @@ type ApiSalesItemsValidator struct { func (p ApiSalesItemsValidator) GetMessage() validate.ValidatorMessages { return validate.ValidatorMessages{} } + +type ApiCreateValidator struct { + Mobile string `validate:"required,max=20"` + Name string `validate:"required,max=256"` + IdCardFront string `validate:"required,max=255"` + IdCardBack string `validate:"required,max=255"` + BusinessLicense string `validate:"omitempty,max=255"` + Account string `validate:"omitempty,max=255"` + Sex int32 `validate:"omitempty,oneof=1 2 3"` + BirthDate string `validate:"omitempty,max=12"` + SaleId int64 `validate:"omitempty,gte=0"` + Type int32 `validate:"required,oneof=1 2 3"` + ProvinceId int64 `validate:"required,gt=0"` + CityId int64 `validate:"required,gt=0"` + DistrictId int64 `validate:"required,gt=0"` + Address string `validate:"required,max=255"` +} + +func (p ApiCreateValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Mobile.required": "手机号不能为空", + "Name.required": "姓名不能为空", + "IdCardFront.required": "身份证正面不能为空", + "IdCardFront.max": "身份证正面地址过长", + "IdCardBack.required": "身份证反面不能为空", + "IdCardBack.max": "身份证反面地址过长", + "BusinessLicense.max": "营业执照地址过长", + "Type.required": "请选择类型", + "Type.oneof": "类型不对", + "ProvinceId.required": "请选择省份", + "ProvinceId.gt": "请选择省份", + "CityId.required": "请选择城市", + "CityId.gt": "请选择城市", + "DistrictId.required": "请选择区县", + "DistrictId.gt": "请选择区县", + "Address.required": "详细地址不能为空", + } +} diff --git a/services/store/internal/logic/webStoreAddLogic.go b/services/store/internal/logic/webStoreAddLogic.go index 6deec49..3bc78db 100644 --- a/services/store/internal/logic/webStoreAddLogic.go +++ b/services/store/internal/logic/webStoreAddLogic.go @@ -72,7 +72,6 @@ func (l *WebStoreAddLogic) WebStoreAdd(in *store.WebStoreAddReq) (*store.Respons return l.fail(utils.SetError(utils.Fail, cErr.GetMsg())) } - l.Logger.Error(1111111) groupId, sErr := l.getSaleInfo(adminInfo.ID) if sErr != utils.Ok { return l.fail(sErr) @@ -136,10 +135,14 @@ func (l *WebStoreAddLogic) WebStoreAdd(in *store.WebStoreAddReq) (*store.Respons } modelObj.Commit() + Time := utils.Now().String() + + md5 := utils.MD5Encrypt(strconv.Itoa(int(data.Id)) + data.Name + Time) wecomrpc.SendMessage(l.ctx, l.svcCtx.WeComName, wecomrpc.SendMessageJob{ BizId: int(data.Id), // 门店ID BizType: wecomrpc.BizTypeStore, Type: wecomrpc.ProductSubmitReview, + Key: md5, }) modelObj.Commit() @@ -252,12 +255,3 @@ func (l *WebStoreAddLogic) createUser(info dao.StoreCreate, mobile, password str return utils.Ok } - -func (l *WebStoreAddLogic) sendMessage() { - // biz_type: 1产品 2门店 3地址 4销售;type: 消息场景;action: 0未用 1通过 2拒绝 - wecomrpc.SendMessage(l.ctx, l.svcCtx.WeComName, wecomrpc.SendMessageJob{ - BizId: objID, // 门店ID - BizType: wecomrpc.BizTypeStore, - Type: wecomrpc.ProductSubmitReview, - }) -} diff --git a/services/wecom/.gitignore b/services/wecom/.gitignore index 0457a55..92a8598 100644 --- a/services/wecom/.gitignore +++ b/services/wecom/.gitignore @@ -1,2 +1,5 @@ # Ignore go build binary wecom +tmp +run.toml +logs \ No newline at end of file diff --git a/services/wecom/run.toml b/services/wecom/run.toml deleted file mode 100644 index bd86fad..0000000 --- a/services/wecom/run.toml +++ /dev/null @@ -1,78 +0,0 @@ -[base] - login_out_time=43200 #api接口超时时间分 - login_refresh_out_time=83200 - name = "wecom-service" - listenOn = "0.0.0.0:10800" - mode = "dev" -[log] - path = "logs" - serviceName = "wecom-service" - mode = "file" - encoding = "plain" - level = "info" - keepDays = 7 - maxSize = 50 - maxBackups = 5 - compress = false - -[wecom] - skip = true - department_id = 1 - corp_id = "wwb83e24dcf1946e3e" - icon_url = "https://skin-test-api.ailuowan.com/images/20260509/1778321760824864613.png" - - review_agent_id = 1000002 - notify_agent_id = 1000003 - - review_secret = "bgLqhoLm_SFnEpxvOYX3RZKNMJbPYE9dc_bIHhntuDw" - contact_secret = "2wXeMVHIvq_Z9X-7h4xtfwH9JXJuMpnZa9gKOKlmGkg" - notify_secret = "7oFeb8MFpJG-vWLxce6qj2mqzwZAiSKmR9Qwrnr57vA" - - # 直接审批人 - product_reviewer_ids = "user962uMB|user69TMqt|user97vhfF" - store_reviewer_ids = "user962uMB|user69TMqt|user97vhfF" - address_reviewer_ids = "user962uMB|user69TMqt|user97vhfF" - - # 一审 - product_notify_first_ids = "user962uMB|user69TMqt|user97vhfF" - store_notify_first_ids = "user962uMB|user69TMqt|user97vhfF" - address_notify_first_ids = "user962uMB|user69TMqt|user97vhfF" - - # 二审 - product_notify_second_ids = "user962uMB|user69TMqt|user97vhfF" - store_notify_second_ids = "user962uMB|user69TMqt|user97vhfF" - address_notify_second_ids = "user962uMB|user69TMqt|user97vhfF" - - # 小程序添加销售 - sales_notify_apply_ids = "user962uMB|user69TMqt|user97vhfF" - -[mysql] - host = '39.106.171.204' - port = 33066 - user = 'root' - password = 'MOLXRZNOU4Y4' - database = 'dms-wecom' - charset = 'utf8mb4' - prefix = '' - debug = true -[mysql_read] - host = '39.106.171.204' - port = 33066 - user = 'root' - password = 'MOLXRZNOU4Y4' - database = 'dms-wecom' - charset = 'utf8mb4' - prefix = '' - -[redis] - host = '39.106.171.204' - password = 'lLMLcuPpzSj' - port = 6379 - db = 0 - -[encrypt] - data_key = "u2t9T3luZtoRfhBstkFN6TiIMW38BA8a" - -[services] - sale = "sale-service" - admin = "admin-service"