From a21b93f569dee32878b67d75faa23a70db8edd6b Mon Sep 17 00:00:00 2001 From: gjs Date: Tue, 25 Aug 2026 08:58:22 +0800 Subject: [PATCH] order address apis --- pkg/utils/encrypt.go | 7 + pkg/utils/status.go | 2 + rpc/lonelog/lonelog.proto | 1 - rpc/order/order.pb | Bin 15820 -> 16302 bytes rpc/order/order.proto | 48 +- rpc/order/pb/order.pb.go | 411 ++++++++++++++---- rpc/order/pb/order_grpc.pb.go | 140 ++++-- .../admin/internal/logic/admineditlogic.go | 2 +- services/lonelog/internal/logic/itemslogic.go | 4 - services/order/internal/dao/address.go | 50 ++- services/order/internal/dao/cart.go | 10 +- .../order/internal/logic/addressItemLogic.go | 66 ++- .../internal/logic/webAddressCreateLogic.go | 27 +- .../internal/logic/webAddressDefLogic.go | 60 ++- .../internal/logic/webAddressDelLogic.go | 67 +++ .../internal/logic/webAddressEditLogic.go | 88 +++- .../internal/logic/webAddressInfoLogic.go | 62 +++ .../internal/logic/webAddressItemsLogic.go | 38 +- .../order/internal/logic/webCartEditLogic.go | 60 ++- services/order/internal/logic/webCartLogic.go | 43 +- ...essStatusLogic.go => webCreateOneLogic.go} | 9 +- services/order/internal/server/orderServer.go | 22 +- services/order/orderClient/order.go | 34 +- services/order/validator/address.go | 35 +- services/order/validator/cart.go | 22 +- 25 files changed, 1123 insertions(+), 185 deletions(-) create mode 100644 services/order/internal/logic/webAddressDelLogic.go create mode 100644 services/order/internal/logic/webAddressInfoLogic.go rename services/order/internal/logic/{webAddressStatusLogic.go => webCreateOneLogic.go} (56%) diff --git a/pkg/utils/encrypt.go b/pkg/utils/encrypt.go index dd073e7..1ca2f45 100644 --- a/pkg/utils/encrypt.go +++ b/pkg/utils/encrypt.go @@ -124,6 +124,13 @@ func DecryptPhone(phone string) (string, Error) { return newPhone, nil } +func DecryptPhoneReplace(mobile string) string { + if len(mobile) < NumberEleven { + return mobile + } + return mobile[:NumberThree] + "****" + mobile[NumberSeven:NumberEleven] +} + func GetSearchPhone(mobile string) string { phone := StringEmpty if len(mobile) == 11 { diff --git a/pkg/utils/status.go b/pkg/utils/status.go index 46ee40f..a53ec20 100644 --- a/pkg/utils/status.go +++ b/pkg/utils/status.go @@ -52,6 +52,7 @@ const ( StoreAuthBind = 1 // 绑定 StoreAuthUnBind = 2 // 解绑 + StatusOk = 1 //正常 StatusApply = 2 //申请 StatusFirstVerify = 3 //一审 StatusSecondVerify = 4 //二审 @@ -61,6 +62,7 @@ const ( StatusAdminSecondVerify = 14 //二审 StatusAdminWaitPass = 19 //等待审核 StatusAdminSecondRefuse = 16 //审核失败 + StatusDel = 7 //删除 RpcTimeOut = 5000 //服务连接超时时间 毫秒 ) diff --git a/rpc/lonelog/lonelog.proto b/rpc/lonelog/lonelog.proto index 099182f..073a1b2 100644 --- a/rpc/lonelog/lonelog.proto +++ b/rpc/lonelog/lonelog.proto @@ -12,7 +12,6 @@ message ItemsRequest { int32 type = 3; string ip = 4; int64 admin_id = 5; - int64 service_id = 6; repeated string time = 7; } diff --git a/rpc/order/order.pb b/rpc/order/order.pb index 0b586a2bdb34c36b9deb08ff864206bd6b3c062b..337aaf624c997beb5a42d6367994b57e11006b8c 100644 GIT binary patch delta 585 zcmX?8y{>-4V`HY1;+vlu?_dbFWl(Bi zX=-talI7$RW~$~wLR>5*l?AC1OkjOrwvr+jw{v1q2~;Iq2_r(ut%$u*9b1*Wsa8G_{u|qA1izhra z2^uPSsX{V(`Jk}TLklNGD@jh}rpr$zGs!AROm4IkVb;&jn>@wxxKbn+FVFzTl$4^> z;$oN793gS232;A525O%C#Y$Q|$BI!)2u*z&PW1}P(Oi58qdoJ|^0BH_uoM!}Pb|pP zFEiFpgg8S#6Q~$uSp*k9k_jcLxy3?4Q0IYy3hXjpYb9}aE_P5T03!!358{C2H!rZ( GVFCd3#kG$B delta 254 zcmZ2if2MlFV`HZ0!keEO?_iuPX?BazZt@p1J0T@LE*{t1f|AOh)WXu#;u0m*$uZ`t zlXsZQO*XVRJ^76Z=VDe%My3;-li96yOjfo&q>;=e5T2Ukn37VIT3j4ll2}q&EF`U$ zUzCzsqzB_COiiA5!t3N|;{>M#KSLP1vP diff --git a/rpc/order/order.proto b/rpc/order/order.proto index 99d98f6..6dedb70 100644 --- a/rpc/order/order.proto +++ b/rpc/order/order.proto @@ -29,6 +29,13 @@ message CreateOrderRequest { string note = 2; } +message CreateOrderOneRequest { + int64 address_id = 1; + string note = 2; + int64 productid = 3; + int32 num = 4; +} + message EditAddressRequest { string district = 1; string address = 2; @@ -43,6 +50,7 @@ message EditAddressRequest { message StatusAddressRequest { int64 id = 1; int32 status = 2; + string reason = 3; } message EmptyRequest { @@ -50,12 +58,26 @@ message EmptyRequest { message EditCartRequest { string info = 1; + int32 type = 2; +} + +message CartRequest { + int32 type = 1; } message IdRequest { int64 id = 1; } +message IdAndTypeRequest { + int64 id = 1; + int32 type = 2; +} + +message TypeRequest { + int32 type = 1; +} + message AddressItemsRequest { int32 page = 1; int32 size = 2; @@ -64,7 +86,7 @@ message AddressItemsRequest { string mobile = 5; int64 store_id = 6; int64 sale_id = 7; - string time = 8; + repeated string time = 8; } message OrderAuditingItemsRequest { @@ -99,6 +121,13 @@ service order { }; }; + rpc WebCreateOne(CreateOrderOneRequest) returns(Response){ + option (google.api.http) = { + post: "/api/v3/order/create/one" + body: "*" + }; + }; + rpc WebAddressCreate(EditAddressRequest) returns(Response){ option (google.api.http) = { post: "/api/v3/address/create" @@ -111,26 +140,32 @@ service order { body: "*" }; }; - rpc WebAddressStatus(StatusAddressRequest) returns(Response){ + rpc WebAddressDel(IdAndTypeRequest) returns(Response){ option (google.api.http) = { - post: "/api/v3/address/status" + post: "/api/v3/address/del" body: "*" }; }; - rpc WebAddressDef(IdRequest) returns(Response){ + rpc WebAddressDef(IdAndTypeRequest) returns(Response){ option (google.api.http) = { post: "/api/v3/address/def" body: "*" }; }; - rpc WebAddressItems(EmptyRequest) returns(Response){ + rpc WebAddressInfo(IdAndTypeRequest) returns(Response){ + option (google.api.http) = { + get: "/api/v3/address/info" + body: "*" + }; + }; + rpc WebAddressItems(TypeRequest) returns(Response){ option (google.api.http) = { get: "/api/v3/address/items" body: "*" }; }; - rpc WebCart(EmptyRequest) returns(Response){ + rpc WebCart(CartRequest) returns(Response){ option (google.api.http) = { get: "/api/v3/cart" body: "*" @@ -149,6 +184,7 @@ service order { body: "*" }; }; + rpc OrderAuditingItems(OrderAuditingItemsRequest) returns(Response){ option (google.api.http) = { get: "/admin/v3/order/auditing/items" diff --git a/rpc/order/pb/order.pb.go b/rpc/order/pb/order.pb.go index 2907376..c415883 100644 --- a/rpc/order/pb/order.pb.go +++ b/rpc/order/pb/order.pb.go @@ -242,6 +242,74 @@ func (x *CreateOrderRequest) GetNote() string { return "" } +type CreateOrderOneRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + AddressId int64 `protobuf:"varint,1,opt,name=address_id,json=addressId,proto3" json:"address_id,omitempty"` + Note string `protobuf:"bytes,2,opt,name=note,proto3" json:"note,omitempty"` + Productid int64 `protobuf:"varint,3,opt,name=productid,proto3" json:"productid,omitempty"` + Num int32 `protobuf:"varint,4,opt,name=num,proto3" json:"num,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CreateOrderOneRequest) Reset() { + *x = CreateOrderOneRequest{} + mi := &file_order_order_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CreateOrderOneRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CreateOrderOneRequest) ProtoMessage() {} + +func (x *CreateOrderOneRequest) ProtoReflect() protoreflect.Message { + mi := &file_order_order_proto_msgTypes[3] + 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 CreateOrderOneRequest.ProtoReflect.Descriptor instead. +func (*CreateOrderOneRequest) Descriptor() ([]byte, []int) { + return file_order_order_proto_rawDescGZIP(), []int{3} +} + +func (x *CreateOrderOneRequest) GetAddressId() int64 { + if x != nil { + return x.AddressId + } + return 0 +} + +func (x *CreateOrderOneRequest) GetNote() string { + if x != nil { + return x.Note + } + return "" +} + +func (x *CreateOrderOneRequest) GetProductid() int64 { + if x != nil { + return x.Productid + } + return 0 +} + +func (x *CreateOrderOneRequest) GetNum() int32 { + if x != nil { + return x.Num + } + return 0 +} + type EditAddressRequest struct { state protoimpl.MessageState `protogen:"open.v1"` District string `protobuf:"bytes,1,opt,name=district,proto3" json:"district,omitempty"` @@ -258,7 +326,7 @@ type EditAddressRequest struct { func (x *EditAddressRequest) Reset() { *x = EditAddressRequest{} - mi := &file_order_order_proto_msgTypes[3] + mi := &file_order_order_proto_msgTypes[4] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -270,7 +338,7 @@ func (x *EditAddressRequest) String() string { func (*EditAddressRequest) ProtoMessage() {} func (x *EditAddressRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[3] + mi := &file_order_order_proto_msgTypes[4] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -283,7 +351,7 @@ func (x *EditAddressRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use EditAddressRequest.ProtoReflect.Descriptor instead. func (*EditAddressRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{3} + return file_order_order_proto_rawDescGZIP(), []int{4} } func (x *EditAddressRequest) GetDistrict() string { @@ -346,13 +414,14 @@ type StatusAddressRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` Status int32 `protobuf:"varint,2,opt,name=status,proto3" json:"status,omitempty"` + Reason string `protobuf:"bytes,3,opt,name=reason,proto3" json:"reason,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *StatusAddressRequest) Reset() { *x = StatusAddressRequest{} - mi := &file_order_order_proto_msgTypes[4] + mi := &file_order_order_proto_msgTypes[5] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -364,7 +433,7 @@ func (x *StatusAddressRequest) String() string { func (*StatusAddressRequest) ProtoMessage() {} func (x *StatusAddressRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[4] + mi := &file_order_order_proto_msgTypes[5] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -377,7 +446,7 @@ func (x *StatusAddressRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use StatusAddressRequest.ProtoReflect.Descriptor instead. func (*StatusAddressRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{4} + return file_order_order_proto_rawDescGZIP(), []int{5} } func (x *StatusAddressRequest) GetId() int64 { @@ -394,6 +463,13 @@ func (x *StatusAddressRequest) GetStatus() int32 { return 0 } +func (x *StatusAddressRequest) GetReason() string { + if x != nil { + return x.Reason + } + return "" +} + type EmptyRequest struct { state protoimpl.MessageState `protogen:"open.v1"` unknownFields protoimpl.UnknownFields @@ -402,7 +478,7 @@ type EmptyRequest struct { func (x *EmptyRequest) Reset() { *x = EmptyRequest{} - mi := &file_order_order_proto_msgTypes[5] + mi := &file_order_order_proto_msgTypes[6] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -414,7 +490,7 @@ func (x *EmptyRequest) String() string { func (*EmptyRequest) ProtoMessage() {} func (x *EmptyRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[5] + mi := &file_order_order_proto_msgTypes[6] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -427,19 +503,20 @@ func (x *EmptyRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use EmptyRequest.ProtoReflect.Descriptor instead. func (*EmptyRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{5} + return file_order_order_proto_rawDescGZIP(), []int{6} } type EditCartRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Info string `protobuf:"bytes,1,opt,name=info,proto3" json:"info,omitempty"` + Type int32 `protobuf:"varint,2,opt,name=type,proto3" json:"type,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *EditCartRequest) Reset() { *x = EditCartRequest{} - mi := &file_order_order_proto_msgTypes[6] + mi := &file_order_order_proto_msgTypes[7] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -451,7 +528,7 @@ func (x *EditCartRequest) String() string { func (*EditCartRequest) ProtoMessage() {} func (x *EditCartRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[6] + mi := &file_order_order_proto_msgTypes[7] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -464,7 +541,7 @@ func (x *EditCartRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use EditCartRequest.ProtoReflect.Descriptor instead. func (*EditCartRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{6} + return file_order_order_proto_rawDescGZIP(), []int{7} } func (x *EditCartRequest) GetInfo() string { @@ -474,6 +551,57 @@ func (x *EditCartRequest) GetInfo() string { return "" } +func (x *EditCartRequest) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + +type CartRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Type int32 `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *CartRequest) Reset() { + *x = CartRequest{} + mi := &file_order_order_proto_msgTypes[8] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *CartRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*CartRequest) ProtoMessage() {} + +func (x *CartRequest) ProtoReflect() protoreflect.Message { + mi := &file_order_order_proto_msgTypes[8] + 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 CartRequest.ProtoReflect.Descriptor instead. +func (*CartRequest) Descriptor() ([]byte, []int) { + return file_order_order_proto_rawDescGZIP(), []int{8} +} + +func (x *CartRequest) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + type IdRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` @@ -483,7 +611,7 @@ type IdRequest struct { func (x *IdRequest) Reset() { *x = IdRequest{} - mi := &file_order_order_proto_msgTypes[7] + mi := &file_order_order_proto_msgTypes[9] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -495,7 +623,7 @@ func (x *IdRequest) String() string { func (*IdRequest) ProtoMessage() {} func (x *IdRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[7] + mi := &file_order_order_proto_msgTypes[9] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -508,7 +636,7 @@ func (x *IdRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use IdRequest.ProtoReflect.Descriptor instead. func (*IdRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{7} + return file_order_order_proto_rawDescGZIP(), []int{9} } func (x *IdRequest) GetId() int64 { @@ -518,6 +646,102 @@ func (x *IdRequest) GetId() int64 { return 0 } +type IdAndTypeRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Type int32 `protobuf:"varint,2,opt,name=type,proto3" json:"type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *IdAndTypeRequest) Reset() { + *x = IdAndTypeRequest{} + mi := &file_order_order_proto_msgTypes[10] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *IdAndTypeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*IdAndTypeRequest) ProtoMessage() {} + +func (x *IdAndTypeRequest) ProtoReflect() protoreflect.Message { + mi := &file_order_order_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 IdAndTypeRequest.ProtoReflect.Descriptor instead. +func (*IdAndTypeRequest) Descriptor() ([]byte, []int) { + return file_order_order_proto_rawDescGZIP(), []int{10} +} + +func (x *IdAndTypeRequest) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *IdAndTypeRequest) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + +type TypeRequest struct { + state protoimpl.MessageState `protogen:"open.v1"` + Type int32 `protobuf:"varint,1,opt,name=type,proto3" json:"type,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *TypeRequest) Reset() { + *x = TypeRequest{} + mi := &file_order_order_proto_msgTypes[11] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *TypeRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*TypeRequest) ProtoMessage() {} + +func (x *TypeRequest) ProtoReflect() protoreflect.Message { + mi := &file_order_order_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 TypeRequest.ProtoReflect.Descriptor instead. +func (*TypeRequest) Descriptor() ([]byte, []int) { + return file_order_order_proto_rawDescGZIP(), []int{11} +} + +func (x *TypeRequest) GetType() int32 { + if x != nil { + return x.Type + } + return 0 +} + type AddressItemsRequest struct { state protoimpl.MessageState `protogen:"open.v1"` Page int32 `protobuf:"varint,1,opt,name=page,proto3" json:"page,omitempty"` @@ -527,14 +751,14 @@ type AddressItemsRequest struct { Mobile string `protobuf:"bytes,5,opt,name=mobile,proto3" json:"mobile,omitempty"` StoreId int64 `protobuf:"varint,6,opt,name=store_id,json=storeId,proto3" json:"store_id,omitempty"` SaleId int64 `protobuf:"varint,7,opt,name=sale_id,json=saleId,proto3" json:"sale_id,omitempty"` - Time string `protobuf:"bytes,8,opt,name=time,proto3" json:"time,omitempty"` + Time []string `protobuf:"bytes,8,rep,name=time,proto3" json:"time,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } func (x *AddressItemsRequest) Reset() { *x = AddressItemsRequest{} - mi := &file_order_order_proto_msgTypes[8] + mi := &file_order_order_proto_msgTypes[12] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -546,7 +770,7 @@ func (x *AddressItemsRequest) String() string { func (*AddressItemsRequest) ProtoMessage() {} func (x *AddressItemsRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[8] + mi := &file_order_order_proto_msgTypes[12] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -559,7 +783,7 @@ func (x *AddressItemsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AddressItemsRequest.ProtoReflect.Descriptor instead. func (*AddressItemsRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{8} + return file_order_order_proto_rawDescGZIP(), []int{12} } func (x *AddressItemsRequest) GetPage() int32 { @@ -611,11 +835,11 @@ func (x *AddressItemsRequest) GetSaleId() int64 { return 0 } -func (x *AddressItemsRequest) GetTime() string { +func (x *AddressItemsRequest) GetTime() []string { if x != nil { return x.Time } - return "" + return nil } type OrderAuditingItemsRequest struct { @@ -628,7 +852,7 @@ type OrderAuditingItemsRequest struct { func (x *OrderAuditingItemsRequest) Reset() { *x = OrderAuditingItemsRequest{} - mi := &file_order_order_proto_msgTypes[9] + mi := &file_order_order_proto_msgTypes[13] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -640,7 +864,7 @@ func (x *OrderAuditingItemsRequest) String() string { func (*OrderAuditingItemsRequest) ProtoMessage() {} func (x *OrderAuditingItemsRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[9] + mi := &file_order_order_proto_msgTypes[13] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -653,7 +877,7 @@ func (x *OrderAuditingItemsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use OrderAuditingItemsRequest.ProtoReflect.Descriptor instead. func (*OrderAuditingItemsRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{9} + return file_order_order_proto_rawDescGZIP(), []int{13} } func (x *OrderAuditingItemsRequest) GetPage() int32 { @@ -681,7 +905,7 @@ type OrderAuditingRequest struct { func (x *OrderAuditingRequest) Reset() { *x = OrderAuditingRequest{} - mi := &file_order_order_proto_msgTypes[10] + mi := &file_order_order_proto_msgTypes[14] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -693,7 +917,7 @@ func (x *OrderAuditingRequest) String() string { func (*OrderAuditingRequest) ProtoMessage() {} func (x *OrderAuditingRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[10] + mi := &file_order_order_proto_msgTypes[14] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -706,7 +930,7 @@ func (x *OrderAuditingRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use OrderAuditingRequest.ProtoReflect.Descriptor instead. func (*OrderAuditingRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{10} + return file_order_order_proto_rawDescGZIP(), []int{14} } func (x *OrderAuditingRequest) GetId() int64 { @@ -741,7 +965,7 @@ type AdminCreateOrderRequest struct { func (x *AdminCreateOrderRequest) Reset() { *x = AdminCreateOrderRequest{} - mi := &file_order_order_proto_msgTypes[11] + mi := &file_order_order_proto_msgTypes[15] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -753,7 +977,7 @@ func (x *AdminCreateOrderRequest) String() string { func (*AdminCreateOrderRequest) ProtoMessage() {} func (x *AdminCreateOrderRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[11] + mi := &file_order_order_proto_msgTypes[15] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -766,7 +990,7 @@ func (x *AdminCreateOrderRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use AdminCreateOrderRequest.ProtoReflect.Descriptor instead. func (*AdminCreateOrderRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{11} + return file_order_order_proto_rawDescGZIP(), []int{15} } func (x *AdminCreateOrderRequest) GetAddressId() int64 { @@ -813,7 +1037,13 @@ const file_order_order_proto_rawDesc = "" + "\x12CreateOrderRequest\x12\x1d\n" + "\n" + "address_id\x18\x01 \x01(\x03R\taddressId\x12\x12\n" + - "\x04note\x18\x02 \x01(\tR\x04note\"\xd7\x01\n" + + "\x04note\x18\x02 \x01(\tR\x04note\"z\n" + + "\x15CreateOrderOneRequest\x12\x1d\n" + + "\n" + + "address_id\x18\x01 \x01(\x03R\taddressId\x12\x12\n" + + "\x04note\x18\x02 \x01(\tR\x04note\x12\x1c\n" + + "\tproductid\x18\x03 \x01(\x03R\tproductid\x12\x10\n" + + "\x03num\x18\x04 \x01(\x05R\x03num\"\xd7\x01\n" + "\x12EditAddressRequest\x12\x1a\n" + "\bdistrict\x18\x01 \x01(\tR\bdistrict\x12\x18\n" + "\aaddress\x18\x02 \x01(\tR\aaddress\x12\x12\n" + @@ -822,15 +1052,24 @@ const file_order_order_proto_rawDesc = "" + "\fdistrict_ids\x18\x05 \x01(\tR\vdistrictIds\x12\x18\n" + "\adefault\x18\x06 \x01(\bR\adefault\x12\x0e\n" + "\x02id\x18\a \x01(\x03R\x02id\x12\x12\n" + - "\x04type\x18\b \x01(\x05R\x04type\">\n" + + "\x04type\x18\b \x01(\x05R\x04type\"V\n" + "\x14StatusAddressRequest\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" + - "\x06status\x18\x02 \x01(\x05R\x06status\"\x0e\n" + - "\fEmptyRequest\"%\n" + + "\x06status\x18\x02 \x01(\x05R\x06status\x12\x16\n" + + "\x06reason\x18\x03 \x01(\tR\x06reason\"\x0e\n" + + "\fEmptyRequest\"9\n" + "\x0fEditCartRequest\x12\x12\n" + - "\x04info\x18\x01 \x01(\tR\x04info\"\x1b\n" + + "\x04info\x18\x01 \x01(\tR\x04info\x12\x12\n" + + "\x04type\x18\x02 \x01(\x05R\x04type\"!\n" + + "\vCartRequest\x12\x12\n" + + "\x04type\x18\x01 \x01(\x05R\x04type\"\x1b\n" + "\tIdRequest\x12\x0e\n" + - "\x02id\x18\x01 \x01(\x03R\x02id\"\xd2\x01\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"6\n" + + "\x10IdAndTypeRequest\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + + "\x04type\x18\x02 \x01(\x05R\x04type\"!\n" + + "\vTypeRequest\x12\x12\n" + + "\x04type\x18\x01 \x01(\x05R\x04type\"\xd2\x01\n" + "\x13AddressItemsRequest\x12\x12\n" + "\x04page\x18\x01 \x01(\x05R\x04page\x12\x12\n" + "\x04size\x18\x02 \x01(\x05R\x04size\x12\x1f\n" + @@ -840,7 +1079,7 @@ const file_order_order_proto_rawDesc = "" + "\x06mobile\x18\x05 \x01(\tR\x06mobile\x12\x19\n" + "\bstore_id\x18\x06 \x01(\x03R\astoreId\x12\x17\n" + "\asale_id\x18\a \x01(\x03R\x06saleId\x12\x12\n" + - "\x04time\x18\b \x01(\tR\x04time\"C\n" + + "\x04time\x18\b \x03(\tR\x04time\"C\n" + "\x19OrderAuditingItemsRequest\x12\x12\n" + "\x04page\x18\x01 \x01(\x05R\x04page\x12\x12\n" + "\x04size\x18\x02 \x01(\x05R\x04size\"V\n" + @@ -852,16 +1091,18 @@ const file_order_order_proto_rawDesc = "" + "\n" + "address_id\x18\x01 \x01(\x03R\taddressId\x12\x12\n" + "\x04note\x18\x02 \x01(\tR\x04note\x12\x12\n" + - "\x04info\x18\x03 \x01(\tR\x04info2\xc8\t\n" + + "\x04info\x18\x03 \x01(\tR\x04info2\x84\v\n" + "\x05order\x12T\n" + "\x05Items\x12\x18.order.OrderItemsRequest\x1a\x0f.order.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\x12\x15/admin/v3/order/items\x12X\n" + - "\tWebCreate\x12\x19.order.CreateOrderRequest\x1a\x0f.order.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\"\x14/api/v3/order/create\x12a\n" + + "\tWebCreate\x12\x19.order.CreateOrderRequest\x1a\x0f.order.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\"\x14/api/v3/order/create\x12b\n" + + "\fWebCreateOne\x12\x1c.order.CreateOrderOneRequest\x1a\x0f.order.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\"\x18/api/v3/order/create/one\x12a\n" + "\x10WebAddressCreate\x12\x19.order.EditAddressRequest\x1a\x0f.order.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\"\x16/api/v3/address/create\x12]\n" + - "\x0eWebAddressEdit\x12\x19.order.EditAddressRequest\x1a\x0f.order.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\"\x14/api/v3/address/edit\x12c\n" + - "\x10WebAddressStatus\x12\x1b.order.StatusAddressRequest\x1a\x0f.order.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\"\x16/api/v3/address/status\x12R\n" + - "\rWebAddressDef\x12\x10.order.IdRequest\x1a\x0f.order.Response\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\"\x13/api/v3/address/def\x12Y\n" + - "\x0fWebAddressItems\x12\x13.order.EmptyRequest\x1a\x0f.order.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\x12\x15/api/v3/address/items\x12H\n" + - "\aWebCart\x12\x13.order.EmptyRequest\x1a\x0f.order.Response\"\x17\x82\xd3\xe4\x93\x02\x11:\x01*\x12\f/api/v3/cart\x12T\n" + + "\x0eWebAddressEdit\x12\x19.order.EditAddressRequest\x1a\x0f.order.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\"\x14/api/v3/address/edit\x12Y\n" + + "\rWebAddressDel\x12\x17.order.IdAndTypeRequest\x1a\x0f.order.Response\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\"\x13/api/v3/address/del\x12Y\n" + + "\rWebAddressDef\x12\x17.order.IdAndTypeRequest\x1a\x0f.order.Response\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\"\x13/api/v3/address/def\x12[\n" + + "\x0eWebAddressInfo\x12\x17.order.IdAndTypeRequest\x1a\x0f.order.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\x12\x14/api/v3/address/info\x12X\n" + + "\x0fWebAddressItems\x12\x12.order.TypeRequest\x1a\x0f.order.Response\" \x82\xd3\xe4\x93\x02\x1a:\x01*\x12\x15/api/v3/address/items\x12G\n" + + "\aWebCart\x12\x12.order.CartRequest\x1a\x0f.order.Response\"\x17\x82\xd3\xe4\x93\x02\x11:\x01*\x12\f/api/v3/cart\x12T\n" + "\vWebCartEdit\x12\x16.order.EditCartRequest\x1a\x0f.order.Response\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\"\x11/api/v3/cart/edit\x12^\n" + "\vAddressItem\x12\x1a.order.AddressItemsRequest\x1a\x0f.order.Response\"\"\x82\xd3\xe4\x93\x02\x1c:\x01*\x12\x17/admin/v3/address/items\x12r\n" + "\x12OrderAuditingItems\x12 .order.OrderAuditingItemsRequest\x1a\x0f.order.Response\")\x82\xd3\xe4\x93\x02#:\x01*\x12\x1e/admin/v3/order/auditing/items\x12b\n" + @@ -880,50 +1121,58 @@ func file_order_order_proto_rawDescGZIP() []byte { return file_order_order_proto_rawDescData } -var file_order_order_proto_msgTypes = make([]protoimpl.MessageInfo, 12) +var file_order_order_proto_msgTypes = make([]protoimpl.MessageInfo, 16) var file_order_order_proto_goTypes = []any{ (*OrderItemsRequest)(nil), // 0: order.OrderItemsRequest (*Response)(nil), // 1: order.Response (*CreateOrderRequest)(nil), // 2: order.CreateOrderRequest - (*EditAddressRequest)(nil), // 3: order.EditAddressRequest - (*StatusAddressRequest)(nil), // 4: order.StatusAddressRequest - (*EmptyRequest)(nil), // 5: order.EmptyRequest - (*EditCartRequest)(nil), // 6: order.EditCartRequest - (*IdRequest)(nil), // 7: order.IdRequest - (*AddressItemsRequest)(nil), // 8: order.AddressItemsRequest - (*OrderAuditingItemsRequest)(nil), // 9: order.OrderAuditingItemsRequest - (*OrderAuditingRequest)(nil), // 10: order.OrderAuditingRequest - (*AdminCreateOrderRequest)(nil), // 11: order.AdminCreateOrderRequest + (*CreateOrderOneRequest)(nil), // 3: order.CreateOrderOneRequest + (*EditAddressRequest)(nil), // 4: order.EditAddressRequest + (*StatusAddressRequest)(nil), // 5: order.StatusAddressRequest + (*EmptyRequest)(nil), // 6: order.EmptyRequest + (*EditCartRequest)(nil), // 7: order.EditCartRequest + (*CartRequest)(nil), // 8: order.CartRequest + (*IdRequest)(nil), // 9: order.IdRequest + (*IdAndTypeRequest)(nil), // 10: order.IdAndTypeRequest + (*TypeRequest)(nil), // 11: order.TypeRequest + (*AddressItemsRequest)(nil), // 12: order.AddressItemsRequest + (*OrderAuditingItemsRequest)(nil), // 13: order.OrderAuditingItemsRequest + (*OrderAuditingRequest)(nil), // 14: order.OrderAuditingRequest + (*AdminCreateOrderRequest)(nil), // 15: order.AdminCreateOrderRequest } var file_order_order_proto_depIdxs = []int32{ 0, // 0: order.order.Items:input_type -> order.OrderItemsRequest 2, // 1: order.order.WebCreate:input_type -> order.CreateOrderRequest - 3, // 2: order.order.WebAddressCreate:input_type -> order.EditAddressRequest - 3, // 3: order.order.WebAddressEdit:input_type -> order.EditAddressRequest - 4, // 4: order.order.WebAddressStatus:input_type -> order.StatusAddressRequest - 7, // 5: order.order.WebAddressDef:input_type -> order.IdRequest - 5, // 6: order.order.WebAddressItems:input_type -> order.EmptyRequest - 5, // 7: order.order.WebCart:input_type -> order.EmptyRequest - 6, // 8: order.order.WebCartEdit:input_type -> order.EditCartRequest - 8, // 9: order.order.AddressItem:input_type -> order.AddressItemsRequest - 9, // 10: order.order.OrderAuditingItems:input_type -> order.OrderAuditingItemsRequest - 10, // 11: order.order.OrderAuditing:input_type -> order.OrderAuditingRequest - 11, // 12: order.order.OrderCreate:input_type -> order.AdminCreateOrderRequest - 1, // 13: order.order.Items:output_type -> order.Response - 1, // 14: order.order.WebCreate:output_type -> order.Response - 1, // 15: order.order.WebAddressCreate:output_type -> order.Response - 1, // 16: order.order.WebAddressEdit:output_type -> order.Response - 1, // 17: order.order.WebAddressStatus:output_type -> order.Response - 1, // 18: order.order.WebAddressDef:output_type -> order.Response - 1, // 19: order.order.WebAddressItems:output_type -> order.Response - 1, // 20: order.order.WebCart:output_type -> order.Response - 1, // 21: order.order.WebCartEdit:output_type -> order.Response - 1, // 22: order.order.AddressItem:output_type -> order.Response - 1, // 23: order.order.OrderAuditingItems:output_type -> order.Response - 1, // 24: order.order.OrderAuditing:output_type -> order.Response - 1, // 25: order.order.OrderCreate:output_type -> order.Response - 13, // [13:26] is the sub-list for method output_type - 0, // [0:13] is the sub-list for method input_type + 3, // 2: order.order.WebCreateOne:input_type -> order.CreateOrderOneRequest + 4, // 3: order.order.WebAddressCreate:input_type -> order.EditAddressRequest + 4, // 4: order.order.WebAddressEdit:input_type -> order.EditAddressRequest + 10, // 5: order.order.WebAddressDel:input_type -> order.IdAndTypeRequest + 10, // 6: order.order.WebAddressDef:input_type -> order.IdAndTypeRequest + 10, // 7: order.order.WebAddressInfo:input_type -> order.IdAndTypeRequest + 11, // 8: order.order.WebAddressItems:input_type -> order.TypeRequest + 8, // 9: order.order.WebCart:input_type -> order.CartRequest + 7, // 10: order.order.WebCartEdit:input_type -> order.EditCartRequest + 12, // 11: order.order.AddressItem:input_type -> order.AddressItemsRequest + 13, // 12: order.order.OrderAuditingItems:input_type -> order.OrderAuditingItemsRequest + 14, // 13: order.order.OrderAuditing:input_type -> order.OrderAuditingRequest + 15, // 14: order.order.OrderCreate:input_type -> order.AdminCreateOrderRequest + 1, // 15: order.order.Items:output_type -> order.Response + 1, // 16: order.order.WebCreate:output_type -> order.Response + 1, // 17: order.order.WebCreateOne:output_type -> order.Response + 1, // 18: order.order.WebAddressCreate:output_type -> order.Response + 1, // 19: order.order.WebAddressEdit:output_type -> order.Response + 1, // 20: order.order.WebAddressDel:output_type -> order.Response + 1, // 21: order.order.WebAddressDef:output_type -> order.Response + 1, // 22: order.order.WebAddressInfo:output_type -> order.Response + 1, // 23: order.order.WebAddressItems:output_type -> order.Response + 1, // 24: order.order.WebCart:output_type -> order.Response + 1, // 25: order.order.WebCartEdit:output_type -> order.Response + 1, // 26: order.order.AddressItem:output_type -> order.Response + 1, // 27: order.order.OrderAuditingItems:output_type -> order.Response + 1, // 28: order.order.OrderAuditing:output_type -> order.Response + 1, // 29: order.order.OrderCreate:output_type -> order.Response + 15, // [15:30] is the sub-list for method output_type + 0, // [0:15] is the sub-list for method input_type 0, // [0:0] is the sub-list for extension type_name 0, // [0:0] is the sub-list for extension extendee 0, // [0:0] is the sub-list for field type_name @@ -940,7 +1189,7 @@ func file_order_order_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_order_order_proto_rawDesc), len(file_order_order_proto_rawDesc)), NumEnums: 0, - NumMessages: 12, + NumMessages: 16, NumExtensions: 0, NumServices: 1, }, diff --git a/rpc/order/pb/order_grpc.pb.go b/rpc/order/pb/order_grpc.pb.go index 9262df6..4124cea 100644 --- a/rpc/order/pb/order_grpc.pb.go +++ b/rpc/order/pb/order_grpc.pb.go @@ -21,10 +21,12 @@ const _ = grpc.SupportPackageIsVersion9 const ( Order_Items_FullMethodName = "/order.order/Items" Order_WebCreate_FullMethodName = "/order.order/WebCreate" + Order_WebCreateOne_FullMethodName = "/order.order/WebCreateOne" Order_WebAddressCreate_FullMethodName = "/order.order/WebAddressCreate" Order_WebAddressEdit_FullMethodName = "/order.order/WebAddressEdit" - Order_WebAddressStatus_FullMethodName = "/order.order/WebAddressStatus" + Order_WebAddressDel_FullMethodName = "/order.order/WebAddressDel" Order_WebAddressDef_FullMethodName = "/order.order/WebAddressDef" + Order_WebAddressInfo_FullMethodName = "/order.order/WebAddressInfo" Order_WebAddressItems_FullMethodName = "/order.order/WebAddressItems" Order_WebCart_FullMethodName = "/order.order/WebCart" Order_WebCartEdit_FullMethodName = "/order.order/WebCartEdit" @@ -40,12 +42,14 @@ const ( type OrderClient interface { Items(ctx context.Context, in *OrderItemsRequest, opts ...grpc.CallOption) (*Response, error) WebCreate(ctx context.Context, in *CreateOrderRequest, opts ...grpc.CallOption) (*Response, error) + WebCreateOne(ctx context.Context, in *CreateOrderOneRequest, opts ...grpc.CallOption) (*Response, error) WebAddressCreate(ctx context.Context, in *EditAddressRequest, opts ...grpc.CallOption) (*Response, error) WebAddressEdit(ctx context.Context, in *EditAddressRequest, opts ...grpc.CallOption) (*Response, error) - WebAddressStatus(ctx context.Context, in *StatusAddressRequest, opts ...grpc.CallOption) (*Response, error) - WebAddressDef(ctx context.Context, in *IdRequest, opts ...grpc.CallOption) (*Response, error) - WebAddressItems(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*Response, error) - WebCart(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*Response, error) + WebAddressDel(ctx context.Context, in *IdAndTypeRequest, opts ...grpc.CallOption) (*Response, error) + WebAddressDef(ctx context.Context, in *IdAndTypeRequest, opts ...grpc.CallOption) (*Response, error) + WebAddressInfo(ctx context.Context, in *IdAndTypeRequest, opts ...grpc.CallOption) (*Response, error) + WebAddressItems(ctx context.Context, in *TypeRequest, opts ...grpc.CallOption) (*Response, error) + WebCart(ctx context.Context, in *CartRequest, opts ...grpc.CallOption) (*Response, error) WebCartEdit(ctx context.Context, in *EditCartRequest, opts ...grpc.CallOption) (*Response, error) AddressItem(ctx context.Context, in *AddressItemsRequest, opts ...grpc.CallOption) (*Response, error) OrderAuditingItems(ctx context.Context, in *OrderAuditingItemsRequest, opts ...grpc.CallOption) (*Response, error) @@ -81,6 +85,16 @@ func (c *orderClient) WebCreate(ctx context.Context, in *CreateOrderRequest, opt return out, nil } +func (c *orderClient) WebCreateOne(ctx context.Context, in *CreateOrderOneRequest, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Order_WebCreateOne_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *orderClient) WebAddressCreate(ctx context.Context, in *EditAddressRequest, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) @@ -101,17 +115,17 @@ func (c *orderClient) WebAddressEdit(ctx context.Context, in *EditAddressRequest return out, nil } -func (c *orderClient) WebAddressStatus(ctx context.Context, in *StatusAddressRequest, opts ...grpc.CallOption) (*Response, error) { +func (c *orderClient) WebAddressDel(ctx context.Context, in *IdAndTypeRequest, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) - err := c.cc.Invoke(ctx, Order_WebAddressStatus_FullMethodName, in, out, cOpts...) + err := c.cc.Invoke(ctx, Order_WebAddressDel_FullMethodName, in, out, cOpts...) if err != nil { return nil, err } return out, nil } -func (c *orderClient) WebAddressDef(ctx context.Context, in *IdRequest, opts ...grpc.CallOption) (*Response, error) { +func (c *orderClient) WebAddressDef(ctx context.Context, in *IdAndTypeRequest, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) err := c.cc.Invoke(ctx, Order_WebAddressDef_FullMethodName, in, out, cOpts...) @@ -121,7 +135,17 @@ func (c *orderClient) WebAddressDef(ctx context.Context, in *IdRequest, opts ... return out, nil } -func (c *orderClient) WebAddressItems(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*Response, error) { +func (c *orderClient) WebAddressInfo(ctx context.Context, in *IdAndTypeRequest, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Order_WebAddressInfo_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *orderClient) WebAddressItems(ctx context.Context, in *TypeRequest, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) err := c.cc.Invoke(ctx, Order_WebAddressItems_FullMethodName, in, out, cOpts...) @@ -131,7 +155,7 @@ func (c *orderClient) WebAddressItems(ctx context.Context, in *EmptyRequest, opt return out, nil } -func (c *orderClient) WebCart(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*Response, error) { +func (c *orderClient) WebCart(ctx context.Context, in *CartRequest, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) err := c.cc.Invoke(ctx, Order_WebCart_FullMethodName, in, out, cOpts...) @@ -197,12 +221,14 @@ func (c *orderClient) OrderCreate(ctx context.Context, in *AdminCreateOrderReque type OrderServer interface { Items(context.Context, *OrderItemsRequest) (*Response, error) WebCreate(context.Context, *CreateOrderRequest) (*Response, error) + WebCreateOne(context.Context, *CreateOrderOneRequest) (*Response, error) WebAddressCreate(context.Context, *EditAddressRequest) (*Response, error) WebAddressEdit(context.Context, *EditAddressRequest) (*Response, error) - WebAddressStatus(context.Context, *StatusAddressRequest) (*Response, error) - WebAddressDef(context.Context, *IdRequest) (*Response, error) - WebAddressItems(context.Context, *EmptyRequest) (*Response, error) - WebCart(context.Context, *EmptyRequest) (*Response, error) + WebAddressDel(context.Context, *IdAndTypeRequest) (*Response, error) + WebAddressDef(context.Context, *IdAndTypeRequest) (*Response, error) + WebAddressInfo(context.Context, *IdAndTypeRequest) (*Response, error) + WebAddressItems(context.Context, *TypeRequest) (*Response, error) + WebCart(context.Context, *CartRequest) (*Response, error) WebCartEdit(context.Context, *EditCartRequest) (*Response, error) AddressItem(context.Context, *AddressItemsRequest) (*Response, error) OrderAuditingItems(context.Context, *OrderAuditingItemsRequest) (*Response, error) @@ -224,22 +250,28 @@ func (UnimplementedOrderServer) Items(context.Context, *OrderItemsRequest) (*Res func (UnimplementedOrderServer) WebCreate(context.Context, *CreateOrderRequest) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method WebCreate not implemented") } +func (UnimplementedOrderServer) WebCreateOne(context.Context, *CreateOrderOneRequest) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method WebCreateOne not implemented") +} func (UnimplementedOrderServer) WebAddressCreate(context.Context, *EditAddressRequest) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method WebAddressCreate not implemented") } func (UnimplementedOrderServer) WebAddressEdit(context.Context, *EditAddressRequest) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method WebAddressEdit not implemented") } -func (UnimplementedOrderServer) WebAddressStatus(context.Context, *StatusAddressRequest) (*Response, error) { - return nil, status.Error(codes.Unimplemented, "method WebAddressStatus not implemented") +func (UnimplementedOrderServer) WebAddressDel(context.Context, *IdAndTypeRequest) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method WebAddressDel not implemented") } -func (UnimplementedOrderServer) WebAddressDef(context.Context, *IdRequest) (*Response, error) { +func (UnimplementedOrderServer) WebAddressDef(context.Context, *IdAndTypeRequest) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method WebAddressDef not implemented") } -func (UnimplementedOrderServer) WebAddressItems(context.Context, *EmptyRequest) (*Response, error) { +func (UnimplementedOrderServer) WebAddressInfo(context.Context, *IdAndTypeRequest) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method WebAddressInfo not implemented") +} +func (UnimplementedOrderServer) WebAddressItems(context.Context, *TypeRequest) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method WebAddressItems not implemented") } -func (UnimplementedOrderServer) WebCart(context.Context, *EmptyRequest) (*Response, error) { +func (UnimplementedOrderServer) WebCart(context.Context, *CartRequest) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method WebCart not implemented") } func (UnimplementedOrderServer) WebCartEdit(context.Context, *EditCartRequest) (*Response, error) { @@ -314,6 +346,24 @@ func _Order_WebCreate_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _Order_WebCreateOne_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(CreateOrderOneRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OrderServer).WebCreateOne(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Order_WebCreateOne_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OrderServer).WebCreateOne(ctx, req.(*CreateOrderOneRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Order_WebAddressCreate_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(EditAddressRequest) if err := dec(in); err != nil { @@ -350,26 +400,26 @@ func _Order_WebAddressEdit_Handler(srv interface{}, ctx context.Context, dec fun return interceptor(ctx, in, info, handler) } -func _Order_WebAddressStatus_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(StatusAddressRequest) +func _Order_WebAddressDel_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(IdAndTypeRequest) if err := dec(in); err != nil { return nil, err } if interceptor == nil { - return srv.(OrderServer).WebAddressStatus(ctx, in) + return srv.(OrderServer).WebAddressDel(ctx, in) } info := &grpc.UnaryServerInfo{ Server: srv, - FullMethod: Order_WebAddressStatus_FullMethodName, + FullMethod: Order_WebAddressDel_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(OrderServer).WebAddressStatus(ctx, req.(*StatusAddressRequest)) + return srv.(OrderServer).WebAddressDel(ctx, req.(*IdAndTypeRequest)) } return interceptor(ctx, in, info, handler) } func _Order_WebAddressDef_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(IdRequest) + in := new(IdAndTypeRequest) if err := dec(in); err != nil { return nil, err } @@ -381,13 +431,31 @@ func _Order_WebAddressDef_Handler(srv interface{}, ctx context.Context, dec func FullMethod: Order_WebAddressDef_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(OrderServer).WebAddressDef(ctx, req.(*IdRequest)) + return srv.(OrderServer).WebAddressDef(ctx, req.(*IdAndTypeRequest)) + } + return interceptor(ctx, in, info, handler) +} + +func _Order_WebAddressInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(IdAndTypeRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OrderServer).WebAddressInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Order_WebAddressInfo_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OrderServer).WebAddressInfo(ctx, req.(*IdAndTypeRequest)) } return interceptor(ctx, in, info, handler) } func _Order_WebAddressItems_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(EmptyRequest) + in := new(TypeRequest) if err := dec(in); err != nil { return nil, err } @@ -399,13 +467,13 @@ func _Order_WebAddressItems_Handler(srv interface{}, ctx context.Context, dec fu FullMethod: Order_WebAddressItems_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(OrderServer).WebAddressItems(ctx, req.(*EmptyRequest)) + return srv.(OrderServer).WebAddressItems(ctx, req.(*TypeRequest)) } return interceptor(ctx, in, info, handler) } func _Order_WebCart_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(EmptyRequest) + in := new(CartRequest) if err := dec(in); err != nil { return nil, err } @@ -417,7 +485,7 @@ func _Order_WebCart_Handler(srv interface{}, ctx context.Context, dec func(inter FullMethod: Order_WebCart_FullMethodName, } handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(OrderServer).WebCart(ctx, req.(*EmptyRequest)) + return srv.(OrderServer).WebCart(ctx, req.(*CartRequest)) } return interceptor(ctx, in, info, handler) } @@ -527,6 +595,10 @@ var Order_ServiceDesc = grpc.ServiceDesc{ MethodName: "WebCreate", Handler: _Order_WebCreate_Handler, }, + { + MethodName: "WebCreateOne", + Handler: _Order_WebCreateOne_Handler, + }, { MethodName: "WebAddressCreate", Handler: _Order_WebAddressCreate_Handler, @@ -536,13 +608,17 @@ var Order_ServiceDesc = grpc.ServiceDesc{ Handler: _Order_WebAddressEdit_Handler, }, { - MethodName: "WebAddressStatus", - Handler: _Order_WebAddressStatus_Handler, + MethodName: "WebAddressDel", + Handler: _Order_WebAddressDel_Handler, }, { MethodName: "WebAddressDef", Handler: _Order_WebAddressDef_Handler, }, + { + MethodName: "WebAddressInfo", + Handler: _Order_WebAddressInfo_Handler, + }, { MethodName: "WebAddressItems", Handler: _Order_WebAddressItems_Handler, diff --git a/services/admin/internal/logic/admineditlogic.go b/services/admin/internal/logic/admineditlogic.go index 36c7a0c..7f28dc0 100644 --- a/services/admin/internal/logic/admineditlogic.go +++ b/services/admin/internal/logic/admineditlogic.go @@ -50,7 +50,7 @@ func (l *AdminEditLogic) AdminEdit(in *admin.AdminEditRequest) (*admin.Response, return l.fail(utils.ErrorEncryptAesError) } modelObj := model.AdminModel{}.Init() - var action = utils.ActionAdd{} + var action utils.ActionAdd if in.Id > utils.NumberZero && info.Id < utils.NumberOne { w := modelbase.Params{Eq: map[string]string{"id": strconv.Itoa(int(in.Id))}} info = dao.Admin{} diff --git a/services/lonelog/internal/logic/itemslogic.go b/services/lonelog/internal/logic/itemslogic.go index 7f15eb9..dc04683 100644 --- a/services/lonelog/internal/logic/itemslogic.go +++ b/services/lonelog/internal/logic/itemslogic.go @@ -55,10 +55,6 @@ func (l *ItemsLogic) Items(in *lonelog.ItemsRequest) (*lonelog.Response, error) w.Other["create_time < ?"] = in.Time[utils.NumberOne] } - if in.ServiceId > utils.NumberZero { - eq["service_id"] = strconv.FormatInt(in.ServiceId, utils.NumberTen) - } - w.Eq = eq var data []dao.ActionLog items, err := modelObj.Page(w, &data) diff --git a/services/order/internal/dao/address.go b/services/order/internal/dao/address.go index 4c40b7b..37e363a 100644 --- a/services/order/internal/dao/address.go +++ b/services/order/internal/dao/address.go @@ -1,25 +1,53 @@ package dao -const DeliveryAddressDefaultYes = 1 //默认 -const DeliveryAddressDefaultNo = 2 //不默认 -const DeliveryAddressTypeStore = 1 +const AddressDefaultYes = 1 //默认 +const AddressDefaultNo = 2 //不默认 +const AddressTypeStore = 1 +const AddressTypeSale = 2 +const AddressTypeUser = 3 type Address struct { Id int64 `json:"id" gorm:"id"` TargetId int64 `json:"target_id" gorm:"target_id"` // 对象ID District string `json:"district" gorm:"district"` // 地区 DistrictIds string `json:"district_ids" gorm:"district_ids"` // 地区IDS - Default int32 `json:"default" gorm:"default"` // 默认:1为默认,2为不默认 - Address string `json:"address" gorm:"address"` // 地址 - SaleId int64 `json:"sale_id" gorm:"sale_id"` // 销售ID - GroupId int64 `json:"group_id" gorm:"group_id"` // 分组ID - Name string `json:"name" gorm:"name"` // 收货人姓名 - Mobile string `json:"mobile" gorm:"mobile"` // 收货人手机 - Type int32 `json:"type" gorm:"type"` // 类型 1门店 , 2销售,3为用户 - Status int32 `json:"status" gorm:"status"` // 状态,1是正常,2为申请,3为一审核,4为二审核中,5为拒绝申请,6为审核失败,7为删除 + Default uint8 `gorm:"column:default;type:tinyint(1);default:2;comment:默认:1为默认,2为不默认" json:"default"` + Address string `json:"address" gorm:"address"` // 地址 + SaleId int64 `json:"sale_id" gorm:"sale_id"` // 销售ID + GroupId int64 `json:"group_id" gorm:"group_id"` // 分组ID + Name string `json:"name" gorm:"name"` // 收货人姓名 + Mobile string `json:"mobile" gorm:"mobile"` // 收货人手机 + Type int32 `json:"type" gorm:"type"` // 类型 1门店 , 2销售,3为用户 + Status int32 `json:"status" gorm:"status"` // 状态,1是正常,2为申请,3为一审核,4为二审核中,5为拒绝申请,6为审核失败,7为删除 Reason string `json:"reason" gorm:"reason"` NewContent string `json:"new_content" gorm:"new_content"` // 编辑后的内容 TypeName string `json:"type_name" gorm:"type_name"` // 类型名 AdminId int64 `json:"admin_id" gorm:"admin_id"` AdminName string `json:"admin_name" gorm:"admin_name"` + AesMobile string `gorm:"-" json:"aes_mobile"` +} + +type AllDefault struct { + Default uint8 `gorm:"column:default;type:tinyint(1);default:2;comment:默认:1为默认,2为不默认" json:"default"` +} + +type Default struct { + Id int64 `json:"id" gorm:"id"` + Default uint8 `gorm:"column:default;type:tinyint(1);default:2;comment:默认:1为默认,2为不默认" json:"default"` +} + +type WebStatus struct { + Id int64 `json:"id" gorm:"id"` + Status int32 `json:"status" gorm:"status"` // 状态,1是正常,2为申请,3为一审核,4为二审核中,5为拒绝申请,6为审核失败,7为删除 +} + +type WebAddressInfo struct { + Id int64 `json:"id" gorm:"id"` + District string `json:"district" gorm:"district"` // 地区 + DistrictIds string `json:"district_ids" gorm:"district_ids"` // 地区IDS + Default uint8 `gorm:"column:default;type:tinyint(1);default:2;comment:默认:1为默认,2为不默认" json:"default"` + Address string `json:"address" gorm:"address"` // 地址 + Name string `json:"name" gorm:"name"` // 收货人姓名 + Mobile string `json:"mobile" gorm:"mobile"` // 收货人手机 + Status int32 `json:"status" gorm:"status"` // 状态,1是正常,2为申请,3为一审核,4为二审核中,5为拒绝申请,6为审核失败,7为删除 } diff --git a/services/order/internal/dao/cart.go b/services/order/internal/dao/cart.go index c18931a..55ca739 100644 --- a/services/order/internal/dao/cart.go +++ b/services/order/internal/dao/cart.go @@ -1,10 +1,18 @@ package dao +const CartTypeStore = 1 +const CartTypeSale = 2 +const CartTypeUser = 3 + type Cart struct { Id int64 `json:"id" gorm:"id"` Content string `json:"content" gorm:"content"` // 内容 StoreId int64 `json:"store_id" gorm:"store_id"` // 门店ID SaleId int64 `json:"sale_id" gorm:"sale_id"` // 销售ID - Type bool `json:"type" gorm:"type"` // 类型,1为门店添加,2为销售添加 + Type int8 `json:"type" gorm:"type"` // 类型,1为门店添加,2为销售添加 UserId int64 `json:"user_id" gorm:"user_id"` // 用户ID } + +type CartInfo struct { + Content string `json:"content" gorm:"content"` // 内容 +} diff --git a/services/order/internal/logic/addressItemLogic.go b/services/order/internal/logic/addressItemLogic.go index ab4730a..0dcf428 100644 --- a/services/order/internal/logic/addressItemLogic.go +++ b/services/order/internal/logic/addressItemLogic.go @@ -2,9 +2,13 @@ package logic import ( "context" - + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" "lone-services/rpc/order/pb" + "lone-services/services/order/internal/dao" + "lone-services/services/order/internal/model" "lone-services/services/order/internal/svc" + "strconv" "github.com/zeromicro/go-zero/core/logx" ) @@ -25,7 +29,63 @@ func NewAddressItemLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Addre } func (l *AddressItemLogic) AddressItem(in *order.AddressItemsRequest) (*order.Response, error) { - // todo: add your logic here and delete this line + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo) + } + var info []dao.Address + w := modelbase.Params{ + Page: int(in.Page), + Size: int(in.Size), + Order: "id desc", + } - return &order.Response{}, nil + w.Like = make(map[string]string) + w.Eq = make(map[string]string) + w.Other = make(map[string]string) + if len(in.Name) > utils.NumberZero { + w.Like["name LIKE ? "] = "%%" + in.Name + "%%" + } + //Time string + if len(in.Mobile) > utils.NumberZero { + phone := utils.GetSearchPhone(in.Mobile) + if len(phone) > utils.NumberZero { + w.Like["mobile LIKE ? "] = "%%" + phone + "%%" + } + } + if in.DistrictId > utils.NumberZero { + w.Other["FIND_IN_SET(?, district_ids)"] = strconv.FormatInt(in.DistrictId, utils.NumberTen) + } + if len(in.Name) > utils.NumberZero { + w.Eq["name"] = in.Name + } + if in.StoreId > utils.NumberZero { + w.Eq["target_id"] = strconv.FormatInt(in.StoreId, utils.NumberTen) + w.Eq["type"] = strconv.Itoa(dao.AddressTypeStore) + } + if in.SaleId > utils.NumberZero { + w.Eq["target_id"] = strconv.FormatInt(in.SaleId, utils.NumberTen) + w.Eq["type"] = strconv.Itoa(dao.AddressTypeSale) + } + + if len(in.Time) > utils.NumberZero { + w.Other["create_time > ?"] = in.Time[utils.NumberZero] + w.Other["create_time < ?"] = in.Time[utils.NumberOne] + } + + err := model.AddressModel{}.Init().Items(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.ErrorNotFund) + } + for key, v := range info { + mobile, aErr := utils.DecryptPhone(v.Mobile) + if aErr == nil { + info[key].AesMobile = v.Mobile + l.Logger.Error(mobile) + info[key].Mobile = utils.DecryptPhoneReplace(mobile) + l.Logger.Error(utils.DecryptPhoneReplace(mobile)) + } + } + return l.ok(info) } diff --git a/services/order/internal/logic/webAddressCreateLogic.go b/services/order/internal/logic/webAddressCreateLogic.go index 0f4a2d1..7ebe663 100644 --- a/services/order/internal/logic/webAddressCreateLogic.go +++ b/services/order/internal/logic/webAddressCreateLogic.go @@ -2,12 +2,14 @@ package logic import ( "context" + "lone-services/pkg/modelbase" "lone-services/pkg/utils" "lone-services/rpc/order/pb" "lone-services/services/order/internal/dao" "lone-services/services/order/internal/model" "lone-services/services/order/internal/svc" "lone-services/services/order/validator" + "strconv" jsoniter "github.com/json-iterator/go" "github.com/zeromicro/go-zero/core/logx" @@ -53,6 +55,10 @@ func (l *WebAddressCreateLogic) WebAddressCreate(in *order.EditAddressRequest) ( Mobile: encryPhone, Type: in.Type, Status: utils.StatusApply, + Default: dao.AddressDefaultNo, + } + if in.Type == dao.AddressTypeUser { + data.Status = utils.StatusOk } jsonStr, err := jsoniter.MarshalToString(data) @@ -66,13 +72,32 @@ func (l *WebAddressCreateLogic) WebAddressCreate(in *order.EditAddressRequest) ( data.GroupId = adminInfo.GroupId modelObj := model.AddressModel{}.Init() + modelObj.Begin() + if in.Default { + data.Default = dao.AddressDefaultYes + w := modelbase.Params{Eq: map[string]string{ + "target_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen), + "type": strconv.Itoa(int(in.Type)), + }} + + _, err = modelObj.Edit(w, &dao.AllDefault{ + Default: dao.AddressDefaultNo, + }) + if err != nil { + l.Logger.Error(err) + modelObj.Rollback() + return l.fail(utils.Fail) + } + } err = modelObj.Create(&data) if err != nil { l.Logger.Error(err) + modelObj.Rollback() return l.fail(utils.Fail) } - return l.ok(data.Id) + modelObj.Commit() + return l.ok(data.Id) } diff --git a/services/order/internal/logic/webAddressDefLogic.go b/services/order/internal/logic/webAddressDefLogic.go index 2891828..6abc488 100644 --- a/services/order/internal/logic/webAddressDefLogic.go +++ b/services/order/internal/logic/webAddressDefLogic.go @@ -2,6 +2,12 @@ package logic import ( "context" + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/services/order/internal/dao" + "lone-services/services/order/internal/model" + "lone-services/services/order/validator" + "strconv" "lone-services/rpc/order/pb" "lone-services/services/order/internal/svc" @@ -24,8 +30,56 @@ func NewWebAddressDefLogic(ctx context.Context, svcCtx *svc.ServiceContext) *Web } } -func (l *WebAddressDefLogic) WebAddressDef(in *order.IdRequest) (*order.Response, error) { - // todo: add your logic here and delete this line +func (l *WebAddressDefLogic) WebAddressDef(in *order.IdAndTypeRequest) (*order.Response, error) { + var v validator.AddressDefValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo) + } + + var info dao.Default + w := modelbase.Params{Eq: map[string]string{ + "Id": strconv.FormatInt(in.Id, utils.NumberTen), + "target_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen), + "type": strconv.Itoa(int(in.Type)), + }} + err := model.AddressModel{}.Init().GetOne(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.ErrorNotFund) + } + if info.Id < utils.NumberOne { + return l.fail(utils.ErrorNotFund) + } + + modelObj := model.AddressModel{}.Init() + + modelObj.Begin() + info.Default = dao.AddressDefaultYes + ww := modelbase.Params{Eq: map[string]string{ + "target_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen), + "type": strconv.Itoa(int(in.Type)), + }} + + _, err = modelObj.Edit(ww, &dao.AllDefault{ + Default: dao.AddressDefaultNo, + }) + if err != nil { + l.Logger.Error(err) + modelObj.Rollback() + return l.fail(utils.Fail) + } + _, err = modelObj.Edit(w, &info) + if err != nil { + l.Logger.Error(err) + modelObj.Rollback() + return l.fail(utils.Fail) + } + + modelObj.Commit() + return l.ok(info.Id) - return &order.Response{}, nil } diff --git a/services/order/internal/logic/webAddressDelLogic.go b/services/order/internal/logic/webAddressDelLogic.go new file mode 100644 index 0000000..a46a04a --- /dev/null +++ b/services/order/internal/logic/webAddressDelLogic.go @@ -0,0 +1,67 @@ +package logic + +import ( + "context" + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/services/order/internal/dao" + "lone-services/services/order/internal/model" + "lone-services/services/order/validator" + "strconv" + + "lone-services/rpc/order/pb" + "lone-services/services/order/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" +) + +type WebAddressDelLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + BaseLogic +} + +func NewWebAddressDelLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WebAddressDelLogic { + return &WebAddressDelLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *WebAddressDelLogic) WebAddressDel(in *order.IdAndTypeRequest) (*order.Response, error) { + var v validator.AddressDefValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo) + } + + var info dao.WebStatus + w := modelbase.Params{Eq: map[string]string{ + "id": strconv.FormatInt(in.Id, utils.NumberTen), + "target_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen), + "type": strconv.Itoa(int(in.Type)), + }} + err := model.AddressModel{}.Init().GetOne(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.ErrorNotFund) + } + if info.Id < utils.NumberOne { + return l.fail(utils.ErrorNotFund) + } + + modelObj := model.AddressModel{}.Init() + info.Status = utils.StatusDel + _, err = modelObj.Edit(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail) + } + + return l.ok(info.Id) +} diff --git a/services/order/internal/logic/webAddressEditLogic.go b/services/order/internal/logic/webAddressEditLogic.go index 3a7f38f..5756d11 100644 --- a/services/order/internal/logic/webAddressEditLogic.go +++ b/services/order/internal/logic/webAddressEditLogic.go @@ -2,10 +2,17 @@ package logic import ( "context" + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/services/order/internal/dao" + "lone-services/services/order/internal/model" + "lone-services/services/order/validator" + "strconv" "lone-services/rpc/order/pb" "lone-services/services/order/internal/svc" + jsoniter "github.com/json-iterator/go" "github.com/zeromicro/go-zero/core/logx" ) @@ -25,7 +32,84 @@ func NewWebAddressEditLogic(ctx context.Context, svcCtx *svc.ServiceContext) *We } func (l *WebAddressEditLogic) WebAddressEdit(in *order.EditAddressRequest) (*order.Response, error) { - // todo: add your logic here and delete this line + var v validator.AddressEditValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo) + } + encryPhone, cErr := utils.EncryptPhone(in.Mobile) + if cErr != nil { + l.Logger.Error(cErr) + return l.fail(utils.ErrorEncryptAesError) + } + + if in.Id < utils.NumberOne { + return l.out(utils.ErrorParams, "地址ID不能为空") + } + + var info dao.Address + w := modelbase.Params{Eq: map[string]string{ + "id": strconv.FormatInt(in.Id, utils.NumberTen), + "target_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen), + "type": strconv.Itoa(int(in.Type)), + }} + err := model.AddressModel{}.Init().GetOne(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.ErrorNotFund) + } + if info.Id < utils.NumberOne { + return l.fail(utils.ErrorNotFund) + } + + if info.Type == dao.AddressTypeUser { + info.District = in.District + info.DistrictIds = in.DistrictIds + info.Address = in.Address + info.Name = in.Name + info.Mobile = encryPhone + info.Status = utils.StatusOk + } else { + jsonStr, err := jsoniter.MarshalToString(v) + if err != nil { + l.Logger.Error("转换失败:", err) + return l.fail(utils.ErrorJsonDataError) + } + info.NewContent = jsonStr + info.Status = utils.StatusApply + } + + info.Default = dao.AddressDefaultNo + modelObj := model.AddressModel{}.Init() + + modelObj.Begin() + if in.Default { + info.Default = dao.AddressDefaultYes + ww := modelbase.Params{Eq: map[string]string{ + "target_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen), + "type": strconv.Itoa(int(in.Type)), + }} + + _, err = modelObj.Edit(ww, &dao.AllDefault{ + Default: dao.AddressDefaultNo, + }) + if err != nil { + l.Logger.Error(err) + modelObj.Rollback() + return l.fail(utils.Fail) + } + } + _, err = modelObj.Edit(w, &info) + if err != nil { + l.Logger.Error(err) + modelObj.Rollback() + return l.fail(utils.Fail) + } + + modelObj.Commit() + return l.ok(info.Id) - return &order.Response{}, nil } diff --git a/services/order/internal/logic/webAddressInfoLogic.go b/services/order/internal/logic/webAddressInfoLogic.go new file mode 100644 index 0000000..352e983 --- /dev/null +++ b/services/order/internal/logic/webAddressInfoLogic.go @@ -0,0 +1,62 @@ +package logic + +import ( + "context" + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/services/order/internal/dao" + "lone-services/services/order/internal/model" + "lone-services/services/order/validator" + "strconv" + + "lone-services/rpc/order/pb" + "lone-services/services/order/internal/svc" + + "github.com/zeromicro/go-zero/core/logx" +) + +type WebAddressInfoLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger + BaseLogic +} + +func NewWebAddressInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WebAddressInfoLogic { + return &WebAddressInfoLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *WebAddressInfoLogic) WebAddressInfo(in *order.IdAndTypeRequest) (*order.Response, error) { + var v validator.AddressDefValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo) + } + var info dao.WebAddressInfo + w := modelbase.Params{ + Order: "`default` asc, `status` desc", + Not: map[string]string{"status": strconv.Itoa(utils.StatusDel)}, + Eq: map[string]string{ + "id": strconv.FormatInt(in.Id, utils.NumberTen), + "target_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen), + "type": strconv.Itoa(int(in.Type))}, + } + + err := model.AddressModel{}.Init().GetOne(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.ErrorNotFund) + } + mobile, aErr := utils.DecryptPhone(info.Mobile) + if aErr == nil { + info.Mobile = mobile + } + return l.ok(info) +} diff --git a/services/order/internal/logic/webAddressItemsLogic.go b/services/order/internal/logic/webAddressItemsLogic.go index d26e863..1004cab 100644 --- a/services/order/internal/logic/webAddressItemsLogic.go +++ b/services/order/internal/logic/webAddressItemsLogic.go @@ -2,6 +2,12 @@ package logic import ( "context" + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/services/order/internal/dao" + "lone-services/services/order/internal/model" + "lone-services/services/order/validator" + "strconv" "lone-services/rpc/order/pb" "lone-services/services/order/internal/svc" @@ -24,8 +30,34 @@ func NewWebAddressItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *W } } -func (l *WebAddressItemsLogic) WebAddressItems(in *order.EmptyRequest) (*order.Response, error) { - // todo: add your logic here and delete this line +func (l *WebAddressItemsLogic) WebAddressItems(in *order.TypeRequest) (*order.Response, error) { + var v validator.WebAddressItemsValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo) + } + var info []dao.WebAddressInfo + w := modelbase.Params{ + Order: "`default` asc, `status` desc", + Not: map[string]string{"status": strconv.Itoa(utils.StatusDel)}, + Eq: map[string]string{ + "target_id": strconv.FormatInt(adminInfo.ID, utils.NumberTen), + "type": strconv.Itoa(int(in.Type))}, + } - return &order.Response{}, nil + err := model.AddressModel{}.Init().Items(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.ErrorNotFund) + } + for key, v := range info { + mobile, aErr := utils.DecryptPhone(v.Mobile) + if aErr == nil { + info[key].Mobile = mobile + } + } + return l.ok(info) } diff --git a/services/order/internal/logic/webCartEditLogic.go b/services/order/internal/logic/webCartEditLogic.go index 0d46507..6b8389d 100644 --- a/services/order/internal/logic/webCartEditLogic.go +++ b/services/order/internal/logic/webCartEditLogic.go @@ -2,9 +2,14 @@ package logic import ( "context" - + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" "lone-services/rpc/order/pb" + "lone-services/services/order/internal/dao" + "lone-services/services/order/internal/model" "lone-services/services/order/internal/svc" + "lone-services/services/order/validator" + "strconv" "github.com/zeromicro/go-zero/core/logx" ) @@ -25,7 +30,56 @@ func NewWebCartEditLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WebCa } func (l *WebCartEditLogic) WebCartEdit(in *order.EditCartRequest) (*order.Response, error) { - // todo: add your logic here and delete this line + var v validator.CartEditValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo) + } + var info dao.Cart + w := modelbase.Params{ + Eq: map[string]string{ + "type": strconv.Itoa(int(in.Type)), + }, + } + switch in.Type { + case dao.CartTypeSale: + w.Eq["sale_id"] = strconv.FormatInt(adminInfo.ID, utils.NumberTen) + case dao.CartTypeUser: + w.Eq["user_id"] = strconv.FormatInt(adminInfo.ID, utils.NumberTen) + case dao.CartTypeStore: + w.Eq["store_id"] = strconv.FormatInt(adminInfo.ID, utils.NumberTen) + } - return &order.Response{}, nil + mobileObj := model.CartModel{}.Init() + err := mobileObj.GetOne(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.ErrorNotFund) + } + + info.Content = in.Info + info.Type = int8(in.Type) + switch in.Type { + case dao.CartTypeSale: + info.SaleId = adminInfo.ID + case dao.CartTypeUser: + info.UserId = adminInfo.ID + case dao.CartTypeStore: + info.StoreId = adminInfo.ID + } + + if info.Id < utils.NumberOne { + err = mobileObj.Create(&info) + } else { + _, err = mobileObj.Edit(w, &info) + } + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail) + } + + return l.ok(utils.NumberOne) } diff --git a/services/order/internal/logic/webCartLogic.go b/services/order/internal/logic/webCartLogic.go index 2cf3e03..0bdacd3 100644 --- a/services/order/internal/logic/webCartLogic.go +++ b/services/order/internal/logic/webCartLogic.go @@ -2,6 +2,12 @@ package logic import ( "context" + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/services/order/internal/dao" + "lone-services/services/order/internal/model" + "lone-services/services/order/validator" + "strconv" "lone-services/rpc/order/pb" "lone-services/services/order/internal/svc" @@ -24,8 +30,39 @@ func NewWebCartLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WebCartLo } } -func (l *WebCartLogic) WebCart(in *order.EmptyRequest) (*order.Response, error) { - // todo: add your logic here and delete this line +func (l *WebCartLogic) WebCart(in *order.CartRequest) (*order.Response, error) { + var v validator.CartValidator + if fail := l.checkParams(in, &v); fail != nil { + return fail, nil + } + adminInfo := utils.GetUserFromCtx(l.ctx) + if adminInfo.ID < utils.NumberOne { + return l.fail(utils.ErrorNoLoginInfo) + } + var info dao.CartInfo + w := modelbase.Params{ + Eq: map[string]string{ + "type": strconv.Itoa(int(in.Type)), + }, + } + switch in.Type { + case dao.CartTypeSale: + w.Eq["sale_id"] = strconv.FormatInt(adminInfo.ID, utils.NumberTen) + case dao.CartTypeUser: + w.Eq["user_id"] = strconv.FormatInt(adminInfo.ID, utils.NumberTen) + case dao.CartTypeStore: + w.Eq["store_id"] = strconv.FormatInt(adminInfo.ID, utils.NumberTen) + } - return &order.Response{}, nil + err := model.CartModel{}.Init().GetOne(w, &info) + if err != nil { + l.Logger.Error(err) + return l.fail(utils.ErrorNotFund) + } + if err != nil { + l.Logger.Error(err) + return l.fail(utils.Fail) + } + + return l.ok(info) } diff --git a/services/order/internal/logic/webAddressStatusLogic.go b/services/order/internal/logic/webCreateOneLogic.go similarity index 56% rename from services/order/internal/logic/webAddressStatusLogic.go rename to services/order/internal/logic/webCreateOneLogic.go index 563903f..a57acdf 100644 --- a/services/order/internal/logic/webAddressStatusLogic.go +++ b/services/order/internal/logic/webCreateOneLogic.go @@ -9,22 +9,21 @@ import ( "github.com/zeromicro/go-zero/core/logx" ) -type WebAddressStatusLogic struct { +type WebCreateOneLogic struct { ctx context.Context svcCtx *svc.ServiceContext logx.Logger - BaseLogic } -func NewWebAddressStatusLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WebAddressStatusLogic { - return &WebAddressStatusLogic{ +func NewWebCreateOneLogic(ctx context.Context, svcCtx *svc.ServiceContext) *WebCreateOneLogic { + return &WebCreateOneLogic{ ctx: ctx, svcCtx: svcCtx, Logger: logx.WithContext(ctx), } } -func (l *WebAddressStatusLogic) WebAddressStatus(in *order.StatusAddressRequest) (*order.Response, error) { +func (l *WebCreateOneLogic) WebCreateOne(in *order.CreateOrderOneRequest) (*order.Response, error) { // todo: add your logic here and delete this line return &order.Response{}, nil diff --git a/services/order/internal/server/orderServer.go b/services/order/internal/server/orderServer.go index 62f445f..04ae1a8 100644 --- a/services/order/internal/server/orderServer.go +++ b/services/order/internal/server/orderServer.go @@ -33,6 +33,11 @@ func (s *OrderServer) WebCreate(ctx context.Context, in *order.CreateOrderReques return l.WebCreate(in) } +func (s *OrderServer) WebCreateOne(ctx context.Context, in *order.CreateOrderOneRequest) (*order.Response, error) { + l := logic.NewWebCreateOneLogic(ctx, s.svcCtx) + return l.WebCreateOne(in) +} + func (s *OrderServer) WebAddressCreate(ctx context.Context, in *order.EditAddressRequest) (*order.Response, error) { l := logic.NewWebAddressCreateLogic(ctx, s.svcCtx) return l.WebAddressCreate(in) @@ -43,22 +48,27 @@ func (s *OrderServer) WebAddressEdit(ctx context.Context, in *order.EditAddressR return l.WebAddressEdit(in) } -func (s *OrderServer) WebAddressStatus(ctx context.Context, in *order.StatusAddressRequest) (*order.Response, error) { - l := logic.NewWebAddressStatusLogic(ctx, s.svcCtx) - return l.WebAddressStatus(in) +func (s *OrderServer) WebAddressDel(ctx context.Context, in *order.IdAndTypeRequest) (*order.Response, error) { + l := logic.NewWebAddressDelLogic(ctx, s.svcCtx) + return l.WebAddressDel(in) } -func (s *OrderServer) WebAddressDef(ctx context.Context, in *order.IdRequest) (*order.Response, error) { +func (s *OrderServer) WebAddressDef(ctx context.Context, in *order.IdAndTypeRequest) (*order.Response, error) { l := logic.NewWebAddressDefLogic(ctx, s.svcCtx) return l.WebAddressDef(in) } -func (s *OrderServer) WebAddressItems(ctx context.Context, in *order.EmptyRequest) (*order.Response, error) { +func (s *OrderServer) WebAddressInfo(ctx context.Context, in *order.IdAndTypeRequest) (*order.Response, error) { + l := logic.NewWebAddressInfoLogic(ctx, s.svcCtx) + return l.WebAddressInfo(in) +} + +func (s *OrderServer) WebAddressItems(ctx context.Context, in *order.TypeRequest) (*order.Response, error) { l := logic.NewWebAddressItemsLogic(ctx, s.svcCtx) return l.WebAddressItems(in) } -func (s *OrderServer) WebCart(ctx context.Context, in *order.EmptyRequest) (*order.Response, error) { +func (s *OrderServer) WebCart(ctx context.Context, in *order.CartRequest) (*order.Response, error) { l := logic.NewWebCartLogic(ctx, s.svcCtx) return l.WebCart(in) } diff --git a/services/order/orderClient/order.go b/services/order/orderClient/order.go index 3b01251..fa85849 100644 --- a/services/order/orderClient/order.go +++ b/services/order/orderClient/order.go @@ -16,26 +16,32 @@ import ( type ( AddressItemsRequest = order.AddressItemsRequest AdminCreateOrderRequest = order.AdminCreateOrderRequest + CartRequest = order.CartRequest + CreateOrderOneRequest = order.CreateOrderOneRequest CreateOrderRequest = order.CreateOrderRequest EditAddressRequest = order.EditAddressRequest EditCartRequest = order.EditCartRequest EmptyRequest = order.EmptyRequest + IdAndTypeRequest = order.IdAndTypeRequest IdRequest = order.IdRequest OrderAuditingItemsRequest = order.OrderAuditingItemsRequest OrderAuditingRequest = order.OrderAuditingRequest OrderItemsRequest = order.OrderItemsRequest Response = order.Response StatusAddressRequest = order.StatusAddressRequest + TypeRequest = order.TypeRequest Order interface { Items(ctx context.Context, in *OrderItemsRequest, opts ...grpc.CallOption) (*Response, error) WebCreate(ctx context.Context, in *CreateOrderRequest, opts ...grpc.CallOption) (*Response, error) + WebCreateOne(ctx context.Context, in *CreateOrderOneRequest, opts ...grpc.CallOption) (*Response, error) WebAddressCreate(ctx context.Context, in *EditAddressRequest, opts ...grpc.CallOption) (*Response, error) WebAddressEdit(ctx context.Context, in *EditAddressRequest, opts ...grpc.CallOption) (*Response, error) - WebAddressStatus(ctx context.Context, in *StatusAddressRequest, opts ...grpc.CallOption) (*Response, error) - WebAddressDef(ctx context.Context, in *IdRequest, opts ...grpc.CallOption) (*Response, error) - WebAddressItems(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*Response, error) - WebCart(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*Response, error) + WebAddressDel(ctx context.Context, in *IdAndTypeRequest, opts ...grpc.CallOption) (*Response, error) + WebAddressDef(ctx context.Context, in *IdAndTypeRequest, opts ...grpc.CallOption) (*Response, error) + WebAddressInfo(ctx context.Context, in *IdAndTypeRequest, opts ...grpc.CallOption) (*Response, error) + WebAddressItems(ctx context.Context, in *TypeRequest, opts ...grpc.CallOption) (*Response, error) + WebCart(ctx context.Context, in *CartRequest, opts ...grpc.CallOption) (*Response, error) WebCartEdit(ctx context.Context, in *EditCartRequest, opts ...grpc.CallOption) (*Response, error) AddressItem(ctx context.Context, in *AddressItemsRequest, opts ...grpc.CallOption) (*Response, error) OrderAuditingItems(ctx context.Context, in *OrderAuditingItemsRequest, opts ...grpc.CallOption) (*Response, error) @@ -64,6 +70,11 @@ func (m *defaultOrder) WebCreate(ctx context.Context, in *CreateOrderRequest, op return client.WebCreate(ctx, in, opts...) } +func (m *defaultOrder) WebCreateOne(ctx context.Context, in *CreateOrderOneRequest, opts ...grpc.CallOption) (*Response, error) { + client := order.NewOrderClient(m.cli.Conn()) + return client.WebCreateOne(ctx, in, opts...) +} + func (m *defaultOrder) WebAddressCreate(ctx context.Context, in *EditAddressRequest, opts ...grpc.CallOption) (*Response, error) { client := order.NewOrderClient(m.cli.Conn()) return client.WebAddressCreate(ctx, in, opts...) @@ -74,22 +85,27 @@ func (m *defaultOrder) WebAddressEdit(ctx context.Context, in *EditAddressReques return client.WebAddressEdit(ctx, in, opts...) } -func (m *defaultOrder) WebAddressStatus(ctx context.Context, in *StatusAddressRequest, opts ...grpc.CallOption) (*Response, error) { +func (m *defaultOrder) WebAddressDel(ctx context.Context, in *IdAndTypeRequest, opts ...grpc.CallOption) (*Response, error) { client := order.NewOrderClient(m.cli.Conn()) - return client.WebAddressStatus(ctx, in, opts...) + return client.WebAddressDel(ctx, in, opts...) } -func (m *defaultOrder) WebAddressDef(ctx context.Context, in *IdRequest, opts ...grpc.CallOption) (*Response, error) { +func (m *defaultOrder) WebAddressDef(ctx context.Context, in *IdAndTypeRequest, opts ...grpc.CallOption) (*Response, error) { client := order.NewOrderClient(m.cli.Conn()) return client.WebAddressDef(ctx, in, opts...) } -func (m *defaultOrder) WebAddressItems(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*Response, error) { +func (m *defaultOrder) WebAddressInfo(ctx context.Context, in *IdAndTypeRequest, opts ...grpc.CallOption) (*Response, error) { + client := order.NewOrderClient(m.cli.Conn()) + return client.WebAddressInfo(ctx, in, opts...) +} + +func (m *defaultOrder) WebAddressItems(ctx context.Context, in *TypeRequest, opts ...grpc.CallOption) (*Response, error) { client := order.NewOrderClient(m.cli.Conn()) return client.WebAddressItems(ctx, in, opts...) } -func (m *defaultOrder) WebCart(ctx context.Context, in *EmptyRequest, opts ...grpc.CallOption) (*Response, error) { +func (m *defaultOrder) WebCart(ctx context.Context, in *CartRequest, opts ...grpc.CallOption) (*Response, error) { client := order.NewOrderClient(m.cli.Conn()) return client.WebCart(ctx, in, opts...) } diff --git a/services/order/validator/address.go b/services/order/validator/address.go index ae36a94..5b897c0 100644 --- a/services/order/validator/address.go +++ b/services/order/validator/address.go @@ -4,28 +4,33 @@ import "lone-services/pkg/validate" // AddressDefValidator 查看列表 type AddressDefValidator struct { - Id int64 `validate:"required"` + Id int64 `validate:"required"` + Type int32 `validate:"required,oneof=1 2 3"` //类型 1门店 , 2销售,3为用户 } // GetMessage 查看列表 - 提示消息 func (p AddressDefValidator) GetMessage() validate.ValidatorMessages { return validate.ValidatorMessages{ - "Id.required": "Id不能为空", + "Id.required": "Id不能为空", + "Type.required": "类型不能为空", + "Type.oneof": "类型不对", } } // AddressStatusValidator 查看列表 type AddressStatusValidator struct { - Id int64 `validate:"required"` - Status int32 `validate:"required,oneof=1 2"` + Id int64 `validate:"required"` + Status int32 `validate:"required,oneof=1 2"` + Reason string `validate:"required_if=Status 2"` } // GetMessage 查看列表 - 提示消息 func (p AddressStatusValidator) GetMessage() validate.ValidatorMessages { return validate.ValidatorMessages{ - "Id.required": "Id不能为空", - "Status.required": "状态不能为空", - "Status.oneof": "状态不对", + "Id.required": "Id不能为空", + "Status.required": "状态不能为空", + "Status.oneof": "状态不对", + "Reason.required_if": "理由不能为空", } } @@ -34,7 +39,7 @@ type AddressEditValidator struct { District string `validate:"required"` Address string `validate:"required"` Name string `validate:"required"` - Mobile string `validate:"required"` + Mobile string `validate:"required,mobile"` DistrictIds string `validate:"required"` Type int32 `validate:"required,oneof=1 2 3"` //类型 1门店 , 2销售,3为用户 Default bool @@ -47,6 +52,7 @@ func (p AddressEditValidator) GetMessage() validate.ValidatorMessages { "Address.required": "地址不能为空", "Name.required": "姓名不能为空", "Mobile.required": "手机不能为空", + "Mobile.mobile": "手机号不对", "DistrictIds.required": "区域ID不能为空", "Type.required": "类型不能为空", "Type.oneof": "类型不对", @@ -67,3 +73,16 @@ type AdminAddressItemsValidator struct { func (p AdminAddressItemsValidator) GetMessage() validate.ValidatorMessages { return validate.ValidatorMessages{} } + +type WebAddressItemsValidator struct { + Type int32 `validate:"required,oneof=1 2 3"` //类型 1门店 , 2销售,3为用户 + +} + +// GetMessage 查看列表 - 提示消息 +func (p WebAddressItemsValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Type.required": "类型不能为空", + "Type.oneof": "类型不对", + } +} diff --git a/services/order/validator/cart.go b/services/order/validator/cart.go index 2bac657..a89bbe1 100644 --- a/services/order/validator/cart.go +++ b/services/order/validator/cart.go @@ -4,10 +4,28 @@ import "lone-services/pkg/validate" // CartEditValidator 查看列表 type CartEditValidator struct { - Info string + Info string `validate:"required"` + Type int32 `validate:"required,oneof=1 2 3"` //类型 1门店 , 2销售,3为用户 } // GetMessage 查看列表 - 提示消息 func (p CartEditValidator) GetMessage() validate.ValidatorMessages { - return validate.ValidatorMessages{} + return validate.ValidatorMessages{ + "Info.required": "类型不能为空", + "Type.required": "类型不能为空", + "Type.oneof": "类型不对", + } +} + +type CartValidator struct { + Type int32 `validate:"required,oneof=1 2 3"` //类型 1门店 , 2销售,3为用户 + +} + +// GetMessage 查看列表 - 提示消息 +func (p CartValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Type.required": "类型不能为空", + "Type.oneof": "类型不对", + } }