|
|
@@ -36,6 +36,8 @@ import org.jeecg.modules.fw.service.IFwRoomLockService;
|
|
|
import org.jeecg.modules.fw.service.IFwRoomRepairService;
|
|
|
import org.jeecg.modules.fw.vo.FwRoomLockVo;
|
|
|
import org.jeecg.modules.fw.vo.FwRoomRepairVo;
|
|
|
+import org.jeecg.modules.kc.entity.KcDepositoryInGoods;
|
|
|
+import org.jeecg.modules.kc.service.IKcDepositoryInGoodsService;
|
|
|
import org.jeecg.modules.rooms.Enum.RoomStatusEnum;
|
|
|
import org.jeecg.modules.rooms.Enum.TimeOutRuleEnum;
|
|
|
import org.jeecg.modules.rooms.Vo.BookingRealtimeVo;
|
|
|
@@ -159,6 +161,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
@Autowired
|
|
|
private RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private IKcDepositoryInGoodsService depositoryInGoodsService;
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String bookingOrderSave(BookingOrderSaveDto item, Boolean isTeam,Boolean isLiving,String hotelId) {
|
|
|
@@ -1138,16 +1143,32 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
if(ObjectUtils.isEmpty(cesAllDayPriceRule)) {
|
|
|
throw new JeecgBootException("未找到超时收费规则");
|
|
|
}
|
|
|
-
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.setTime(livingOrder.getDueOutTime());
|
|
|
- calendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
+ Calendar calendar = getRemindTime(livingOrder, cesAllDayPriceRule, livingRoomOrderInfo.getBookingType());
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
|
|
|
+ System.out.println(format.format(calendar.getTime()));
|
|
|
redisTemplate.opsForZSet().add("overTimerOrder", livingOrder.getId(), calendar.getTimeInMillis());
|
|
|
roomsService.getReserveRoom();
|
|
|
//</editor-fold>
|
|
|
return livingOrder.getId();
|
|
|
}
|
|
|
|
|
|
+ public Calendar getRemindTime(BusRoomsLivingOrder livingOrder, CesAllDayPriceRule cesAllDayPriceRule, Integer BookingType){
|
|
|
+ Calendar calendar = Calendar.getInstance();
|
|
|
+ if (ObjectUtil.equals(BookingType, 1)) {
|
|
|
+ calendar.setTime(livingOrder.getArrivalTime());
|
|
|
+ calendar.add(Calendar.DAY_OF_YEAR, 1);
|
|
|
+ Calendar overDate = Calendar.getInstance();
|
|
|
+ overDate.setTime(livingOrder.getDueOutTime());
|
|
|
+ calendar.set(Calendar.HOUR_OF_DAY, overDate.get(Calendar.HOUR_OF_DAY));
|
|
|
+ calendar.set(Calendar.MINUTE, overDate.get(Calendar.MINUTE));
|
|
|
+ calendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
+ }else if(ObjectUtil.equals(BookingType, 2)){
|
|
|
+ // TODO: 2023/10/24 钟点房超时时间
|
|
|
+ calendar.setTime(livingOrder.getDueOutTime());
|
|
|
+ }
|
|
|
+ return calendar;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public String customerLiving(BookingOrderSaveDto livingData, Boolean isTeam, String hotelId) {
|
|
|
@@ -1267,6 +1288,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
Map<String,BigDecimal> feeMap = getRoomOrderFees(livingOrder.getId());
|
|
|
livingOrder.setXiaoFei(feeMap.get("xf"));
|
|
|
livingOrder.setShouKuan(feeMap.get("sk"));
|
|
|
+ livingOrder.setDeposit(feeMap.get("yj"));
|
|
|
// 获取入住天数
|
|
|
livingOrder.setLiveDayCount(getLivingDayCount(livingOrder));
|
|
|
// 设置居住单的团队联房标签
|
|
|
@@ -1311,17 +1333,23 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
.eq("living_order_id",livingOrderId).eq("preferential_status",1));
|
|
|
List<BusOrderFee> xiaofeiList = fees.stream().filter(s->s.getFeeType().equals(1)).collect(Collectors.toList());
|
|
|
List<BusOrderFee> shoukuanList = fees.stream().filter(s->s.getFeeType().equals(2)).collect(Collectors.toList());
|
|
|
+ List<BusOrderFee> depositList = shoukuanList.stream().filter(s->ObjectUtil.equals(s.getSubjectType(),"1")).collect(Collectors.toList());
|
|
|
final BigDecimal[] xiaoFeiTotal = {new BigDecimal(0)};
|
|
|
final BigDecimal[] shouKuanTotal = {new BigDecimal(0)};
|
|
|
+ final BigDecimal[] depositTotal = {new BigDecimal(0)};
|
|
|
xiaofeiList.forEach(s->{
|
|
|
xiaoFeiTotal[0] = xiaoFeiTotal[0].add(s.getMoney());
|
|
|
});
|
|
|
shoukuanList.forEach(s->{
|
|
|
shouKuanTotal[0] = shouKuanTotal[0].add(s.getMoney());
|
|
|
});
|
|
|
+ depositList.forEach(s->{
|
|
|
+ depositTotal[0] = depositTotal[0].add(s.getMoney());
|
|
|
+ });
|
|
|
Map<String,BigDecimal> items = new HashMap<>();
|
|
|
items.put("xf",xiaoFeiTotal[0]);
|
|
|
items.put("sk",shouKuanTotal[0]);
|
|
|
+ items.put("yj",depositTotal[0]);
|
|
|
return items;
|
|
|
}
|
|
|
|
|
|
@@ -1547,148 +1575,153 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
|
|
|
public Boolean syncRoomOverTimeOrder(String hotelId) {
|
|
|
// 查询出当前时间内需要处理的超时订单
|
|
|
- Set<Object> set = redisTemplate.opsForZSet().rangeByScore("overTimerOrder", 0, Calendar.getInstance().getTimeInMillis());
|
|
|
- CesAllDayPriceRule cesAllDayPriceRule = allDayPriceRuleService.getOne(Wrappers.<CesAllDayPriceRule>lambdaQuery().eq(CesAllDayPriceRule::getHotelId,hotelId).eq(CesAllDayPriceRule::getInvalid,false));
|
|
|
+ Set<Object> set = redisTemplate.opsForZSet().rangeByScore("overTimerOrder", 0, Calendar.getInstance().getTimeInMillis());CesAllDayPriceRule cesAllDayPriceRule = allDayPriceRuleService.getOne(Wrappers.<CesAllDayPriceRule>lambdaQuery().eq(CesAllDayPriceRule::getHotelId,hotelId).eq(CesAllDayPriceRule::getInvalid,false));
|
|
|
if(CollUtil.isEmpty(set)){
|
|
|
return true;
|
|
|
}
|
|
|
if(ObjectUtils.isEmpty(cesAllDayPriceRule)) {
|
|
|
throw new JeecgBootException("未找到超时收费规则");
|
|
|
}
|
|
|
- // 如果房间超时是按分钟加收费用
|
|
|
- if (TimeOutRuleEnum.ADD_BY_MINUTE.getKey().equals(cesAllDayPriceRule.getTimeOutRule())){
|
|
|
- addByMinute(set, cesAllDayPriceRule);
|
|
|
- }else if (TimeOutRuleEnum.ADD_BY_DAY.getKey().equals(cesAllDayPriceRule.getTimeOutRule())){
|
|
|
- addByDay(set, cesAllDayPriceRule);
|
|
|
- }else if (TimeOutRuleEnum.NOT_ADD.getKey().equals(cesAllDayPriceRule.getTimeOutRule())) {
|
|
|
- notAdd(set, cesAllDayPriceRule);
|
|
|
- }
|
|
|
+ LambdaQueryWrapper<BusRoomsLivingOrder> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.in(BusRoomsLivingOrder::getId,set);
|
|
|
+ List<BusRoomsLivingOrder> livingOrderList = roomsLivingOrderService.list(queryWrapper);
|
|
|
+ livingOrderList.forEach(e -> {
|
|
|
+ BusRoomBookingOrders roomBookingOrder = getById(e.getBookingOrderId());
|
|
|
+ if (ObjectUtil.isEmpty(roomBookingOrder)){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 全天房
|
|
|
+ if (ObjectUtil.equals(1,roomBookingOrder.getBookingType())){
|
|
|
+ // 如果房间超时是按分钟加收费用
|
|
|
+ if (TimeOutRuleEnum.ADD_BY_MINUTE.getKey().equals(cesAllDayPriceRule.getTimeOutRule())){
|
|
|
+ addByMinute(e, cesAllDayPriceRule);
|
|
|
+ }else if (TimeOutRuleEnum.ADD_BY_DAY.getKey().equals(cesAllDayPriceRule.getTimeOutRule())){
|
|
|
+ addByDay(e, cesAllDayPriceRule);
|
|
|
+ }else if (TimeOutRuleEnum.NOT_ADD.getKey().equals(cesAllDayPriceRule.getTimeOutRule())) {
|
|
|
+ notAdd(e, cesAllDayPriceRule);
|
|
|
+ }
|
|
|
+ // 钟点房
|
|
|
+ } else if(ObjectUtil.equals(2,roomBookingOrder.getBookingType())){
|
|
|
+ // TODO: 2023/10/24 钟点房超时收费
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 超时收费规则是按分钟
|
|
|
*/
|
|
|
- public void addByMinute(Set<Object> set, CesAllDayPriceRule cesAllDayPriceRule){
|
|
|
+ public void addByMinute(BusRoomsLivingOrder livingOrder, CesAllDayPriceRule cesAllDayPriceRule){
|
|
|
Date date = new Date();
|
|
|
Calendar nextCalendar = Calendar.getInstance();
|
|
|
- set.forEach(e -> {
|
|
|
- nextCalendar.setTime(date);
|
|
|
- BusRoomsLivingOrder livingOrder = roomsLivingOrderService.getById(e.toString());
|
|
|
- if(ObjectUtil.isNotEmpty(livingOrder)){
|
|
|
- BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
- if (ObjectUtil.isEmpty(bookingroom)){
|
|
|
- throw new JeecgBootException("未找到订单对应的房间");
|
|
|
- }
|
|
|
- // 查询当天房间超时消费
|
|
|
- BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
|
|
|
- // 需要支付完整费用时间的最后时间
|
|
|
- Date endTime = getFullFeeTime(date, cesAllDayPriceRule);
|
|
|
- // 当前时间加上超时收费时间
|
|
|
- nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
- // 当前时间加上超时收费时间 < 按全天收费时间的标准
|
|
|
- if (nextCalendar.getTime().compareTo(endTime) < 0){
|
|
|
- // 不满足的情况下,添加超时收费,设置下一次收费时间戳
|
|
|
- fee.setDayTime(date);
|
|
|
- fee.setMoney(fee.getMoney().add(cesAllDayPriceRule.getPrice()));
|
|
|
- redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
-
|
|
|
- // 如果下一次增加收费时间大于 全天收费时间 设置
|
|
|
- }else {
|
|
|
- // 如果满足全天收费要求,预离时间增加1天
|
|
|
- CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
|
|
|
- fee.setMoney(layout.getMarketPrice());
|
|
|
- fee.setDayTime(date);
|
|
|
- nextCalendar.setTime(livingOrder.getDueOutTime());
|
|
|
- nextCalendar.add(Calendar.DAY_OF_YEAR,1);
|
|
|
- livingOrder.setDueOutTime(nextCalendar.getTime());
|
|
|
- roomsLivingOrderService.updateById(livingOrder);
|
|
|
- // 下一次收费时间戳
|
|
|
- nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
- // 添加每日房费
|
|
|
- addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
|
|
|
- }
|
|
|
- // 移除处理过的时间订单,添加订单下一次超时的时间戳
|
|
|
- redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
- redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(),nextCalendar.getTimeInMillis());
|
|
|
- feeService.saveOrUpdate(fee);
|
|
|
- }
|
|
|
- });
|
|
|
+ nextCalendar.setTime(date);
|
|
|
+ BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
+ if (ObjectUtil.isEmpty(bookingroom)){
|
|
|
+ log.info("未找到订单{}对应的房间", livingOrder.getId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 查询当天房间超时消费
|
|
|
+ BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
|
|
|
+ // 需要支付完整费用时间的最后时间
|
|
|
+ Date endTime = getFullFeeTime(date, cesAllDayPriceRule);
|
|
|
+ // 当前时间加上超时收费时间
|
|
|
+ nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
+ // 当前时间加上超时收费时间 < 按全天收费时间的标准
|
|
|
+ if (nextCalendar.getTime().compareTo(endTime) < 0){
|
|
|
+ // 不满足的情况下,添加超时收费,设置下一次收费时间戳
|
|
|
+ fee.setDayTime(date);
|
|
|
+ fee.setMoney(fee.getMoney().add(cesAllDayPriceRule.getPrice()));
|
|
|
+ redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
+
|
|
|
+ // 如果下一次增加收费时间大于 全天收费时间 设置
|
|
|
+ }else {
|
|
|
+ // 如果满足全天收费要求,预离时间增加1天
|
|
|
+ CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
|
|
|
+ BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
|
|
|
+ fee.setMoney(dayPrice.getPrice());
|
|
|
+ fee.setDayTime(date);
|
|
|
+ nextCalendar.setTime(livingOrder.getDueOutTime());
|
|
|
+ nextCalendar.add(Calendar.DAY_OF_YEAR,1);
|
|
|
+ livingOrder.setDueOutTime(nextCalendar.getTime());
|
|
|
+ roomsLivingOrderService.updateById(livingOrder);
|
|
|
+ // 下一次收费时间戳
|
|
|
+ nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
+ // 添加每日房费
|
|
|
+ }
|
|
|
+ // 移除处理过的时间订单,添加订单下一次超时的时间戳
|
|
|
+ redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
+ redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(),nextCalendar.getTimeInMillis());
|
|
|
+ feeService.saveOrUpdate(fee);
|
|
|
}
|
|
|
|
|
|
- public void addByDay(Set<Object> set, CesAllDayPriceRule cesAllDayPriceRule){
|
|
|
+ public void addByDay(BusRoomsLivingOrder livingOrder, CesAllDayPriceRule cesAllDayPriceRule){
|
|
|
Date date = new Date();
|
|
|
Calendar nextCalendar = Calendar.getInstance();
|
|
|
- set.forEach(e -> {
|
|
|
- BusRoomsLivingOrder livingOrder = roomsLivingOrderService.getById(e.toString());
|
|
|
- if(ObjectUtil.isNotEmpty(livingOrder)) {
|
|
|
- BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
- if (ObjectUtil.isEmpty(bookingroom)) {
|
|
|
- log.info("未找到订单{}对应的房间", livingOrder.getId());
|
|
|
- return;
|
|
|
- }
|
|
|
- CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
|
|
|
- // 查询当天房间超时消费
|
|
|
- BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
|
|
|
- // 需要支付完整费用时间的最后时间
|
|
|
- Date endTime = getFullFeeTime(date, cesAllDayPriceRule);
|
|
|
- if (nextCalendar.getTime().compareTo(endTime) < 0){
|
|
|
- fee.setMoney(layout.getMarketPrice().divide(new BigDecimal(2)));
|
|
|
- nextCalendar.setTime(endTime);
|
|
|
- } else {
|
|
|
- fee.setMoney(layout.getMarketPrice());
|
|
|
- nextCalendar.setTime(livingOrder.getDueOutTime());
|
|
|
- nextCalendar.add(Calendar.DAY_OF_YEAR,1);
|
|
|
- livingOrder.setDueOutTime(nextCalendar.getTime());
|
|
|
- roomsLivingOrderService.updateById(livingOrder);
|
|
|
- // 下一次收费时间戳
|
|
|
- nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
- // 添加每日房费
|
|
|
- addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
|
|
|
- }
|
|
|
- // 移除处理过的时间订单,添加订单下一次超时的时间戳
|
|
|
- redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
- redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(),nextCalendar.getTimeInMillis());
|
|
|
- feeService.saveOrUpdate(fee);
|
|
|
- }
|
|
|
- });
|
|
|
+ BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
+ if (ObjectUtil.isEmpty(bookingroom)) {
|
|
|
+ log.info("未找到订单{}对应的房间", livingOrder.getId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
|
|
|
+ // 查询当天房间超时消费
|
|
|
+ BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
|
|
|
+ // 需要支付完整费用时间的最后时间
|
|
|
+ Date endTime = getFullFeeTime(date, cesAllDayPriceRule);
|
|
|
+ if (nextCalendar.getTime().compareTo(endTime) < 0){
|
|
|
+ // 超时收取半天费用
|
|
|
+ fee.setMoney(layout.getMarketPrice().divide(new BigDecimal(2)));
|
|
|
+ nextCalendar.setTime(endTime);
|
|
|
+ } else {
|
|
|
+ // 添加每日房费
|
|
|
+ BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
|
|
|
+ fee.setMoney(dayPrice.getPrice());
|
|
|
+ nextCalendar.setTime(livingOrder.getDueOutTime());
|
|
|
+ nextCalendar.add(Calendar.DAY_OF_YEAR,1);
|
|
|
+ livingOrder.setDueOutTime(nextCalendar.getTime());
|
|
|
+ roomsLivingOrderService.updateById(livingOrder);
|
|
|
+ // 下一次收费时间戳
|
|
|
+ nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
+ }
|
|
|
+ // 移除处理过的时间订单,添加订单下一次超时的时间戳
|
|
|
+ redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
+ redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(),nextCalendar.getTimeInMillis());
|
|
|
+ feeService.saveOrUpdate(fee);
|
|
|
}
|
|
|
|
|
|
- public void notAdd(Set<Object> set, CesAllDayPriceRule cesAllDayPriceRule){
|
|
|
+ public void notAdd(BusRoomsLivingOrder livingOrder, CesAllDayPriceRule cesAllDayPriceRule){
|
|
|
Date date = new Date();
|
|
|
Calendar nextCalendar = Calendar.getInstance();
|
|
|
- set.forEach(e -> {
|
|
|
- BusRoomsLivingOrder livingOrder = roomsLivingOrderService.getById(e.toString());
|
|
|
- if(ObjectUtil.isNotEmpty(livingOrder)) {
|
|
|
- BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
- if (ObjectUtil.isEmpty(bookingroom)) {
|
|
|
- throw new JeecgBootException("未找到订单对应的房间");
|
|
|
- }
|
|
|
- CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
|
|
|
- // 查询当天房间超时消费
|
|
|
- BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
|
|
|
- // 需要支付完整费用时间的最后时间
|
|
|
- Date endTime = getFullFeeTime(date, cesAllDayPriceRule);
|
|
|
- if (nextCalendar.getTime().compareTo(endTime) >= 0){
|
|
|
- fee.setMoney(layout.getMarketPrice());
|
|
|
- nextCalendar.setTime(livingOrder.getDueOutTime());
|
|
|
- nextCalendar.add(Calendar.DAY_OF_YEAR,1);
|
|
|
- livingOrder.setDueOutTime(nextCalendar.getTime());
|
|
|
- roomsLivingOrderService.updateById(livingOrder);
|
|
|
- // 下一次收费时间戳
|
|
|
- nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
- // 添加每日房费
|
|
|
- addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
|
|
|
- }
|
|
|
- // 移除处理过的时间订单,添加订单下一次超时的时间戳
|
|
|
- redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
- redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(),nextCalendar.getTimeInMillis());
|
|
|
- feeService.saveOrUpdate(fee);
|
|
|
- }
|
|
|
- });
|
|
|
+ BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
+ if (ObjectUtil.isEmpty(bookingroom)) {
|
|
|
+ log.info("未找到订单{}对应的房间", livingOrder.getId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
|
|
|
+ // 查询当天房间超时消费
|
|
|
+ BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
|
|
|
+ // 需要支付完整费用时间的最后时间
|
|
|
+ Date endTime = getFullFeeTime(date, cesAllDayPriceRule);
|
|
|
+ if (nextCalendar.getTime().compareTo(endTime) >= 0){
|
|
|
+ // 添加每日房费
|
|
|
+ BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
|
|
|
+ fee.setMoney(dayPrice.getPrice());
|
|
|
+ nextCalendar.setTime(livingOrder.getDueOutTime());
|
|
|
+ nextCalendar.add(Calendar.DAY_OF_YEAR,1);
|
|
|
+ livingOrder.setDueOutTime(nextCalendar.getTime());
|
|
|
+ roomsLivingOrderService.updateById(livingOrder);
|
|
|
+ // 下一次收费时间戳
|
|
|
+ nextCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
|
|
|
+ }
|
|
|
+ // 移除处理过的时间订单,添加订单下一次超时的时间戳
|
|
|
+ redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
|
|
|
+ redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(),nextCalendar.getTimeInMillis());
|
|
|
+ feeService.saveOrUpdate(fee);
|
|
|
}
|
|
|
|
|
|
- public void addDayPrice(BusRoomsLivingOrder livingOrder, BusBookingRooms bookingroom, BigDecimal money){
|
|
|
+ public BusLivingLayoutDayPrice addDayPrice(BusRoomsLivingOrder livingOrder, BusBookingRooms bookingroom, BigDecimal money){
|
|
|
List<BusLivingLayoutDayPrice> dayPrices = livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
|
|
|
.eq("living_order_id",livingOrder.getId()));
|
|
|
Optional<BusLivingLayoutDayPrice> opPrice = dayPrices.stream().filter(a-> DateUtils.formatDate(a.getDayTime()).equals(DateUtils.formatDate(livingOrder.getDueOutTime()))).findFirst();
|
|
|
@@ -1706,19 +1739,27 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
nPrice.setLivingOrderId(livingOrder.getId());
|
|
|
nPrice.setLivingType(livingOrder.getLivingType());
|
|
|
livingLayoutDayPriceService.save(nPrice);
|
|
|
+ return nPrice;
|
|
|
}
|
|
|
+ return opPrice.get();
|
|
|
}
|
|
|
|
|
|
public BusOrderFee getOverTimeFee(BusRoomsLivingOrder livingOrder, BusBookingRooms bookingroom){
|
|
|
+ Calendar nowCalendar = Calendar.getInstance();
|
|
|
+ nowCalendar.set(Calendar.HOUR_OF_DAY, 0);
|
|
|
+ nowCalendar.set(Calendar.MINUTE, 0);
|
|
|
+ nowCalendar.set(Calendar.SECOND, 0);
|
|
|
+ nowCalendar.set(Calendar.MILLISECOND, 0);
|
|
|
List<BusOrderFee> feeList = feeService.list(Wrappers.<BusOrderFee>lambdaQuery()
|
|
|
.eq(BusOrderFee::getLivingOrderId, livingOrder.getId()).eq(BusOrderFee::getPreferentialStatus, 1)
|
|
|
- .eq(BusOrderFee::getSubjectType, FeeSubjectType.MEI_RI_FANG_FEI.getKey()).gt(BusOrderFee::getCreateTime, livingOrder.getDueOutTime()));
|
|
|
+ .eq(BusOrderFee::getSubjectType, FeeSubjectType.MEI_RI_FANG_FEI.getKey()).ge(BusOrderFee::getCreateTime, nowCalendar.getTime()));
|
|
|
if (CollUtil.isNotEmpty(feeList)) {
|
|
|
return feeList.get(0);
|
|
|
}
|
|
|
BusOrderFee fee = new BusOrderFee();
|
|
|
fee.setMoney(new BigDecimal(0));
|
|
|
fee.setCreateTime(new Date());
|
|
|
+ fee.setDayTime(new Date());
|
|
|
fee.setSubjectType(FeeSubjectType.MEI_RI_FANG_FEI.getKey());
|
|
|
fee.setLivingOrderId(livingOrder.getId());
|
|
|
fee.setHotelId(livingOrder.getHotelId());
|
|
|
@@ -1793,6 +1834,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
// TODO: 2023/10/19 删除预约每日房价,还不确定要不要删
|
|
|
} else {
|
|
|
dayPrices.addAll(living.getLayoutDayPriceList());
|
|
|
+ living.setIsStayOver(true);
|
|
|
}
|
|
|
|
|
|
});
|
|
|
@@ -2179,6 +2221,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
BusBookingRooms bookingRoom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
if(bookingRoom == null) throw new JeecgBootException("未找到房间关联");
|
|
|
List<BusOrderFeeGoods> orderFeeGoodList = new ArrayList<>();
|
|
|
+ List<CesGoods> goodList = new ArrayList<>();
|
|
|
fees.forEach(roomFee->{
|
|
|
roomFee.setLivingOrderId(livingOrderId);
|
|
|
roomFee.setRoomId(bookingRoom.getRoomId());
|
|
|
@@ -2193,12 +2236,35 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
roomFee.getFeeGoodVo().setCreateTime(new Date());
|
|
|
roomFee.getFeeGoodVo().setHotelId(livingOrder.getHotelId());
|
|
|
orderFeeGoodList.add(roomFee.getFeeGoodVo());
|
|
|
+ CesGoods goods = cesGoodsServiceImpl.getById(roomFee.getFeeGoodVo().getGoodsId());
|
|
|
+ Integer newInventory = goods.getInventory() - roomFee.getFeeGoodVo().getNum();
|
|
|
+ if (newInventory < 0){
|
|
|
+ throw new JeecgBootException("库存量不足");
|
|
|
+ }
|
|
|
+ goods.setInventory(newInventory);
|
|
|
+ goodList.add(goods);
|
|
|
+ KcDepositoryInGoods depositoryInGoods = addDepositoryInGood(roomFee.getFeeGoodVo());
|
|
|
+
|
|
|
+ depositoryInGoodsService.addSell(depositoryInGoods);
|
|
|
+
|
|
|
}
|
|
|
});
|
|
|
+ cesGoodsServiceImpl.updateBatchById(goodList);
|
|
|
orderFeeGoodsService.saveBatch(orderFeeGoodList);
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
+ public KcDepositoryInGoods addDepositoryInGood(BusOrderFeeGoodsVo feeGood){
|
|
|
+ KcDepositoryInGoods depositoryInGoods = new KcDepositoryInGoods();
|
|
|
+ depositoryInGoods.setGoodsId(feeGood.getGoodsId());
|
|
|
+ depositoryInGoods.setNum(feeGood.getNum());
|
|
|
+ depositoryInGoods.setFeeId(feeGood.getOrderFeeId());
|
|
|
+ depositoryInGoods.setHotelId(feeGood.getHotelId());
|
|
|
+// depositoryInGoods.setTenantId(user.getRelTenantIds());
|
|
|
+ depositoryInGoods.setCreateTime(new Date());
|
|
|
+ return depositoryInGoods;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean unionOrder(String roomId,String targetRoomId, String bookingOrderId, String hotelId) {
|
|
|
@@ -3052,57 +3118,59 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
s.setCreateTime(new Date());
|
|
|
s.setFeeType(2);// 收款
|
|
|
s.setHotelId(hotelId);
|
|
|
+ s.setVipCardId(livingData.getOrderInfo().getVipCustomerId());
|
|
|
if(FeeSubjectType.val(s.getSubjectType()) == null) {
|
|
|
throw new JeecgBootException("收款项目不存在,请核对后操作");
|
|
|
}
|
|
|
- BusRoomPayType payType = payTypeService.getById(s.getPayType());
|
|
|
- if (payType == null){
|
|
|
- throw new JeecgBootException("支付方式不存在");
|
|
|
- }
|
|
|
- if("会员卡".equals(payType.getName())){
|
|
|
- BusMemberBalanceLog memberBalanceLog = new BusMemberBalanceLog();
|
|
|
- if (user.getRelTenantIds() != null && !user.getRelTenantIds().isEmpty()) {
|
|
|
- memberBalanceLog.setTenantId(user.getRelTenantIds());
|
|
|
- } else {
|
|
|
- throw new JeecgBootException("当前登录人租户信息错误");
|
|
|
- }
|
|
|
- memberBalanceLog.setWithhold(s.getMoney());
|
|
|
- memberBalanceLog.setMoney(BigDecimal.valueOf(0));
|
|
|
- memberBalanceLog.setMemberId(livingData.getOrderInfo().getVipCustomerId());
|
|
|
- memberBalanceLog.setHotelId(livingData.getOrderInfo().getHotelId());
|
|
|
- memberBalanceLog.setType(2);
|
|
|
- memberBalanceLog.setOrderFeeId(s.getId());
|
|
|
- memberBalanceLogService.saveBalance(memberBalanceLog);
|
|
|
- }
|
|
|
- });
|
|
|
- if(!findRoomFees.isEmpty()) 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);
|
|
|
- }
|
|
|
+// BusRoomPayType payType = payTypeService.getById(s.getPayType());
|
|
|
+// if (payType == null){
|
|
|
+// throw new JeecgBootException("支付方式不存在");
|
|
|
+// }
|
|
|
+// if("会员卡".equals(payType.getName())){
|
|
|
+// BusMemberBalanceLog memberBalanceLog = new BusMemberBalanceLog();
|
|
|
+// if (user.getRelTenantIds() != null && !user.getRelTenantIds().isEmpty()) {
|
|
|
+// memberBalanceLog.setTenantId(user.getRelTenantIds());
|
|
|
+// } else {
|
|
|
+// throw new JeecgBootException("当前登录人租户信息错误");
|
|
|
+// }
|
|
|
+// memberBalanceLog.setWithhold(s.getMoney());
|
|
|
+// memberBalanceLog.setMoney(BigDecimal.valueOf(0));
|
|
|
+// memberBalanceLog.setMemberId(livingData.getOrderInfo().getVipCustomerId());
|
|
|
+// memberBalanceLog.setHotelId(livingData.getOrderInfo().getHotelId());
|
|
|
+// memberBalanceLog.setType(2);
|
|
|
+// memberBalanceLog.setOrderFeeId(s.getId());
|
|
|
+// memberBalanceLogService.saveBalance(memberBalanceLog);
|
|
|
+// }
|
|
|
});
|
|
|
+// if(!findRoomFees.isEmpty()) 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);
|
|
|
+// }
|
|
|
+// });
|
|
|
+ feeService.collectionBatch(findRoomFees, hotelId);
|
|
|
}
|
|
|
// 另外每个房间还要在入住时生成每日房费账单
|
|
|
BusOrderFee roomFee = new BusOrderFee();
|
|
|
@@ -3414,6 +3482,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
});
|
|
|
feeService.collectionBatch(param.getOrderFeeList(),livingOrder.getHotelId());
|
|
|
livingLayoutDayPriceService.saveBatch(param.getLayoutDayPriceList());
|
|
|
+ LambdaUpdateWrapper<BusRoomsLivingOrder> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ livingOrder.setIsChangeRoom(true);
|
|
|
+ roomsLivingOrderService.updateById(livingOrder);
|
|
|
return true;
|
|
|
}
|
|
|
|