|
|
@@ -12,6 +12,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
@@ -29,9 +30,7 @@ import org.jeecg.modules.business.entity.*;
|
|
|
import org.jeecg.modules.business.enums.*;
|
|
|
import org.jeecg.modules.business.mapper.BusRoomBookingOrdersMapper;
|
|
|
import org.jeecg.modules.business.service.*;
|
|
|
-import org.jeecg.modules.business.strategy.PricingStrategy;
|
|
|
import org.jeecg.modules.business.strategy.PricingStrategyFactory;
|
|
|
-import org.jeecg.modules.business.strategy.impl.*;
|
|
|
import org.jeecg.modules.business.util.MxTools;
|
|
|
import org.jeecg.modules.business.vo.*;
|
|
|
import org.jeecg.modules.fw.entity.FwRoomClean;
|
|
|
@@ -59,7 +58,6 @@ import org.jeecg.modules.system.entity.SysUser;
|
|
|
import org.jeecg.modules.system.service.ISysUserService;
|
|
|
import org.jeecg.modules.system.service.impl.SysBaseApiImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -191,19 +189,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
@Resource
|
|
|
private SysBaseApiImpl sysBaseAPI;
|
|
|
|
|
|
-
|
|
|
@Resource
|
|
|
private PricingStrategyFactory pricingStrategyFactory;
|
|
|
- @Resource
|
|
|
- private MinuteAddStrategy minuteAddStrategy;
|
|
|
- @Resource
|
|
|
- private DayAddStrategy dayAddStrategy;
|
|
|
- @Resource
|
|
|
- private NotAddStrategy notAddStrategy;
|
|
|
- @Resource
|
|
|
- private HourRoomStrategy hourRoomStrategy;
|
|
|
- @Resource
|
|
|
- private LongRentStrategy longRentStrategy;
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -2061,6 +2048,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
BusOrderFee orderFee = new BusOrderFee();
|
|
|
orderFee.setMoney(living.getPayMoney());
|
|
|
orderFee.setPayType(living.getPayType());
|
|
|
+ orderFee.setVipCardId(living.getVipCustomerId());
|
|
|
+ orderFee.setAgreementUnitId(living.getContractTeamId());
|
|
|
orderFee.setFeeType(2);
|
|
|
orderFee.setSubjectType(2);
|
|
|
orderFee.setRemark("预收房费");
|
|
|
@@ -2222,12 +2211,15 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Boolean livingSettleBillCheckOut(List<BusOrderFee> settleFees, String livingOrderId) {
|
|
|
if(livingOrderId == null || livingOrderId.isEmpty()) throw new JeecgBootException("参数错误");
|
|
|
- BusRoomsLivingOrder livingOrder = roomsLivingOrderService.getOne(Wrappers.<BusRoomsLivingOrder>query()
|
|
|
- .eq("id",livingOrderId));
|
|
|
+ BusRoomsLivingOrder livingOrder = roomsLivingOrderService.getById(livingOrderId);
|
|
|
if(livingOrder == null) throw new JeecgBootException("未找到任何入住订单");
|
|
|
BusBookingRooms mainRoom = bookingRoomsService.getOne(Wrappers.<BusBookingRooms>query()
|
|
|
.eq("id",livingOrder.getBookingRoomId()));
|
|
|
if(mainRoom == null) throw new JeecgBootException("没有找到房间");
|
|
|
+ if (!mainRoom.getIsMain()){
|
|
|
+ String bookingId = splitLiving(livingOrderId);
|
|
|
+ livingOrder = roomsLivingOrderService.getById(livingOrderId);
|
|
|
+ }
|
|
|
List<BusRoomsLivingOrder> releLivingingOrders = roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>lambdaQuery()
|
|
|
.eq(BusRoomsLivingOrder::getBookingOrderId, livingOrder.getBookingOrderId()));
|
|
|
if (CollUtil.isEmpty(releLivingingOrders)){
|
|
|
@@ -2244,9 +2236,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
livingOrder.setSettleType(SettleTypeEnum.SETTLE_LEAVE.getKey());
|
|
|
roomsLivingOrderService.updateById(livingOrder);
|
|
|
// 当前居住单中未结算的费用
|
|
|
- List<BusOrderFee> feeItems = getLivingOrderFees(livingOrderId).stream().filter(
|
|
|
- s->s.getPreferentialStatus().equals(1)// 找到未结账的
|
|
|
- ).collect(Collectors.toList());
|
|
|
+ List<BusOrderFee> feeItems = getLivingOrderFees(livingOrderId);
|
|
|
|
|
|
final BigDecimal[] shoukuan = {new BigDecimal(0)};
|
|
|
final BigDecimal[] xiaofei = {new BigDecimal(0)};
|
|
|
@@ -2401,6 +2391,56 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public Boolean cancelLeaveSettle(String bookingOrderId, String livingOrderId) {
|
|
|
+ if (StrUtil.isEmpty(bookingOrderId)){
|
|
|
+ throw new JeecgBootException("请选择订单");
|
|
|
+ }
|
|
|
+ List<BusRoomsLivingOrder> livingOrderList = roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>lambdaQuery()
|
|
|
+ .eq(BusRoomsLivingOrder::getBookingOrderId, bookingOrderId));
|
|
|
+ livingOrderList.forEach(livingOrder -> {
|
|
|
+ BusBookingRooms bookingRooms = bookingRoomsService.getById(livingOrder.getBookingRoomId());
|
|
|
+ if(bookingRooms == null) throw new JeecgBootException("数据异常");
|
|
|
+ CesRooms room = roomsService.getOne(Wrappers.<CesRooms>query().eq("id",bookingRooms.getRoomId()));
|
|
|
+ if(room == null) throw new JeecgBootException("未找到订单信息");
|
|
|
+ if (!RoomStatusEnum.EMPTY_DIRTY.getKey().equals(room.getRoomStatus()) && !RoomStatusEnum.EMPTY_CLEAR.getKey().equals(room.getRoomStatus())){
|
|
|
+ throw new JeecgBootException("房间不能重新入住");
|
|
|
+ }
|
|
|
+ room.setLivingOrderId(livingOrderId);
|
|
|
+ room.setRoomStatus(RoomStatusEnum.LIVE_DIRTY.getKey());
|
|
|
+ room.setLastRoomStatus(RoomStatusEnum.EMPTY_DIRTY.getKey());
|
|
|
+ livingOrder.setSettleType(SettleTypeEnum.UN_LEAVE.getKey());
|
|
|
+ roomsLivingOrderService.updateById(livingOrder);
|
|
|
+ roomsService.updateById(room);
|
|
|
+ });
|
|
|
+
|
|
|
+ // 结账收款时产生的收款单(收款单可能为负)
|
|
|
+ List<BusOrderFee> busOrderFees = feeService.list(Wrappers.<BusOrderFee>lambdaQuery().eq(BusOrderFee::getIsSettleFee, true)
|
|
|
+ .eq(BusOrderFee::getLivingOrderId, livingOrderId));
|
|
|
+ // 所有会员支付的收款单id
|
|
|
+ List<String> vipFeeIds = busOrderFees.stream().filter(e -> StrUtil.isNotEmpty(e.getVipCardId()))
|
|
|
+ .map(BusOrderFee::getId).collect(Collectors.toList());
|
|
|
+ if (!vipFeeIds.isEmpty()){
|
|
|
+ // 结账时会员支付日志
|
|
|
+ List<BusMemberBalanceLog> balanceLogs = memberBalanceLogService.list(Wrappers
|
|
|
+ .<BusMemberBalanceLog>lambdaQuery().in(BusMemberBalanceLog::getOrderFeeId, vipFeeIds));
|
|
|
+ Map<String, List<BusMemberBalanceLog>> balanceLogMap = balanceLogs.stream().collect(Collectors.groupingBy(BusMemberBalanceLog::getMemberId));
|
|
|
+ // 存储会员卡号id和该卡号结账时消费的金额
|
|
|
+ Map<String, BigDecimal> vipMoneyMap = new HashMap<>();
|
|
|
+ balanceLogMap.forEach((vipId, logs) -> {
|
|
|
+ BigDecimal money = logs.stream().map(BusMemberBalanceLog::getMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ vipMoneyMap.put(vipId, money);
|
|
|
+ });
|
|
|
+ Set<String> vipIds = vipMoneyMap.keySet();
|
|
|
+ List<BusMemberCard> busMemberCards = memberCardService.listByIds(vipIds);
|
|
|
+ busMemberCards.forEach(e -> e.setBalance(e.getBalance().add(vipMoneyMap.get(e.getId()))));
|
|
|
+ memberCardService.updateBatchById(busMemberCards);
|
|
|
+ memberBalanceLogService.removeBatchByIds(balanceLogs);
|
|
|
+ }
|
|
|
+ feeService.removeBatchByIds(busOrderFees);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public IPage<RoomLivingQueryVo> getLivingPageData(Integer status,String keyw, Page<RoomLivingQueryVo> page,String hotelId) {
|
|
|
IPage<RoomLivingQueryVo> roomLivings = baseMapper.getPage(page, status, keyw, hotelId);
|
|
|
|
|
|
@@ -3236,7 +3276,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
return roomsService.getById(bookingRoom.getRoomId()).getHotelId();
|
|
|
}
|
|
|
private void settleFee(BusBookingRooms mainRoom, BusRoomsLivingOrder mainRoomOrder, List<BusOrderFee> feeItems, List<BusOrderFee> settleFees) {
|
|
|
- if(settleFees.size() == 0) throw new JeecgBootException("参数错误");
|
|
|
+ if(settleFees.isEmpty()) throw new JeecgBootException("参数错误");
|
|
|
String hotelId = getBookingRoomHotelId(mainRoom);
|
|
|
LoginUser user = TokenUtils.getAuthUser();
|
|
|
// if(user == null) throw new JeecgBootException("请登录");
|
|
|
@@ -3284,14 +3324,17 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
vipCard.setBalance(vipCard.getBalance().subtract(s.getMoney()));
|
|
|
memberCardService.updateById(vipCard);
|
|
|
// log
|
|
|
+ s.setId(String.valueOf(IdWorker.getId()));
|
|
|
BusMemberBalanceLog balanceLog = new BusMemberBalanceLog();
|
|
|
+ balanceLog.setOrderFeeId(s.getId());
|
|
|
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("房间收费扣款");
|
|
|
+ String remark = s.getMoney() != null && s.getMoney().compareTo(BigDecimal.valueOf(0)) > 0 ? "房间收费扣款" : "房间收费收款";
|
|
|
+ balanceLog.setRemarks(remark);
|
|
|
balanceLog.setHotelId(hotelId);
|
|
|
if(user!=null) {
|
|
|
balanceLog.setTenantId(user.getRelTenantIds());
|
|
|
@@ -3301,8 +3344,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
|
|
|
balanceLog.setCode(BusMemberBalanceLogServiceImpl.randomNumber("KF"));
|
|
|
balanceLog.setCreateTime(new Date());
|
|
|
memberBalanceLogService.save(balanceLog);
|
|
|
+ s.setVipCardId(vipCard.getId());
|
|
|
// todo 积分规则
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
s.setFeeType(2);
|