From e999672037b72e590a381649cf324de44036b937 Mon Sep 17 00:00:00 2001 From: laodaming <11058467+laudamine@user.noreply.gitee.com> Date: Fri, 10 Nov 2023 15:29:44 +0800 Subject: [PATCH] fix --- .../internal/logic/calculatecartpricelogic.go | 2 +- .../shopping-cart/internal/logic/getcartslogic.go | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/server/shopping-cart/internal/logic/calculatecartpricelogic.go b/server/shopping-cart/internal/logic/calculatecartpricelogic.go index 0ace472b..617363ee 100644 --- a/server/shopping-cart/internal/logic/calculatecartpricelogic.go +++ b/server/shopping-cart/internal/logic/calculatecartpricelogic.go @@ -116,7 +116,7 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri if fittingInfo, ok := mapModel[*cart.FittingId]; ok { fittingPrice = *fittingInfo.Price } else { - return errors.New(fmt.Sprintf("cart contain some one witch lose fitting:%d", *cart.FittingId)) + logx.Error(fmt.Sprintf("cart contain some one witch lose fitting:%d", *cart.FittingId)) } } //计算价格 diff --git a/server/shopping-cart/internal/logic/getcartslogic.go b/server/shopping-cart/internal/logic/getcartslogic.go index dbe0f267..4a6cbbaa 100644 --- a/server/shopping-cart/internal/logic/getcartslogic.go +++ b/server/shopping-cart/internal/logic/getcartslogic.go @@ -116,14 +116,14 @@ func (l *GetCartsLogic) GetCarts(req *types.GetCartsReq, userinfo *auth.UserInfo fittingPrice := int64(0) if *cart.FittingId > 0 { curFittingInfo, ok := mapModel[*cart.FittingId] - if !ok { - return resp.SetStatusWithMessage(basic.CodeServiceErr, fmt.Sprintf("cart contain some one witch lose fitting:%d", *cart.FittingId)) - } - fittingPrice = *curFittingInfo.Price - //取大的为步进量基数 - if *curFittingInfo.PackedUnit > stepPurchaseQuantity { - stepPurchaseQuantity = *curFittingInfo.PackedUnit + if ok { + fittingPrice = *curFittingInfo.Price + //取大的为步进量基数 + if *curFittingInfo.PackedUnit > stepPurchaseQuantity { + stepPurchaseQuantity = *curFittingInfo.PackedUnit + } } + logx.Error(fmt.Sprintf("cart contain some one witch lose fitting:%d", *cart.FittingId)) } //计算阶梯价格 totalPrice, itemPrice, err := l.svcCtx.Repositories.NewShoppingCart.CaculateStepPrice(*cart.PurchaseQuantity, stepPrice, fittingPrice)