diff --git a/model/gmodel/fs_order_logic.go b/model/gmodel/fs_order_logic.go index 503231af..a6fdb2b2 100644 --- a/model/gmodel/fs_order_logic.go +++ b/model/gmodel/fs_order_logic.go @@ -97,7 +97,7 @@ type OrderStatus struct { type OrderProduct struct { TotalPrice AmountInfo `json:"amount"` // 商品总价 ExpectedDeliveryTime *time.Time `json:"expected_delivery_time"` // 预计到货时间 - PurchaseQuantity int64 `json:"purchase_quantity"` // 购买数量 + PurchaseQuantity PurchaseQuantity `json:"purchase_quantity"` // 购买数量 ProductID int64 `json:"product_id"` // 商品ID ProductName string `json:"product_name"` // 商品名称 ItemPrice AmountInfo `json:"product_price"` // 商品单价 @@ -112,6 +112,10 @@ type OrderProduct struct { StepNum []int `json:"step_num"` // 阶梯数量 IsHighlyCustomized int64 `json:"is_highly_customized"` } +type PurchaseQuantity struct { + Current interface{} `json:"current"` + Initiate interface{} `json:"initiate"` +} type OrderProductSizeInfo struct { SizeID int64 `json:"size_id"` diff --git a/service/repositories/order.go b/service/repositories/order.go index 4e5b135d..974be1ca 100644 --- a/service/repositories/order.go +++ b/service/repositories/order.go @@ -863,7 +863,10 @@ func (d *defaultOrder) Create(ctx context.Context, in *CreateReq) (res *CreateRe OriginalCurrency: in.OriginalCurrency, }), ExpectedDeliveryTime: &in.ExpectedDeliveryTime, - PurchaseQuantity: *shoppingCart.PurchaseQuantity, + PurchaseQuantity: gmodel.PurchaseQuantity{ + Current: *shoppingCart.PurchaseQuantity, + Initiate: *shoppingCart.PurchaseQuantity, + }, ProductID: *shoppingCart.ProductId, ProductCover: *shoppingCart.ShoppingCartProduct.Cover, ProductCoverMetadata: productCoverMetadata, @@ -1032,7 +1035,8 @@ func (d *defaultOrder) OrderDetailHandler(ctx context.Context, orderInfo *gmodel if original == 1 { for orderProductKey, orderProduct := range orderDetail.OrderProduct { orderDetail.OrderProduct[orderProductKey].TotalPrice = order.GetAmountInfoFormat(&orderProduct.TotalPrice) - orderDetail.OrderProduct[orderProductKey].ItemPrice = order.GetAmountInfoFormat(&orderProduct.ItemPrice) + orderDetail.OrderProduct[orderProductKey].TotalPrice = order.GetAmountInfoFormat(&orderProduct.TotalPrice) + orderDetail.OrderProduct[orderProductKey].PurchaseQuantity = order.GetPurchaseQuantity(&orderProduct.PurchaseQuantity) orderDetail.OrderProduct[orderProductKey].ShoppingCartSnapshot = nil orderDetail.OrderProduct[orderProductKey].ProductSnapshot = nil } diff --git a/utils/order/order.go b/utils/order/order.go index 61b49a16..5337531b 100644 --- a/utils/order/order.go +++ b/utils/order/order.go @@ -5,6 +5,7 @@ import ( "fusenapi/constants" "fusenapi/model/gmodel" "fusenapi/utils/format" + "strconv" "time" ) @@ -112,6 +113,14 @@ func GetAmountInfoFormat(req *gmodel.AmountInfo) gmodel.AmountInfo { } } +// 处理商品数量 +func GetPurchaseQuantity(req *gmodel.PurchaseQuantity) gmodel.PurchaseQuantity { + return gmodel.PurchaseQuantity{ + Initiate: strconv.FormatInt(int64(req.Initiate.(float64)), 10), + Current: strconv.FormatInt(int64(req.Current.(float64)), 10), + } +} + // 生成订单编号 func GenerateOrderNumber() string { t := time.Now()