Commit 70868f48 by 吕明尚

修改订单金额计算

parent 87514e92
...@@ -1747,13 +1747,18 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1747,13 +1747,18 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
ComputedOrderPriceResponse priceResponse = new ComputedOrderPriceResponse(); ComputedOrderPriceResponse priceResponse = new ComputedOrderPriceResponse();
SRoom room = roomService.getById(request.getRoomId()); SRoom room = roomService.getById(request.getRoomId());
BigDecimal totalPrice = computeTotalPrice(room.getPrice(), request.getPreStartDate(), request.getPreEndDate()); BigDecimal totalPrice = computeTotalPrice(room.getPrice(), request.getPreStartDate(), request.getPreEndDate());
BigDecimal payPrice; BigDecimal payPrice = new BigDecimal(0);
if (!ObjectUtils.isEmpty(request.getRoomLabelId())) {
RoomLabel roomLabel = roomLabelService.selectRoomLabelById(request.getRoomLabelId()); RoomLabel roomLabel = roomLabelService.selectRoomLabelById(request.getRoomLabelId());
if (ObjectUtils.isEmpty(roomLabel.getPackId())) { if (ObjectUtils.isEmpty(roomLabel.getPackId())) {
payPrice = totalPrice; payPrice = totalPrice;
} else { } else {
payPrice = computeTotalPrice(roomLabel.getPackId(), totalPrice); payPrice = computeTotalPrice(roomLabel.getPackId(), totalPrice);
} }
} else if (!ObjectUtils.isEmpty(request.getPackId())) {
payPrice = computeTotalPrice(request.getPackId(), totalPrice);
}
priceResponse.setTotalFee(payPrice); priceResponse.setTotalFee(payPrice);
// 计算优惠券金额 // 计算优惠券金额
if (ObjectUtil.isNull(request.getCouponId()) || request.getCouponId() <= 0) { if (ObjectUtil.isNull(request.getCouponId()) || request.getCouponId() <= 0) {
...@@ -1811,11 +1816,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme ...@@ -1811,11 +1816,16 @@ public class SOrderServiceImpl extends ServiceImpl<SOrderMapper, SOrder> impleme
if (consumerCoupon.getMinPrice().compareTo(priceResponse.getTotalFee()) > 0) { if (consumerCoupon.getMinPrice().compareTo(priceResponse.getTotalFee()) > 0) {
throw new BaseException("总金额小于优惠券最小使用金额"); throw new BaseException("总金额小于优惠券最小使用金额");
} }
BigDecimal subtract = new BigDecimal(0);
if (!ObjectUtils.isEmpty(request.getRoomLabelId())) {
RoomLabel roomLabel = roomLabelService.selectRoomLabelById(request.getRoomLabelId()); RoomLabel roomLabel = roomLabelService.selectRoomLabelById(request.getRoomLabelId());
//(促销价-优惠券促销价)+((时长-促销时长)*单价)
SRoom room = roomService.getById(request.getRoomId()); SRoom room = roomService.getById(request.getRoomId());
BigDecimal subtract = (roomLabel.getPromotionAmount().subtract(consumerCoupon.getSalePrice())). subtract = (roomLabel.getPromotionAmount().subtract(consumerCoupon.getSalePrice())).
add(((DateUtils.differentHour(request.getPreStartDate(), request.getPreEndDate()).subtract(new BigDecimal(roomLabel.getPromotionDuration()))).multiply(room.getPrice()))); add(((DateUtils.differentHour(request.getPreStartDate(), request.getPreEndDate()).subtract(new BigDecimal(roomLabel.getPromotionDuration()))).multiply(room.getPrice())));
} else if (!ObjectUtils.isEmpty(request.getPackId())) {
SPack byId = packService.getById(request.getPackId());
subtract = byId.getPrice().subtract(consumerCoupon.getSalePrice());
}
//判断是否为负数 //判断是否为负数
if (subtract.compareTo(BigDecimal.ZERO) < 0) { if (subtract.compareTo(BigDecimal.ZERO) < 0) {
priceResponse.setPayFee(BigDecimal.ZERO); priceResponse.setPayFee(BigDecimal.ZERO);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment