|
|
@@ -107,6 +107,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
private IBusMemberCardService memberCardService;
|
|
|
|
|
|
@Resource
|
|
|
+ private IBusMarketMemberService marketMemberService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
private IBusMemberBalanceLogService memberBalanceLogService;
|
|
|
|
|
|
@Resource
|
|
|
@@ -1432,9 +1435,12 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
}
|
|
|
});
|
|
|
BigDecimal m = shoukuan[0].subtract(xiaofei[0]);
|
|
|
- settleFees.get(0).setMoney(m);
|
|
|
- if(m.doubleValue() < 0) settleFees.get(0).setCustorerOrderRemark("结账退款");
|
|
|
- else settleFees.get(0).setCustorerOrderRemark("结账收款");
|
|
|
+ BigDecimal nowMoney = settleFees.stream().map(BusOrderFee::getMoney).reduce(BigDecimal.ZERO,BigDecimal::add);
|
|
|
+ if (new BigDecimal(0).equals(m.add(nowMoney))){
|
|
|
+ throw new JeecgBootException("账单未平账");
|
|
|
+ }
|
|
|
+// if(m.doubleValue() < 0) settleFees.get(0).setCustorerOrderRemark("结账退款");
|
|
|
+// else settleFees.get(0).setCustorerOrderRemark("结账收款");
|
|
|
// // 消费账单
|
|
|
// List<BusOrderFee> xiaoFeiFees = feeItems.stream().filter(s->s.getFeeType().equals(1)).collect(Collectors.toList());
|
|
|
// // 收款
|
|
|
@@ -1963,8 +1969,29 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- if(info.getCustomerType() != null && CustomerTypeEnum.val(info.getCustomerType()) != null) {
|
|
|
+ if(info.getCustomerType() != null && CustomerTypeEnum.val(info.getCustomerType()) != null && !info.getVipCustomerId().isEmpty()) {
|
|
|
+ BusMemberCard memberCard = memberCardService.getById(info.getVipCustomerId());
|
|
|
+ if (ObjectUtil.isEmpty(memberCard)){
|
|
|
+ throw new JeecgBootException("未找到相应的会员");
|
|
|
+ }
|
|
|
+ BusMarketMember marketMember = marketMemberService.getById(memberCard.getGradeId());
|
|
|
+ if (ObjectUtil.isEmpty(marketMember) || ObjectUtil.isEmpty(marketMember.getDiscount())){
|
|
|
+ throw new JeecgBootException("会员异常");
|
|
|
+ }
|
|
|
order.setCustomerType(info.getCustomerType());
|
|
|
+ // 找出房费订单和每日价格,按会员价算
|
|
|
+ List<BusOrderFee> orderFeeList = feeService.list(Wrappers.<BusOrderFee>lambdaQuery()
|
|
|
+ .eq(BusOrderFee::getLivingOrderId, order.getId()).eq(BusOrderFee::getSubjectType, FeeSubjectType.MEI_RI_FANG_FEI.getKey()));
|
|
|
+ orderFeeList.forEach(e -> {
|
|
|
+ e.setMoney(e.getMoney().multiply(marketMember.getDiscount()).divide(BigDecimal.valueOf(100)));
|
|
|
+ });
|
|
|
+ List<BusLivingLayoutDayPrice> livingDayPrice = livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>lambdaQuery()
|
|
|
+ .eq(BusLivingLayoutDayPrice::getLivingOrderId, order.getId()));
|
|
|
+ livingDayPrice.forEach(e -> {
|
|
|
+ e.setPrice(e.getPrice().multiply(marketMember.getDiscount()).divide(BigDecimal.valueOf(100)));
|
|
|
+ });
|
|
|
+ feeService.updateBatchById(orderFeeList);
|
|
|
+ livingLayoutDayPriceService.updateBatchById(livingDayPrice);
|
|
|
roomsLivingOrderService.updateById(order);
|
|
|
return true;
|
|
|
}
|
|
|
@@ -2293,90 +2320,76 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
LoginUser user = TokenUtils.getAuthUser();
|
|
|
// if(user == null) throw new JeecgBootException("请登录");
|
|
|
if(hotelId == null) throw new JeecgBootException("未找到酒店");
|
|
|
- BusOrderFee preferFeeItem = null;
|
|
|
- if(settleFees.stream().anyMatch(s-> BooleanUtil.isTrue(s.getIsPreferential()))){
|
|
|
- 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.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.setSubjectType(FeeSubjectType.YOU_HUI.getKey());
|
|
|
- preferFeeItem.setFeeType(1);
|
|
|
- preferFeeItem.setRoomId(mainRoom.getRoomId());
|
|
|
- preferFeeItem.setPayType(null);
|
|
|
- preferFeeItem.setMoney(preferFeeItem.getMoney().multiply(BigDecimal.valueOf(-1)));// 消费为负数 就是优惠
|
|
|
- preferFeeItem.setLivingOrderId(mainRoomOrder.getId());
|
|
|
- preferFeeItem.setPreferentialStatus(2);
|
|
|
- preferFeeItem.setHotelId(hotelId);
|
|
|
- feeService.save(preferFeeItem);
|
|
|
- }
|
|
|
List<BusRoomPayType> payTypes = payTypeService.list();
|
|
|
settleFees.forEach(s->{
|
|
|
- if(BooleanUtil.isTrue(s.getIsPreferential())) 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()));
|
|
|
- memberCardService.updateById(vipCard);
|
|
|
- // log
|
|
|
- BusMemberBalanceLog balanceLog = new BusMemberBalanceLog();
|
|
|
- balanceLog.setMoney(s.getMoney());
|
|
|
- balanceLog.setBalance(vipCard.getBalance());
|
|
|
- balanceLog.setType(2);// 扣费
|
|
|
- balanceLog.setMemberId(mainRoomOrder.getVipCustomerId());
|
|
|
- balanceLog.setStatus(1);// TODO:不知道干什么用的 貌似是个啥支付状态
|
|
|
- balanceLog.setGiveMoney(new BigDecimal(0));
|
|
|
- balanceLog.setRemarks("房间收费扣款");
|
|
|
- balanceLog.setHotelId(hotelId);
|
|
|
- if(user!=null) {
|
|
|
- balanceLog.setTenantId(user.getRelTenantIds());
|
|
|
+ if(BooleanUtil.isTrue(s.getIsPreferential())) {
|
|
|
+ if(s.getCouponscashId() != null && !s.getCouponscashId().isEmpty()) {
|
|
|
+ BusMarketCouponsCashUsed couponTicket = marketCouponsCashUsedService.getById(s.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);
|
|
|
}
|
|
|
- balanceLog.setPaymentMethod("");
|
|
|
- balanceLog.setPayMoney(new BigDecimal(0));
|
|
|
- balanceLog.setCode(BusMemberBalanceLogServiceImpl.randomNumber("KF"));
|
|
|
- balanceLog.setCreateTime(new Date());
|
|
|
- memberBalanceLogService.save(balanceLog);
|
|
|
- // todo 积分规则
|
|
|
+ }
|
|
|
+ s.setFeeType(1);
|
|
|
+ s.setSubjectType(FeeSubjectType.YOU_HUI.getKey());
|
|
|
+ s.setPayType(null);
|
|
|
+ } else {
|
|
|
+ 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()));
|
|
|
+ memberCardService.updateById(vipCard);
|
|
|
+ // log
|
|
|
+ BusMemberBalanceLog balanceLog = new BusMemberBalanceLog();
|
|
|
+ balanceLog.setMoney(s.getMoney());
|
|
|
+ balanceLog.setBalance(vipCard.getBalance());
|
|
|
+ balanceLog.setType(2);// 扣费
|
|
|
+ balanceLog.setMemberId(mainRoomOrder.getVipCustomerId());
|
|
|
+ balanceLog.setStatus(1);// TODO:不知道干什么用的 貌似是个啥支付状态
|
|
|
+ balanceLog.setGiveMoney(new BigDecimal(0));
|
|
|
+ balanceLog.setRemarks("房间收费扣款");
|
|
|
+ balanceLog.setHotelId(hotelId);
|
|
|
+ if(user!=null) {
|
|
|
+ balanceLog.setTenantId(user.getRelTenantIds());
|
|
|
+ }
|
|
|
+ balanceLog.setPaymentMethod("");
|
|
|
+ balanceLog.setPayMoney(new BigDecimal(0));
|
|
|
+ balanceLog.setCode(BusMemberBalanceLogServiceImpl.randomNumber("KF"));
|
|
|
+ balanceLog.setCreateTime(new Date());
|
|
|
+ memberBalanceLogService.save(balanceLog);
|
|
|
+ // todo 积分规则
|
|
|
|
|
|
+ }
|
|
|
}
|
|
|
+ s.setFeeType(2);
|
|
|
+ s.setSubjectType(FeeSubjectType.JIE_ZHANG.getKey());
|
|
|
+ s.setContactId(mainRoomOrder.getContactId());
|
|
|
}
|
|
|
- s.setCreateTime(new Date());
|
|
|
s.setPreferentialStatus(2);
|
|
|
- s.setFeeType(2);
|
|
|
- s.setContactId(mainRoomOrder.getContactId());
|
|
|
- s.setLivingOrderId(mainRoomOrder.getId());
|
|
|
+ s.setCreateTime(new Date());
|
|
|
s.setRoomId(mainRoom.getRoomId());
|
|
|
- s.setSubjectType(FeeSubjectType.JIE_ZHANG.getKey());
|
|
|
- });
|
|
|
+ s.setLivingOrderId(mainRoomOrder.getId());
|
|
|
+ s.setHotelId(hotelId);
|
|
|
|
|
|
- List<BusOrderFee> jiezhangFees = settleFees.stream().filter(s->s.getIsPreferential() == null || s.getIsPreferential().equals(false)).collect(Collectors.toList());
|
|
|
- jiezhangFees.forEach(a->{
|
|
|
- a.setHotelId(hotelId);
|
|
|
});
|
|
|
- if(jiezhangFees.size() > 0) {
|
|
|
- feeService.saveBatch(jiezhangFees);
|
|
|
+ if(settleFees.size() > 0) {
|
|
|
+ feeService.saveBatch(settleFees);
|
|
|
} else throw new JeecgBootException("参数没有结账收费项目");
|
|
|
feeItems.forEach(s->{
|
|
|
s.setPreferentialStatus(2);
|