|
|
@@ -102,6 +102,11 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
@Resource
|
|
|
private CesAllDayPriceRuleServiceImpl allDayPriceRuleService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IBusAgreementOrderFeeService agreementOrderFeeService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private IBusMarketAgreementUnitService marketAgreementUnitService;
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String bookingOrderSave(BookingOrderSaveDto item, Boolean isTeam,Boolean isLiving) {
|
|
|
@@ -1997,7 +2002,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
}
|
|
|
private Map<String,String> bookingRoomToLiving(BookingOrderSaveDto livingData, List<ExtendBusBookingRoomsVo> roomIds, BookingOrderEditVo bookingOrderVo,String hotelId) {
|
|
|
Map<String,String> results = new HashMap<>();
|
|
|
-
|
|
|
+ List<BusRoomPayType> payTypes = payTypeService.list(Wrappers.<BusRoomPayType>query().eq("hotel_id",hotelId));
|
|
|
+ LoginUser user = TokenUtils.getAuthUser();
|
|
|
roomIds.forEach(bkRoom-> {
|
|
|
if(livingData.getRoomIds().stream().filter(s->s.getRoomId().equals(bkRoom.getRoomId())).count() == 0)
|
|
|
throw new JeecgBootException("房间信息未找到");
|
|
|
@@ -2009,6 +2015,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
if(livingData.getOrderFees()!=null && livingData.getOrderFees().size() > 0 ) {
|
|
|
List<BusOrderFee> findRoomFees = livingData.getOrderFees().stream().filter(t->t.getRoomId().equals(bkRoom.getRoomId())).collect(Collectors.toList());
|
|
|
findRoomFees.forEach(s->{
|
|
|
+
|
|
|
s.setRoomId(bkRoom.getRoomId());
|
|
|
s.setLivingOrderId(livingOrderId);
|
|
|
s.setCreateTime(new Date());
|
|
|
@@ -2019,6 +2026,33 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
}
|
|
|
});
|
|
|
if(findRoomFees.size() > 0) feeService.saveBatch(findRoomFees);
|
|
|
+ // 处理协议单位记账
|
|
|
+ findRoomFees.forEach(s->{
|
|
|
+ if(payTypes.stream().anyMatch(k->k.getId().equals(s.getPayType()) && k.getName().equals("单位记账")) ) {
|
|
|
+ BusAgreementOrderFee agreementOrderFee = new BusAgreementOrderFee();
|
|
|
+ if(s.getAgreementUnitId() == null || s.getAgreementUnitId().isEmpty()) throw new JeecgBootException("请选择协议单位");
|
|
|
+ BusMarketAgreementUnit unit = marketAgreementUnitService.getById(s.getAgreementUnitId());
|
|
|
+ if(unit == null) throw new JeecgBootException("协议单位未找到");
|
|
|
+ if(unit.getBookkStatus() != null && unit.getBookkStatus().equals(1)) throw new JeecgBootException("不允许该单位记账");
|
|
|
+ BigDecimal usedAmount;
|
|
|
+ if(unit.getAmountUsed() == null) usedAmount = new BigDecimal(0);
|
|
|
+ else usedAmount = unit.getAmountUsed();
|
|
|
+ double incrementBalance = (usedAmount.add(s.getMoney())).doubleValue();
|
|
|
+ // 记账限额超出,返回异常结果!
|
|
|
+ if(unit.getBookkeeping() != null && !unit.getBookkeeping().equals(new BigDecimal(0)) && unit.getBookkeeping().doubleValue() < incrementBalance)
|
|
|
+ throw new JeecgBootException("记账超额!记账单位限额为"+unit.getBookkeeping().doubleValue()+",已使用"+usedAmount.doubleValue());
|
|
|
+ agreementOrderFee.setAgreementUnitId(s.getAgreementUnitId());
|
|
|
+ agreementOrderFee.setOrderFeeId(s.getId());
|
|
|
+ agreementOrderFee.setCreatedTime(new Date());
|
|
|
+ agreementOrderFee.setCreateUserId(user != null ?user.getId():"");
|
|
|
+ agreementOrderFee.setSettleStatus(1);
|
|
|
+ agreementOrderFeeService.save(agreementOrderFee);
|
|
|
+ // 更新已使用的记账
|
|
|
+ unit.setAmountUsed(new BigDecimal(incrementBalance));
|
|
|
+ unit.setUpdateTime(new Date());
|
|
|
+ marketAgreementUnitService.updateById(unit);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
// 另外每个房间还要在入住时生成每日房费账单
|
|
|
BusOrderFee roomFee = new BusOrderFee();
|