diff --git a/shoppingCart-service/client/client.go b/shoppingCart-service/client/client.go index 747ae59..f4d403b 100644 --- a/shoppingCart-service/client/client.go +++ b/shoppingCart-service/client/client.go @@ -30,7 +30,7 @@ func main() { const ( //DTM 服务地址 DtmServer = "http://192.168.100.131:36789/api/dtmsvr" - QSBusi = "http://192.168.1.135:6668" //注意 + QSBusi = "http://192.168.40.84:6668" //注意 ) var CartId int32 = 1 var Number int32 = 1 @@ -54,7 +54,8 @@ func main() { hystrixStreamHandler := hystrix.NewStreamHandler() hystrixStreamHandler.Start() go func() { - err := http.ListenAndServe(net.JoinHostPort("192.168.100.1", "9096"), hystrixStreamHandler) + //本机地址 + err := http.ListenAndServe(net.JoinHostPort("192.168.40.84", "9096"), hystrixStreamHandler) if err != nil { log.Panic(err) } diff --git a/shoppingCart-service/domain/repository/cart_repository.go b/shoppingCart-service/domain/repository/cart_repository.go index 0c44cda..7e5acd5 100644 --- a/shoppingCart-service/domain/repository/cart_repository.go +++ b/shoppingCart-service/domain/repository/cart_repository.go @@ -19,6 +19,7 @@ import ( type ICartRepository interface { AddCart(*proto.AddCartReq) (*model.ShoppingCart, error) UpdateCart(req *proto.UpdateCartReq) (*model.ShoppingCart, error) + GetOrderTotal(int32List []int32) (obj float32, err error) } // 创建实例 @@ -69,3 +70,16 @@ func (u *CartRepository) UpdateCart(req *proto.UpdateCartReq) (obj *model.Shoppi fmt.Println("repository UpdateCart >>>> ", cart) return &cart, tb.Error //err } + +// 统计订单价格 +func (u *CartRepository) GetOrderTotal(int32List []int32) (obj float32, err error) { + sql := "select sum(c.Number * s.sell_price) from `shopping_cart` c \n" + + "LEFT JOIN `product_sku` s on c.product_sku_id=s.id\n" + + "where c.id in ?" + var totalPrice float32 + tb := u.mysqlDB.Raw(sql, int32List).Scan(&totalPrice) + //Update("order_status", trade.OrderStatus) + //err = errors.New("400", "测试异常", 400) + fmt.Println("GetOrderTotal >>>> ", totalPrice) + return totalPrice, tb.Error //err +} diff --git a/shoppingCart-service/domain/service/cart_service.go b/shoppingCart-service/domain/service/cart_service.go index 8645880..f405659 100644 --- a/shoppingCart-service/domain/service/cart_service.go +++ b/shoppingCart-service/domain/service/cart_service.go @@ -9,6 +9,7 @@ import ( type ICartService interface { AddCart(*proto.AddCartReq) (obj *model.ShoppingCart, err error) UpdateCart(*proto.UpdateCartReq) (obj *model.ShoppingCart, err error) + GetOrderTotal(int32List []int32) (obj float32, err error) } type CartService struct { cartRepository repository.ICartRepository @@ -30,3 +31,6 @@ func (u *CartService) AddCart(req *proto.AddCartReq) (obj *model.ShoppingCart, e func (u *CartService) UpdateCart(req *proto.UpdateCartReq) (obj *model.ShoppingCart, err error) { return u.cartRepository.UpdateCart(req) } +func (u *CartService) GetOrderTotal(int32List []int32) (obj float32, err error) { + return u.cartRepository.GetOrderTotal(int32List) +} diff --git a/shoppingCart-service/handler/cart_handler.go b/shoppingCart-service/handler/cart_handler.go index 039bc1c..33aa57b 100644 --- a/shoppingCart-service/handler/cart_handler.go +++ b/shoppingCart-service/handler/cart_handler.go @@ -5,6 +5,8 @@ import ( "fmt" "shoppingCart/domain/service" "shoppingCart/proto" + "strconv" + "strings" ) type CartHandler struct { @@ -41,3 +43,28 @@ func (u *CartHandler) UpdateCart(ctx context.Context, req *proto.UpdateCartReq, } return err } + +// (int32List []int32) (obj *float32, err error) +func (u *CartHandler) GetOrderTotal(ctx context.Context, req *proto.OrderTotalReq, obj *proto.OrderTotalResp) error { + //int32List := SplitToInt32List(req.GetCartIds(), ",") + obj.TotalPrice, _ = u.CartService.GetOrderTotal(req.GetCartIds()) + return nil +} + +// 格式化页面传入的cartIds +func SplitToInt32List(str string, sep string) (int32List []int32) { + tempStr := strings.Split(str, sep) + if len(tempStr) > 0 { + for _, item := range tempStr { + if item == "" { + continue + } + val, err := strconv.ParseInt(item, 10, 32) + if err != nil { + continue + } + int32List = append(int32List, int32(val)) + } + } + return int32List +} diff --git a/shoppingCart-service/main.go b/shoppingCart-service/main.go index 4d12b3e..0b35c3f 100644 --- a/shoppingCart-service/main.go +++ b/shoppingCart-service/main.go @@ -62,6 +62,7 @@ func main() { proto.RegisterAddCartHandler(repcService.Server(), &handler.CartHandler{cartService}) //4.注册handler proto.RegisterUpdateCartHandler(repcService.Server(), &handler.CartHandler{cartService}) + proto.RegisterGetOrderTotalHandler(repcService.Server(), &handler.CartHandler{cartService}) //5.启动服务 if err := repcService.Run(); err != nil { diff --git a/shoppingCart-service/proto/cart.pb.go b/shoppingCart-service/proto/cart.pb.go index 9eb161d..e62f550 100644 --- a/shoppingCart-service/proto/cart.pb.go +++ b/shoppingCart-service/proto/cart.pb.go @@ -1609,6 +1609,102 @@ func (x *UpdateSkuResp) GetIsSuccess() bool { return false } +// 计算订单价格 请求 +type OrderTotalReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CartIds []int32 `protobuf:"varint,1,rep,packed,name=cartIds,proto3" json:"cartIds,omitempty"` +} + +func (x *OrderTotalReq) Reset() { + *x = OrderTotalReq{} + if protoimpl.UnsafeEnabled { + mi := &file_cart_proto_msgTypes[20] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OrderTotalReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OrderTotalReq) ProtoMessage() {} + +func (x *OrderTotalReq) ProtoReflect() protoreflect.Message { + mi := &file_cart_proto_msgTypes[20] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OrderTotalReq.ProtoReflect.Descriptor instead. +func (*OrderTotalReq) Descriptor() ([]byte, []int) { + return file_cart_proto_rawDescGZIP(), []int{20} +} + +func (x *OrderTotalReq) GetCartIds() []int32 { + if x != nil { + return x.CartIds + } + return nil +} + +// 计算订单价格 响应 +type OrderTotalResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TotalPrice float32 `protobuf:"fixed32,1,opt,name=totalPrice,proto3" json:"totalPrice,omitempty"` +} + +func (x *OrderTotalResp) Reset() { + *x = OrderTotalResp{} + if protoimpl.UnsafeEnabled { + mi := &file_cart_proto_msgTypes[21] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OrderTotalResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OrderTotalResp) ProtoMessage() {} + +func (x *OrderTotalResp) ProtoReflect() protoreflect.Message { + mi := &file_cart_proto_msgTypes[21] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OrderTotalResp.ProtoReflect.Descriptor instead. +func (*OrderTotalResp) Descriptor() ([]byte, []int) { + return file_cart_proto_rawDescGZIP(), []int{21} +} + +func (x *OrderTotalResp) GetTotalPrice() float32 { + if x != nil { + return x.TotalPrice + } + return 0 +} + var File_cart_proto protoreflect.FileDescriptor var file_cart_proto_rawDesc = []byte{ @@ -1825,49 +1921,60 @@ var file_cart_proto_rawDesc = []byte{ 0x75, 0x22, 0x2d, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, - 0x32, 0x3d, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x43, 0x61, 0x72, 0x74, 0x12, 0x32, 0x0a, 0x07, 0x41, - 0x64, 0x64, 0x43, 0x61, 0x72, 0x74, 0x12, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, - 0x64, 0x64, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, - 0x49, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x72, 0x74, 0x12, 0x3b, 0x0a, - 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x72, 0x74, 0x12, 0x14, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, - 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, - 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x41, 0x0a, 0x08, 0x46, 0x69, - 0x6e, 0x64, 0x43, 0x61, 0x72, 0x74, 0x12, 0x35, 0x0a, 0x08, 0x46, 0x69, 0x6e, 0x64, 0x43, 0x61, - 0x72, 0x74, 0x12, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x43, - 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, - 0x69, 0x6e, 0x64, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x31, 0x0a, - 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x29, 0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, - 0x32, 0x5d, 0x0a, 0x11, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, - 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x48, 0x0a, 0x11, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, - 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, - 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, - 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, - 0x51, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, - 0x75, 0x12, 0x3f, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, - 0x53, 0x6b, 0x75, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, - 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, - 0x22, 0x00, 0x32, 0x52, 0x0a, 0x0d, 0x53, 0x68, 0x6f, 0x77, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, - 0x53, 0x6b, 0x75, 0x12, 0x41, 0x0a, 0x0d, 0x53, 0x68, 0x6f, 0x77, 0x44, 0x65, 0x74, 0x61, 0x69, - 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, - 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, - 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x43, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, - 0x72, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x33, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, - 0x72, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, - 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x45, 0x0a, 0x09, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x12, 0x38, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, - 0x74, 0x65, 0x53, 0x6b, 0x75, 0x12, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, - 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, - 0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x22, 0x29, 0x0a, 0x0d, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x65, + 0x71, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x61, 0x72, 0x74, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, + 0x28, 0x05, 0x52, 0x07, 0x63, 0x61, 0x72, 0x74, 0x49, 0x64, 0x73, 0x22, 0x30, 0x0a, 0x0e, 0x4f, + 0x72, 0x64, 0x65, 0x72, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, + 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x02, 0x52, 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x32, 0x3d, 0x0a, + 0x07, 0x41, 0x64, 0x64, 0x43, 0x61, 0x72, 0x74, 0x12, 0x32, 0x0a, 0x07, 0x41, 0x64, 0x64, 0x43, + 0x61, 0x72, 0x74, 0x12, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x43, + 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, + 0x64, 0x64, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x49, 0x0a, 0x0a, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x72, 0x74, 0x12, 0x3b, 0x0a, 0x0a, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x72, 0x74, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x15, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x72, + 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x41, 0x0a, 0x08, 0x46, 0x69, 0x6e, 0x64, 0x43, + 0x61, 0x72, 0x74, 0x12, 0x35, 0x0a, 0x08, 0x46, 0x69, 0x6e, 0x64, 0x43, 0x61, 0x72, 0x74, 0x12, + 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x43, 0x61, 0x72, 0x74, + 0x52, 0x65, 0x71, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x69, 0x6e, 0x64, + 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x31, 0x0a, 0x04, 0x50, 0x61, + 0x67, 0x65, 0x12, 0x29, 0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x5d, 0x0a, + 0x11, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, + 0x69, 0x6c, 0x12, 0x48, 0x0a, 0x11, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, + 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, + 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, + 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x51, 0x0a, 0x0e, + 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x12, 0x3f, + 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, + 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, + 0x53, 0x6b, 0x75, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, + 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, + 0x52, 0x0a, 0x0d, 0x53, 0x68, 0x6f, 0x77, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x6b, 0x75, + 0x12, 0x41, 0x0a, 0x0d, 0x53, 0x68, 0x6f, 0x77, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x53, 0x6b, + 0x75, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, + 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, + 0x70, 0x22, 0x00, 0x32, 0x43, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x54, 0x6f, + 0x6b, 0x65, 0x6e, 0x12, 0x33, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x54, 0x6f, + 0x6b, 0x65, 0x6e, 0x12, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x6f, 0x6b, 0x65, + 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, 0x6f, 0x6b, + 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x45, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x53, 0x6b, 0x75, 0x12, 0x38, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, + 0x6b, 0x75, 0x12, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, + 0x65, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, + 0x4f, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x54, 0x6f, 0x74, 0x61, 0x6c, + 0x12, 0x3e, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x54, 0x6f, 0x74, 0x61, + 0x6c, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x54, + 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x4f, 0x72, 0x64, 0x65, 0x72, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, + 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x06, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1882,7 +1989,7 @@ func file_cart_proto_rawDescGZIP() []byte { return file_cart_proto_rawDescData } -var file_cart_proto_msgTypes = make([]protoimpl.MessageInfo, 21) +var file_cart_proto_msgTypes = make([]protoimpl.MessageInfo, 23) var file_cart_proto_goTypes = []interface{}{ (*ShoppingCart)(nil), // 0: proto.ShoppingCart (*AddCartReq)(nil), // 1: proto.AddCartReq @@ -1904,13 +2011,15 @@ var file_cart_proto_goTypes = []interface{}{ (*TokenResp)(nil), // 17: proto.TokenResp (*UpdateSkuReq)(nil), // 18: proto.UpdateSkuReq (*UpdateSkuResp)(nil), // 19: proto.UpdateSkuResp - nil, // 20: proto.Product.LabelListEntry + (*OrderTotalReq)(nil), // 20: proto.OrderTotalReq + (*OrderTotalResp)(nil), // 21: proto.OrderTotalResp + nil, // 22: proto.Product.LabelListEntry } var file_cart_proto_depIdxs = []int32{ 10, // 0: proto.AddCartResp.productSimple:type_name -> proto.ProductDetail 13, // 1: proto.AddCartResp.productSkuSimple:type_name -> proto.ProductSku 0, // 2: proto.FindCartResp.shoppingCarts:type_name -> proto.ShoppingCart - 20, // 3: proto.Product.labelList:type_name -> proto.Product.LabelListEntry + 22, // 3: proto.Product.labelList:type_name -> proto.Product.LabelListEntry 7, // 4: proto.PageResp.product:type_name -> proto.Product 10, // 5: proto.ProductDetailResp.productDetail:type_name -> proto.ProductDetail 13, // 6: proto.ProductSkuResp.productSku:type_name -> proto.ProductSku @@ -1924,17 +2033,19 @@ var file_cart_proto_depIdxs = []int32{ 11, // 14: proto.ShowDetailSku.ShowDetailSku:input_type -> proto.ProductDetailReq 16, // 15: proto.GetUserToken.GetUserToken:input_type -> proto.TokenReq 18, // 16: proto.UpdateSku.UpdateSku:input_type -> proto.UpdateSkuReq - 2, // 17: proto.AddCart.AddCart:output_type -> proto.AddCartResp - 4, // 18: proto.UpdateCart.UpdateCart:output_type -> proto.UpdateCartResp - 6, // 19: proto.FindCart.FindCart:output_type -> proto.FindCartResp - 9, // 20: proto.Page.Page:output_type -> proto.PageResp - 12, // 21: proto.ShowProductDetail.ShowProductDetail:output_type -> proto.ProductDetailResp - 15, // 22: proto.ShowProductSku.ShowProductSku:output_type -> proto.ProductSkuResp - 15, // 23: proto.ShowDetailSku.ShowDetailSku:output_type -> proto.ProductSkuResp - 17, // 24: proto.GetUserToken.GetUserToken:output_type -> proto.TokenResp - 19, // 25: proto.UpdateSku.UpdateSku:output_type -> proto.UpdateSkuResp - 17, // [17:26] is the sub-list for method output_type - 8, // [8:17] is the sub-list for method input_type + 20, // 17: proto.GetOrderTotal.GetOrderTotal:input_type -> proto.OrderTotalReq + 2, // 18: proto.AddCart.AddCart:output_type -> proto.AddCartResp + 4, // 19: proto.UpdateCart.UpdateCart:output_type -> proto.UpdateCartResp + 6, // 20: proto.FindCart.FindCart:output_type -> proto.FindCartResp + 9, // 21: proto.Page.Page:output_type -> proto.PageResp + 12, // 22: proto.ShowProductDetail.ShowProductDetail:output_type -> proto.ProductDetailResp + 15, // 23: proto.ShowProductSku.ShowProductSku:output_type -> proto.ProductSkuResp + 15, // 24: proto.ShowDetailSku.ShowDetailSku:output_type -> proto.ProductSkuResp + 17, // 25: proto.GetUserToken.GetUserToken:output_type -> proto.TokenResp + 19, // 26: proto.UpdateSku.UpdateSku:output_type -> proto.UpdateSkuResp + 21, // 27: proto.GetOrderTotal.GetOrderTotal:output_type -> proto.OrderTotalResp + 18, // [18:28] is the sub-list for method output_type + 8, // [8:18] is the sub-list for method input_type 8, // [8:8] is the sub-list for extension type_name 8, // [8:8] is the sub-list for extension extendee 0, // [0:8] is the sub-list for field type_name @@ -2186,6 +2297,30 @@ func file_cart_proto_init() { return nil } } + file_cart_proto_msgTypes[20].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OrderTotalReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_cart_proto_msgTypes[21].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OrderTotalResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -2193,9 +2328,9 @@ func file_cart_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_cart_proto_rawDesc, NumEnums: 0, - NumMessages: 21, + NumMessages: 23, NumExtensions: 0, - NumServices: 9, + NumServices: 10, }, GoTypes: file_cart_proto_goTypes, DependencyIndexes: file_cart_proto_depIdxs, diff --git a/shoppingCart-service/proto/cart.pb.micro.go b/shoppingCart-service/proto/cart.pb.micro.go index 4726911..fa7d718 100644 --- a/shoppingCart-service/proto/cart.pb.micro.go +++ b/shoppingCart-service/proto/cart.pb.micro.go @@ -571,3 +571,64 @@ type updateSkuHandler struct { func (h *updateSkuHandler) UpdateSku(ctx context.Context, in *UpdateSkuReq, out *UpdateSkuResp) error { return h.UpdateSkuHandler.UpdateSku(ctx, in, out) } + +// Api Endpoints for GetOrderTotal service + +func NewGetOrderTotalEndpoints() []*api.Endpoint { + return []*api.Endpoint{} +} + +// Client API for GetOrderTotal service + +type GetOrderTotalService interface { + // rpc 服务 + GetOrderTotal(ctx context.Context, in *OrderTotalReq, opts ...client.CallOption) (*OrderTotalResp, error) +} + +type getOrderTotalService struct { + c client.Client + name string +} + +func NewGetOrderTotalService(name string, c client.Client) GetOrderTotalService { + return &getOrderTotalService{ + c: c, + name: name, + } +} + +func (c *getOrderTotalService) GetOrderTotal(ctx context.Context, in *OrderTotalReq, opts ...client.CallOption) (*OrderTotalResp, error) { + req := c.c.NewRequest(c.name, "GetOrderTotal.GetOrderTotal", in) + out := new(OrderTotalResp) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for GetOrderTotal service + +type GetOrderTotalHandler interface { + // rpc 服务 + GetOrderTotal(context.Context, *OrderTotalReq, *OrderTotalResp) error +} + +func RegisterGetOrderTotalHandler(s server.Server, hdlr GetOrderTotalHandler, opts ...server.HandlerOption) error { + type getOrderTotal interface { + GetOrderTotal(ctx context.Context, in *OrderTotalReq, out *OrderTotalResp) error + } + type GetOrderTotal struct { + getOrderTotal + } + h := &getOrderTotalHandler{hdlr} + return s.Handle(s.NewHandler(&GetOrderTotal{h}, opts...)) +} + +type getOrderTotalHandler struct { + GetOrderTotalHandler +} + +func (h *getOrderTotalHandler) GetOrderTotal(ctx context.Context, in *OrderTotalReq, out *OrderTotalResp) error { + return h.GetOrderTotalHandler.GetOrderTotal(ctx, in, out) +} diff --git a/shoppingCart-service/proto/cart.proto b/shoppingCart-service/proto/cart.proto index 31505d2..d41ba45 100644 --- a/shoppingCart-service/proto/cart.proto +++ b/shoppingCart-service/proto/cart.proto @@ -288,3 +288,16 @@ message UpdateSkuResp { service UpdateSku { rpc UpdateSku (UpdateSkuReq) returns (UpdateSkuResp){} } +// 计算订单价格 请求 +message OrderTotalReq { + repeated int32 cartIds = 1; +} +//计算订单价格 响应 +message OrderTotalResp{ + float totalPrice = 1; +} +//RPC 计算订单价格 服务 接口 +service GetOrderTotal { + //rpc 服务 + rpc GetOrderTotal (OrderTotalReq) returns (OrderTotalResp){} +} diff --git a/trade-order/client/client.go b/trade-order/client/client.go index 9cecd71..2beed2f 100644 --- a/trade-order/client/client.go +++ b/trade-order/client/client.go @@ -32,7 +32,7 @@ func main() { const ( //DTM 服务地址 DtmServer = "http://192.168.100.131:36789/api/dtmsvr" - QSBusi = "http://192.168.1.135:6669" //注意 + QSBusi = "http://192.168.40.84:6669" //注意 ) //var CartId int32 = 1 //var Number int32 = 1 @@ -56,7 +56,7 @@ func main() { hystrixStreamHandler := hystrix.NewStreamHandler() hystrixStreamHandler.Start() go func() { - err := http.ListenAndServe(net.JoinHostPort("192.168.100.1", "9097"), hystrixStreamHandler) + err := http.ListenAndServe(net.JoinHostPort("192.168.40.84", "9097"), hystrixStreamHandler) if err != nil { log.Panic(err) } @@ -76,7 +76,7 @@ func main() { //ShowProductDetailClient := proto.NewShowProductDetailService("shop-product", rpcServer.Client()) //ShowDetailSkuClient := proto.NewShowDetailSkuService("shop-product", rpcServer.Client()) GetUserTokenClient := proto.NewGetUserTokenService("shop-user", rpcServer.Client()) - //UpdateSkuClient := proto.NewUpdateSkuService("shop-product", rpcServer.Client()) + GetOrderTotalClient := proto.NewGetOrderTotalService("shop-cart", rpcServer.Client()) AddTraderClient := proto.NewAddTradeOrderService("trade-order", rpcServer.Client()) UpdateTraderClient := proto.NewUpdateTradeOrderService("trade-order", rpcServer.Client()) @@ -171,11 +171,19 @@ func main() { isVirtual, _ := strconv.ParseBool(c.Request.FormValue("isVirtual")) recipientAddressId, _ := strconv.Atoi(c.Request.FormValue("recipientAddressId")) + //统计价格 + totalReq := &proto.OrderTotalReq{ + CartIds: cartIds, + } + + totalPriceResp, _ := GetOrderTotalClient.GetOrderTotal(context.TODO(), totalReq) + log.Println("totalPrice>>>>>>>>>>>>>>>>>>>>>>>> ", totalPriceResp) //构建tradeOrder tradeOrder := &proto.TradeOrder{} tradeOrder.UserId = int32(sum) tradeOrder.CreateUser = int32(sum) tradeOrder.OrderStatus = 1 + tradeOrder.TotalAmount = totalPriceResp.TotalPrice req := &proto.AddTradeOrderReq{ CartIds: cartIds, IsVirtual: isVirtual, diff --git a/trade-order/domain/repository/trade_repository.go b/trade-order/domain/repository/trade_repository.go index 1c5dc94..fe890a9 100644 --- a/trade-order/domain/repository/trade_repository.go +++ b/trade-order/domain/repository/trade_repository.go @@ -45,6 +45,7 @@ func SwapToStruct(req, target interface{}) (err error) { return err } +// 新增订单 func (u *TradeRepository) AddTradeOrder(req *proto.AddTradeOrderReq) (obj *model.TraderOrder, err error) { trade := &model.TraderOrder{} err = SwapToStruct(req.TradeOrder, trade) @@ -65,6 +66,7 @@ func (u *TradeRepository) AddTradeOrder(req *proto.AddTradeOrderReq) (obj *model return trade, tb.Error //err } +// 修改订单 func (u *TradeRepository) UpdateTradeOrder(req *proto.AddTradeOrderReq) (obj *model.TraderOrder, err error) { trade := model.TraderOrder{} trade.UpdateTime = time.Now() // diff --git a/trade-order/main.go b/trade-order/main.go index 210f347..f591985 100644 --- a/trade-order/main.go +++ b/trade-order/main.go @@ -26,6 +26,7 @@ const ( func main() { //0 配置中心 consulConfig, err := common.GetConsulConfig(consulStr, fileKey) + if err != nil { log.Println("consulConfig err :", err) } @@ -62,7 +63,6 @@ func main() { proto.RegisterAddTradeOrderHandler(repcService.Server(), &handler.TradeOrderHandler{tradeService}) //4.注册handler proto.RegisterUpdateTradeOrderHandler(repcService.Server(), &handler.TradeOrderHandler{tradeService}) - //5.启动服务 if err := repcService.Run(); err != nil { log.Println("start cart service err :", err) diff --git a/trade-order/proto/trade.pb.go b/trade-order/proto/trade.pb.go index cdc7a1f..57254de 100644 --- a/trade-order/proto/trade.pb.go +++ b/trade-order/proto/trade.pb.go @@ -1819,6 +1819,102 @@ func (x *UpdateSkuResp) GetIsSuccess() bool { return false } +// 计算订单价格 请求 +type OrderTotalReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + CartIds []int32 `protobuf:"varint,1,rep,packed,name=cartIds,proto3" json:"cartIds,omitempty"` +} + +func (x *OrderTotalReq) Reset() { + *x = OrderTotalReq{} + if protoimpl.UnsafeEnabled { + mi := &file_trade_proto_msgTypes[22] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OrderTotalReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OrderTotalReq) ProtoMessage() {} + +func (x *OrderTotalReq) ProtoReflect() protoreflect.Message { + mi := &file_trade_proto_msgTypes[22] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OrderTotalReq.ProtoReflect.Descriptor instead. +func (*OrderTotalReq) Descriptor() ([]byte, []int) { + return file_trade_proto_rawDescGZIP(), []int{22} +} + +func (x *OrderTotalReq) GetCartIds() []int32 { + if x != nil { + return x.CartIds + } + return nil +} + +// 计算订单价格 响应 +type OrderTotalResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + TotalPrice float32 `protobuf:"fixed32,1,opt,name=totalPrice,proto3" json:"totalPrice,omitempty"` +} + +func (x *OrderTotalResp) Reset() { + *x = OrderTotalResp{} + if protoimpl.UnsafeEnabled { + mi := &file_trade_proto_msgTypes[23] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *OrderTotalResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*OrderTotalResp) ProtoMessage() {} + +func (x *OrderTotalResp) ProtoReflect() protoreflect.Message { + mi := &file_trade_proto_msgTypes[23] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use OrderTotalResp.ProtoReflect.Descriptor instead. +func (*OrderTotalResp) Descriptor() ([]byte, []int) { + return file_trade_proto_rawDescGZIP(), []int{23} +} + +func (x *OrderTotalResp) GetTotalPrice() float32 { + if x != nil { + return x.TotalPrice + } + return 0 +} + var File_trade_proto protoreflect.FileDescriptor var file_trade_proto_rawDesc = []byte{ @@ -2072,57 +2168,68 @@ var file_trade_proto_rawDesc = []byte{ 0x53, 0x6b, 0x75, 0x52, 0x0a, 0x70, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x22, 0x2d, 0x0a, 0x0d, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x32, 0x55, - 0x0a, 0x0d, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x64, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, - 0x44, 0x0a, 0x0d, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x64, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, - 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x64, - 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x64, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, - 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x5b, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, - 0x72, 0x61, 0x64, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x47, 0x0a, 0x10, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x64, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x17, 0x2e, + 0x01, 0x28, 0x08, 0x52, 0x09, 0x69, 0x73, 0x53, 0x75, 0x63, 0x63, 0x65, 0x73, 0x73, 0x22, 0x29, + 0x0a, 0x0d, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x12, + 0x18, 0x0a, 0x07, 0x63, 0x61, 0x72, 0x74, 0x49, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, + 0x52, 0x07, 0x63, 0x61, 0x72, 0x74, 0x49, 0x64, 0x73, 0x22, 0x30, 0x0a, 0x0e, 0x4f, 0x72, 0x64, + 0x65, 0x72, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x74, + 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x02, 0x52, + 0x0a, 0x74, 0x6f, 0x74, 0x61, 0x6c, 0x50, 0x72, 0x69, 0x63, 0x65, 0x32, 0x55, 0x0a, 0x0d, 0x41, + 0x64, 0x64, 0x54, 0x72, 0x61, 0x64, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x44, 0x0a, 0x0d, + 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x64, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x64, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x64, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, - 0x22, 0x00, 0x32, 0x49, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x72, 0x74, - 0x12, 0x3b, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x72, 0x74, 0x12, 0x14, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x72, - 0x74, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, - 0x61, 0x74, 0x65, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x41, 0x0a, - 0x08, 0x46, 0x69, 0x6e, 0x64, 0x43, 0x61, 0x72, 0x74, 0x12, 0x35, 0x0a, 0x08, 0x46, 0x69, 0x6e, - 0x64, 0x43, 0x61, 0x72, 0x74, 0x12, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x69, - 0x6e, 0x64, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, - 0x32, 0x31, 0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x29, 0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, - 0x12, 0x0e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, - 0x1a, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, - 0x70, 0x22, 0x00, 0x32, 0x5d, 0x0a, 0x11, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, - 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x48, 0x0a, 0x11, 0x53, 0x68, 0x6f, 0x77, - 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x17, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, - 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, - 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, - 0x22, 0x00, 0x32, 0x51, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, - 0x74, 0x53, 0x6b, 0x75, 0x12, 0x3f, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, - 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, - 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, - 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x52, 0x0a, 0x0d, 0x53, 0x68, 0x6f, 0x77, 0x44, 0x65, 0x74, - 0x61, 0x69, 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x41, 0x0a, 0x0d, 0x53, 0x68, 0x6f, 0x77, 0x44, 0x65, - 0x74, 0x61, 0x69, 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, - 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, - 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, - 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x43, 0x0a, 0x0c, 0x47, 0x65, 0x74, - 0x55, 0x73, 0x65, 0x72, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x33, 0x0a, 0x0c, 0x47, 0x65, 0x74, - 0x55, 0x73, 0x65, 0x72, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x45, - 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x12, 0x38, 0x0a, 0x09, 0x55, - 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x12, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x52, - 0x65, 0x73, 0x70, 0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x22, 0x00, 0x32, 0x5b, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x54, 0x72, 0x61, 0x64, + 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x47, 0x0a, 0x10, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x54, 0x72, 0x61, 0x64, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x54, 0x72, 0x61, 0x64, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, + 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x64, 0x64, 0x54, + 0x72, 0x61, 0x64, 0x65, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, + 0x49, 0x0a, 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x72, 0x74, 0x12, 0x3b, 0x0a, + 0x0a, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x72, 0x74, 0x12, 0x14, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, + 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, + 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x41, 0x0a, 0x08, 0x46, 0x69, + 0x6e, 0x64, 0x43, 0x61, 0x72, 0x74, 0x12, 0x35, 0x0a, 0x08, 0x46, 0x69, 0x6e, 0x64, 0x43, 0x61, + 0x72, 0x74, 0x12, 0x12, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, 0x69, 0x6e, 0x64, 0x43, + 0x61, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x46, + 0x69, 0x6e, 0x64, 0x43, 0x61, 0x72, 0x74, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x31, 0x0a, + 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x29, 0x0a, 0x04, 0x50, 0x61, 0x67, 0x65, 0x12, 0x0e, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, + 0x32, 0x5d, 0x0a, 0x11, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, + 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x48, 0x0a, 0x11, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, + 0x52, 0x65, 0x71, 0x1a, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, + 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, + 0x51, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, + 0x75, 0x12, 0x3f, 0x0a, 0x0e, 0x53, 0x68, 0x6f, 0x77, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, + 0x53, 0x6b, 0x75, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, + 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, + 0x22, 0x00, 0x32, 0x52, 0x0a, 0x0d, 0x53, 0x68, 0x6f, 0x77, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, + 0x53, 0x6b, 0x75, 0x12, 0x41, 0x0a, 0x0d, 0x53, 0x68, 0x6f, 0x77, 0x44, 0x65, 0x74, 0x61, 0x69, + 0x6c, 0x53, 0x6b, 0x75, 0x12, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, + 0x64, 0x75, 0x63, 0x74, 0x44, 0x65, 0x74, 0x61, 0x69, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x72, 0x6f, 0x64, 0x75, 0x63, 0x74, 0x53, 0x6b, 0x75, + 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x43, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, + 0x72, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x33, 0x0a, 0x0c, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, + 0x72, 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x12, 0x0f, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x54, + 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x71, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x54, 0x6f, 0x6b, 0x65, 0x6e, 0x52, 0x65, 0x73, 0x70, 0x22, 0x00, 0x32, 0x45, 0x0a, 0x09, 0x55, + 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x12, 0x38, 0x0a, 0x09, 0x55, 0x70, 0x64, 0x61, + 0x74, 0x65, 0x53, 0x6b, 0x75, 0x12, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x70, + 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x71, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x55, 0x70, 0x64, 0x61, 0x74, 0x65, 0x53, 0x6b, 0x75, 0x52, 0x65, 0x73, 0x70, + 0x22, 0x00, 0x32, 0x4f, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x54, 0x6f, + 0x74, 0x61, 0x6c, 0x12, 0x3e, 0x0a, 0x0d, 0x47, 0x65, 0x74, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x54, + 0x6f, 0x74, 0x61, 0x6c, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4f, 0x72, 0x64, + 0x65, 0x72, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x71, 0x1a, 0x15, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x4f, 0x72, 0x64, 0x65, 0x72, 0x54, 0x6f, 0x74, 0x61, 0x6c, 0x52, 0x65, 0x73, + 0x70, 0x22, 0x00, 0x42, 0x0a, 0x5a, 0x08, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -2137,7 +2244,7 @@ func file_trade_proto_rawDescGZIP() []byte { return file_trade_proto_rawDescData } -var file_trade_proto_msgTypes = make([]protoimpl.MessageInfo, 23) +var file_trade_proto_msgTypes = make([]protoimpl.MessageInfo, 25) var file_trade_proto_goTypes = []interface{}{ (*TradeOrder)(nil), // 0: proto.TradeOrder (*AddTradeOrderReq)(nil), // 1: proto.AddTradeOrderReq @@ -2161,14 +2268,16 @@ var file_trade_proto_goTypes = []interface{}{ (*TokenResp)(nil), // 19: proto.TokenResp (*UpdateSkuReq)(nil), // 20: proto.UpdateSkuReq (*UpdateSkuResp)(nil), // 21: proto.UpdateSkuResp - nil, // 22: proto.Product.LabelListEntry + (*OrderTotalReq)(nil), // 22: proto.OrderTotalReq + (*OrderTotalResp)(nil), // 23: proto.OrderTotalResp + nil, // 24: proto.Product.LabelListEntry } var file_trade_proto_depIdxs = []int32{ 0, // 0: proto.AddTradeOrderReq.tradeOrder:type_name -> proto.TradeOrder 0, // 1: proto.AddTradeOrderResp.tradeOrder:type_name -> proto.TradeOrder 3, // 2: proto.AddTradeOrderResp.products:type_name -> proto.ProductOrder 4, // 3: proto.FindCartResp.shoppingCarts:type_name -> proto.ShoppingCart - 22, // 4: proto.Product.labelList:type_name -> proto.Product.LabelListEntry + 24, // 4: proto.Product.labelList:type_name -> proto.Product.LabelListEntry 9, // 5: proto.PageResp.product:type_name -> proto.Product 12, // 6: proto.ProductDetailResp.productDetail:type_name -> proto.ProductDetail 15, // 7: proto.ProductSkuResp.productSku:type_name -> proto.ProductSku @@ -2183,18 +2292,20 @@ var file_trade_proto_depIdxs = []int32{ 13, // 16: proto.ShowDetailSku.ShowDetailSku:input_type -> proto.ProductDetailReq 18, // 17: proto.GetUserToken.GetUserToken:input_type -> proto.TokenReq 20, // 18: proto.UpdateSku.UpdateSku:input_type -> proto.UpdateSkuReq - 2, // 19: proto.AddTradeOrder.AddTradeOrder:output_type -> proto.AddTradeOrderResp - 2, // 20: proto.UpdateTradeOrder.UpdateTradeOrder:output_type -> proto.AddTradeOrderResp - 6, // 21: proto.UpdateCart.UpdateCart:output_type -> proto.UpdateCartResp - 8, // 22: proto.FindCart.FindCart:output_type -> proto.FindCartResp - 11, // 23: proto.Page.Page:output_type -> proto.PageResp - 14, // 24: proto.ShowProductDetail.ShowProductDetail:output_type -> proto.ProductDetailResp - 17, // 25: proto.ShowProductSku.ShowProductSku:output_type -> proto.ProductSkuResp - 17, // 26: proto.ShowDetailSku.ShowDetailSku:output_type -> proto.ProductSkuResp - 19, // 27: proto.GetUserToken.GetUserToken:output_type -> proto.TokenResp - 21, // 28: proto.UpdateSku.UpdateSku:output_type -> proto.UpdateSkuResp - 19, // [19:29] is the sub-list for method output_type - 9, // [9:19] is the sub-list for method input_type + 22, // 19: proto.GetOrderTotal.GetOrderTotal:input_type -> proto.OrderTotalReq + 2, // 20: proto.AddTradeOrder.AddTradeOrder:output_type -> proto.AddTradeOrderResp + 2, // 21: proto.UpdateTradeOrder.UpdateTradeOrder:output_type -> proto.AddTradeOrderResp + 6, // 22: proto.UpdateCart.UpdateCart:output_type -> proto.UpdateCartResp + 8, // 23: proto.FindCart.FindCart:output_type -> proto.FindCartResp + 11, // 24: proto.Page.Page:output_type -> proto.PageResp + 14, // 25: proto.ShowProductDetail.ShowProductDetail:output_type -> proto.ProductDetailResp + 17, // 26: proto.ShowProductSku.ShowProductSku:output_type -> proto.ProductSkuResp + 17, // 27: proto.ShowDetailSku.ShowDetailSku:output_type -> proto.ProductSkuResp + 19, // 28: proto.GetUserToken.GetUserToken:output_type -> proto.TokenResp + 21, // 29: proto.UpdateSku.UpdateSku:output_type -> proto.UpdateSkuResp + 23, // 30: proto.GetOrderTotal.GetOrderTotal:output_type -> proto.OrderTotalResp + 20, // [20:31] is the sub-list for method output_type + 9, // [9:20] is the sub-list for method input_type 9, // [9:9] is the sub-list for extension type_name 9, // [9:9] is the sub-list for extension extendee 0, // [0:9] is the sub-list for field type_name @@ -2470,6 +2581,30 @@ func file_trade_proto_init() { return nil } } + file_trade_proto_msgTypes[22].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OrderTotalReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_trade_proto_msgTypes[23].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*OrderTotalResp); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -2477,9 +2612,9 @@ func file_trade_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_trade_proto_rawDesc, NumEnums: 0, - NumMessages: 23, + NumMessages: 25, NumExtensions: 0, - NumServices: 10, + NumServices: 11, }, GoTypes: file_trade_proto_goTypes, DependencyIndexes: file_trade_proto_depIdxs, @@ -3234,3 +3369,77 @@ var _UpdateSku_serviceDesc = grpc.ServiceDesc{ Streams: []grpc.StreamDesc{}, Metadata: "trade.proto", } + +// GetOrderTotalClient is the client API for GetOrderTotal service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://godoc.org/google.golang.org/grpc#ClientConn.NewStream. +type GetOrderTotalClient interface { + // rpc 服务 + GetOrderTotal(ctx context.Context, in *OrderTotalReq, opts ...grpc.CallOption) (*OrderTotalResp, error) +} + +type getOrderTotalClient struct { + cc grpc.ClientConnInterface +} + +func NewGetOrderTotalClient(cc grpc.ClientConnInterface) GetOrderTotalClient { + return &getOrderTotalClient{cc} +} + +func (c *getOrderTotalClient) GetOrderTotal(ctx context.Context, in *OrderTotalReq, opts ...grpc.CallOption) (*OrderTotalResp, error) { + out := new(OrderTotalResp) + err := c.cc.Invoke(ctx, "/proto.GetOrderTotal/GetOrderTotal", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// GetOrderTotalServer is the server API for GetOrderTotal service. +type GetOrderTotalServer interface { + // rpc 服务 + GetOrderTotal(context.Context, *OrderTotalReq) (*OrderTotalResp, error) +} + +// UnimplementedGetOrderTotalServer can be embedded to have forward compatible implementations. +type UnimplementedGetOrderTotalServer struct { +} + +func (*UnimplementedGetOrderTotalServer) GetOrderTotal(context.Context, *OrderTotalReq) (*OrderTotalResp, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetOrderTotal not implemented") +} + +func RegisterGetOrderTotalServer(s *grpc.Server, srv GetOrderTotalServer) { + s.RegisterService(&_GetOrderTotal_serviceDesc, srv) +} + +func _GetOrderTotal_GetOrderTotal_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(OrderTotalReq) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GetOrderTotalServer).GetOrderTotal(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.GetOrderTotal/GetOrderTotal", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GetOrderTotalServer).GetOrderTotal(ctx, req.(*OrderTotalReq)) + } + return interceptor(ctx, in, info, handler) +} + +var _GetOrderTotal_serviceDesc = grpc.ServiceDesc{ + ServiceName: "proto.GetOrderTotal", + HandlerType: (*GetOrderTotalServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "GetOrderTotal", + Handler: _GetOrderTotal_GetOrderTotal_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "trade.proto", +} diff --git a/trade-order/proto/trade.pb.micro.go b/trade-order/proto/trade.pb.micro.go index 1a386e9..de7cf9b 100644 --- a/trade-order/proto/trade.pb.micro.go +++ b/trade-order/proto/trade.pb.micro.go @@ -632,3 +632,64 @@ type updateSkuHandler struct { func (h *updateSkuHandler) UpdateSku(ctx context.Context, in *UpdateSkuReq, out *UpdateSkuResp) error { return h.UpdateSkuHandler.UpdateSku(ctx, in, out) } + +// Api Endpoints for GetOrderTotal service + +func NewGetOrderTotalEndpoints() []*api.Endpoint { + return []*api.Endpoint{} +} + +// Client API for GetOrderTotal service + +type GetOrderTotalService interface { + // rpc 服务 + GetOrderTotal(ctx context.Context, in *OrderTotalReq, opts ...client.CallOption) (*OrderTotalResp, error) +} + +type getOrderTotalService struct { + c client.Client + name string +} + +func NewGetOrderTotalService(name string, c client.Client) GetOrderTotalService { + return &getOrderTotalService{ + c: c, + name: name, + } +} + +func (c *getOrderTotalService) GetOrderTotal(ctx context.Context, in *OrderTotalReq, opts ...client.CallOption) (*OrderTotalResp, error) { + req := c.c.NewRequest(c.name, "GetOrderTotal.GetOrderTotal", in) + out := new(OrderTotalResp) + err := c.c.Call(ctx, req, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// Server API for GetOrderTotal service + +type GetOrderTotalHandler interface { + // rpc 服务 + GetOrderTotal(context.Context, *OrderTotalReq, *OrderTotalResp) error +} + +func RegisterGetOrderTotalHandler(s server.Server, hdlr GetOrderTotalHandler, opts ...server.HandlerOption) error { + type getOrderTotal interface { + GetOrderTotal(ctx context.Context, in *OrderTotalReq, out *OrderTotalResp) error + } + type GetOrderTotal struct { + getOrderTotal + } + h := &getOrderTotalHandler{hdlr} + return s.Handle(s.NewHandler(&GetOrderTotal{h}, opts...)) +} + +type getOrderTotalHandler struct { + GetOrderTotalHandler +} + +func (h *getOrderTotalHandler) GetOrderTotal(ctx context.Context, in *OrderTotalReq, out *OrderTotalResp) error { + return h.GetOrderTotalHandler.GetOrderTotal(ctx, in, out) +} diff --git a/trade-order/proto/trade.proto b/trade-order/proto/trade.proto index b95bd09..9648c9d 100644 --- a/trade-order/proto/trade.proto +++ b/trade-order/proto/trade.proto @@ -303,3 +303,22 @@ message UpdateSkuResp { service UpdateSku { rpc UpdateSku (UpdateSkuReq) returns (UpdateSkuResp){} } + + +// 计算订单价格 请求 +message OrderTotalReq { + repeated int32 cartIds = 1; +} +//计算订单价格 响应 +message OrderTotalResp{ + float totalPrice = 1; +} +//RPC 计算订单价格 服务 接口 +service GetOrderTotal { + //rpc 服务 + rpc GetOrderTotal (OrderTotalReq) returns (OrderTotalResp){} +} + + + +