diff --git a/rpc/order/order.pb b/rpc/order/order.pb index 52f9de1..b3d78a6 100644 Binary files a/rpc/order/order.pb and b/rpc/order/order.pb differ diff --git a/rpc/order/order.proto b/rpc/order/order.proto index 7496079..930e09c 100644 --- a/rpc/order/order.proto +++ b/rpc/order/order.proto @@ -158,6 +158,15 @@ message GetOrderInfoRequest { int32 type = 3; } +message ExistByStoreProductReq { + int64 store_id = 1; + int64 product_id = 2; +} + +message ExistByStoreProductResp { + bool exist = 1; +} + message OrderInfoResponse { int64 id =1; string order_sn = 2; @@ -301,6 +310,8 @@ service order { rpc GetOrderInfo(GetOrderInfoRequest) returns(OrderInfoResponse); //status 1 为已支付 4 支付失败,其它的返回错误 rpc UpdateOrderPayStatus(UpdateOrderPayStatusRequest) returns(UpdateOrderPayStatusResponse); + // 门店是否存在指定产品的有效/待支付订单(内部) + rpc ExistByStoreProduct(ExistByStoreProductReq) returns(ExistByStoreProductResp); /*****************API**********************/ rpc ApiSupply(ApiSupplyRequest) returns(Response){ diff --git a/rpc/order/pb/order.pb.go b/rpc/order/pb/order.pb.go index 70c549b..1983b2f 100644 --- a/rpc/order/pb/order.pb.go +++ b/rpc/order/pb/order.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.11 -// protoc v4.25.8 +// protoc v3.19.4 // source: order/order.proto package order @@ -1530,6 +1530,102 @@ func (x *GetOrderInfoRequest) GetType() int32 { return 0 } +type ExistByStoreProductReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + StoreId int64 `protobuf:"varint,1,opt,name=store_id,json=storeId,proto3" json:"store_id,omitempty"` + ProductId int64 `protobuf:"varint,2,opt,name=product_id,json=productId,proto3" json:"product_id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExistByStoreProductReq) Reset() { + *x = ExistByStoreProductReq{} + mi := &file_order_order_proto_msgTypes[25] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExistByStoreProductReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExistByStoreProductReq) ProtoMessage() {} + +func (x *ExistByStoreProductReq) ProtoReflect() protoreflect.Message { + mi := &file_order_order_proto_msgTypes[25] + 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 ExistByStoreProductReq.ProtoReflect.Descriptor instead. +func (*ExistByStoreProductReq) Descriptor() ([]byte, []int) { + return file_order_order_proto_rawDescGZIP(), []int{25} +} + +func (x *ExistByStoreProductReq) GetStoreId() int64 { + if x != nil { + return x.StoreId + } + return 0 +} + +func (x *ExistByStoreProductReq) GetProductId() int64 { + if x != nil { + return x.ProductId + } + return 0 +} + +type ExistByStoreProductResp struct { + state protoimpl.MessageState `protogen:"open.v1"` + Exist bool `protobuf:"varint,1,opt,name=exist,proto3" json:"exist,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ExistByStoreProductResp) Reset() { + *x = ExistByStoreProductResp{} + mi := &file_order_order_proto_msgTypes[26] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ExistByStoreProductResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ExistByStoreProductResp) ProtoMessage() {} + +func (x *ExistByStoreProductResp) ProtoReflect() protoreflect.Message { + mi := &file_order_order_proto_msgTypes[26] + 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 ExistByStoreProductResp.ProtoReflect.Descriptor instead. +func (*ExistByStoreProductResp) Descriptor() ([]byte, []int) { + return file_order_order_proto_rawDescGZIP(), []int{26} +} + +func (x *ExistByStoreProductResp) GetExist() bool { + if x != nil { + return x.Exist + } + return false +} + type OrderInfoResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` @@ -1565,7 +1661,7 @@ type OrderInfoResponse struct { func (x *OrderInfoResponse) Reset() { *x = OrderInfoResponse{} - mi := &file_order_order_proto_msgTypes[25] + mi := &file_order_order_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1577,7 +1673,7 @@ func (x *OrderInfoResponse) String() string { func (*OrderInfoResponse) ProtoMessage() {} func (x *OrderInfoResponse) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[25] + mi := &file_order_order_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1590,7 +1686,7 @@ func (x *OrderInfoResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use OrderInfoResponse.ProtoReflect.Descriptor instead. func (*OrderInfoResponse) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{25} + return file_order_order_proto_rawDescGZIP(), []int{27} } func (x *OrderInfoResponse) GetId() int64 { @@ -1796,7 +1892,7 @@ type ProductItemsResponse struct { func (x *ProductItemsResponse) Reset() { *x = ProductItemsResponse{} - mi := &file_order_order_proto_msgTypes[26] + mi := &file_order_order_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1808,7 +1904,7 @@ func (x *ProductItemsResponse) String() string { func (*ProductItemsResponse) ProtoMessage() {} func (x *ProductItemsResponse) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[26] + mi := &file_order_order_proto_msgTypes[28] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1821,7 +1917,7 @@ func (x *ProductItemsResponse) ProtoReflect() protoreflect.Message { // Deprecated: Use ProductItemsResponse.ProtoReflect.Descriptor instead. func (*ProductItemsResponse) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{26} + return file_order_order_proto_rawDescGZIP(), []int{28} } func (x *ProductItemsResponse) GetId() int64 { @@ -1878,7 +1974,7 @@ type ApiSupplyRequest struct { func (x *ApiSupplyRequest) Reset() { *x = ApiSupplyRequest{} - mi := &file_order_order_proto_msgTypes[27] + mi := &file_order_order_proto_msgTypes[29] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1890,7 +1986,7 @@ func (x *ApiSupplyRequest) String() string { func (*ApiSupplyRequest) ProtoMessage() {} func (x *ApiSupplyRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[27] + mi := &file_order_order_proto_msgTypes[29] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1903,7 +1999,7 @@ func (x *ApiSupplyRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use ApiSupplyRequest.ProtoReflect.Descriptor instead. func (*ApiSupplyRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{27} + return file_order_order_proto_rawDescGZIP(), []int{29} } func (x *ApiSupplyRequest) GetOrderSn() string { @@ -1947,7 +2043,7 @@ type WebSaleItemsRequest struct { func (x *WebSaleItemsRequest) Reset() { *x = WebSaleItemsRequest{} - mi := &file_order_order_proto_msgTypes[28] + mi := &file_order_order_proto_msgTypes[30] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1959,7 +2055,7 @@ func (x *WebSaleItemsRequest) String() string { func (*WebSaleItemsRequest) ProtoMessage() {} func (x *WebSaleItemsRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[28] + mi := &file_order_order_proto_msgTypes[30] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1972,7 +2068,7 @@ func (x *WebSaleItemsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use WebSaleItemsRequest.ProtoReflect.Descriptor instead. func (*WebSaleItemsRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{28} + return file_order_order_proto_rawDescGZIP(), []int{30} } func (x *WebSaleItemsRequest) GetPage() int32 { @@ -2022,7 +2118,7 @@ type WebStoreItemsRequest struct { func (x *WebStoreItemsRequest) Reset() { *x = WebStoreItemsRequest{} - mi := &file_order_order_proto_msgTypes[29] + mi := &file_order_order_proto_msgTypes[31] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2034,7 +2130,7 @@ func (x *WebStoreItemsRequest) String() string { func (*WebStoreItemsRequest) ProtoMessage() {} func (x *WebStoreItemsRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[29] + mi := &file_order_order_proto_msgTypes[31] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2047,7 +2143,7 @@ func (x *WebStoreItemsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use WebStoreItemsRequest.ProtoReflect.Descriptor instead. func (*WebStoreItemsRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{29} + return file_order_order_proto_rawDescGZIP(), []int{31} } func (x *WebStoreItemsRequest) GetPage() int32 { @@ -2089,7 +2185,7 @@ type StatusRequest struct { func (x *StatusRequest) Reset() { *x = StatusRequest{} - mi := &file_order_order_proto_msgTypes[30] + mi := &file_order_order_proto_msgTypes[32] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2101,7 +2197,7 @@ func (x *StatusRequest) String() string { func (*StatusRequest) ProtoMessage() {} func (x *StatusRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[30] + mi := &file_order_order_proto_msgTypes[32] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2114,7 +2210,7 @@ func (x *StatusRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use StatusRequest.ProtoReflect.Descriptor instead. func (*StatusRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{30} + return file_order_order_proto_rawDescGZIP(), []int{32} } func (x *StatusRequest) GetId() int64 { @@ -2151,7 +2247,7 @@ type SupplyItemsRequest struct { func (x *SupplyItemsRequest) Reset() { *x = SupplyItemsRequest{} - mi := &file_order_order_proto_msgTypes[31] + mi := &file_order_order_proto_msgTypes[33] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -2163,7 +2259,7 @@ func (x *SupplyItemsRequest) String() string { func (*SupplyItemsRequest) ProtoMessage() {} func (x *SupplyItemsRequest) ProtoReflect() protoreflect.Message { - mi := &file_order_order_proto_msgTypes[31] + mi := &file_order_order_proto_msgTypes[33] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -2176,7 +2272,7 @@ func (x *SupplyItemsRequest) ProtoReflect() protoreflect.Message { // Deprecated: Use SupplyItemsRequest.ProtoReflect.Descriptor instead. func (*SupplyItemsRequest) Descriptor() ([]byte, []int) { - return file_order_order_proto_rawDescGZIP(), []int{31} + return file_order_order_proto_rawDescGZIP(), []int{33} } func (x *SupplyItemsRequest) GetPage() int32 { @@ -2325,7 +2421,13 @@ const file_order_order_proto_rawDesc = "" + "\x13GetOrderInfoRequest\x12\x17\n" + "\auser_id\x18\x01 \x01(\x03R\x06userId\x12\x19\n" + "\border_sn\x18\x02 \x01(\tR\aorderSn\x12\x12\n" + - "\x04type\x18\x03 \x01(\x05R\x04type\"\xc5\x06\n" + + "\x04type\x18\x03 \x01(\x05R\x04type\"R\n" + + "\x16ExistByStoreProductReq\x12\x19\n" + + "\bstore_id\x18\x01 \x01(\x03R\astoreId\x12\x1d\n" + + "\n" + + "product_id\x18\x02 \x01(\x03R\tproductId\"/\n" + + "\x17ExistByStoreProductResp\x12\x14\n" + + "\x05exist\x18\x01 \x01(\bR\x05exist\"\xc5\x06\n" + "\x11OrderInfoResponse\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x19\n" + "\border_sn\x18\x02 \x01(\tR\aorderSn\x12\x19\n" + @@ -2394,7 +2496,7 @@ const file_order_order_proto_rawDesc = "" + "\x04size\x18\x02 \x01(\x05R\x04size\x12\x19\n" + "\border_sn\x18\x03 \x01(\tR\aorderSn\x12\x12\n" + "\x04time\x18\x04 \x03(\tR\x04time\x12\x16\n" + - "\x06status\x18\x05 \x01(\x05R\x06status2\xd6\x14\n" + + "\x06status\x18\x05 \x01(\x05R\x06status2\xac\x15\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\x12^\n" + "\vAddressItem\x12\x1a.order.AddressItemsRequest\x1a\x0f.order.Response\"\"\x82\xd3\xe4\x93\x02\x1c:\x01*\x12\x17/admin/v3/address/items\x12n\n" + @@ -2410,6 +2512,7 @@ const file_order_order_proto_rawDesc = "" + "\x18UpdateOrderDeliverStatus\x12&.order.UpdateOrderDeliverStatusRequest\x1a'.order.UpdateOrderDeliverStatusResponse\x12D\n" + "\fGetOrderInfo\x12\x1a.order.GetOrderInfoRequest\x1a\x18.order.OrderInfoResponse\x12_\n" + "\x14UpdateOrderPayStatus\x12\".order.UpdateOrderPayStatusRequest\x1a#.order.UpdateOrderPayStatusResponse\x12T\n" + + "\x13ExistByStoreProduct\x12\x1d.order.ExistByStoreProductReq\x1a\x1e.order.ExistByStoreProductResp\x12T\n" + "\tApiSupply\x12\x17.order.ApiSupplyRequest\x1a\x0f.order.Response\"\x1d\x82\xd3\xe4\x93\x02\x17:\x01*\x12\x12/api/v3/supply/add\x12]\n" + "\rApiSupplyInfo\x12\x1b.order.ApiSupplyInfoRequest\x1a\x0f.order.Response\"\x1e\x82\xd3\xe4\x93\x02\x18:\x01*\x12\x13/api/v3/supply/info\x12X\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" + @@ -2437,7 +2540,7 @@ func file_order_order_proto_rawDescGZIP() []byte { return file_order_order_proto_rawDescData } -var file_order_order_proto_msgTypes = make([]protoimpl.MessageInfo, 32) +var file_order_order_proto_msgTypes = make([]protoimpl.MessageInfo, 34) var file_order_order_proto_goTypes = []any{ (*OrderItemsRequest)(nil), // 0: order.OrderItemsRequest (*Response)(nil), // 1: order.Response @@ -2464,16 +2567,18 @@ var file_order_order_proto_goTypes = []any{ (*UpdateAddressSaleInfoResponse)(nil), // 22: order.UpdateAddressSaleInfoResponse (*UpdateAddressSaleInfoRequest)(nil), // 23: order.UpdateAddressSaleInfoRequest (*GetOrderInfoRequest)(nil), // 24: order.GetOrderInfoRequest - (*OrderInfoResponse)(nil), // 25: order.OrderInfoResponse - (*ProductItemsResponse)(nil), // 26: order.ProductItemsResponse - (*ApiSupplyRequest)(nil), // 27: order.ApiSupplyRequest - (*WebSaleItemsRequest)(nil), // 28: order.WebSaleItemsRequest - (*WebStoreItemsRequest)(nil), // 29: order.WebStoreItemsRequest - (*StatusRequest)(nil), // 30: order.StatusRequest - (*SupplyItemsRequest)(nil), // 31: order.SupplyItemsRequest + (*ExistByStoreProductReq)(nil), // 25: order.ExistByStoreProductReq + (*ExistByStoreProductResp)(nil), // 26: order.ExistByStoreProductResp + (*OrderInfoResponse)(nil), // 27: order.OrderInfoResponse + (*ProductItemsResponse)(nil), // 28: order.ProductItemsResponse + (*ApiSupplyRequest)(nil), // 29: order.ApiSupplyRequest + (*WebSaleItemsRequest)(nil), // 30: order.WebSaleItemsRequest + (*WebStoreItemsRequest)(nil), // 31: order.WebStoreItemsRequest + (*StatusRequest)(nil), // 32: order.StatusRequest + (*SupplyItemsRequest)(nil), // 33: order.SupplyItemsRequest } var file_order_order_proto_depIdxs = []int32{ - 26, // 0: order.OrderInfoResponse.product_items:type_name -> order.ProductItemsResponse + 28, // 0: order.OrderInfoResponse.product_items:type_name -> order.ProductItemsResponse 0, // 1: order.order.Items:input_type -> order.OrderItemsRequest 13, // 2: order.order.AddressItem:input_type -> order.AddressItemsRequest 14, // 3: order.order.AddressByStore:input_type -> order.AddressByStoreItemsRequest @@ -2482,56 +2587,58 @@ var file_order_order_proto_depIdxs = []int32{ 17, // 6: order.order.OrderCreate:input_type -> order.AdminCreateOrderRequest 0, // 7: order.order.OrderDown:input_type -> order.OrderItemsRequest 9, // 8: order.order.OrderInfo:input_type -> order.IdRequest - 31, // 9: order.order.SupplyItems:input_type -> order.SupplyItemsRequest - 30, // 10: order.order.SupplyStatus:input_type -> order.StatusRequest + 33, // 9: order.order.SupplyItems:input_type -> order.SupplyItemsRequest + 32, // 10: order.order.SupplyStatus:input_type -> order.StatusRequest 23, // 11: order.order.UpdateAddressSaleInfo:input_type -> order.UpdateAddressSaleInfoRequest 18, // 12: order.order.UpdateOrderDeliverStatus:input_type -> order.UpdateOrderDeliverStatusRequest 24, // 13: order.order.GetOrderInfo:input_type -> order.GetOrderInfoRequest 19, // 14: order.order.UpdateOrderPayStatus:input_type -> order.UpdateOrderPayStatusRequest - 27, // 15: order.order.ApiSupply:input_type -> order.ApiSupplyRequest - 10, // 16: order.order.ApiSupplyInfo:input_type -> order.ApiSupplyInfoRequest - 3, // 17: order.order.WebCreate:input_type -> order.CreateOrderRequest - 4, // 18: order.order.WebCreateOne:input_type -> order.CreateOrderOneRequest - 5, // 19: order.order.WebAddressCreate:input_type -> order.EditAddressRequest - 5, // 20: order.order.WebAddressEdit:input_type -> order.EditAddressRequest - 11, // 21: order.order.WebAddressDel:input_type -> order.IdAndTypeRequest - 11, // 22: order.order.WebAddressDef:input_type -> order.IdAndTypeRequest - 11, // 23: order.order.WebAddressInfo:input_type -> order.IdAndTypeRequest - 12, // 24: order.order.WebAddressItems:input_type -> order.TypeRequest - 8, // 25: order.order.WebCart:input_type -> order.CartRequest - 7, // 26: order.order.WebCartEdit:input_type -> order.EditCartRequest - 28, // 27: order.order.WebSaleItems:input_type -> order.WebSaleItemsRequest - 29, // 28: order.order.WebStoreItems:input_type -> order.WebStoreItemsRequest - 1, // 29: order.order.Items:output_type -> order.Response - 1, // 30: order.order.AddressItem:output_type -> order.Response - 1, // 31: order.order.AddressByStore:output_type -> order.Response - 1, // 32: order.order.OrderAuditingItems:output_type -> order.Response - 1, // 33: order.order.OrderAuditing:output_type -> order.Response - 1, // 34: order.order.OrderCreate:output_type -> order.Response - 2, // 35: order.order.OrderDown:output_type -> order.ExcelExportResponse - 1, // 36: order.order.OrderInfo:output_type -> order.Response - 1, // 37: order.order.SupplyItems:output_type -> order.Response - 1, // 38: order.order.SupplyStatus:output_type -> order.Response - 22, // 39: order.order.UpdateAddressSaleInfo:output_type -> order.UpdateAddressSaleInfoResponse - 21, // 40: order.order.UpdateOrderDeliverStatus:output_type -> order.UpdateOrderDeliverStatusResponse - 25, // 41: order.order.GetOrderInfo:output_type -> order.OrderInfoResponse - 20, // 42: order.order.UpdateOrderPayStatus:output_type -> order.UpdateOrderPayStatusResponse - 1, // 43: order.order.ApiSupply:output_type -> order.Response - 1, // 44: order.order.ApiSupplyInfo:output_type -> order.Response - 1, // 45: order.order.WebCreate:output_type -> order.Response - 1, // 46: order.order.WebCreateOne:output_type -> order.Response - 1, // 47: order.order.WebAddressCreate:output_type -> order.Response - 1, // 48: order.order.WebAddressEdit:output_type -> order.Response - 1, // 49: order.order.WebAddressDel:output_type -> order.Response - 1, // 50: order.order.WebAddressDef:output_type -> order.Response - 1, // 51: order.order.WebAddressInfo:output_type -> order.Response - 1, // 52: order.order.WebAddressItems:output_type -> order.Response - 1, // 53: order.order.WebCart:output_type -> order.Response - 1, // 54: order.order.WebCartEdit:output_type -> order.Response - 1, // 55: order.order.WebSaleItems:output_type -> order.Response - 1, // 56: order.order.WebStoreItems:output_type -> order.Response - 29, // [29:57] is the sub-list for method output_type - 1, // [1:29] is the sub-list for method input_type + 25, // 15: order.order.ExistByStoreProduct:input_type -> order.ExistByStoreProductReq + 29, // 16: order.order.ApiSupply:input_type -> order.ApiSupplyRequest + 10, // 17: order.order.ApiSupplyInfo:input_type -> order.ApiSupplyInfoRequest + 3, // 18: order.order.WebCreate:input_type -> order.CreateOrderRequest + 4, // 19: order.order.WebCreateOne:input_type -> order.CreateOrderOneRequest + 5, // 20: order.order.WebAddressCreate:input_type -> order.EditAddressRequest + 5, // 21: order.order.WebAddressEdit:input_type -> order.EditAddressRequest + 11, // 22: order.order.WebAddressDel:input_type -> order.IdAndTypeRequest + 11, // 23: order.order.WebAddressDef:input_type -> order.IdAndTypeRequest + 11, // 24: order.order.WebAddressInfo:input_type -> order.IdAndTypeRequest + 12, // 25: order.order.WebAddressItems:input_type -> order.TypeRequest + 8, // 26: order.order.WebCart:input_type -> order.CartRequest + 7, // 27: order.order.WebCartEdit:input_type -> order.EditCartRequest + 30, // 28: order.order.WebSaleItems:input_type -> order.WebSaleItemsRequest + 31, // 29: order.order.WebStoreItems:input_type -> order.WebStoreItemsRequest + 1, // 30: order.order.Items:output_type -> order.Response + 1, // 31: order.order.AddressItem:output_type -> order.Response + 1, // 32: order.order.AddressByStore:output_type -> order.Response + 1, // 33: order.order.OrderAuditingItems:output_type -> order.Response + 1, // 34: order.order.OrderAuditing:output_type -> order.Response + 1, // 35: order.order.OrderCreate:output_type -> order.Response + 2, // 36: order.order.OrderDown:output_type -> order.ExcelExportResponse + 1, // 37: order.order.OrderInfo:output_type -> order.Response + 1, // 38: order.order.SupplyItems:output_type -> order.Response + 1, // 39: order.order.SupplyStatus:output_type -> order.Response + 22, // 40: order.order.UpdateAddressSaleInfo:output_type -> order.UpdateAddressSaleInfoResponse + 21, // 41: order.order.UpdateOrderDeliverStatus:output_type -> order.UpdateOrderDeliverStatusResponse + 27, // 42: order.order.GetOrderInfo:output_type -> order.OrderInfoResponse + 20, // 43: order.order.UpdateOrderPayStatus:output_type -> order.UpdateOrderPayStatusResponse + 26, // 44: order.order.ExistByStoreProduct:output_type -> order.ExistByStoreProductResp + 1, // 45: order.order.ApiSupply:output_type -> order.Response + 1, // 46: order.order.ApiSupplyInfo:output_type -> order.Response + 1, // 47: order.order.WebCreate:output_type -> order.Response + 1, // 48: order.order.WebCreateOne:output_type -> order.Response + 1, // 49: order.order.WebAddressCreate:output_type -> order.Response + 1, // 50: order.order.WebAddressEdit:output_type -> order.Response + 1, // 51: order.order.WebAddressDel:output_type -> order.Response + 1, // 52: order.order.WebAddressDef:output_type -> order.Response + 1, // 53: order.order.WebAddressInfo:output_type -> order.Response + 1, // 54: order.order.WebAddressItems:output_type -> order.Response + 1, // 55: order.order.WebCart:output_type -> order.Response + 1, // 56: order.order.WebCartEdit:output_type -> order.Response + 1, // 57: order.order.WebSaleItems:output_type -> order.Response + 1, // 58: order.order.WebStoreItems:output_type -> order.Response + 30, // [30:59] is the sub-list for method output_type + 1, // [1:30] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name @@ -2548,7 +2655,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: 32, + NumMessages: 34, NumExtensions: 0, NumServices: 1, }, diff --git a/rpc/order/pb/order_grpc.pb.go b/rpc/order/pb/order_grpc.pb.go index a9780b6..56a570d 100644 --- a/rpc/order/pb/order_grpc.pb.go +++ b/rpc/order/pb/order_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.6.2 -// - protoc v4.25.8 +// - protoc v3.19.4 // source: order/order.proto package order @@ -33,6 +33,7 @@ const ( Order_UpdateOrderDeliverStatus_FullMethodName = "/order.order/UpdateOrderDeliverStatus" Order_GetOrderInfo_FullMethodName = "/order.order/GetOrderInfo" Order_UpdateOrderPayStatus_FullMethodName = "/order.order/UpdateOrderPayStatus" + Order_ExistByStoreProduct_FullMethodName = "/order.order/ExistByStoreProduct" Order_ApiSupply_FullMethodName = "/order.order/ApiSupply" Order_ApiSupplyInfo_FullMethodName = "/order.order/ApiSupplyInfo" Order_WebCreate_FullMethodName = "/order.order/WebCreate" @@ -69,6 +70,8 @@ type OrderClient interface { GetOrderInfo(ctx context.Context, in *GetOrderInfoRequest, opts ...grpc.CallOption) (*OrderInfoResponse, error) // status 1 为已支付 4 支付失败,其它的返回错误 UpdateOrderPayStatus(ctx context.Context, in *UpdateOrderPayStatusRequest, opts ...grpc.CallOption) (*UpdateOrderPayStatusResponse, error) + // 门店是否存在指定产品的有效/待支付订单(内部) + ExistByStoreProduct(ctx context.Context, in *ExistByStoreProductReq, opts ...grpc.CallOption) (*ExistByStoreProductResp, error) // ****************API********************* ApiSupply(ctx context.Context, in *ApiSupplyRequest, opts ...grpc.CallOption) (*Response, error) ApiSupplyInfo(ctx context.Context, in *ApiSupplyInfoRequest, opts ...grpc.CallOption) (*Response, error) @@ -234,6 +237,16 @@ func (c *orderClient) UpdateOrderPayStatus(ctx context.Context, in *UpdateOrderP return out, nil } +func (c *orderClient) ExistByStoreProduct(ctx context.Context, in *ExistByStoreProductReq, opts ...grpc.CallOption) (*ExistByStoreProductResp, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(ExistByStoreProductResp) + err := c.cc.Invoke(ctx, Order_ExistByStoreProduct_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *orderClient) ApiSupply(ctx context.Context, in *ApiSupplyRequest, opts ...grpc.CallOption) (*Response, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(Response) @@ -394,6 +407,8 @@ type OrderServer interface { GetOrderInfo(context.Context, *GetOrderInfoRequest) (*OrderInfoResponse, error) // status 1 为已支付 4 支付失败,其它的返回错误 UpdateOrderPayStatus(context.Context, *UpdateOrderPayStatusRequest) (*UpdateOrderPayStatusResponse, error) + // 门店是否存在指定产品的有效/待支付订单(内部) + ExistByStoreProduct(context.Context, *ExistByStoreProductReq) (*ExistByStoreProductResp, error) // ****************API********************* ApiSupply(context.Context, *ApiSupplyRequest) (*Response, error) ApiSupplyInfo(context.Context, *ApiSupplyInfoRequest) (*Response, error) @@ -461,6 +476,9 @@ func (UnimplementedOrderServer) GetOrderInfo(context.Context, *GetOrderInfoReque func (UnimplementedOrderServer) UpdateOrderPayStatus(context.Context, *UpdateOrderPayStatusRequest) (*UpdateOrderPayStatusResponse, error) { return nil, status.Error(codes.Unimplemented, "method UpdateOrderPayStatus not implemented") } +func (UnimplementedOrderServer) ExistByStoreProduct(context.Context, *ExistByStoreProductReq) (*ExistByStoreProductResp, error) { + return nil, status.Error(codes.Unimplemented, "method ExistByStoreProduct not implemented") +} func (UnimplementedOrderServer) ApiSupply(context.Context, *ApiSupplyRequest) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method ApiSupply not implemented") } @@ -776,6 +794,24 @@ func _Order_UpdateOrderPayStatus_Handler(srv interface{}, ctx context.Context, d return interceptor(ctx, in, info, handler) } +func _Order_ExistByStoreProduct_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ExistByStoreProductReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(OrderServer).ExistByStoreProduct(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Order_ExistByStoreProduct_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(OrderServer).ExistByStoreProduct(ctx, req.(*ExistByStoreProductReq)) + } + return interceptor(ctx, in, info, handler) +} + func _Order_ApiSupply_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(ApiSupplyRequest) if err := dec(in); err != nil { @@ -1091,6 +1127,10 @@ var Order_ServiceDesc = grpc.ServiceDesc{ MethodName: "UpdateOrderPayStatus", Handler: _Order_UpdateOrderPayStatus_Handler, }, + { + MethodName: "ExistByStoreProduct", + Handler: _Order_ExistByStoreProduct_Handler, + }, { MethodName: "ApiSupply", Handler: _Order_ApiSupply_Handler, diff --git a/rpc/product/pb/product.pb.go b/rpc/product/pb/product.pb.go index 58e288f..ce3a6eb 100644 --- a/rpc/product/pb/product.pb.go +++ b/rpc/product/pb/product.pb.go @@ -1420,6 +1420,275 @@ func (x *NumberAddReq) GetNumber() uint32 { return 0 } +type ApiItemsReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ApiItemsReq) Reset() { + *x = ApiItemsReq{} + mi := &file_product_product_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ApiItemsReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApiItemsReq) ProtoMessage() {} + +func (x *ApiItemsReq) ProtoReflect() protoreflect.Message { + mi := &file_product_product_proto_msgTypes[20] + 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 ApiItemsReq.ProtoReflect.Descriptor instead. +func (*ApiItemsReq) Descriptor() ([]byte, []int) { + return file_product_product_proto_rawDescGZIP(), []int{20} +} + +func (x *ApiItemsReq) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +type ApiInfoReq struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ApiInfoReq) Reset() { + *x = ApiInfoReq{} + mi := &file_product_product_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ApiInfoReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApiInfoReq) ProtoMessage() {} + +func (x *ApiInfoReq) ProtoReflect() protoreflect.Message { + mi := &file_product_product_proto_msgTypes[21] + 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 ApiInfoReq.ProtoReflect.Descriptor instead. +func (*ApiInfoReq) Descriptor() ([]byte, []int) { + return file_product_product_proto_rawDescGZIP(), []int{21} +} + +func (x *ApiInfoReq) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +// C 端产品字段(对齐老 ProductWebInfo) +type ApiItem struct { + state protoimpl.MessageState `protogen:"open.v1"` + Id int64 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"` + Name string `protobuf:"bytes,2,opt,name=name,proto3" json:"name,omitempty"` + Subhead string `protobuf:"bytes,3,opt,name=subhead,proto3" json:"subhead,omitempty"` + Content string `protobuf:"bytes,4,opt,name=content,proto3" json:"content,omitempty"` + ModelCode string `protobuf:"bytes,5,opt,name=model_code,json=modelCode,proto3" json:"model_code,omitempty"` + Price float64 `protobuf:"fixed64,6,opt,name=price,proto3" json:"price,omitempty"` + StorePrice float64 `protobuf:"fixed64,7,opt,name=store_price,json=storePrice,proto3" json:"store_price,omitempty"` + SalePrice float64 `protobuf:"fixed64,8,opt,name=sale_price,json=salePrice,proto3" json:"sale_price,omitempty"` + Images []string `protobuf:"bytes,9,rep,name=images,proto3" json:"images,omitempty"` + Label string `protobuf:"bytes,10,opt,name=label,proto3" json:"label,omitempty"` + IsBuy uint32 `protobuf:"varint,11,opt,name=is_buy,json=isBuy,proto3" json:"is_buy,omitempty"` + PeriodValidity int32 `protobuf:"varint,12,opt,name=period_validity,json=periodValidity,proto3" json:"period_validity,omitempty"` + IsIndex uint32 `protobuf:"varint,13,opt,name=is_index,json=isIndex,proto3" json:"is_index,omitempty"` + IndexImage string `protobuf:"bytes,14,opt,name=index_image,json=indexImage,proto3" json:"index_image,omitempty"` + Type uint32 `protobuf:"varint,15,opt,name=type,proto3" json:"type,omitempty"` + NormsNumber uint32 `protobuf:"varint,16,opt,name=norms_number,json=normsNumber,proto3" json:"norms_number,omitempty"` + Number uint32 `protobuf:"varint,17,opt,name=number,proto3" json:"number,omitempty"` + IsPermit uint32 `protobuf:"varint,18,opt,name=is_permit,json=isPermit,proto3" json:"is_permit,omitempty"` + unknownFields protoimpl.UnknownFields + sizeCache protoimpl.SizeCache +} + +func (x *ApiItem) Reset() { + *x = ApiItem{} + mi := &file_product_product_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) +} + +func (x *ApiItem) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*ApiItem) ProtoMessage() {} + +func (x *ApiItem) ProtoReflect() protoreflect.Message { + mi := &file_product_product_proto_msgTypes[22] + 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 ApiItem.ProtoReflect.Descriptor instead. +func (*ApiItem) Descriptor() ([]byte, []int) { + return file_product_product_proto_rawDescGZIP(), []int{22} +} + +func (x *ApiItem) GetId() int64 { + if x != nil { + return x.Id + } + return 0 +} + +func (x *ApiItem) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +func (x *ApiItem) GetSubhead() string { + if x != nil { + return x.Subhead + } + return "" +} + +func (x *ApiItem) GetContent() string { + if x != nil { + return x.Content + } + return "" +} + +func (x *ApiItem) GetModelCode() string { + if x != nil { + return x.ModelCode + } + return "" +} + +func (x *ApiItem) GetPrice() float64 { + if x != nil { + return x.Price + } + return 0 +} + +func (x *ApiItem) GetStorePrice() float64 { + if x != nil { + return x.StorePrice + } + return 0 +} + +func (x *ApiItem) GetSalePrice() float64 { + if x != nil { + return x.SalePrice + } + return 0 +} + +func (x *ApiItem) GetImages() []string { + if x != nil { + return x.Images + } + return nil +} + +func (x *ApiItem) GetLabel() string { + if x != nil { + return x.Label + } + return "" +} + +func (x *ApiItem) GetIsBuy() uint32 { + if x != nil { + return x.IsBuy + } + return 0 +} + +func (x *ApiItem) GetPeriodValidity() int32 { + if x != nil { + return x.PeriodValidity + } + return 0 +} + +func (x *ApiItem) GetIsIndex() uint32 { + if x != nil { + return x.IsIndex + } + return 0 +} + +func (x *ApiItem) GetIndexImage() string { + if x != nil { + return x.IndexImage + } + return "" +} + +func (x *ApiItem) GetType() uint32 { + if x != nil { + return x.Type + } + return 0 +} + +func (x *ApiItem) GetNormsNumber() uint32 { + if x != nil { + return x.NormsNumber + } + return 0 +} + +func (x *ApiItem) GetNumber() uint32 { + if x != nil { + return x.Number + } + return 0 +} + +func (x *ApiItem) GetIsPermit() uint32 { + if x != nil { + return x.IsPermit + } + return 0 +} + type ItemsData struct { state protoimpl.MessageState `protogen:"open.v1"` Count int64 `protobuf:"varint,1,opt,name=count,proto3" json:"count,omitempty"` @@ -1430,7 +1699,7 @@ type ItemsData struct { func (x *ItemsData) Reset() { *x = ItemsData{} - mi := &file_product_product_proto_msgTypes[20] + mi := &file_product_product_proto_msgTypes[23] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1442,7 +1711,7 @@ func (x *ItemsData) String() string { func (*ItemsData) ProtoMessage() {} func (x *ItemsData) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[20] + mi := &file_product_product_proto_msgTypes[23] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1455,7 +1724,7 @@ func (x *ItemsData) ProtoReflect() protoreflect.Message { // Deprecated: Use ItemsData.ProtoReflect.Descriptor instead. func (*ItemsData) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{20} + return file_product_product_proto_rawDescGZIP(), []int{23} } func (x *ItemsData) GetCount() int64 { @@ -1482,7 +1751,7 @@ type VerifyItemsData struct { func (x *VerifyItemsData) Reset() { *x = VerifyItemsData{} - mi := &file_product_product_proto_msgTypes[21] + mi := &file_product_product_proto_msgTypes[24] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1494,7 +1763,7 @@ func (x *VerifyItemsData) String() string { func (*VerifyItemsData) ProtoMessage() {} func (x *VerifyItemsData) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[21] + mi := &file_product_product_proto_msgTypes[24] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1507,7 +1776,7 @@ func (x *VerifyItemsData) ProtoReflect() protoreflect.Message { // Deprecated: Use VerifyItemsData.ProtoReflect.Descriptor instead. func (*VerifyItemsData) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{21} + return file_product_product_proto_rawDescGZIP(), []int{24} } func (x *VerifyItemsData) GetCount() int64 { @@ -1544,7 +1813,7 @@ type VerifyParams struct { func (x *VerifyParams) Reset() { *x = VerifyParams{} - mi := &file_product_product_proto_msgTypes[22] + mi := &file_product_product_proto_msgTypes[25] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1556,7 +1825,7 @@ func (x *VerifyParams) String() string { func (*VerifyParams) ProtoMessage() {} func (x *VerifyParams) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[22] + mi := &file_product_product_proto_msgTypes[25] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1569,7 +1838,7 @@ func (x *VerifyParams) ProtoReflect() protoreflect.Message { // Deprecated: Use VerifyParams.ProtoReflect.Descriptor instead. func (*VerifyParams) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{22} + return file_product_product_proto_rawDescGZIP(), []int{25} } func (x *VerifyParams) GetId() int64 { @@ -1668,7 +1937,7 @@ type VerifyItem struct { func (x *VerifyItem) Reset() { *x = VerifyItem{} - mi := &file_product_product_proto_msgTypes[23] + mi := &file_product_product_proto_msgTypes[26] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1680,7 +1949,7 @@ func (x *VerifyItem) String() string { func (*VerifyItem) ProtoMessage() {} func (x *VerifyItem) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[23] + mi := &file_product_product_proto_msgTypes[26] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1693,7 +1962,7 @@ func (x *VerifyItem) ProtoReflect() protoreflect.Message { // Deprecated: Use VerifyItem.ProtoReflect.Descriptor instead. func (*VerifyItem) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{23} + return file_product_product_proto_rawDescGZIP(), []int{26} } func (x *VerifyItem) GetName() string { @@ -1734,7 +2003,7 @@ type NameItem struct { func (x *NameItem) Reset() { *x = NameItem{} - mi := &file_product_product_proto_msgTypes[24] + mi := &file_product_product_proto_msgTypes[27] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1746,7 +2015,7 @@ func (x *NameItem) String() string { func (*NameItem) ProtoMessage() {} func (x *NameItem) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[24] + mi := &file_product_product_proto_msgTypes[27] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1759,7 +2028,7 @@ func (x *NameItem) ProtoReflect() protoreflect.Message { // Deprecated: Use NameItem.ProtoReflect.Descriptor instead. func (*NameItem) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{24} + return file_product_product_proto_rawDescGZIP(), []int{27} } func (x *NameItem) GetId() int64 { @@ -1820,7 +2089,7 @@ type Item struct { func (x *Item) Reset() { *x = Item{} - mi := &file_product_product_proto_msgTypes[25] + mi := &file_product_product_proto_msgTypes[28] ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) ms.StoreMessageInfo(mi) } @@ -1832,7 +2101,7 @@ func (x *Item) String() string { func (*Item) ProtoMessage() {} func (x *Item) ProtoReflect() protoreflect.Message { - mi := &file_product_product_proto_msgTypes[25] + mi := &file_product_product_proto_msgTypes[28] if x != nil { ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) if ms.LoadMessageInfo() == nil { @@ -1845,7 +2114,7 @@ func (x *Item) ProtoReflect() protoreflect.Message { // Deprecated: Use Item.ProtoReflect.Descriptor instead. func (*Item) Descriptor() ([]byte, []int) { - return file_product_product_proto_rawDescGZIP(), []int{25} + return file_product_product_proto_rawDescGZIP(), []int{28} } func (x *Item) GetId() int64 { @@ -2231,7 +2500,36 @@ const file_product_product_proto_rawDesc = "" + "\x05items\x18\x02 \x03(\v2\x13.product.NumberItemR\x05items\"6\n" + "\fNumberAddReq\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x16\n" + - "\x06number\x18\x02 \x01(\rR\x06number\"F\n" + + "\x06number\x18\x02 \x01(\rR\x06number\"!\n" + + "\vApiItemsReq\x12\x12\n" + + "\x04name\x18\x01 \x01(\tR\x04name\"\x1c\n" + + "\n" + + "ApiInfoReq\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\"\xec\x03\n" + + "\aApiItem\x12\x0e\n" + + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x12\n" + + "\x04name\x18\x02 \x01(\tR\x04name\x12\x18\n" + + "\asubhead\x18\x03 \x01(\tR\asubhead\x12\x18\n" + + "\acontent\x18\x04 \x01(\tR\acontent\x12\x1d\n" + + "\n" + + "model_code\x18\x05 \x01(\tR\tmodelCode\x12\x14\n" + + "\x05price\x18\x06 \x01(\x01R\x05price\x12\x1f\n" + + "\vstore_price\x18\a \x01(\x01R\n" + + "storePrice\x12\x1d\n" + + "\n" + + "sale_price\x18\b \x01(\x01R\tsalePrice\x12\x16\n" + + "\x06images\x18\t \x03(\tR\x06images\x12\x14\n" + + "\x05label\x18\n" + + " \x01(\tR\x05label\x12\x15\n" + + "\x06is_buy\x18\v \x01(\rR\x05isBuy\x12'\n" + + "\x0fperiod_validity\x18\f \x01(\x05R\x0eperiodValidity\x12\x19\n" + + "\bis_index\x18\r \x01(\rR\aisIndex\x12\x1f\n" + + "\vindex_image\x18\x0e \x01(\tR\n" + + "indexImage\x12\x12\n" + + "\x04type\x18\x0f \x01(\rR\x04type\x12!\n" + + "\fnorms_number\x18\x10 \x01(\rR\vnormsNumber\x12\x16\n" + + "\x06number\x18\x11 \x01(\rR\x06number\x12\x1b\n" + + "\tis_permit\x18\x12 \x01(\rR\bisPermit\"F\n" + "\tItemsData\x12\x14\n" + "\x05count\x18\x01 \x01(\x03R\x05count\x12#\n" + "\x05items\x18\x02 \x03(\v2\r.product.ItemR\x05items\"R\n" + @@ -2317,7 +2615,7 @@ const file_product_product_proto_rawDesc = "" + "\x06reason\x18\" \x01(\tR\x06reason\x12\x1d\n" + "\n" + "admin_name\x18# \x01(\tR\tadminName\x12\x12\n" + - "\x04edit\x18$ \x01(\rR\x04edit2\xe8\v\n" + + "\x04edit\x18$ \x01(\rR\x04edit2\x8d\r\n" + "\aProduct\x12M\n" + "\x06Create\x12\x12.product.CreateReq\x1a\x11.product.Response\"\x1c\x82\xd3\xe4\x93\x02\x16:\x01*\"\x11/admin/v3/product\x12N\n" + "\x04Info\x12\x10.product.InfoReq\x1a\x11.product.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\x12\x16/admin/v3/product/info\x12K\n" + @@ -2331,13 +2629,15 @@ const file_product_product_proto_rawDesc = "" + "\tEditApply\x12\x15.product.EditApplyReq\x1a\x11.product.Response\"'\x82\xd3\xe4\x93\x02!:\x01*\"\x1c/admin/v3/product/edit/apply\x12V\n" + "\bEditBase\x12\x14.product.EditBaseReq\x1a\x11.product.Response\"!\x82\xd3\xe4\x93\x02\x1b:\x01*\x1a\x16/admin/v3/product/base\x12k\n" + "\x0fEditSusceptible\x12\x1b.product.EditSusceptibleReq\x1a\x11.product.Response\"(\x82\xd3\xe4\x93\x02\":\x01*\x1a\x1d/admin/v3/product/susceptible\x12k\n" + - "\rEditApplyPass\x12\x19.product.EditApplyPassReq\x1a\x11.product.Response\",\x82\xd3\xe4\x93\x02&:\x01*\x1a!/admin/v3/product/edit/apply/pass\x124\n" + + "\rEditApplyPass\x12\x19.product.EditApplyPassReq\x1a\x11.product.Response\",\x82\xd3\xe4\x93\x02&:\x01*\x1a!/admin/v3/product/edit/apply/pass\x12Z\n" + + "\tNumberAdd\x12\x15.product.NumberAddReq\x1a\x11.product.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\x1a\x18/admin/v3/product/number\x12O\n" + + "\bApiItems\x12\x14.product.ApiItemsReq\x1a\x11.product.Response\"\x1a\x82\xd3\xe4\x93\x02\x14:\x01*\x12\x0f/api/v3/product\x12R\n" + + "\aApiInfo\x12\x13.product.ApiInfoReq\x1a\x11.product.Response\"\x1f\x82\xd3\xe4\x93\x02\x19:\x01*\x12\x14/api/v3/product/info\x124\n" + "\x06Number\x12\x12.product.NumberReq\x1a\x16.google.protobuf.Empty\x12>\n" + "\vNumberItems\x12\x17.product.NumberItemsReq\x1a\x16.google.protobuf.Empty\x12/\n" + "\bInfoById\x12\x14.product.InfoByIdReq\x1a\r.product.Item\x12=\n" + "\n" + - "ItemsByIds\x12\x16.product.ItemsByIdsReq\x1a\x17.product.ItemsByIdsData\x12Z\n" + - "\tNumberAdd\x12\x15.product.NumberAddReq\x1a\x11.product.Response\"#\x82\xd3\xe4\x93\x02\x1d:\x01*\x1a\x18/admin/v3/product/numberB\x1bZ\x19lone-services/rpc/productb\x06proto3" + "ItemsByIds\x12\x16.product.ItemsByIdsReq\x1a\x17.product.ItemsByIdsDataB\x1bZ\x19lone-services/rpc/productb\x06proto3" var ( file_product_product_proto_rawDescOnce sync.Once @@ -2351,7 +2651,7 @@ func file_product_product_proto_rawDescGZIP() []byte { return file_product_product_proto_rawDescData } -var file_product_product_proto_msgTypes = make([]protoimpl.MessageInfo, 26) +var file_product_product_proto_msgTypes = make([]protoimpl.MessageInfo, 29) var file_product_product_proto_goTypes = []any{ (*Response)(nil), // 0: product.Response (*InfoByIdReq)(nil), // 1: product.InfoByIdReq @@ -2373,21 +2673,24 @@ var file_product_product_proto_goTypes = []any{ (*NumberItem)(nil), // 17: product.NumberItem (*NumberItemsReq)(nil), // 18: product.NumberItemsReq (*NumberAddReq)(nil), // 19: product.NumberAddReq - (*ItemsData)(nil), // 20: product.ItemsData - (*VerifyItemsData)(nil), // 21: product.VerifyItemsData - (*VerifyParams)(nil), // 22: product.VerifyParams - (*VerifyItem)(nil), // 23: product.VerifyItem - (*NameItem)(nil), // 24: product.NameItem - (*Item)(nil), // 25: product.Item - (*emptypb.Empty)(nil), // 26: google.protobuf.Empty + (*ApiItemsReq)(nil), // 20: product.ApiItemsReq + (*ApiInfoReq)(nil), // 21: product.ApiInfoReq + (*ApiItem)(nil), // 22: product.ApiItem + (*ItemsData)(nil), // 23: product.ItemsData + (*VerifyItemsData)(nil), // 24: product.VerifyItemsData + (*VerifyParams)(nil), // 25: product.VerifyParams + (*VerifyItem)(nil), // 26: product.VerifyItem + (*NameItem)(nil), // 27: product.NameItem + (*Item)(nil), // 28: product.Item + (*emptypb.Empty)(nil), // 29: google.protobuf.Empty } var file_product_product_proto_depIdxs = []int32{ - 25, // 0: product.ItemsByIdsData.items:type_name -> product.Item + 28, // 0: product.ItemsByIdsData.items:type_name -> product.Item 17, // 1: product.NumberItemsReq.items:type_name -> product.NumberItem - 25, // 2: product.ItemsData.items:type_name -> product.Item - 23, // 3: product.VerifyItemsData.items:type_name -> product.VerifyItem - 22, // 4: product.VerifyItem.new:type_name -> product.VerifyParams - 22, // 5: product.VerifyItem.old:type_name -> product.VerifyParams + 28, // 2: product.ItemsData.items:type_name -> product.Item + 26, // 3: product.VerifyItemsData.items:type_name -> product.VerifyItem + 25, // 4: product.VerifyItem.new:type_name -> product.VerifyParams + 25, // 5: product.VerifyItem.old:type_name -> product.VerifyParams 4, // 6: product.Product.Create:input_type -> product.CreateReq 5, // 7: product.Product.Info:input_type -> product.InfoReq 6, // 8: product.Product.Items:input_type -> product.ItemsReq @@ -2401,31 +2704,35 @@ var file_product_product_proto_depIdxs = []int32{ 14, // 16: product.Product.EditBase:input_type -> product.EditBaseReq 15, // 17: product.Product.EditSusceptible:input_type -> product.EditSusceptibleReq 13, // 18: product.Product.EditApplyPass:input_type -> product.EditApplyPassReq - 16, // 19: product.Product.Number:input_type -> product.NumberReq - 18, // 20: product.Product.NumberItems:input_type -> product.NumberItemsReq - 1, // 21: product.Product.InfoById:input_type -> product.InfoByIdReq - 2, // 22: product.Product.ItemsByIds:input_type -> product.ItemsByIdsReq - 19, // 23: product.Product.NumberAdd:input_type -> product.NumberAddReq - 0, // 24: product.Product.Create:output_type -> product.Response - 0, // 25: product.Product.Info:output_type -> product.Response - 0, // 26: product.Product.Items:output_type -> product.Response - 0, // 27: product.Product.Names:output_type -> product.Response - 0, // 28: product.Product.Status:output_type -> product.Response - 0, // 29: product.Product.Sort:output_type -> product.Response - 0, // 30: product.Product.Verify:output_type -> product.Response - 0, // 31: product.Product.VerifyFirst:output_type -> product.Response - 0, // 32: product.Product.VerifySecond:output_type -> product.Response - 0, // 33: product.Product.EditApply:output_type -> product.Response - 0, // 34: product.Product.EditBase:output_type -> product.Response - 0, // 35: product.Product.EditSusceptible:output_type -> product.Response - 0, // 36: product.Product.EditApplyPass:output_type -> product.Response - 26, // 37: product.Product.Number:output_type -> google.protobuf.Empty - 26, // 38: product.Product.NumberItems:output_type -> google.protobuf.Empty - 25, // 39: product.Product.InfoById:output_type -> product.Item - 3, // 40: product.Product.ItemsByIds:output_type -> product.ItemsByIdsData - 0, // 41: product.Product.NumberAdd:output_type -> product.Response - 24, // [24:42] is the sub-list for method output_type - 6, // [6:24] is the sub-list for method input_type + 19, // 19: product.Product.NumberAdd:input_type -> product.NumberAddReq + 20, // 20: product.Product.ApiItems:input_type -> product.ApiItemsReq + 21, // 21: product.Product.ApiInfo:input_type -> product.ApiInfoReq + 16, // 22: product.Product.Number:input_type -> product.NumberReq + 18, // 23: product.Product.NumberItems:input_type -> product.NumberItemsReq + 1, // 24: product.Product.InfoById:input_type -> product.InfoByIdReq + 2, // 25: product.Product.ItemsByIds:input_type -> product.ItemsByIdsReq + 0, // 26: product.Product.Create:output_type -> product.Response + 0, // 27: product.Product.Info:output_type -> product.Response + 0, // 28: product.Product.Items:output_type -> product.Response + 0, // 29: product.Product.Names:output_type -> product.Response + 0, // 30: product.Product.Status:output_type -> product.Response + 0, // 31: product.Product.Sort:output_type -> product.Response + 0, // 32: product.Product.Verify:output_type -> product.Response + 0, // 33: product.Product.VerifyFirst:output_type -> product.Response + 0, // 34: product.Product.VerifySecond:output_type -> product.Response + 0, // 35: product.Product.EditApply:output_type -> product.Response + 0, // 36: product.Product.EditBase:output_type -> product.Response + 0, // 37: product.Product.EditSusceptible:output_type -> product.Response + 0, // 38: product.Product.EditApplyPass:output_type -> product.Response + 0, // 39: product.Product.NumberAdd:output_type -> product.Response + 0, // 40: product.Product.ApiItems:output_type -> product.Response + 0, // 41: product.Product.ApiInfo:output_type -> product.Response + 29, // 42: product.Product.Number:output_type -> google.protobuf.Empty + 29, // 43: product.Product.NumberItems:output_type -> google.protobuf.Empty + 28, // 44: product.Product.InfoById:output_type -> product.Item + 3, // 45: product.Product.ItemsByIds:output_type -> product.ItemsByIdsData + 26, // [26:46] is the sub-list for method output_type + 6, // [6:26] is the sub-list for method input_type 6, // [6:6] is the sub-list for extension type_name 6, // [6:6] is the sub-list for extension extendee 0, // [0:6] is the sub-list for field type_name @@ -2442,7 +2749,7 @@ func file_product_product_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: unsafe.Slice(unsafe.StringData(file_product_product_proto_rawDesc), len(file_product_product_proto_rawDesc)), NumEnums: 0, - NumMessages: 26, + NumMessages: 29, NumExtensions: 0, NumServices: 1, }, diff --git a/rpc/product/pb/product_grpc.pb.go b/rpc/product/pb/product_grpc.pb.go index 315aba0..b4818d8 100644 --- a/rpc/product/pb/product_grpc.pb.go +++ b/rpc/product/pb/product_grpc.pb.go @@ -8,7 +8,6 @@ package product import ( context "context" - grpc "google.golang.org/grpc" codes "google.golang.org/grpc/codes" status "google.golang.org/grpc/status" @@ -34,11 +33,13 @@ const ( Product_EditBase_FullMethodName = "/product.Product/EditBase" Product_EditSusceptible_FullMethodName = "/product.Product/EditSusceptible" Product_EditApplyPass_FullMethodName = "/product.Product/EditApplyPass" + Product_NumberAdd_FullMethodName = "/product.Product/NumberAdd" + Product_ApiItems_FullMethodName = "/product.Product/ApiItems" + Product_ApiInfo_FullMethodName = "/product.Product/ApiInfo" Product_Number_FullMethodName = "/product.Product/Number" Product_NumberItems_FullMethodName = "/product.Product/NumberItems" Product_InfoById_FullMethodName = "/product.Product/InfoById" Product_ItemsByIds_FullMethodName = "/product.Product/ItemsByIds" - Product_NumberAdd_FullMethodName = "/product.Product/NumberAdd" ) // ProductClient is the client API for Product service. @@ -65,15 +66,18 @@ type ProductClient interface { EditSusceptible(ctx context.Context, in *EditSusceptibleReq, opts ...grpc.CallOption) (*Response, error) // TODO: 临时接口,企微编辑申请审批对接后删除 EditApplyPass(ctx context.Context, in *EditApplyPassReq, opts ...grpc.CallOption) (*Response, error) + // 增加库存 + NumberAdd(ctx context.Context, in *NumberAddReq, opts ...grpc.CallOption) (*Response, error) + ApiItems(ctx context.Context, in *ApiItemsReq, opts ...grpc.CallOption) (*Response, error) + ApiInfo(ctx context.Context, in *ApiInfoReq, opts ...grpc.CallOption) (*Response, error) // 增减库存 - // type: 1 增加, 2 减少 Number(ctx context.Context, in *NumberReq, opts ...grpc.CallOption) (*emptypb.Empty, error) // 批量增减库存 NumberItems(ctx context.Context, in *NumberItemsReq, opts ...grpc.CallOption) (*emptypb.Empty, error) + // 获取单个产品详情 InfoById(ctx context.Context, in *InfoByIdReq, opts ...grpc.CallOption) (*Item, error) + // 获取多个产品详情 ItemsByIds(ctx context.Context, in *ItemsByIdsReq, opts ...grpc.CallOption) (*ItemsByIdsData, error) - // 增加库存 - NumberAdd(ctx context.Context, in *NumberAddReq, opts ...grpc.CallOption) (*Response, error) } type productClient struct { @@ -214,6 +218,36 @@ func (c *productClient) EditApplyPass(ctx context.Context, in *EditApplyPassReq, return out, nil } +func (c *productClient) NumberAdd(ctx context.Context, in *NumberAddReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Product_NumberAdd_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *productClient) ApiItems(ctx context.Context, in *ApiItemsReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Product_ApiItems_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *productClient) ApiInfo(ctx context.Context, in *ApiInfoReq, opts ...grpc.CallOption) (*Response, error) { + cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) + out := new(Response) + err := c.cc.Invoke(ctx, Product_ApiInfo_FullMethodName, in, out, cOpts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *productClient) Number(ctx context.Context, in *NumberReq, opts ...grpc.CallOption) (*emptypb.Empty, error) { cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) out := new(emptypb.Empty) @@ -254,16 +288,6 @@ func (c *productClient) ItemsByIds(ctx context.Context, in *ItemsByIdsReq, opts return out, nil } -func (c *productClient) NumberAdd(ctx context.Context, in *NumberAddReq, opts ...grpc.CallOption) (*Response, error) { - cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...) - out := new(Response) - err := c.cc.Invoke(ctx, Product_NumberAdd_FullMethodName, in, out, cOpts...) - if err != nil { - return nil, err - } - return out, nil -} - // ProductServer is the server API for Product service. // All implementations must embed UnimplementedProductServer // for forward compatibility. @@ -288,15 +312,18 @@ type ProductServer interface { EditSusceptible(context.Context, *EditSusceptibleReq) (*Response, error) // TODO: 临时接口,企微编辑申请审批对接后删除 EditApplyPass(context.Context, *EditApplyPassReq) (*Response, error) - // 增减库存 - // type: 1 增加, 2 减少 - Number(context.Context, *NumberReq) (*emptypb.Empty, error) - // 批量增减库存(服务内按 id 排序后在同一事务中执行,防死锁) - NumberItems(context.Context, *NumberItemsReq) (*emptypb.Empty, error) - InfoById(context.Context, *InfoByIdReq) (*Item, error) - ItemsByIds(context.Context, *ItemsByIdsReq) (*ItemsByIdsData, error) // 增加库存 NumberAdd(context.Context, *NumberAddReq) (*Response, error) + ApiItems(context.Context, *ApiItemsReq) (*Response, error) + ApiInfo(context.Context, *ApiInfoReq) (*Response, error) + // 增减库存 + Number(context.Context, *NumberReq) (*emptypb.Empty, error) + // 批量增减库存 + NumberItems(context.Context, *NumberItemsReq) (*emptypb.Empty, error) + // 获取单个产品详情 + InfoById(context.Context, *InfoByIdReq) (*Item, error) + // 获取多个产品详情 + ItemsByIds(context.Context, *ItemsByIdsReq) (*ItemsByIdsData, error) mustEmbedUnimplementedProductServer() } @@ -346,6 +373,15 @@ func (UnimplementedProductServer) EditSusceptible(context.Context, *EditSuscepti func (UnimplementedProductServer) EditApplyPass(context.Context, *EditApplyPassReq) (*Response, error) { return nil, status.Error(codes.Unimplemented, "method EditApplyPass not implemented") } +func (UnimplementedProductServer) NumberAdd(context.Context, *NumberAddReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method NumberAdd not implemented") +} +func (UnimplementedProductServer) ApiItems(context.Context, *ApiItemsReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method ApiItems not implemented") +} +func (UnimplementedProductServer) ApiInfo(context.Context, *ApiInfoReq) (*Response, error) { + return nil, status.Error(codes.Unimplemented, "method ApiInfo not implemented") +} func (UnimplementedProductServer) Number(context.Context, *NumberReq) (*emptypb.Empty, error) { return nil, status.Error(codes.Unimplemented, "method Number not implemented") } @@ -358,9 +394,6 @@ func (UnimplementedProductServer) InfoById(context.Context, *InfoByIdReq) (*Item func (UnimplementedProductServer) ItemsByIds(context.Context, *ItemsByIdsReq) (*ItemsByIdsData, error) { return nil, status.Error(codes.Unimplemented, "method ItemsByIds not implemented") } -func (UnimplementedProductServer) NumberAdd(context.Context, *NumberAddReq) (*Response, error) { - return nil, status.Error(codes.Unimplemented, "method NumberAdd not implemented") -} func (UnimplementedProductServer) mustEmbedUnimplementedProductServer() {} func (UnimplementedProductServer) testEmbeddedByValue() {} @@ -616,6 +649,60 @@ func _Product_EditApplyPass_Handler(srv interface{}, ctx context.Context, dec fu return interceptor(ctx, in, info, handler) } +func _Product_NumberAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(NumberAddReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServer).NumberAdd(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Product_NumberAdd_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServer).NumberAdd(ctx, req.(*NumberAddReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _Product_ApiItems_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ApiItemsReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServer).ApiItems(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Product_ApiItems_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServer).ApiItems(ctx, req.(*ApiItemsReq)) + } + return interceptor(ctx, in, info, handler) +} + +func _Product_ApiInfo_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(ApiInfoReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(ProductServer).ApiInfo(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: Product_ApiInfo_FullMethodName, + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(ProductServer).ApiInfo(ctx, req.(*ApiInfoReq)) + } + return interceptor(ctx, in, info, handler) +} + func _Product_Number_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(NumberReq) if err := dec(in); err != nil { @@ -688,24 +775,6 @@ func _Product_ItemsByIds_Handler(srv interface{}, ctx context.Context, dec func( return interceptor(ctx, in, info, handler) } -func _Product_NumberAdd_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(NumberAddReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(ProductServer).NumberAdd(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: Product_NumberAdd_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(ProductServer).NumberAdd(ctx, req.(*NumberAddReq)) - } - return interceptor(ctx, in, info, handler) -} - // Product_ServiceDesc is the grpc.ServiceDesc for Product service. // It's only intended for direct use with grpc.RegisterService, // and not to be introspected or modified (even as a copy) @@ -765,6 +834,18 @@ var Product_ServiceDesc = grpc.ServiceDesc{ MethodName: "EditApplyPass", Handler: _Product_EditApplyPass_Handler, }, + { + MethodName: "NumberAdd", + Handler: _Product_NumberAdd_Handler, + }, + { + MethodName: "ApiItems", + Handler: _Product_ApiItems_Handler, + }, + { + MethodName: "ApiInfo", + Handler: _Product_ApiInfo_Handler, + }, { MethodName: "Number", Handler: _Product_Number_Handler, @@ -781,10 +862,6 @@ var Product_ServiceDesc = grpc.ServiceDesc{ MethodName: "ItemsByIds", Handler: _Product_ItemsByIds_Handler, }, - { - MethodName: "NumberAdd", - Handler: _Product_NumberAdd_Handler, - }, }, Streams: []grpc.StreamDesc{}, Metadata: "product/product.proto", diff --git a/rpc/product/product.pb b/rpc/product/product.pb index 8d10079..3f045a6 100644 Binary files a/rpc/product/product.pb and b/rpc/product/product.pb differ diff --git a/rpc/product/product.proto b/rpc/product/product.proto index fa7ec18..431b3b4 100644 --- a/rpc/product/product.proto +++ b/rpc/product/product.proto @@ -102,6 +102,20 @@ service Product { }; } + rpc ApiItems(ApiItemsReq) returns (Response) { + option (google.api.http) = { + get: "/api/v3/product" + body: "*" + }; + } + + rpc ApiInfo(ApiInfoReq) returns (Response) { + option (google.api.http) = { + get: "/api/v3/product/info" + body: "*" + }; + } + // 增减库存 rpc Number(NumberReq) returns (google.protobuf.Empty); // 批量增减库存 @@ -260,6 +274,36 @@ message NumberAddReq { uint32 number = 2; } +message ApiItemsReq { + string name = 1; +} + +message ApiInfoReq { + int64 id = 1; +} + +// C 端产品字段(对齐老 ProductWebInfo) +message ApiItem { + int64 id = 1; + string name = 2; + string subhead = 3; + string content = 4; + string model_code = 5; + double price = 6; + double store_price = 7; + double sale_price = 8; + repeated string images = 9; + string label = 10; + uint32 is_buy = 11; + int32 period_validity = 12; + uint32 is_index = 13; + string index_image = 14; + uint32 type = 15; + uint32 norms_number = 16; + uint32 number = 17; + uint32 is_permit = 18; +} + message ItemsData { int64 count = 1; repeated Item items = 2; diff --git a/rpc/store/pb/store.pb.go b/rpc/store/pb/store.pb.go index 7e51d7e..05282b2 100644 --- a/rpc/store/pb/store.pb.go +++ b/rpc/store/pb/store.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.36.11 -// protoc v4.25.8 +// protoc v3.19.4 // source: store/store.proto package store @@ -857,6 +857,8 @@ type InfoResponse struct { CityName string `protobuf:"bytes,27,opt,name=city_name,json=cityName,proto3" json:"city_name,omitempty"` County int64 `protobuf:"varint,28,opt,name=county,proto3" json:"county,omitempty"` CountyName string `protobuf:"bytes,29,opt,name=county_name,json=countyName,proto3" json:"county_name,omitempty"` + BuyAmount float64 `protobuf:"fixed64,30,opt,name=buy_amount,json=buyAmount,proto3" json:"buy_amount,omitempty"` + ResidualNumber int32 `protobuf:"varint,31,opt,name=residual_number,json=residualNumber,proto3" json:"residual_number,omitempty"` unknownFields protoimpl.UnknownFields sizeCache protoimpl.SizeCache } @@ -1094,6 +1096,20 @@ func (x *InfoResponse) GetCountyName() string { return "" } +func (x *InfoResponse) GetBuyAmount() float64 { + if x != nil { + return x.BuyAmount + } + return 0 +} + +func (x *InfoResponse) GetResidualNumber() int32 { + if x != nil { + return x.ResidualNumber + } + return 0 +} + type ItemsResponse struct { state protoimpl.MessageState `protogen:"open.v1"` Items []*InfoResponse `protobuf:"bytes,1,rep,name=items,proto3" json:"items,omitempty"` @@ -2315,7 +2331,7 @@ const file_store_store_proto_rawDesc = "" + "\tcity_name\x18\x1e \x01(\tR\bcityName\x12\x16\n" + "\x06county\x18\x1f \x01(\x03R\x06county\x12\x1f\n" + "\vcounty_name\x18 \x01(\tR\n" + - "countyName\"\xdf\x06\n" + + "countyName\"\xa7\a\n" + "\fInfoResponse\x12\x0e\n" + "\x02id\x18\x01 \x01(\x03R\x02id\x12\x1f\n" + "\vuser_mobile\x18\x02 \x01(\tR\n" + @@ -2349,7 +2365,10 @@ const file_store_store_proto_rawDesc = "" + "\tcity_name\x18\x1b \x01(\tR\bcityName\x12\x16\n" + "\x06county\x18\x1c \x01(\x03R\x06county\x12\x1f\n" + "\vcounty_name\x18\x1d \x01(\tR\n" + - "countyName\":\n" + + "countyName\x12\x1d\n" + + "\n" + + "buy_amount\x18\x1e \x01(\x01R\tbuyAmount\x12'\n" + + "\x0fresidual_number\x18\x1f \x01(\x05R\x0eresidualNumber\":\n" + "\rItemsResponse\x12)\n" + "\x05items\x18\x01 \x03(\v2\x13.store.InfoResponseR\x05items\"8\n" + "\rToSaleRequest\x12\x0e\n" + diff --git a/rpc/store/pb/store_grpc.pb.go b/rpc/store/pb/store_grpc.pb.go index 43b467f..ad51dec 100644 --- a/rpc/store/pb/store_grpc.pb.go +++ b/rpc/store/pb/store_grpc.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go-grpc. DO NOT EDIT. // versions: // - protoc-gen-go-grpc v1.6.2 -// - protoc v4.25.8 +// - protoc v3.19.4 // source: store/store.proto package store diff --git a/rpc/store/store.pb b/rpc/store/store.pb index 8c50577..9bc2737 100644 Binary files a/rpc/store/store.pb and b/rpc/store/store.pb differ diff --git a/rpc/store/store.proto b/rpc/store/store.proto index 112a4c3..62187fd 100644 --- a/rpc/store/store.proto +++ b/rpc/store/store.proto @@ -123,6 +123,8 @@ message InfoResponse { string city_name = 27; int64 county = 28; string county_name = 29; + double buy_amount = 30; + int32 residual_number = 31; } message ItemsResponse { diff --git a/services/order/internal/logic/existByStoreProductLogic.go b/services/order/internal/logic/existByStoreProductLogic.go new file mode 100644 index 0000000..1ba333e --- /dev/null +++ b/services/order/internal/logic/existByStoreProductLogic.go @@ -0,0 +1,59 @@ +package logic + +import ( + "context" + "strconv" + + "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" + + "github.com/zeromicro/go-zero/core/logx" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" +) + +type ExistByStoreProductLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewExistByStoreProductLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ExistByStoreProductLogic { + return &ExistByStoreProductLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +// ExistByStoreProduct 门店是否存在指定产品的已支付/待支付/支付中订单(内部) +func (l *ExistByStoreProductLogic) ExistByStoreProduct(in *order.ExistByStoreProductReq) (*order.ExistByStoreProductResp, error) { + if in.StoreId < utils.NumberOne || in.ProductId < utils.NumberOne { + return nil, status.Error(codes.InvalidArgument, utils.ErrorParams.Msg) + } + + var info dao.OrderInfo + err := model.OrderModel{}.Init().GetOne(modelbase.Params{ + Eq: map[string]string{ + "product_ids": strconv.FormatInt(in.ProductId, utils.NumberTen), + "store_id": strconv.FormatInt(in.StoreId, utils.NumberTen), + }, + In: map[string][]string{ + "status": { + utils.StringStatusOk, + strconv.Itoa(dao.OrderPayStatusWait), + strconv.Itoa(dao.OrderPayStatusIn), + }, + }, + }, &info) + if err != nil { + l.Errorf("exist by store product: %v", err) + return nil, status.Error(codes.Internal, utils.Fail.Msg) + } + + return &order.ExistByStoreProductResp{Exist: info.Id >= utils.NumberOne}, nil +} diff --git a/services/order/internal/server/orderServer.go b/services/order/internal/server/orderServer.go index ab1eab4..9b64d2e 100644 --- a/services/order/internal/server/orderServer.go +++ b/services/order/internal/server/orderServer.go @@ -1,5 +1,5 @@ // Code generated by goctl. DO NOT EDIT. -// goctl 1.10.2 +// goctl 1.10.1 // Source: order.proto package server @@ -95,6 +95,12 @@ func (s *OrderServer) UpdateOrderPayStatus(ctx context.Context, in *order.Update return l.UpdateOrderPayStatus(in) } +// 门店是否存在指定产品的有效/待支付订单(内部) +func (s *OrderServer) ExistByStoreProduct(ctx context.Context, in *order.ExistByStoreProductReq) (*order.ExistByStoreProductResp, error) { + l := logic.NewExistByStoreProductLogic(ctx, s.svcCtx) + return l.ExistByStoreProduct(in) +} + // API func (s *OrderServer) ApiSupply(ctx context.Context, in *order.ApiSupplyRequest) (*order.Response, error) { l := logic.NewApiSupplyLogic(ctx, s.svcCtx) diff --git a/services/order/orderClient/order.go b/services/order/orderClient/order.go index 18df3c5..8037838 100644 --- a/services/order/orderClient/order.go +++ b/services/order/orderClient/order.go @@ -1,5 +1,5 @@ // Code generated by goctl. DO NOT EDIT. -// goctl 1.10.2 +// goctl 1.10.1 // Source: order.proto package orderClient @@ -26,6 +26,8 @@ type ( EditCartRequest = order.EditCartRequest EmptyRequest = order.EmptyRequest ExcelExportResponse = order.ExcelExportResponse + ExistByStoreProductReq = order.ExistByStoreProductReq + ExistByStoreProductResp = order.ExistByStoreProductResp GetOrderInfoRequest = order.GetOrderInfoRequest IdAndTypeRequest = order.IdAndTypeRequest IdRequest = order.IdRequest @@ -64,6 +66,8 @@ type ( GetOrderInfo(ctx context.Context, in *GetOrderInfoRequest, opts ...grpc.CallOption) (*OrderInfoResponse, error) // status 1 为已支付 4 支付失败,其它的返回错误 UpdateOrderPayStatus(ctx context.Context, in *UpdateOrderPayStatusRequest, opts ...grpc.CallOption) (*UpdateOrderPayStatusResponse, error) + // 门店是否存在指定产品的有效/待支付订单(内部) + ExistByStoreProduct(ctx context.Context, in *ExistByStoreProductReq, opts ...grpc.CallOption) (*ExistByStoreProductResp, error) // API ApiSupply(ctx context.Context, in *ApiSupplyRequest, opts ...grpc.CallOption) (*Response, error) ApiSupplyInfo(ctx context.Context, in *ApiSupplyInfoRequest, opts ...grpc.CallOption) (*Response, error) @@ -164,6 +168,12 @@ func (m *defaultOrder) UpdateOrderPayStatus(ctx context.Context, in *UpdateOrder return client.UpdateOrderPayStatus(ctx, in, opts...) } +// 门店是否存在指定产品的有效/待支付订单(内部) +func (m *defaultOrder) ExistByStoreProduct(ctx context.Context, in *ExistByStoreProductReq, opts ...grpc.CallOption) (*ExistByStoreProductResp, error) { + client := order.NewOrderClient(m.cli.Conn()) + return client.ExistByStoreProduct(ctx, in, opts...) +} + // API func (m *defaultOrder) ApiSupply(ctx context.Context, in *ApiSupplyRequest, opts ...grpc.CallOption) (*Response, error) { client := order.NewOrderClient(m.cli.Conn()) diff --git a/services/payment/internal/logic/refundLogic.go b/services/payment/internal/logic/refundLogic.go index fdb38e0..fb410d8 100644 --- a/services/payment/internal/logic/refundLogic.go +++ b/services/payment/internal/logic/refundLogic.go @@ -78,7 +78,6 @@ func (l *RefundLogic) Refund(in *payment.RefundReq) (*payment.Response, error) { TotalFen: totalFen, Currency: "CNY", }) - fmt.Println("outTradeNo", outTradeNo, "outRefundNo", outRefundNo) if err != nil { l.Errorf("refund: %v", err) return outResponse(utils.Fail, err.Error()), nil diff --git a/services/product/internal/dao/product.go b/services/product/internal/dao/product.go index 176f797..d8f25f9 100644 --- a/services/product/internal/dao/product.go +++ b/services/product/internal/dao/product.go @@ -182,6 +182,28 @@ type VerifyFirstEditStatus struct { VerifyStatus uint8 `gorm:"column:verify_status" json:"verify_status"` } +// WebInfo C 端列表/详情投影(对齐老 ProductWebInfo) +type WebInfo struct { + Id int `gorm:"column:id"` + Name string `gorm:"column:name"` + Subhead string `gorm:"column:subhead"` + Content string `gorm:"column:content"` + ModelCode string `gorm:"column:model_code"` + Price float32 `gorm:"column:price"` + StorePrice float32 `gorm:"column:store_price"` + SalePrice float32 `gorm:"column:sale_price"` + Images string `gorm:"column:images"` + Label string `gorm:"column:label"` + IsBuy uint8 `gorm:"column:is_buy"` + PeriodValidity int16 `gorm:"column:period_validity"` + IsIndex uint8 `gorm:"column:is_index"` + IndexImage string `gorm:"column:index_image"` + Type uint8 `gorm:"column:type"` + NormsNumber uint8 `gorm:"column:norms_number"` + Number uint `gorm:"column:number"` + IsPermit uint8 `gorm:"-"` +} + // Info 列表/详情查询投影 type Info struct { Id int `gorm:"column:id"` diff --git a/services/product/internal/logic/apiInfoLogic.go b/services/product/internal/logic/apiInfoLogic.go new file mode 100644 index 0000000..39fbb59 --- /dev/null +++ b/services/product/internal/logic/apiInfoLogic.go @@ -0,0 +1,120 @@ +package logic + +import ( + "context" + "strconv" + + "lone-services/pkg/modelbase" + "lone-services/pkg/rpcclient" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + orderpb "lone-services/rpc/order/pb" + product "lone-services/rpc/product/pb" + storepb "lone-services/rpc/store/pb" + "lone-services/services/product/internal/dao" + "lone-services/services/product/internal/model" + "lone-services/services/product/internal/svc" + "lone-services/services/product/validator" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ApiInfoLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewApiInfoLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApiInfoLogic { + return &ApiInfoLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *ApiInfoLogic) ApiInfo(in *product.ApiInfoReq) (*product.Response, error) { + var req validator.ApiProductInfoValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return outResponse(utils.ErrorParams, msg), nil + } + + userInfo := utils.GetUserFromCtx(l.ctx) + + var info dao.WebInfo + err := model.ProductModel{}.Init().GetOne(modelbase.Params{ + Eq: map[string]string{ + "id": strconv.FormatInt(req.Id, utils.NumberTen), + "status": utils.StringStatusOk, + }, + Other: map[string]string{"publish_time < ? ": utils.Now().String()}, + }, &info) + if err != nil { + l.Errorf("api product info: %v", err) + return failResponse(utils.Fail), nil + } + if info.Id < utils.NumberOne { + return failResponse(utils.ErrorNotFund), nil + } + + // 试用资格仅门店登录时计算 + if userInfo.StoreId >= utils.NumberOne { + if err := l.fillStorePermit(&info, userInfo.StoreId); err != nil { + l.Errorf("api product info permit: %v", err) + return failResponse(utils.Fail), nil + } + } + + return okResponse(toApiItem(info)), nil +} + +func (l *ApiInfoLogic) fillStorePermit(info *dao.WebInfo, storeId int64) error { + switch info.Type { + case dao.ProductFirstTry: + exist, err := existStoreProductOrder(l.ctx, l.svcCtx.OrderSvcName, storeId, int64(info.Id)) + if err != nil { + l.Errorf("api product info first-try order: %v", err) + return nil + } + if !exist { + info.IsPermit = utils.NumberOne + } + case dao.ProductTry: + storeInfo, err := getStoreInfoById(l.ctx, l.svcCtx.StoreSvcName, storeId) + if err != nil { + return err + } + tryAmount := float64(utils.GetConfigInt("try.try_amount")) + tryError := utils.GetConfigInt("try.try_error") + if storeInfo.BuyAmount > tryAmount && int(storeInfo.ResidualNumber) < tryError { + info.IsPermit = utils.NumberOne + } + } + return nil +} + +func getStoreInfoById(ctx context.Context, storeSvcName string, storeId int64) (*storepb.InfoResponse, error) { + cli, err := rpcclient.Get(storeSvcName) + if err != nil { + return nil, err + } + return storepb.NewStoreClient(cli.Conn()).GetInfoById(ctx, &storepb.IdRequest{Id: storeId}) +} + +func existStoreProductOrder(ctx context.Context, orderSvcName string, storeId, productId int64) (bool, error) { + cli, err := rpcclient.Get(orderSvcName) + if err != nil { + return false, err + } + resp, err := orderpb.NewOrderClient(cli.Conn()).ExistByStoreProduct(ctx, &orderpb.ExistByStoreProductReq{ + StoreId: storeId, + ProductId: productId, + }) + if err != nil { + return false, err + } + if resp == nil { + return false, nil + } + return resp.Exist, nil +} diff --git a/services/product/internal/logic/apiItemsLogic.go b/services/product/internal/logic/apiItemsLogic.go new file mode 100644 index 0000000..09cade2 --- /dev/null +++ b/services/product/internal/logic/apiItemsLogic.go @@ -0,0 +1,72 @@ +package logic + +import ( + "context" + "strconv" + + "lone-services/pkg/modelbase" + "lone-services/pkg/utils" + "lone-services/pkg/validate" + product "lone-services/rpc/product/pb" + "lone-services/services/product/internal/dao" + "lone-services/services/product/internal/model" + "lone-services/services/product/internal/svc" + "lone-services/services/product/validator" + + "github.com/zeromicro/go-zero/core/logx" +) + +type ApiItemsLogic struct { + ctx context.Context + svcCtx *svc.ServiceContext + logx.Logger +} + +func NewApiItemsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ApiItemsLogic { + return &ApiItemsLogic{ + ctx: ctx, + svcCtx: svcCtx, + Logger: logx.WithContext(ctx), + } +} + +func (l *ApiItemsLogic) ApiItems(in *product.ApiItemsReq) (*product.Response, error) { + var req validator.ApiProductItemsValidator + if msg := validate.ValidateFromProto(in, &req); msg != utils.StringEmpty { + return outResponse(utils.ErrorParams, msg), nil + } + + userInfo := utils.GetUserFromCtx(l.ctx) + if !userInfo.Valid || userInfo.ID < utils.NumberOne { + return failResponse(utils.ErrorNoLoginInfo), nil + } + + w := modelbase.Params{ + Eq: map[string]string{ + "status": utils.StringStatusOk, + "sales_model": strconv.Itoa(dao.ProductSalesModelOffline), + }, + Other: map[string]string{ + "publish_time < ? ": utils.Now().String(), + }, + Order: "sort DESC, id DESC", + } + if len(req.Name) > utils.NumberZero { + w.Like = map[string]string{ + "name LIKE ? ": "%%" + req.Name + "%%", + } + } + + var rows []dao.WebInfo + err := model.ProductModel{}.Init().Items(w, &rows) + if err != nil { + l.Errorf("api product items: %v", err) + return failResponse(utils.Fail), nil + } + + items := make([]*product.ApiItem, 0, len(rows)) + for _, row := range rows { + items = append(items, toApiItem(row)) + } + return okResponse(items), nil +} diff --git a/services/product/internal/logic/convert.go b/services/product/internal/logic/convert.go index db70b38..4ff0eab 100644 --- a/services/product/internal/logic/convert.go +++ b/services/product/internal/logic/convert.go @@ -11,6 +11,29 @@ import ( jsoniter "github.com/json-iterator/go" ) +func toApiItem(row dao.WebInfo) *product.ApiItem { + return &product.ApiItem{ + Id: int64(row.Id), + Name: row.Name, + Subhead: row.Subhead, + Content: row.Content, + ModelCode: row.ModelCode, + Price: utils.RoundFloat(float64(row.Price)), + StorePrice: utils.RoundFloat(float64(row.StorePrice)), + SalePrice: utils.RoundFloat(float64(row.SalePrice)), + Images: splitImages(row.Images), + Label: row.Label, + IsBuy: uint32(row.IsBuy), + PeriodValidity: int32(row.PeriodValidity), + IsIndex: uint32(row.IsIndex), + IndexImage: row.IndexImage, + Type: uint32(row.Type), + NormsNumber: uint32(row.NormsNumber), + Number: uint32(row.Number), + IsPermit: uint32(row.IsPermit), + } +} + func toProductItem(row dao.Info) *product.Item { publishTime := "" if !row.PublishTime.IsZero() { diff --git a/services/product/internal/logic/response.go b/services/product/internal/logic/response.go index 7e319cf..f9283e5 100644 --- a/services/product/internal/logic/response.go +++ b/services/product/internal/logic/response.go @@ -7,8 +7,11 @@ import ( jsoniter "github.com/json-iterator/go" ) +// 关闭 EscapeHTML,避免 content 中
被编成 \u003cp\u003e +var jsonAPI = jsoniter.Config{EscapeHTML: false}.Froze() + func okResponse(data any) *product.Response { - buf, _ := jsoniter.Marshal(data) + buf, _ := jsonAPI.Marshal(data) return &product.Response{ Code: utils.Ok.Code, Msg: utils.Ok.Msg, diff --git a/services/product/internal/server/productServer.go b/services/product/internal/server/productServer.go index be62e49..3fb4ec9 100644 --- a/services/product/internal/server/productServer.go +++ b/services/product/internal/server/productServer.go @@ -96,30 +96,42 @@ func (s *ProductServer) EditApplyPass(ctx context.Context, in *product.EditApply return l.EditApplyPass(in) } +// 增加库存 +func (s *ProductServer) NumberAdd(ctx context.Context, in *product.NumberAddReq) (*product.Response, error) { + l := logic.NewNumberAddLogic(ctx, s.svcCtx) + return l.NumberAdd(in) +} + +func (s *ProductServer) ApiItems(ctx context.Context, in *product.ApiItemsReq) (*product.Response, error) { + l := logic.NewApiItemsLogic(ctx, s.svcCtx) + return l.ApiItems(in) +} + +func (s *ProductServer) ApiInfo(ctx context.Context, in *product.ApiInfoReq) (*product.Response, error) { + l := logic.NewApiInfoLogic(ctx, s.svcCtx) + return l.ApiInfo(in) +} + // 增减库存 func (s *ProductServer) Number(ctx context.Context, in *product.NumberReq) (*emptypb.Empty, error) { l := logic.NewNumberLogic(ctx, s.svcCtx) return l.Number(in) } -// 批量增减库存(服务内按 id 排序后在同一事务中执行,防死锁) +// 批量增减库存 func (s *ProductServer) NumberItems(ctx context.Context, in *product.NumberItemsReq) (*emptypb.Empty, error) { l := logic.NewNumberItemsLogic(ctx, s.svcCtx) return l.NumberItems(in) } +// 获取单个产品详情 func (s *ProductServer) InfoById(ctx context.Context, in *product.InfoByIdReq) (*product.Item, error) { l := logic.NewInfoByIdLogic(ctx, s.svcCtx) return l.InfoById(in) } +// 获取多个产品详情 func (s *ProductServer) ItemsByIds(ctx context.Context, in *product.ItemsByIdsReq) (*product.ItemsByIdsData, error) { l := logic.NewItemsByIdsLogic(ctx, s.svcCtx) return l.ItemsByIds(in) } - -// 增加库存 -func (s *ProductServer) NumberAdd(ctx context.Context, in *product.NumberAddReq) (*product.Response, error) { - l := logic.NewNumberAddLogic(ctx, s.svcCtx) - return l.NumberAdd(in) -} diff --git a/services/product/internal/svc/servicecontext.go b/services/product/internal/svc/servicecontext.go index deb7430..61c69f9 100644 --- a/services/product/internal/svc/servicecontext.go +++ b/services/product/internal/svc/servicecontext.go @@ -14,6 +14,8 @@ type ServiceContext struct { Prefix string ChoreSvcName string WecomSvcName string + StoreSvcName string + OrderSvcName string } func NewServiceContext(c config.Config, db *gorm.DB) *ServiceContext { @@ -25,11 +27,21 @@ func NewServiceContext(c config.Config, db *gorm.DB) *ServiceContext { if wecomSvc == utils.StringEmpty { logx.Error("config services.wecom empty") } + storeSvc := utils.GetConfigString("services.store") + if storeSvc == utils.StringEmpty { + logx.Error("config services.store empty") + } + orderSvc := utils.GetConfigString("services.order") + if orderSvc == utils.StringEmpty { + logx.Error("config services.order empty") + } return &ServiceContext{ Config: c, DB: db, Prefix: utils.GetConfigString("mysql.prefix"), ChoreSvcName: choreSvc, WecomSvcName: wecomSvc, + StoreSvcName: storeSvc, + OrderSvcName: orderSvc, } } diff --git a/services/product/productClient/product.go b/services/product/productClient/product.go index 9a52541..6696347 100644 --- a/services/product/productClient/product.go +++ b/services/product/productClient/product.go @@ -16,6 +16,9 @@ import ( ) type ( + ApiInfoReq = product.ApiInfoReq + ApiItem = product.ApiItem + ApiItemsReq = product.ApiItemsReq CreateReq = product.CreateReq EditApplyPassReq = product.EditApplyPassReq EditApplyReq = product.EditApplyReq @@ -64,14 +67,18 @@ type ( EditSusceptible(ctx context.Context, in *EditSusceptibleReq, opts ...grpc.CallOption) (*Response, error) // TODO: 临时接口,企微编辑申请审批对接后删除 EditApplyPass(ctx context.Context, in *EditApplyPassReq, opts ...grpc.CallOption) (*Response, error) - // 增减库存 - Number(ctx context.Context, in *NumberReq, opts ...grpc.CallOption) (*emptypb.Empty, error) - // 批量增减库存(服务内按 id 排序后在同一事务中执行,防死锁) - NumberItems(ctx context.Context, in *NumberItemsReq, opts ...grpc.CallOption) (*emptypb.Empty, error) - InfoById(ctx context.Context, in *InfoByIdReq, opts ...grpc.CallOption) (*Item, error) - ItemsByIds(ctx context.Context, in *ItemsByIdsReq, opts ...grpc.CallOption) (*ItemsByIdsData, error) // 增加库存 NumberAdd(ctx context.Context, in *NumberAddReq, opts ...grpc.CallOption) (*Response, error) + ApiItems(ctx context.Context, in *ApiItemsReq, opts ...grpc.CallOption) (*Response, error) + ApiInfo(ctx context.Context, in *ApiInfoReq, opts ...grpc.CallOption) (*Response, error) + // 增减库存 + Number(ctx context.Context, in *NumberReq, opts ...grpc.CallOption) (*emptypb.Empty, error) + // 批量增减库存 + NumberItems(ctx context.Context, in *NumberItemsReq, opts ...grpc.CallOption) (*emptypb.Empty, error) + // 获取单个产品详情 + InfoById(ctx context.Context, in *InfoByIdReq, opts ...grpc.CallOption) (*Item, error) + // 获取多个产品详情 + ItemsByIds(ctx context.Context, in *ItemsByIdsReq, opts ...grpc.CallOption) (*ItemsByIdsData, error) } defaultProduct struct { @@ -157,30 +164,42 @@ func (m *defaultProduct) EditApplyPass(ctx context.Context, in *EditApplyPassReq return client.EditApplyPass(ctx, in, opts...) } +// 增加库存 +func (m *defaultProduct) NumberAdd(ctx context.Context, in *NumberAddReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.NumberAdd(ctx, in, opts...) +} + +func (m *defaultProduct) ApiItems(ctx context.Context, in *ApiItemsReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.ApiItems(ctx, in, opts...) +} + +func (m *defaultProduct) ApiInfo(ctx context.Context, in *ApiInfoReq, opts ...grpc.CallOption) (*Response, error) { + client := product.NewProductClient(m.cli.Conn()) + return client.ApiInfo(ctx, in, opts...) +} + // 增减库存 func (m *defaultProduct) Number(ctx context.Context, in *NumberReq, opts ...grpc.CallOption) (*emptypb.Empty, error) { client := product.NewProductClient(m.cli.Conn()) return client.Number(ctx, in, opts...) } -// 批量增减库存(服务内按 id 排序后在同一事务中执行,防死锁) +// 批量增减库存 func (m *defaultProduct) NumberItems(ctx context.Context, in *NumberItemsReq, opts ...grpc.CallOption) (*emptypb.Empty, error) { client := product.NewProductClient(m.cli.Conn()) return client.NumberItems(ctx, in, opts...) } +// 获取单个产品详情 func (m *defaultProduct) InfoById(ctx context.Context, in *InfoByIdReq, opts ...grpc.CallOption) (*Item, error) { client := product.NewProductClient(m.cli.Conn()) return client.InfoById(ctx, in, opts...) } +// 获取多个产品详情 func (m *defaultProduct) ItemsByIds(ctx context.Context, in *ItemsByIdsReq, opts ...grpc.CallOption) (*ItemsByIdsData, error) { client := product.NewProductClient(m.cli.Conn()) return client.ItemsByIds(ctx, in, opts...) } - -// 增加库存 -func (m *defaultProduct) NumberAdd(ctx context.Context, in *NumberAddReq, opts ...grpc.CallOption) (*Response, error) { - client := product.NewProductClient(m.cli.Conn()) - return client.NumberAdd(ctx, in, opts...) -} diff --git a/services/product/validator/validator.go b/services/product/validator/validator.go index 1fd3c3c..836f78a 100644 --- a/services/product/validator/validator.go +++ b/services/product/validator/validator.go @@ -64,6 +64,27 @@ func (p ProductInfoValidator) GetMessage() validate.ValidatorMessages { } } +type ApiProductInfoValidator struct { + Id int64 `validate:"required,gt=0"` +} + +func (p ApiProductInfoValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Id.required": "ID不能为空", + "Id.gt": "ID必须大于0", + } +} + +type ApiProductItemsValidator struct { + Name string `validate:"max=256"` +} + +func (p ApiProductItemsValidator) GetMessage() validate.ValidatorMessages { + return validate.ValidatorMessages{ + "Name.max": "产品名长度不能超过256", + } +} + type ProductItemsValidator struct { Name string `validate:"max=256"` Page uint32 `validate:"omitempty,min=1"` @@ -163,12 +184,12 @@ func (p ProductEditApplyPassValidator) GetMessage() validate.ValidatorMessages { } type ProductEditBaseValidator struct { - Id int64 `validate:"required,gt=0"` - Name string `validate:"required,max=256"` - Subhead string `validate:"required,max=255"` - Content string `validate:"required"` - Waybill string `validate:"required,max=255"` - Weight float64 `validate:"required"` + Id int64 `validate:"required,gt=0"` + Name string `validate:"required,max=256"` + Subhead string `validate:"required,max=255"` + Content string `validate:"required"` + Waybill string `validate:"required,max=255"` + Weight float64 `validate:"required"` Cubage string `validate:"required,max=255"` Images []string `validate:"required,min=1,dive,required"` PeriodValidity int32 `validate:"required"` diff --git a/services/store/internal/logic/getInfoByIdLogic.go b/services/store/internal/logic/getInfoByIdLogic.go index 2f0a188..be7790f 100644 --- a/services/store/internal/logic/getInfoByIdLogic.go +++ b/services/store/internal/logic/getInfoByIdLogic.go @@ -68,5 +68,7 @@ func (l *GetInfoByIdLogic) GetInfoById(in *store.IdRequest) (*store.InfoResponse DistrictIds: info.District, Area: info.Area, BankInfo: info.BankInfo, + BuyAmount: info.BuyAmount, + ResidualNumber: info.ResidualNumber, }, nil } diff --git a/services/store/internal/logic/getInfoByIdsLogic.go b/services/store/internal/logic/getInfoByIdsLogic.go index 7859712..77feb95 100644 --- a/services/store/internal/logic/getInfoByIdsLogic.go +++ b/services/store/internal/logic/getInfoByIdsLogic.go @@ -67,6 +67,8 @@ func (l *GetInfoByIdsLogic) GetInfoByIds(in *store.IdsRequest) (*store.ItemsResp DistrictIds: item.District, Area: item.Area, BankInfo: item.BankInfo, + BuyAmount: item.BuyAmount, + ResidualNumber: item.ResidualNumber, }) }