fix: 优惠券使用顺序调整
This commit is contained in:
parent
8a33d49c7c
commit
04023c3f30
|
|
@ -12,6 +12,8 @@ public class OrderPriceDTO {
|
||||||
private BigDecimal originAmount = BigDecimal.ZERO;
|
private BigDecimal originAmount = BigDecimal.ZERO;
|
||||||
private BigDecimal totalAmount = BigDecimal.ZERO;
|
private BigDecimal totalAmount = BigDecimal.ZERO;
|
||||||
private BigDecimal packAmount = BigDecimal.ZERO;
|
private BigDecimal packAmount = BigDecimal.ZERO;
|
||||||
|
// 打折折扣金额
|
||||||
|
private BigDecimal discountAmount = BigDecimal.ZERO;
|
||||||
private boolean hasNewInfo = false;
|
private boolean hasNewInfo = false;
|
||||||
private List<TbOrderDetail> newOrderDetailList = new ArrayList<>();
|
private List<TbOrderDetail> newOrderDetailList = new ArrayList<>();
|
||||||
private List<TbOrderDetail> removeOrderDetailList = new ArrayList<>();
|
private List<TbOrderDetail> removeOrderDetailList = new ArrayList<>();
|
||||||
|
|
|
||||||
|
|
@ -229,12 +229,15 @@ public class TbCashierCart implements Serializable {
|
||||||
if (discountRadio == null) {
|
if (discountRadio == null) {
|
||||||
discountRadio = new BigDecimal("1");
|
discountRadio = new BigDecimal("1");
|
||||||
}
|
}
|
||||||
resetTotalAmount(discountRadio);
|
|
||||||
if (num == null) {
|
if (num == null) {
|
||||||
num = totalNumber;
|
num = totalNumber;
|
||||||
}
|
}
|
||||||
|
|
||||||
return totalAmount.divide(totalNumber, 9, RoundingMode.HALF_UP).multiply(num).setScale(2, RoundingMode.HALF_UP);
|
if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
|
return num.multiply(memberPrice).multiply(discountRadio).add(packFee).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
}else {
|
||||||
|
return num.multiply(discountSaleAmount != null ? discountSaleAmount : salePrice).add(packFee).multiply(discountRadio).setScale(2, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
// if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) {
|
// if (isMember != null && isMember == 1 && memberPrice != null && memberPrice.compareTo(BigDecimal.ZERO) > 0) {
|
||||||
// return num.multiply(memberPrice);
|
// return num.multiply(memberPrice);
|
||||||
// } else {
|
// } else {
|
||||||
|
|
|
||||||
|
|
@ -1307,7 +1307,6 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
currentUseNum = cashierCart.getNumber();
|
currentUseNum = cashierCart.getNumber();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// 创建结余购物车
|
// 创建结余购物车
|
||||||
balanceCart = BeanUtil.copyProperties(cashierCart, TbCashierCart.class);
|
balanceCart = BeanUtil.copyProperties(cashierCart, TbCashierCart.class);
|
||||||
balanceCart.setUserCouponId(null);
|
balanceCart.setUserCouponId(null);
|
||||||
|
|
@ -1409,7 +1408,7 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
couponInfoDTO.setOutRecordList(outRecords);
|
couponInfoDTO.setOutRecordList(outRecords);
|
||||||
couponInfoDTO.setCouponMap(usedCouponMap);
|
couponInfoDTO.setCouponMap(usedCouponMap);
|
||||||
|
|
||||||
return discountAmount.multiply(orderInfo.getDiscountRatio());
|
return discountAmount;
|
||||||
}
|
}
|
||||||
|
|
||||||
private OrderCouponInfoDTO getCouponInfo(Integer memberId, Integer shopId, List<UserCouponInfoDTO> userCouponInfoDTOList, BigDecimal orderAmount, Set<String> productIds) {
|
private OrderCouponInfoDTO getCouponInfo(Integer memberId, Integer shopId, List<UserCouponInfoDTO> userCouponInfoDTOList, BigDecimal orderAmount, Set<String> productIds) {
|
||||||
|
|
@ -1586,6 +1585,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
|
|
||||||
// 已经退款和使用优惠券的商品不进行统计金额
|
// 已经退款和使用优惠券的商品不进行统计金额
|
||||||
if (!"return".equals(cashierCart.getStatus()) && cashierCart.getUserCouponId() == null) {
|
if (!"return".equals(cashierCart.getStatus()) && cashierCart.getUserCouponId() == null) {
|
||||||
|
BigDecimal originalTotal = cashierCart.getTotalAmountByNum(cashierCart.getTotalNumber(), BigDecimal.ONE);
|
||||||
|
priceDTO.setDiscountAmount(priceDTO.getDiscountAmount().add(originalTotal.subtract(cashierCart.getTotalAmount())));
|
||||||
priceDTO.setTotalAmount(priceDTO.getTotalAmount().add(cashierCart.getTotalAmount()));
|
priceDTO.setTotalAmount(priceDTO.getTotalAmount().add(cashierCart.getTotalAmount()));
|
||||||
priceDTO.setPackAmount(priceDTO.getPackAmount().add(cashierCart.getPackFee()));
|
priceDTO.setPackAmount(priceDTO.getPackAmount().add(cashierCart.getPackFee()));
|
||||||
}
|
}
|
||||||
|
|
@ -2116,6 +2117,8 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
// 返还上次使用的券
|
// 返还上次使用的券
|
||||||
returnCoupon(orderInfo, true);
|
returnCoupon(orderInfo, true);
|
||||||
|
|
||||||
|
// 设置折扣比例
|
||||||
|
orderInfo.setDiscountRatio(payDTO.getDiscount());
|
||||||
|
|
||||||
Set<String> productIdSet = new HashSet<>();
|
Set<String> productIdSet = new HashSet<>();
|
||||||
List<TbCashierCart> cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId());
|
List<TbCashierCart> cashierCarts = mpCashierCartService.selectByOrderIdAndState(orderInfo.getId());
|
||||||
|
|
@ -2140,12 +2143,13 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
// 更新订单信息
|
// 更新订单信息
|
||||||
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(orderInfo.getShopId(), orderInfo.getTableId());
|
ShopEatTypeInfoDTO shopEatTypeInfoDTO = checkEatModel(orderInfo.getShopId(), orderInfo.getTableId());
|
||||||
OrderPriceDTO priceDTO = createOrderDetailWithCoupon(activateCartInfo, orderInfo, payDTO.getShopId(), false, shopEatTypeInfoDTO);
|
OrderPriceDTO priceDTO = createOrderDetailWithCoupon(activateCartInfo, orderInfo, payDTO.getShopId(), false, shopEatTypeInfoDTO);
|
||||||
BigDecimal finalAmount = priceDTO.getTotalAmount().multiply(payDTO.getDiscount()).setScale(2, RoundingMode.HALF_UP);
|
BigDecimal finalAmount = priceDTO.getTotalAmount().setScale(2, RoundingMode.HALF_UP);
|
||||||
|
|
||||||
orderInfo.setUpdatedAt(System.currentTimeMillis());
|
orderInfo.setUpdatedAt(System.currentTimeMillis());
|
||||||
orderInfo.setSettlementAmount(finalAmount);
|
orderInfo.setSettlementAmount(finalAmount);
|
||||||
orderInfo.setAmount(finalAmount);
|
orderInfo.setAmount(finalAmount);
|
||||||
orderInfo.setOrderAmount(finalAmount);
|
orderInfo.setOrderAmount(finalAmount);
|
||||||
|
orderInfo.setDiscountAmount(priceDTO.getDiscountAmount());
|
||||||
|
|
||||||
// 计算订单优惠
|
// 计算订单优惠
|
||||||
TbActivateOutRecord outRecord = calcOrderInfoDiscount(payDTO, orderInfo, couponInfo);
|
TbActivateOutRecord outRecord = calcOrderInfoDiscount(payDTO, orderInfo, couponInfo);
|
||||||
|
|
@ -2251,17 +2255,17 @@ public class TbShopTableServiceImpl implements TbShopTableService {
|
||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal finalAmount = null;
|
BigDecimal finalAmount = null;
|
||||||
// 计算订单折扣信息
|
|
||||||
if (payDTO.getDiscount().compareTo(new BigDecimal("1")) != 0) {
|
|
||||||
finalAmount = resetAmountByDiscount(payDTO, orderInfo);
|
|
||||||
}else {
|
|
||||||
finalAmount = orderInfo.getOrderAmount();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 计算优惠券积分折扣信息
|
// 计算优惠券积分折扣信息
|
||||||
if (payDTO.getVipUserId() != null) {
|
if (payDTO.getVipUserId() != null) {
|
||||||
// 计算商品券折扣
|
// 计算商品券折扣
|
||||||
finalAmount = calcDiscountAndUpdateInfo(payDTO, orderInfo);
|
finalAmount = calcDiscountAndUpdateInfo(payDTO, orderInfo);
|
||||||
|
} else {
|
||||||
|
if (payDTO.getDiscount().compareTo(new BigDecimal("1")) != 0) {
|
||||||
|
finalAmount = resetAmountByDiscount(payDTO, orderInfo);
|
||||||
|
} else {
|
||||||
|
finalAmount = orderInfo.getOrderAmount();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isOnline = false;
|
boolean isOnline = false;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue