ソースを参照

撤销结账时,将结账账单撤回

许智捷 1 年間 前
コミット
c6358fee5e

+ 18 - 26
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusOrderFeeController.java

@@ -1,50 +1,42 @@
 package org.jeecg.modules.business.controller;
 
 
-import java.util.*;
-import java.util.stream.Collectors;
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.util.ObjectUtil;
-import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+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.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.exception.JeecgBootException;
+import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.modules.business.entity.BusOrderFee;
 import org.jeecg.modules.business.enums.FeeType;
 import org.jeecg.modules.business.service.IBusOrderFeeService;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import lombok.extern.slf4j.Slf4j;
-
-
-import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.modules.business.vo.RoomOrderFeeVo;
-import org.jeecg.modules.rooms.Enum.ChargeTypeEnum;
 import org.jeecg.modules.rooms.entity.CesHouseLongRentCharge;
-import org.jeecg.modules.rooms.entity.CesRooms;
-import org.jeecg.modules.rooms.service.CesRoomsServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.jeecg.common.aspect.annotation.AutoLog;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
 
  /**
  * @Description: bus_order_fee
@@ -135,7 +127,7 @@ public class BusOrderFeeController extends JeecgController<BusOrderFee, IBusOrde
 	 //@RequiresPermissions("business:bus_order_fee:add")
 	 @Transactional(rollbackFor = Exception.class)
 	 @PostMapping(value = "/refundBatch")
-	 public Result<Boolean> refundBatch(@RequestBody List<BusOrderFee> busOrderFeeList) {
+	 public Result<Boolean> refundBatch(@RequestBody List<BusOrderFee> busOrderFeeList,String hotelId) {
 		 List<String> feeIds = busOrderFeeList.stream().map(BusOrderFee::getId).collect(Collectors.toList());
 		 if (feeIds.isEmpty()){
 			 return Result.OK();
@@ -163,7 +155,7 @@ public class BusOrderFeeController extends JeecgController<BusOrderFee, IBusOrde
 		 wrapper.set(BusOrderFee::getPreferentialStatus,1);
 		 wrapper.in(CollUtil.isNotEmpty(consumeFeeIds),BusOrderFee::getId, consumeFeeIds);
 		 busOrderFeeService.update(wrapper);
-		 return Result.OK(busOrderFeeService.refundBatch(busOrderFeeList));
+		 return Result.OK(busOrderFeeService.refundBatch(busOrderFeeList, hotelId));
 	 }
 
 	 /**
@@ -228,7 +220,7 @@ public class BusOrderFeeController extends JeecgController<BusOrderFee, IBusOrde
 	 public Result<List<BusOrderFee>> refundList(@RequestBody List<String> livingOrderIds) {
 		 LambdaQueryWrapper<BusOrderFee> qw = new LambdaQueryWrapper<>();
 		 qw.eq(BusOrderFee::getFeeType, FeeType.COLLECTION.getKey());
-		 qw.eq(BusOrderFee::getPreferentialStatus, 1);
+//		 qw.eq(BusOrderFee::getPreferentialStatus, 1);
 		 qw.in(CollUtil.isNotEmpty(livingOrderIds), BusOrderFee::getLivingOrderId, livingOrderIds);
 		 List<BusOrderFee> orderFees = busOrderFeeService.list(qw);
 		 return Result.OK(orderFees);

+ 56 - 41
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusRoomBookingOrdersController.java

@@ -1,22 +1,21 @@
 package org.jeecg.modules.business.controller;
 
-import java.util.*;
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
 import cn.hutool.core.date.DateTime;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.fasterxml.jackson.annotation.JsonFormat;
-import org.apache.poi.ss.formula.functions.T;
-import org.apache.shiro.SecurityUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.exception.JeecgBootException;
+import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
-import org.jeecg.common.system.vo.LoginUser;
-import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.business.dto.*;
 import org.jeecg.modules.business.entity.*;
 import org.jeecg.modules.business.enums.BookingStatusTypeEnum;
@@ -24,27 +23,25 @@ import org.jeecg.modules.business.enums.CustomerTypeEnum;
 import org.jeecg.modules.business.enums.LivingTypeEnum;
 import org.jeecg.modules.business.enums.SettleTypeEnum;
 import org.jeecg.modules.business.mapper.BusRoomBookingOrdersMapper;
+import org.jeecg.modules.business.service.IBusDictItemService;
 import org.jeecg.modules.business.service.IBusRoomBookingOrdersService;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import lombok.extern.slf4j.Slf4j;
-
 import org.jeecg.modules.business.service.IBusRoomsLivingOrderService;
 import org.jeecg.modules.business.vo.*;
 import org.jeecg.modules.rooms.Vo.LivingContinueVo;
-import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.servlet.ModelAndView;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.jeecg.common.aspect.annotation.AutoLog;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.*;
+import java.util.stream.Collectors;
  /**
  * @Description: 酒店预定订单
  * @Author: jeecg-boot
@@ -59,6 +56,8 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 
 	@Resource
 	private IBusRoomsLivingOrderService roomsLivingOrderService;
+	 @Autowired
+	 private IBusDictItemService busDictItemService;
 	/**
 	 * 分页列表查询
 	 *
@@ -262,17 +261,6 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	 }
 
 	 /**
-	  * 全部结账
-	  * @param bookingOrderId
-	  * @return
-	  */
-	 @ApiOperation(value="酒店预定订单-全部结账", notes="酒店预定订单-全部结账")
-	 @RequestMapping(value = "/settle-checkout",method = RequestMethod.POST)
-	 public Result<Boolean> settleCheckout(@RequestBody List<BusOrderFee> fees, String bookingOrderId) {
-	 	Boolean isOk = service.settleBillCheckOut(fees,bookingOrderId);
-	 	return Result.OK(isOk);
-	 }
-	 /**
 	  * 续住/提前
 	  * @return
 	  */
@@ -282,7 +270,6 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 		 List<LivingContinueVo> livingContinueList = service.getContinueOrder(bookingOrderId, hotelId);
 		 return Result.OK(livingContinueList);
 	 }
-
 	 /**
 	  * 续住前判断是否被预约
 	  */
@@ -305,6 +292,19 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	 }
 
 	 /**
+	  * 全部结账
+	  * @param bookingOrderId
+	  * @return
+	  */
+	 @ApiOperation(value="酒店预定订单-全部结账", notes="酒店预定订单-全部结账")
+	 @RequestMapping(value = "/settle-checkout",method = RequestMethod.POST)
+	 public Result<Boolean> settleCheckout(@RequestBody List<BusOrderFee> fees, String bookingOrderId) {
+		 fees.forEach(e -> e.setIsSettleFee(true));
+		 Boolean isOk = service.settleBillCheckOut(fees,bookingOrderId);
+		 return Result.OK(isOk);
+	 }
+
+	 /**
 	  * 单房结账
 	  * @param livingOrderId
 	  * @return
@@ -312,6 +312,7 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	 @ApiOperation(value="酒店预定订单-单房结账", notes="酒店预定订单-单房结账")
 	 @RequestMapping(value = "/living-settle-checkout",method = RequestMethod.POST)
 	 public Result<Boolean> livingSettleBillCheckOut(@RequestBody List<BusOrderFee> fees, String livingOrderId) {
+		 fees.forEach(e -> e.setIsSettleFee(true));
 		 Boolean isOk = service.livingSettleBillCheckOut(fees,livingOrderId);
 		 return Result.OK(isOk);
 	 }
@@ -363,6 +364,16 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	 }
 
 	 /**
+	  * 撤销先走不结
+	  */
+	 @ApiOperation(value="撤销结账", notes="撤销结账")
+	 @RequestMapping(value = "/cancel-leave-settle",method = RequestMethod.POST)
+	 public Result<Boolean> cancelLeaveSettle(String bookingOrderId,String livingOrderId){
+		 Boolean isOk = service.cancelLeaveSettle(bookingOrderId,livingOrderId);
+		 return Result.OK(isOk);
+	 }
+
+	 /**
 	  * 获取入住订单
 	  * @param status
 	  * @return
@@ -465,9 +476,6 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 
 	 /**
 	  * 客單
-	  * @param type 1 入住订单查询->livingStatus | 2 bookingStatus
-	  * @param livingStatus -1 正常入住,1 已结账退房,2 先走未结,3 联房退房
-	  * @param bookingStatus 1 预定中 2 在住 3 已取消
 	  * @return
 	  */
 	 @ApiOperation(value="酒店预定订单-客历", notes="酒店预定订单-客历")
@@ -624,18 +632,25 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 		 if (kedanOrderDto.getType() == 1){
 			 title = "入住单";
 			 pRes = baseMapper.getKeLiLiving(page, kedanOrderDto);
+			 Set<String> customerSourceId = pRes.getRecords().stream().map(KeLiItemVo::getCustomerSource).collect(Collectors.toSet());
+			 List<BusDictItem> customerSourceList = busDictItemService.listByIds(customerSourceId);
 			 pRes.getRecords().forEach(e -> {
-				 e.setCustomerTypeText(CustomerTypeEnum.val(e.getCustomerType()).getTitle());
-				 e.setOTypeText(LivingTypeEnum.val(e.getOType()).getTitle());
-				 e.setStatusText(SettleTypeEnum.val(e.getSettleType()).getTitle());
+				 Optional<BusDictItem> dictItem = customerSourceList.stream().filter(source -> (source.getId().equals(e.getCustomerSource()))).findFirst();
+				 dictItem.ifPresent(source -> e.setCustomerSource(source.getItemText()));
+				 e.setCustomerTypeText(Objects.requireNonNull(CustomerTypeEnum.val(e.getCustomerType())).getTitle());
+				 e.setOTypeText(Objects.requireNonNull(LivingTypeEnum.val(e.getOType())).getTitle());
+				 e.setStatusText(Objects.requireNonNull(SettleTypeEnum.val(e.getSettleType())).getTitle());
 				 e.setConsumerText(e.getYushou().subtract(e.getYuE()));
 			 });
 		 } else if (kedanOrderDto.getType() == 2){
 			 title = "预约单";
 			 pRes = baseMapper.getKeBooking(page, kedanOrderDto);
+			 Set<String> customerSourceId = pRes.getRecords().stream().map(KeLiItemVo::getCustomerSource).collect(Collectors.toSet());
+			 List<BusDictItem> customerSourceList = busDictItemService.listByIds(customerSourceId);
 			 pRes.getRecords().forEach(e -> {
-				 e.setCustomerTypeText(CustomerTypeEnum.val(e.getCustomerType()).getTitle());
-				 e.setOTypeText(LivingTypeEnum.val(e.getOType()).getTitle());
+				 Optional<BusDictItem> dictItem = customerSourceList.stream().filter(source -> (source.equals(e.getCustomerSource()))).findFirst();
+				 dictItem.ifPresent(source -> e.setCustomerSource(source.getItemText()));e.setCustomerTypeText(CustomerTypeEnum.val(e.getCustomerType()).getTitle());
+				 e.setOTypeText(Objects.requireNonNull(LivingTypeEnum.val(e.getOType())).getTitle());
 				 String status = "";
 				 if (Objects.equals(e.getBookingStatus(), BookingStatusTypeEnum.NORMAL.getKey())) {
 					 if (StrUtil.isNotEmpty(e.getLivingId())){
@@ -643,8 +658,8 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 					 } else {
 						 status = e.getArrivalTime().after(new Date()) ? CommonConstant.BOOKING : CommonConstant.WILL_EXPIRE;
 					 }
-				 } else{
-					 status = BookingStatusTypeEnum.val(e.getBookingStatus()).getTitle();
+				 } else if (BookingStatusTypeEnum.val(e.getBookingStatus()) != null){
+					 status = Objects.requireNonNull(BookingStatusTypeEnum.val(e.getBookingStatus())).getTitle();
 				 }
 				 e.setStatusText(status);
 			 });

+ 2 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/BusOrderFee.java

@@ -147,6 +147,8 @@ public class BusOrderFee implements Serializable {
     private Boolean bookingYj;
     @ApiModelProperty(value = "是超时费用")
     private Boolean isOverTime;
+    @ApiModelProperty(value = "是最终结账")
+    private Boolean isSettleFee;
 
 
     @ApiModelProperty(value = "每天价格")

+ 2 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IBusOrderFeeService.java

@@ -3,10 +3,9 @@ package org.jeecg.modules.business.service;
 import cn.hutool.core.date.DateTime;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import org.jeecg.modules.business.entity.BusBookingRooms;
+import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.business.entity.BusLivingLayoutDayPrice;
 import org.jeecg.modules.business.entity.BusOrderFee;
-import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.business.entity.BusRoomsLivingOrder;
 import org.jeecg.modules.business.vo.RoomOrderFeeVo;
 import org.jeecg.modules.rooms.entity.CesHouseLongRentCharge;
@@ -25,7 +24,7 @@ public interface IBusOrderFeeService extends IService<BusOrderFee> {
 
     Boolean strikeBalance(List<BusOrderFee> busOrderFeeList);
 
-    Boolean refundBatch(List<BusOrderFee> busOrderFeeList);
+    Boolean refundBatch(List<BusOrderFee> busOrderFeeList, String hotelId);
 
     Boolean collectionBatch(List<BusOrderFee> busOrderFeeList, String hotelId);
 

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IBusRoomBookingOrdersService.java

@@ -61,7 +61,7 @@ public interface IBusRoomBookingOrdersService extends IService<BusRoomBookingOrd
     String splitLiving(String livingOrderId);
     Boolean leaveNotSettle(String bookingOrderId, String livingOrderId);
     Boolean cancelLeaveNotSettle(String bookingOrderId, String livingOrderId);
-
+    Boolean cancelLeaveSettle(String bookingOrderId, String livingOrderId);
     IPage<RoomLivingQueryVo> getLivingPageData(Integer status,String keyw, Page<RoomLivingQueryVo> page,String hotelId);
     IPage<RoomLivingQueryVo> getUnionLivingPageData(String keyw, Page<RoomLivingQueryVo> page,String hotelId);
     IPage<KeLiItemVo> getLivingOrderKL(Page<KeLiItemVo> page, KedanOrderDto kedanOrderDto);

+ 3 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusOrderFeeServiceImpl.java

@@ -153,8 +153,8 @@ public class BusOrderFeeServiceImpl extends ServiceImpl<BusOrderFeeMapper, BusOr
     }
 
     @Override
-    public Boolean refundBatch(List<BusOrderFee> busOrderFeeList) {
-        List<BusRoomPayType> payTypeList = payTypeService.list();
+    public Boolean refundBatch(List<BusOrderFee> busOrderFeeList, String hotelId) {
+        List<BusRoomPayType> payTypeList = payTypeService.list(Wrappers.<BusRoomPayType>lambdaQuery().eq(BusRoomPayType::getHotelId, hotelId));
         Optional<BusRoomPayType> cardPayType = payTypeList.stream().filter(e -> "会员卡".equals(e.getName())).findFirst();
         cardPayType.ifPresent(e -> {
             // 会员支付的订单
@@ -225,7 +225,7 @@ public class BusOrderFeeServiceImpl extends ServiceImpl<BusOrderFeeMapper, BusOr
         if (CollUtil.isEmpty(busOrderFeeList)){
             return true;
         }
-        List<BusRoomPayType> payTypeList = payTypeService.list();
+        List<BusRoomPayType> payTypeList = payTypeService.list(Wrappers.<BusRoomPayType>lambdaQuery().eq(BusRoomPayType::getHotelId, hotelId));
         payTypeList.stream().filter(e -> "会员卡".equals(e.getName())).findFirst().ifPresent(type -> {
             //找出会员支付的账单,将会员支付的账单中的会员id去重
             List<BusOrderFee> memberPayFee = busOrderFeeList.stream().filter(fee -> type.getId().equals(fee.getPayType())).collect(Collectors.toList());

+ 65 - 22
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusRoomBookingOrdersServiceImpl.java

@@ -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);

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/strategy/PricingStrategyFactory.java

@@ -12,7 +12,7 @@ import java.util.concurrent.ConcurrentHashMap;
 public class PricingStrategyFactory {
 
     @Resource
-    public final Map<String,PricingStrategy> strategys = new ConcurrentHashMap<>();
+    public final Map<String,PricingStrategy> strategys = new ConcurrentHashMap<>(5);
 
     public PricingStrategy getStragegy(String component) throws Exception{
         PricingStrategy strategy = strategys.get(component);

+ 3 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/vo/KeLiItemVo.java

@@ -24,6 +24,7 @@ public class KeLiItemVo {
     @Excel(name = "电话", width = 15)
     private String customerPhone;
     private Integer customerType;
+    @Excel(name = "客户来源", width = 15)
     private String customerSource;
     private Integer oType;
     private Integer bookingStatus;
@@ -37,6 +38,8 @@ public class KeLiItemVo {
     private Date dueOutTime;
     private Integer isLiving;
     private Integer status;
+    @Excel(name = "消费", width = 15)
+    private BigDecimal consumerText;
     @Excel(name = "收款合计", width = 15)
     private BigDecimal yushou;
     @Excel(name = "余额", width = 15)
@@ -50,6 +53,4 @@ public class KeLiItemVo {
     private String customerTypeText;
     @Excel(name = "入住类型", width = 15)
     private String oTypeText;
-    @Excel(name = "消费", width = 15)
-    private BigDecimal consumerText;
 }

+ 9 - 5
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/CesRoomsServiceImpl.java

@@ -26,8 +26,14 @@ import org.jeecg.modules.business.service.impl.BusHotelServiceImpl;
 import org.jeecg.modules.rooms.DTO.*;
 import org.jeecg.modules.rooms.Enum.CouponEnums;
 import org.jeecg.modules.rooms.Enum.RoomStatusEnum;
-import org.jeecg.modules.rooms.Vo.*;
-import org.jeecg.modules.rooms.entity.*;
+import org.jeecg.modules.rooms.Vo.CanUseBuildingRoomsVo;
+import org.jeecg.modules.rooms.Vo.CanUseResultVo;
+import org.jeecg.modules.rooms.Vo.CesRoomsVo;
+import org.jeecg.modules.rooms.Vo.LivingSourceStatVo;
+import org.jeecg.modules.rooms.entity.CesHourRoomRule;
+import org.jeecg.modules.rooms.entity.CesRoomBuildingFloor;
+import org.jeecg.modules.rooms.entity.CesRoomLayout;
+import org.jeecg.modules.rooms.entity.CesRooms;
 import org.jeecg.modules.rooms.mapper.CesRoomsMapper;
 import org.springframework.stereotype.Service;
 
@@ -36,10 +42,8 @@ import javax.transaction.Transactional;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
-import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
-import java.util.logging.SimpleFormatter;
 import java.util.stream.Collectors;
 
 /**
@@ -499,7 +503,7 @@ public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> i
         } else {
             bookingRoomIds = new HashSet<>();
         }
-        List<String> idList = ids.stream().filter(bookingRoomIds::contains).collect(Collectors.toList());
+        List<String> idList = ids.stream().filter(e -> !bookingRoomIds.contains(e)).collect(Collectors.toList());
         UpdateWrapper<CesRooms> updateWrapper = new UpdateWrapper<>();
         if (idList.isEmpty()){
             return true;