Commit 014d8b01 by 吕明尚

修改最优优惠券排序

parent f04ca35d
......@@ -220,13 +220,15 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
BigDecimal totalPrice = timeLong.multiply(room.getPrice());
BigDecimal payPrice = new BigDecimal(0);
RoomLabel roomLabel;
SPack byId;
if (!ObjectUtils.isEmpty(couponRequest.getRoomLabelId())) {
roomLabel = roomLabelService.selectRoomLabelById(couponRequest.getRoomLabelId());
if (ObjectUtils.isEmpty(roomLabel.getPackId())) {
byId = null;
payPrice = totalPrice;
couponRequest.setOrderMode(BuyTypeEnum.TIME.getCode());
} else {
SPack byId = packService.getById(roomLabel.getPackId());
byId = packService.getById(roomLabel.getPackId());
if (!ObjectUtils.isEmpty(byId) && byId.getIsOpen().equals(YesNoEnum.yes.getIndex())) {
payPrice = computeTotalPrice(roomLabel.getPackId(), totalPrice);
couponRequest.setPackageId(roomLabel.getPackId());
......@@ -238,6 +240,7 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
}
}
} else {
byId = null;
roomLabel = null;
if (!ObjectUtils.isEmpty(couponRequest.getPackageId())) {
payPrice = computeTotalPrice(couponRequest.getPackageId(), totalPrice);
......@@ -268,8 +271,12 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
}
//取绝对值
if (vo.getIsAvailable().equals(AvailableEnum.AVAILABLE.getCode())) {
vo.setBalance((roomLabel.getPromotionAmount().subtract(vo.getSalePrice())).
add(((DateUtils.differentHour(couponRequest.getPreStartDate(), couponRequest.getPreEndDate()).subtract(new BigDecimal(roomLabel.getPromotionDuration()))).multiply(room.getPrice()))).abs());
if (!ObjectUtils.isEmpty(roomLabel)) {
vo.setBalance((roomLabel.getPromotionAmount().subtract(vo.getSalePrice())).
add(((DateUtils.differentHour(couponRequest.getPreStartDate(), couponRequest.getPreEndDate()).subtract(new BigDecimal(roomLabel.getPromotionDuration()))).multiply(room.getPrice()))).abs());
} else if (!ObjectUtils.isEmpty(byId)) {
vo.setBalance(byId.getPrice().subtract(vo.getSalePrice()));
}
} else {
vo.setBalance(new BigDecimal("999"));
}
......
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