This commit is contained in:
laodaming
2023-09-26 16:36:35 +08:00
parent 42bd585fe9
commit d07350969f
7 changed files with 56 additions and 65 deletions

View File

@@ -8,7 +8,6 @@ import (
"fusenapi/utils/auth"
"fusenapi/utils/basic"
"fusenapi/utils/format"
"fusenapi/utils/step_price"
"gorm.io/gorm"
"context"
@@ -65,9 +64,11 @@ func (l *CalculateProductPriceLogic) CalculateProductPrice(req *types.CalculateP
return resp.SetStatusWithMessage(basic.CodeDbSqlErr, "failed to get model info")
}
var stepPrice gmodel.StepPriceJsonStruct
if err = json.Unmarshal(*modelInfo.StepPrice, &stepPrice); err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse step price")
if modelInfo.StepPrice != nil && len(*modelInfo.StepPrice) != 0 {
if err = json.Unmarshal(*modelInfo.StepPrice, &stepPrice); err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeJsonErr, "failed to parse step price")
}
}
//配件
fittingPrice := int64(0)
@@ -82,7 +83,7 @@ func (l *CalculateProductPriceLogic) CalculateProductPrice(req *types.CalculateP
}
fittingPrice = *fittingInfo.Price
}
totalPrice, itemPrice, err := step_price.GetNewCentStepPrice(req.PurchaseQuantity, stepPrice, fittingPrice)
totalPrice, itemPrice, err := l.svcCtx.Repositories.NewShoppingCart.CaculateStepPrice(req.PurchaseQuantity, stepPrice, fittingPrice)
if err != nil {
logx.Error(err)
return resp.SetStatusWithMessage(basic.CodeServiceErr, "failed to calculate product price ")