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
|
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)))
|
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)),
|
ItemPrice: fmt.Sprintf("%.3f", format.CentitoDollar(itemPrice)),
|
||||||
TotalPrice: fmt.Sprintf("%.3f", format.CentitoDollar(totalPrice)),
|
TotalPrice: fmt.Sprintf("%.3f", format.CentitoDollar(totalPrice)),
|
||||||
})
|
})
|
||||||
|
updData := &gmodel.FsShoppingCart{
|
||||||
|
PurchaseQuantity: &reqPurchaseQuantity,
|
||||||
|
}
|
||||||
//如果是选中则累加总价
|
//如果是选中则累加总价
|
||||||
if isSelected {
|
if isSelected == 1 {
|
||||||
subTotalPrice += totalPrice
|
subTotalPrice += totalPrice
|
||||||
|
updData.IsSelected = &isSelected
|
||||||
}
|
}
|
||||||
//更新购物车购买数量
|
//更新购物车购买数量
|
||||||
err = shoppingCartModel.Update(l.ctx, cart.Id, userinfo.UserId, &gmodel.FsShoppingCart{
|
if err = shoppingCartModel.Update(l.ctx, cart.Id, userinfo.UserId, updData); err != nil {
|
||||||
PurchaseQuantity: &reqPurchaseQuantity,
|
|
||||||
})
|
|
||||||
if err != nil {
|
|
||||||
logx.Error(err)
|
logx.Error(err)
|
||||||
return errors.New(fmt.Sprintf("failed to update cart`s purchase quantity:%d", cart.Id))
|
return errors.New(fmt.Sprintf("failed to update cart`s purchase quantity:%d", cart.Id))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user