Commit 9f10457d by 吕明尚

修改最优优惠券排序

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