促销金额大于商品金额的极端情况显示问题处理

This commit is contained in:
Chopper 2021-12-24 15:46:25 +08:00
parent 3af0031214
commit b1e70ebf12

View File

@ -349,14 +349,30 @@ public class PriceDetailDTO implements Serializable {
public void setDiscountPrice(Double discountPrice) {
this.discountPrice = discountPrice;
promotionPriceHandler();
this.recount();
}
public void setCouponPrice(Double couponPrice) {
this.couponPrice = couponPrice;
promotionPriceHandler();
this.recount();
}
/**
* 如果促销金额+优惠券金额大于商品金额问题处理
*/
private void promotionPriceHandler() {
if (couponPrice == null || discountPrice == null) {
return;
}
//如果订单优惠总额>商品金额则处理一下数据使得两数相加<=商品金额
if (CurrencyUtil.add(couponPrice, discountPrice) > goodsPrice) {
couponPrice = CurrencyUtil.sub(goodsPrice, discountPrice);
this.setCouponPrice(couponPrice);
}
}
public void setDistributionCommission(Double distributionCommission) {
this.distributionCommission = distributionCommission;
this.recount();