Commit 9f10457d by 吕明尚

修改最优优惠券排序

parent 174fbcaa
......@@ -217,24 +217,20 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
SRoom room = sRoomService.getById(couponRequest.getRoomId());
//计算时长
BigDecimal timeLong = DateUtils.differentHour(couponRequest.getPreStartDate(), couponRequest.getPreEndDate());
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 {
byId = packService.getById(roomLabel.getPackId());
if (!ObjectUtils.isEmpty(byId) && byId.getIsOpen().equals(YesNoEnum.yes.getIndex())) {
payPrice = computeTotalPrice(roomLabel.getPackId(), totalPrice);
couponRequest.setPackageId(roomLabel.getPackId());
couponRequest.setOrderMode(BuyTypeEnum.PACK.getCode());
} else {
payPrice = totalPrice;
byId = null;
couponRequest.setPackageId(null);
couponRequest.setOrderMode(BuyTypeEnum.TIME.getCode());
}
......@@ -243,7 +239,6 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
roomLabel = null;
if (!ObjectUtils.isEmpty(couponRequest.getPackageId())) {
byId = packService.getById(couponRequest.getPackageId());
payPrice = computeTotalPrice(couponRequest.getPackageId(), totalPrice);
couponRequest.setOrderMode(BuyTypeEnum.PACK.getCode());
} else {
throw new RuntimeException("参数异常");
......@@ -257,7 +252,6 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
//查询所有的套餐
List<SPack> sPacks = packService.list();
//迭代
BigDecimal finalPayPrice = payPrice;
SPack finalById = byId;
sConsumerCoupons.forEach(item -> {
checkCoupon(item,couponRequest,sStores,sRooms,sPacks,timeLong);
......@@ -274,7 +268,7 @@ public class SConsumerCouponServiceImpl extends ServiceImpl<SConsumerCouponMappe
if (vo.getIsAvailable().equals(AvailableEnum.AVAILABLE.getCode())) {
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());
add(((timeLong.subtract(new BigDecimal(roomLabel.getPromotionDuration()))).multiply(room.getPrice()))).abs());
} else if (!ObjectUtils.isEmpty(finalById)) {
vo.setBalance(finalById.getPrice().subtract(vo.getSalePrice()));
}
......
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