|
|
@@ -134,6 +134,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
private IBusMarketAgreementUnitService marketAgreementUnitService;
|
|
|
|
|
|
@Resource
|
|
|
+ IBusMarketAgreementCustomerService marketAgreementCustomerService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
private IFwRoomCleanService fwRoomCleanService;
|
|
|
|
|
|
@Resource
|
|
|
@@ -1216,38 +1219,51 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<BusOrderFeeVo> getLivingOrderFee(String orderId) {
|
|
|
+ public List<BusOrderFee> getLivingOrderFee(String orderId, Boolean isAllFee) {
|
|
|
List<BusRoomsLivingOrder> livingOrders = roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>query().eq("booking_order_id",orderId));
|
|
|
- if(livingOrders.size() > 0) {
|
|
|
- List<String> livingOrderIds = livingOrders.stream().map(s->s.getId()).collect(Collectors.toList());
|
|
|
+ if(!livingOrders.isEmpty()) {
|
|
|
+ List<String> livingOrderIds = livingOrders.stream().map(BusRoomsLivingOrder::getId).collect(Collectors.toList());
|
|
|
// 所有订单商品关联对象
|
|
|
List<BusOrderFeeGoodsVo> busOrderFeeGoodVos = orderFeeGoodsService.queryOrderGoodDetail(livingOrderIds);
|
|
|
// 所有订单
|
|
|
- List<BusOrderFee> orderFees = feeService.list(Wrappers.<BusOrderFee>query().in("living_order_id",livingOrderIds).gt("money",0).eq("preferential_status", 1));
|
|
|
- ArrayList<BusOrderFeeVo> busOrderFeeVos = new ArrayList<>();
|
|
|
- orderFees.stream().forEach(e ->{
|
|
|
- BusOrderFeeVo busOrderFeeVo = BeanUtil.copyProperties(e, BusOrderFeeVo.class);
|
|
|
- // 订单为 商品订单 时
|
|
|
- if (FeeSubjectType.SHANG_PIN.getKey().equals(e.getSubjectType())){
|
|
|
- List<BusOrderFeeGoodsVo> busOrderFeeGoodsVo = busOrderFeeGoodVos.stream().filter(orderFeeGoodVo -> StrUtil.equals(orderFeeGoodVo.getOrderFeeId(), e.getId())).collect(Collectors.toList());
|
|
|
- // 当一个订单费用是商品时,找出包含的商品,把每种商品都分成一个个订单费用
|
|
|
- busOrderFeeGoodsVo.forEach(goods -> {
|
|
|
- BusOrderFeeVo childOrderFeeVo = BeanUtil.copyProperties(e, BusOrderFeeVo.class);
|
|
|
- childOrderFeeVo.setMoney(goods.getPrice());
|
|
|
- childOrderFeeVo.setFeeGoodVo(goods);
|
|
|
- busOrderFeeVos.add(childOrderFeeVo);
|
|
|
- });
|
|
|
- } else {
|
|
|
- busOrderFeeVos.add(busOrderFeeVo);
|
|
|
- }
|
|
|
+ LambdaQueryWrapper<BusOrderFee> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(BusOrderFee::getLivingOrderId, livingOrderIds);
|
|
|
+ // 如果是null 则查询未结算的, 可以添加false为查询已结算的
|
|
|
+ if (ObjectUtil.isEmpty(isAllFee)){
|
|
|
+ queryWrapper.eq(BusOrderFee::getPreferentialStatus, 1);
|
|
|
+ }
|
|
|
+ List<BusOrderFee> orderFees = feeService.list(queryWrapper);
|
|
|
+ List<BusOrderFee> strikeBalanceFees = orderFees.stream().filter(e -> e.getReturnItem() && FeeType.CONSUME.getKey()
|
|
|
+ .equals(e.getFeeType())).collect(Collectors.toList());
|
|
|
+ // 最终返回费用。当费用是商品消费时找出商品。消费的费用 需要处理掉 冲账的费用
|
|
|
+ ArrayList<BusOrderFee> orderFeeList = new ArrayList<>();
|
|
|
+ orderFees.forEach(e ->{
|
|
|
+ // 订单为 收款单时
|
|
|
+ if (FeeType.COLLECTION.getKey().equals(e.getFeeType())){
|
|
|
+ orderFeeList.add(e);
|
|
|
+ // 订单为 消费单,且不是冲账单
|
|
|
+ } else if (!e.getReturnItem()){
|
|
|
+ BigDecimal strikeBalance = strikeBalanceFees.stream().filter(sbFee -> e.getId().equals(sbFee.getReturnFeeId()))
|
|
|
+ .map(BusOrderFee::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ e.setOriginalMoney(e.getMoney());
|
|
|
+ e.setMoney(e.getMoney().add(strikeBalance));
|
|
|
+ // 如果消费费用是商品
|
|
|
+ if (FeeSubjectType.SHANG_PIN.getKey().equals(e.getSubjectType()) || FeeSubjectType.DIAN_PIN.getKey().equals(e.getSubjectType())){
|
|
|
+ Optional<BusOrderFeeGoodsVo> busOrderFeeGoodsVo = busOrderFeeGoodVos.stream()
|
|
|
+ .filter(orderFeeGoodVo -> StrUtil.equals(orderFeeGoodVo.getOrderFeeId(), e.getId())).findFirst();
|
|
|
+ busOrderFeeGoodsVo.ifPresent(e::setFeeGoodVo);
|
|
|
+ }
|
|
|
+ orderFeeList.add(e);
|
|
|
}
|
|
|
- );
|
|
|
- return busOrderFeeVos;
|
|
|
+
|
|
|
+ });
|
|
|
+ return orderFeeList;
|
|
|
}
|
|
|
return new ArrayList<>();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Boolean syncDayRoomOrder(String hotelId) {
|
|
|
List<CesRooms> hotelRooms = roomsService.list(Wrappers.<CesRooms>query().eq("hotel_id",hotelId).eq("invalid",false));
|
|
|
@@ -1419,10 +1435,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
});
|
|
|
roomsLivingOrderService.updateBatchById(livingOrders);
|
|
|
if(livingOrders.size() > 0) {
|
|
|
- List<BusOrderFee> feeItems = getLivingOrderFee(bookingOrderId).stream().filter(
|
|
|
- s->s.getPreferentialStatus().equals(1)// 找到未结账的
|
|
|
- ).collect(Collectors.toList());
|
|
|
-
|
|
|
+ List<BusOrderFee> feeItems = getLivingOrderFee(bookingOrderId, null); // 找到未结账的
|
|
|
|
|
|
final BigDecimal[] shoukuan = {new BigDecimal(0)};
|
|
|
final BigDecimal[] xiaofei = {new BigDecimal(0)};
|
|
|
@@ -1478,7 +1491,12 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
if(livingOrder == null) throw new JeecgBootException("未找到任何入住订单");
|
|
|
BusBookingRooms mainRoom = bookingRoomsService.getOne(Wrappers.<BusBookingRooms>query()
|
|
|
.eq("id",livingOrder.getBookingRoomId()));
|
|
|
- if(mainRoom.getIsMain().equals(true)) throw new JeecgBootException("主房不能单独结账退房");
|
|
|
+ List<BusRoomsLivingOrder> releLivingingOrders = roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>lambdaQuery()
|
|
|
+ .eq(BusRoomsLivingOrder::getBookingOrderId, livingOrder.getBookingOrderId()));
|
|
|
+ if (CollUtil.isEmpty(releLivingingOrders)){
|
|
|
+ throw new JeecgBootException("未找到预定订单");
|
|
|
+ }
|
|
|
+ if(mainRoom.getIsMain().equals(true) && releLivingingOrders.size() > 1) throw new JeecgBootException("查询到其他关联房间,主房不能单独结账退房");
|
|
|
if(mainRoom == null) throw new JeecgBootException("没有找到主房");
|
|
|
|
|
|
BusRoomsLivingOrder mainRoomOrder = livingOrder;
|
|
|
@@ -1659,6 +1677,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
if(livingOrder == null) throw new JeecgBootException("订单不存在");
|
|
|
BusBookingRooms bookingRoom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
if(bookingRoom == null) throw new JeecgBootException("未找到房间关联");
|
|
|
+ List<BusOrderFeeGoods> orderFeeGoodList = new ArrayList<>();
|
|
|
fees.forEach(roomFee->{
|
|
|
roomFee.setLivingOrderId(livingOrderId);
|
|
|
roomFee.setRoomId(bookingRoom.getRoomId());
|
|
|
@@ -1667,18 +1686,15 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
roomFee.setDayTime(new Date());
|
|
|
roomFee.setHotelId(hotelId);
|
|
|
feeService.save(roomFee);
|
|
|
- if(roomFee.getSubjectType().equals(FeeSubjectType.SHANG_PIN.getKey()) && roomFee.getFeeGoods() != null && roomFee.getFeeGoods().size() > 0) {
|
|
|
- // 判断是否相等 搞尼玛~傻逼
|
|
|
- roomFee.getFeeGoods().forEach(s->{
|
|
|
- s.setOrderFeeId(roomFee.getId());
|
|
|
- s.setLivingOrderId(livingOrderId);
|
|
|
- s.setCreateTime(new Date());
|
|
|
- s.setHotelId(livingOrder.getHotelId());
|
|
|
- });
|
|
|
- orderFeeGoodsService.saveBatch(roomFee.getFeeGoods());
|
|
|
+ if(roomFee.getSubjectType().equals(FeeSubjectType.SHANG_PIN.getKey()) && roomFee.getFeeGoodVo() != null) {
|
|
|
+ roomFee.getFeeGoodVo().setOrderFeeId(roomFee.getId());
|
|
|
+ roomFee.getFeeGoodVo().setLivingOrderId(livingOrderId);
|
|
|
+ roomFee.getFeeGoodVo().setCreateTime(new Date());
|
|
|
+ roomFee.getFeeGoodVo().setHotelId(livingOrder.getHotelId());
|
|
|
+ orderFeeGoodList.add(roomFee.getFeeGoodVo());
|
|
|
}
|
|
|
});
|
|
|
-
|
|
|
+ orderFeeGoodsService.saveBatch(orderFeeGoodList);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -1969,30 +1985,83 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
- 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("未找到相应的会员");
|
|
|
+ if(info.getCustomerType() != null && CustomerTypeEnum.val(info.getCustomerType()) != null) {
|
|
|
+
|
|
|
+ // 如果改变的客人类型有会员卡
|
|
|
+ BigDecimal changeDiscount = new BigDecimal(1);
|
|
|
+ String vipCustomerId = "";
|
|
|
+ String marketAgreementCustomerId = "";
|
|
|
+ String contractTeamId = "";
|
|
|
+ if (CustomerTypeEnum.VIP.getKey().equals(info.getCustomerType()) && StrUtil.isNotEmpty(info.getVipCustomerId())){
|
|
|
+ BusMemberCard changeMemberCard = memberCardService.getById(info.getVipCustomerId());
|
|
|
+ if (ObjectUtil.isEmpty(changeMemberCard)){
|
|
|
+ throw new JeecgBootException("未找到相应的会员");
|
|
|
+ }
|
|
|
+ BusMarketMember changeMarketMember = marketMemberService.getById(changeMemberCard.getGradeId());
|
|
|
+ if (ObjectUtil.isEmpty(changeMarketMember) || ObjectUtil.isEmpty(changeMarketMember.getDiscount())){
|
|
|
+ throw new JeecgBootException("会员类型异常");
|
|
|
+ }
|
|
|
+ vipCustomerId = changeMemberCard.getId();
|
|
|
+ changeDiscount = changeMarketMember.getDiscount().divide(new BigDecimal(100));
|
|
|
}
|
|
|
- BusMarketMember marketMember = marketMemberService.getById(memberCard.getGradeId());
|
|
|
- if (ObjectUtil.isEmpty(marketMember) || ObjectUtil.isEmpty(marketMember.getDiscount())){
|
|
|
- throw new JeecgBootException("会员异常");
|
|
|
+
|
|
|
+ //
|
|
|
+ if (CustomerTypeEnum.PROTOCOL.getKey().equals(info.getCustomerType()) && StrUtil.isNotEmpty(info.getContractTeamProtocolId())){
|
|
|
+ BusMarketAgreementCustomer changeMarketAgreementCustomer = marketAgreementCustomerService.getById(info.getContractTeamProtocolId());
|
|
|
+
|
|
|
+ if (ObjectUtil.isEmpty(changeMarketAgreementCustomer) || ObjectUtil.isEmpty(changeMarketAgreementCustomer.getDiscount())){
|
|
|
+ throw new JeecgBootException("合同类型异常");
|
|
|
+ }
|
|
|
+ marketAgreementCustomerId = changeMarketAgreementCustomer.getId();
|
|
|
+ contractTeamId = info.getContractTeamId();
|
|
|
+ changeDiscount = changeMarketAgreementCustomer.getDiscount().divide(new BigDecimal(100));
|
|
|
}
|
|
|
+
|
|
|
+ // 如果原来客人类型有会员卡
|
|
|
+ BigDecimal originalDiscount = new BigDecimal(1);
|
|
|
+ if (StrUtil.isNotEmpty(order.getVipCustomerId())){
|
|
|
+ BusMemberCard originalMemberCard = memberCardService.getById(order.getVipCustomerId());
|
|
|
+ if (ObjectUtil.isEmpty(originalMemberCard)){
|
|
|
+ throw new JeecgBootException("未找到原相应的会员");
|
|
|
+ }
|
|
|
+ BusMarketMember originalMarketMember = marketMemberService.getById(originalMemberCard.getGradeId());
|
|
|
+ if (ObjectUtil.isEmpty(originalMarketMember) || ObjectUtil.isEmpty(originalMarketMember.getDiscount())){
|
|
|
+ throw new JeecgBootException("原会员类型异常");
|
|
|
+ }
|
|
|
+ originalDiscount = originalMarketMember.getDiscount().divide(new BigDecimal(100));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 如果有原合同
|
|
|
+ if (StrUtil.isNotEmpty(order.getContractTeamProtocolId())){
|
|
|
+ BusMarketAgreementCustomer marketAgreementCustomer = marketAgreementCustomerService.getById(order.getContractTeamProtocolId());
|
|
|
+ if (ObjectUtil.isEmpty(marketAgreementCustomer) || ObjectUtil.isEmpty(marketAgreementCustomer.getDiscount())){
|
|
|
+ throw new JeecgBootException("原合同类型异常");
|
|
|
+ }
|
|
|
+ originalDiscount = marketAgreementCustomer.getDiscount().divide(new BigDecimal(100));
|
|
|
+ }
|
|
|
+
|
|
|
order.setCustomerType(info.getCustomerType());
|
|
|
+ order.setVipCustomerId(vipCustomerId);
|
|
|
+ order.setContractTeamId(contractTeamId);
|
|
|
+ order.setContractTeamProtocolId(marketAgreementCustomerId);
|
|
|
// 找出房费订单和每日价格,按会员价算
|
|
|
List<BusOrderFee> orderFeeList = feeService.list(Wrappers.<BusOrderFee>lambdaQuery()
|
|
|
.eq(BusOrderFee::getLivingOrderId, order.getId()).eq(BusOrderFee::getSubjectType, FeeSubjectType.MEI_RI_FANG_FEI.getKey()));
|
|
|
+ // 原始则扣和改变后的折扣
|
|
|
+ BigDecimal finalOriginalDiscount = originalDiscount;
|
|
|
+ BigDecimal finalChangeDiscount = changeDiscount;
|
|
|
orderFeeList.forEach(e -> {
|
|
|
- e.setMoney(e.getMoney().multiply(marketMember.getDiscount()).divide(BigDecimal.valueOf(100)));
|
|
|
+ e.setMoney(e.getMoney().multiply(finalChangeDiscount).divide(finalOriginalDiscount));
|
|
|
});
|
|
|
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)));
|
|
|
+ e.setPrice(e.getPrice().multiply(finalChangeDiscount).divide(finalOriginalDiscount));
|
|
|
});
|
|
|
feeService.updateBatchById(orderFeeList);
|
|
|
livingLayoutDayPriceService.updateBatchById(livingDayPrice);
|
|
|
- roomsLivingOrderService.updateById(order);
|
|
|
+ boolean b = roomsLivingOrderService.updateById(order);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
@@ -2762,6 +2831,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
changeRoom.setRoomStatus(RoomStatusEnum.LIVE_CLEAR.getKey());
|
|
|
changeRoom.setLivingOrderId(livingOrderId);
|
|
|
roomsService.updateById(changeRoom);
|
|
|
+ feeService.update(Wrappers.<BusOrderFee>lambdaUpdate().set(BusOrderFee::getRoomId, changeRoom.getId())
|
|
|
+ .eq(BusOrderFee::getLivingOrderId, livingOrderId));
|
|
|
livingLayoutDayPriceService.remove(Wrappers.<BusLivingLayoutDayPrice>query().eq("living_order_id",livingOrderId));
|
|
|
prices.forEach(s->{
|
|
|
s.setRoomLayoutId(changeRoom.getLayoutId());
|