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);
RoomLabel roomLabel = roomLabelService.selectRoomLabelById(request.getRoomLabelId()); if (!ObjectUtils.isEmpty(request.getRoomLabelId())) {
if (ObjectUtils.isEmpty(roomLabel.getPackId())) { RoomLabel roomLabel = roomLabelService.selectRoomLabelById(request.getRoomLabelId());
payPrice = totalPrice; if (ObjectUtils.isEmpty(roomLabel.getPackId())) {
} else { payPrice = totalPrice;
payPrice = computeTotalPrice(roomLabel.getPackId(), totalPrice); } else {
} 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("总金额小于优惠券最小使用金额");
} }
RoomLabel roomLabel = roomLabelService.selectRoomLabelById(request.getRoomLabelId()); BigDecimal subtract = new BigDecimal(0);
//(促销价-优惠券促销价)+((时长-促销时长)*单价) if (!ObjectUtils.isEmpty(request.getRoomLabelId())) {
SRoom room = roomService.getById(request.getRoomId()); RoomLabel roomLabel = roomLabelService.selectRoomLabelById(request.getRoomLabelId());
BigDecimal subtract = (roomLabel.getPromotionAmount().subtract(consumerCoupon.getSalePrice())). SRoom room = roomService.getById(request.getRoomId());
add(((DateUtils.differentHour(request.getPreStartDate(), request.getPreEndDate()).subtract(new BigDecimal(roomLabel.getPromotionDuration()))).multiply(room.getPrice()))); subtract = (roomLabel.getPromotionAmount().subtract(consumerCoupon.getSalePrice())).
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