|
@@ -73,6 +73,18 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
@Resource
|
|
@Resource
|
|
|
private IBusOrderFeeService feeService;
|
|
private IBusOrderFeeService feeService;
|
|
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IBusMarketCouponsCashUsedService marketCouponsCashUsedService;
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IBusMemberCardService memberCardService;
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IBusMemberBalanceLogService memberBalanceLogService;
|
|
|
|
|
+
|
|
|
|
|
+ @Resource
|
|
|
|
|
+ private IBusRoomPayTypeService payTypeService;
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String bookingOrderSave(BookingOrderSaveDto item, Boolean isTeam) {
|
|
public String bookingOrderSave(BookingOrderSaveDto item, Boolean isTeam) {
|
|
@@ -1185,12 +1197,31 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
return true;
|
|
return true;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ String getBookingRoomHotelId(BusBookingRooms bookingRoom) {
|
|
|
|
|
+ return roomsService.getById(bookingRoom.getRoomId()).getHotelId();
|
|
|
|
|
+ }
|
|
|
private void settleFee(BusBookingRooms mainRoom, BusRoomsLivingOrder mainRoomOrder, List<BusOrderFee> feeItems, List<BusOrderFee> settleFees) {
|
|
private void settleFee(BusBookingRooms mainRoom, BusRoomsLivingOrder mainRoomOrder, List<BusOrderFee> feeItems, List<BusOrderFee> settleFees) {
|
|
|
if(settleFees.size() == 0) throw new JeecgBootException("参数错误");
|
|
if(settleFees.size() == 0) throw new JeecgBootException("参数错误");
|
|
|
|
|
+ String hotelId = getBookingRoomHotelId(mainRoom);
|
|
|
|
|
+ LoginUser user = TokenUtils.getAuthUser();
|
|
|
|
|
+ if(user == null) throw new JeecgBootException("请登录");
|
|
|
|
|
+ if(hotelId == null) throw new JeecgBootException("未找到酒店");
|
|
|
BusOrderFee preferFeeItem = null;
|
|
BusOrderFee preferFeeItem = null;
|
|
|
if(settleFees.stream().anyMatch(s->s.getIsPreferential().equals(true))){
|
|
if(settleFees.stream().anyMatch(s->s.getIsPreferential().equals(true))){
|
|
|
preferFeeItem = settleFees.stream().filter(s->s.getIsPreferential().equals(true)).findFirst().get();
|
|
preferFeeItem = settleFees.stream().filter(s->s.getIsPreferential().equals(true)).findFirst().get();
|
|
|
if(preferFeeItem.getMoney()==null || preferFeeItem.getMoney().compareTo(BigDecimal.valueOf(0)) <= 0) throw new JeecgBootException("优惠价不能小于或等于0");
|
|
if(preferFeeItem.getMoney()==null || preferFeeItem.getMoney().compareTo(BigDecimal.valueOf(0)) <= 0) throw new JeecgBootException("优惠价不能小于或等于0");
|
|
|
|
|
+ if(preferFeeItem.getCouponscashId() != null && !preferFeeItem.getCouponscashId().isEmpty()) {
|
|
|
|
|
+ BusMarketCouponsCashUsed couponTicket = marketCouponsCashUsedService.getById(preferFeeItem.getCouponscashId()); // 优惠票券
|
|
|
|
|
+ if(couponTicket == null) throw new JeecgBootException("优惠券不存在");
|
|
|
|
|
+ if(!couponTicket.getStatus().equals(CouponsStatusEnum.received.getKey())) {
|
|
|
|
|
+ CouponsStatusEnum couponStatusText = CouponsStatusEnum.val(couponTicket.getStatus());
|
|
|
|
|
+ if(couponStatusText == null) throw new JeecgBootException("优惠券状态异常");
|
|
|
|
|
+ throw new JeecgBootException("优惠券"+ couponStatusText.getTitle());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ couponTicket.setStatus(CouponsStatusEnum.used.getKey());
|
|
|
|
|
+ marketCouponsCashUsedService.updateById(couponTicket);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
preferFeeItem.setCreateTime(new Date());
|
|
preferFeeItem.setCreateTime(new Date());
|
|
|
preferFeeItem.setSubjectType(FeeSubjectType.YOU_HUI.getKey());
|
|
preferFeeItem.setSubjectType(FeeSubjectType.YOU_HUI.getKey());
|
|
|
preferFeeItem.setFeeType(1);
|
|
preferFeeItem.setFeeType(1);
|
|
@@ -1201,9 +1232,45 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
preferFeeItem.setPreferentialStatus(2);
|
|
preferFeeItem.setPreferentialStatus(2);
|
|
|
feeService.save(preferFeeItem);
|
|
feeService.save(preferFeeItem);
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
|
|
+ List<BusRoomPayType> payTypes = payTypeService.list();
|
|
|
settleFees.forEach(s->{
|
|
settleFees.forEach(s->{
|
|
|
if(s.getIsPreferential().equals(true)) return;
|
|
if(s.getIsPreferential().equals(true)) return;
|
|
|
|
|
+
|
|
|
|
|
+ String payTypeId = s.getPayType();
|
|
|
|
|
+ if(payTypeId != null && !payTypeId.isEmpty()) {
|
|
|
|
|
+ Optional<BusRoomPayType> opPayType = payTypes.stream().filter(a->a.getId().equals(payTypeId)).findAny();
|
|
|
|
|
+ if(!opPayType.isPresent()) throw new JeecgBootException("收款支付方式错误");
|
|
|
|
|
+ BusRoomPayType payType = opPayType.get();
|
|
|
|
|
+ // 会员卡付费
|
|
|
|
|
+ if(payType.getName().equals("会员卡")) {
|
|
|
|
|
+ if(mainRoomOrder.getCustomerType() == null || !mainRoomOrder.getCustomerType().equals(CustomerTypeEnum.VIP.getKey()))
|
|
|
|
|
+ throw new JeecgBootException("客人类型不是会员");
|
|
|
|
|
+ if(mainRoomOrder.getVipCustomerId() == null || mainRoomOrder.getVipCustomerId().isEmpty())
|
|
|
|
|
+ throw new JeecgBootException("会员不存在");
|
|
|
|
|
+ BusMemberCard vipCard = memberCardService.getById(mainRoomOrder.getVipCustomerId());
|
|
|
|
|
+ if(vipCard == null) throw new JeecgBootException("会员不存在");
|
|
|
|
|
+ if(vipCard.getBalance().compareTo(s.getMoney()) < 0) throw new JeecgBootException("会员卡余额不足");
|
|
|
|
|
+ vipCard.setBalance(vipCard.getBalance().subtract(s.getMoney()));
|
|
|
|
|
+ // log
|
|
|
|
|
+ BusMemberBalanceLog balanceLog = new BusMemberBalanceLog();
|
|
|
|
|
+ balanceLog.setMoney(s.getMoney());
|
|
|
|
|
+ balanceLog.setBalance(vipCard.getBalance());
|
|
|
|
|
+ balanceLog.setType(2);// 扣费
|
|
|
|
|
+ balanceLog.setStatus(1);// TODO:不知道干什么用的 貌似是个啥支付状态
|
|
|
|
|
+ balanceLog.setGiveMoney(new BigDecimal(0));
|
|
|
|
|
+ balanceLog.setRemarks("房间收费扣款");
|
|
|
|
|
+ balanceLog.setHotelId(hotelId);
|
|
|
|
|
+ balanceLog.setTenantId(user.getRelTenantIds());
|
|
|
|
|
+ balanceLog.setPaymentMethod("");
|
|
|
|
|
+ balanceLog.setPayMoney(new BigDecimal(0));
|
|
|
|
|
+ balanceLog.setCode(BusMemberBalanceLogServiceImpl.randomNumber("KF"));
|
|
|
|
|
+ balanceLog.setCreateTime(new Date());
|
|
|
|
|
+ memberBalanceLogService.save(balanceLog);
|
|
|
|
|
+ // todo 积分规则
|
|
|
|
|
+
|
|
|
|
|
+// memberBalanceLogService.
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
s.setCreateTime(new Date());
|
|
s.setCreateTime(new Date());
|
|
|
s.setPreferentialStatus(2);
|
|
s.setPreferentialStatus(2);
|
|
|
s.setFeeType(2);
|
|
s.setFeeType(2);
|