From e87dd4f80082c9bc0350fa07552088ded2afc23f Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Thu, 21 Sep 2023 15:40:56 +0800 Subject: [PATCH] fix --- .../internal/logic/getcartslogic.go | 23 ++++++---------- server/shopping-cart/internal/types/types.go | 27 ++++++++++--------- server_api/shopping-cart.api | 27 ++++++++++--------- 3 files changed, 36 insertions(+), 41 deletions(-) diff --git a/server/shopping-cart/internal/logic/getcartslogic.go b/server/shopping-cart/internal/logic/getcartslogic.go index 96a53135..c0b3fe7d 100644 --- a/server/shopping-cart/internal/logic/getcartslogic.go +++ b/server/shopping-cart/internal/logic/getcartslogic.go @@ -123,19 +123,11 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo } } //计算价格 - itemPrice, totalPrice, stepNum, _, err := l.svcCtx.Repositories.NewShoppingCart.CaculateCartPrice(*cart.PurchaseQuantity, &sizePrice, fittingPrice) + itemPrice, totalPrice, _, _, err := l.svcCtx.Repositories.NewShoppingCart.CaculateCartPrice(*cart.PurchaseQuantity, &sizePrice, fittingPrice) if err != nil { logx.Error(err) return resp.SetStatusWithMessage(basic.CodeServiceErr, err.Error()) } - //获取阶梯数量 - stepQuantityList := make([]int64, 0, 20) - tmpMinBuyNum := *sizePrice.MinBuyNum - for tmpMinBuyNum < (int64(stepNum[len(stepNum)-1]) + 5) { - tmpQuantity := tmpMinBuyNum * (*sizePrice.EachBoxNum) - stepQuantityList = append(stepQuantityList, tmpQuantity) - tmpMinBuyNum++ - } //尺寸信息 sizeCapacity := snapShot.SizeInfo.Capacity if sizeInfo, ok := mapSize[*cart.SizeId]; ok { @@ -190,12 +182,13 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo Qrcode: snapShot.UserDiyInformation.Qrcode, Slogan: snapShot.UserDiyInformation.Slogan, }, - PurchaseQuantity: *cart.PurchaseQuantity, - StepNum: stepQuantityList, - IsInvalid: false, - InvalidDescription: "", - IsHighlyCustomized: *cart.IsHighlyCustomized > 0, - IsSelected: *cart.IsSelected > 0, + PurchaseQuantity: *cart.PurchaseQuantity, + MinPurchaseQuantity: *sizePrice.EachBoxNum * (*sizePrice.MinBuyNum), + StepPurchaseQuantity: *sizePrice.EachBoxNum, + IsInvalid: false, + InvalidDescription: "", + IsHighlyCustomized: *cart.IsHighlyCustomized > 0, + IsSelected: *cart.IsSelected > 0, } //是否有失效的 if description, ok := mapCartChange[cart.Id]; ok { diff --git a/server/shopping-cart/internal/types/types.go b/server/shopping-cart/internal/types/types.go index ed87d501..b30ae342 100644 --- a/server/shopping-cart/internal/types/types.go +++ b/server/shopping-cart/internal/types/types.go @@ -39,19 +39,20 @@ type GetCartsRsp struct { } type CartItem struct { - CartId int64 `json:"cart_id"` - ProductInfo ProductInfo `json:"product_info"` //产品信息 - SizeInfo SizeInfo `json:"size_info"` //尺寸信息 - FittingInfo FittingInfo `json:"fitting_info"` //配件信息 - ItemPrice string `json:"item_price"` //单价 - TotalPrice string `json:"total_price"` //单价X数量=总价 - DiyInformation DiyInformation `json:"diy_information"` //diy信息 - StepNum []int64 `json:"step_num"` //阶梯数量 - PurchaseQuantity int64 `json:"purchase_quantity"` //当前购买数量 - IsHighlyCustomized bool `json:"is_highly_customized"` //是否高度定制 - IsInvalid bool `json:"is_invalid"` //是否无效 - InvalidDescription string `json:"invalid_description"` //无效原因 - IsSelected bool `json:"is_selected"` //是否选中 + CartId int64 `json:"cart_id"` + ProductInfo ProductInfo `json:"product_info"` //产品信息 + SizeInfo SizeInfo `json:"size_info"` //尺寸信息 + FittingInfo FittingInfo `json:"fitting_info"` //配件信息 + ItemPrice string `json:"item_price"` //单价 + TotalPrice string `json:"total_price"` //单价X数量=总价 + DiyInformation DiyInformation `json:"diy_information"` //diy信息 + PurchaseQuantity int64 `json:"purchase_quantity"` //当前购买数量 + MinPurchaseQuantity int64 `json:"min_purchase_quantity"` //起购数量 + StepPurchaseQuantity int64 `json:"step_purchase_quantity"` //购买加或者减少步进量 + IsHighlyCustomized bool `json:"is_highly_customized"` //是否高度定制 + IsInvalid bool `json:"is_invalid"` //是否无效 + InvalidDescription string `json:"invalid_description"` //无效原因 + IsSelected bool `json:"is_selected"` //是否选中 } type ProductInfo struct { diff --git a/server_api/shopping-cart.api b/server_api/shopping-cart.api index 5ab4f029..5b73ac76 100644 --- a/server_api/shopping-cart.api +++ b/server_api/shopping-cart.api @@ -56,19 +56,20 @@ type GetCartsRsp { CartList []CartItem `json:"cart_list"` } type CartItem { - CartId int64 `json:"cart_id"` - ProductInfo ProductInfo `json:"product_info"` //产品信息 - SizeInfo SizeInfo `json:"size_info"` //尺寸信息 - FittingInfo FittingInfo `json:"fitting_info"` //配件信息 - ItemPrice string `json:"item_price"` //单价 - TotalPrice string `json:"total_price"` //单价X数量=总价 - DiyInformation DiyInformation `json:"diy_information"` //diy信息 - StepNum []int64 `json:"step_num"` //阶梯数量 - PurchaseQuantity int64 `json:"purchase_quantity"` //当前购买数量 - IsHighlyCustomized bool `json:"is_highly_customized"` //是否高度定制 - IsInvalid bool `json:"is_invalid"` //是否无效 - InvalidDescription string `json:"invalid_description"` //无效原因 - IsSelected bool `json:"is_selected"` //是否选中 + CartId int64 `json:"cart_id"` + ProductInfo ProductInfo `json:"product_info"` //产品信息 + SizeInfo SizeInfo `json:"size_info"` //尺寸信息 + FittingInfo FittingInfo `json:"fitting_info"` //配件信息 + ItemPrice string `json:"item_price"` //单价 + TotalPrice string `json:"total_price"` //单价X数量=总价 + DiyInformation DiyInformation `json:"diy_information"` //diy信息 + PurchaseQuantity int64 `json:"purchase_quantity"` //当前购买数量 + MinPurchaseQuantity int64 `json:"min_purchase_quantity"` //起购数量 + StepPurchaseQuantity int64 `json:"step_purchase_quantity"` //购买加或者减少步进量 + IsHighlyCustomized bool `json:"is_highly_customized"` //是否高度定制 + IsInvalid bool `json:"is_invalid"` //是否无效 + InvalidDescription string `json:"invalid_description"` //无效原因 + IsSelected bool `json:"is_selected"` //是否选中 } type ProductInfo { ProductId int64 `json:"product_id"` //产品id