Commit 014d8b01 by 吕明尚

修改最优优惠券排序

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