11
This commit is contained in:
parent
f284702448
commit
9342ab8c24
|
@ -129,7 +129,10 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri
|
|||
}
|
||||
//请求的数量
|
||||
reqPurchaseQuantity := mapCalculateQuantity[cart.Id].PurchaseQuantity
|
||||
isSelected := mapCalculateQuantity[cart.Id].IsSelected
|
||||
isSelected := int64(0)
|
||||
if mapCalculateQuantity[cart.Id].IsSelected {
|
||||
isSelected = 1
|
||||
}
|
||||
//购买箱数
|
||||
boxQuantity := int(math.Ceil(float64(reqPurchaseQuantity) / float64(*sizePrice.EachBoxNum)))
|
||||
//根据数量获取阶梯价格中对应的价格
|
||||
|
@ -149,15 +152,16 @@ func (l *CalculateCartPriceLogic) CalculateCartPrice(req *types.CalculateCartPri
|
|||
ItemPrice: fmt.Sprintf("%.3f", format.CentitoDollar(itemPrice)),
|
||||
TotalPrice: fmt.Sprintf("%.3f", format.CentitoDollar(totalPrice)),
|
||||
})
|
||||
updData := &gmodel.FsShoppingCart{
|
||||
PurchaseQuantity: &reqPurchaseQuantity,
|
||||
}
|
||||
//如果是选中则累加总价
|
||||
if isSelected {
|
||||
if isSelected == 1 {
|
||||
subTotalPrice += totalPrice
|
||||
updData.IsSelected = &isSelected
|
||||
}
|
||||
//更新购物车购买数量
|
||||
err = shoppingCartModel.Update(l.ctx, cart.Id, userinfo.UserId, &gmodel.FsShoppingCart{
|
||||
PurchaseQuantity: &reqPurchaseQuantity,
|
||||
})
|
||||
if err != nil {
|
||||
if err = shoppingCartModel.Update(l.ctx, cart.Id, userinfo.UserId, updData); err != nil {
|
||||
logx.Error(err)
|
||||
return errors.New(fmt.Sprintf("failed to update cart`s purchase quantity:%d", cart.Id))
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user