Parcourir la source

添加预定超时,添加长租房收费,添加长租房读表功能,修改客单、预约单

许智捷 il y a 1 an
Parent
commit
ac54ee17bf
33 fichiers modifiés avec 707 ajouts et 245 suppressions
  1. 3 0
      jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java
  2. 1 0
      jeecg-boot-base-core/src/main/java/org/jeecg/common/system/base/controller/JeecgController.java
  3. 2 2
      jeecg-mall-api/src/main/java/org/jeecg/modules/bus/controller/HotelController.java
  4. 1 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusHotelController.java
  5. 3 2
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusHousePriceSchemeLayoutController.java
  6. 19 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusOrderFeeController.java
  7. 101 34
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusRoomBookingOrdersController.java
  8. 4 3
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/dto/BookingLayoutRoomsDto.java
  9. 5 3
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/BusOrderFee.java
  10. 2 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/enums/BookingStatusTypeEnum.java
  11. 1 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/BusRoomBookingOrdersMapper.java
  12. 42 35
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/BusRoomBookingOrdersMapper.xml
  13. 3 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IBusOrderFeeService.java
  14. 5 7
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IBusRoomBookingOrdersService.java
  15. 81 15
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusOrderFeeServiceImpl.java
  16. 182 129
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusRoomBookingOrdersServiceImpl.java
  17. 21 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/vo/KeLiItemVo.java
  18. 1 2
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/LivingRoomOrderFeeJob.java
  19. 52 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/Enum/ReadTypeEnum.java
  20. 2 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/Vo/LivingRealtimeVo.java
  21. 35 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/controller/CesHouseLongRentChargesController.java
  22. 13 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/controller/CesHouseLongRentMeterLogController.java
  23. 0 3
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/controller/CesHousePriceSchemeController.java
  24. 13 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/controller/CesRoomsController.java
  25. 2 2
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/entity/CesHouseLongRentCharge.java
  26. 32 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/entity/CesHouseLongRentMeterLog.java
  27. 4 3
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/entity/CesRooms.java
  28. 7 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/mapper/CesHouseLongRentMeterLogMapper.java
  29. 6 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/mapper/xml/CesHouseLongRentMeterLogMapper.xml
  30. 45 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/CesRoomLayoutServiceImpl.java
  31. 1 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/CesRoomsServiceImpl.java
  32. 7 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/ICesHouseLongRentMeterLogService.java
  33. 11 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/impl/CesHouseLongRentMeterLogServiceImpl.java

+ 3 - 0
jeecg-boot-base-core/src/main/java/org/jeecg/common/constant/CommonConstant.java

@@ -441,4 +441,7 @@ public interface CommonConstant {
      */
     String PHONE_REDIS_KEY_PRE = "phone_msg";
 
+    String LIVING = "已入住";
+    String BOOKING = "已入住";
+    String WILL_EXPIRE = "今日应到未到";
 }

+ 1 - 0
jeecg-boot-base-core/src/main/java/org/jeecg/common/system/base/controller/JeecgController.java

@@ -200,4 +200,5 @@ public class JeecgController<T, S extends IService<T>> {
         }
         return Result.error("文件导入失败!");
     }
+
 }

+ 2 - 2
jeecg-mall-api/src/main/java/org/jeecg/modules/bus/controller/HotelController.java

@@ -482,13 +482,13 @@ public class HotelController extends WebConfig {
     @RequestMapping(value = "/kedan-orders", method = RequestMethod.GET)
     @ApiLogin
     @ApiVersion(group = ApiVersionConstant.FAP_MALLAPI101)
-    public Result<IPage<KeLiItemVo>> keli(Page<KeLiItemVo> page, String keyw, Integer livingStatus, String hotelId, Integer type, Integer bookingStatus, Date startTime,Date endTime) {
+    public Result<IPage<KeLiItemVo>> keli(Page<KeLiItemVo> page, String keyw, Integer livingStatus, String hotelId, Integer type, Integer bookingStatus, Date startTime,Date endTime,String layoutId, String customerType) {
         if (type == null) throw new JeecgBootException("参数错误");
         if (type == 1 && livingStatus == null) throw new JeecgBootException("参数错误");
         if (type == 2 && bookingStatus == null) throw new JeecgBootException("参数错误");
         String userId = ThirdSessionHolder.getUserId();
         if (type == 1)
-            return Result.OK(busRoomBookingOrdersService.getLivingOrderKL(livingStatus, keyw, hotelId, userId, page, startTime, endTime));
+            return Result.OK(busRoomBookingOrdersService.getLivingOrderKL(livingStatus, keyw, hotelId, userId,layoutId,customerType, page, startTime, endTime));
         if (type == 2)
             return Result.OK(busRoomBookingOrdersService.getBookingOrderKL(bookingStatus, keyw, hotelId, userId, page, startTime, endTime));
         return null;

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusHotelController.java

@@ -509,7 +509,7 @@ public class BusHotelController extends JeecgController<BusHotel, IBusHotelServi
 		BeanUtil.copyProperties(priceScheme, weekScheme);
 		weekScheme.setSchemeType(1);
 		BeanUtil.copyProperties(priceScheme, holidayScheme);
-		weekScheme.setSchemeType(2);
+		holidayScheme.setSchemeType(2);
 		housePriceSchemeService.saveBatch(priceSchemeList);
 
 		return Result.OK("添加成功!");

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

@@ -71,8 +71,9 @@ public class BusHousePriceSchemeLayoutController extends JeecgController<BusHous
 								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
 								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
 								   HttpServletRequest req) {
-		if (type != null){
-			CesHousePriceScheme housePriceScheme = housePriceSchemeService.getOne(Wrappers.<CesHousePriceScheme>lambdaQuery().eq(CesHousePriceScheme::getSchemeType,type).last("limit 1"));
+		if (type != null) {
+			CesHousePriceScheme housePriceScheme = housePriceSchemeService.getOne(Wrappers.<CesHousePriceScheme>lambdaQuery()
+					.eq(CesHousePriceScheme::getSchemeType,type).eq(CesHousePriceScheme::getHotelId, busHousePriceSchemeLayout.getHotelId()).last("limit 1"));
 			busHousePriceSchemeLayout.setSchemeId(housePriceScheme.getId());
 		}
 		QueryWrapper<BusHousePriceSchemeLayout> queryWrapper = QueryGenerator.initQueryWrapper(busHousePriceSchemeLayout, req.getParameterMap());

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

@@ -3,6 +3,7 @@ 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;
 
@@ -32,6 +33,10 @@ 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;
@@ -55,6 +60,7 @@ public class BusOrderFeeController extends JeecgController<BusOrderFee, IBusOrde
 	@Autowired
 	private IBusOrderFeeService busOrderFeeService;
 
+
 	/**
 	 * 分页列表查询
 	 *
@@ -228,6 +234,19 @@ public class BusOrderFeeController extends JeecgController<BusOrderFee, IBusOrde
 		 return Result.OK(orderFees);
 	 }
 
+	 /**
+	  *  编辑
+	  *
+	  * @param
+	  * @return
+	  */
+	 @AutoLog(value = "")
+	 @ApiOperation(value="添加读表费", notes="添加读表费")
+	 @PostMapping(value = "/addMeterFee")
+	 public Result addMeterFee(@RequestBody List<CesHouseLongRentCharge> longRentChargeList) {
+		 Boolean isSuccess = service.addMeterFee(longRentChargeList);
+		 return isSuccess ? Result.OK("读表成功") : Result.error("读表失败");
+	 }
 
 	 /**
 	  *  编辑

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

@@ -6,15 +6,26 @@ import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
 
 import cn.hutool.core.date.DateTime;
+import cn.hutool.core.util.StrUtil;
 import com.fasterxml.jackson.annotation.JsonFormat;
+import org.apache.poi.ss.formula.functions.T;
+import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.exception.JeecgBootException;
 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.BatchOrderSavaDto;
 import org.jeecg.modules.business.dto.BookingOrderSaveDto;
 import org.jeecg.modules.business.dto.UpdateOrderInfoDto;
 import org.jeecg.modules.business.dto.UpdateOrderPriceDto;
 import org.jeecg.modules.business.entity.*;
+import org.jeecg.modules.business.enums.BookingStatusTypeEnum;
+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.IBusRoomBookingOrdersService;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -26,6 +37,9 @@ 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.format.annotation.DateTimeFormat;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.web.bind.annotation.*;
@@ -189,31 +203,6 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 		return Result.OK(busRoomBookingOrders);
 	}
 
-    /**
-    * 导出excel
-    *
-    * @param request
-    * @param busRoomBookingOrders
-    */
-    //@RequiresPermissions("business:bus_room_booking_orders:exportXls")
-    @RequestMapping(value = "/exportXls")
-    public ModelAndView exportXls(HttpServletRequest request, BusRoomBookingOrders busRoomBookingOrders) {
-        return super.exportXls(request, busRoomBookingOrders, BusRoomBookingOrders.class, "酒店预定订单");
-    }
-
-    /**
-      * 通过excel导入数据
-    *
-    * @param request
-    * @param response
-    * @return
-    */
-    //@RequiresPermissions("business:bus_room_booking_orders:importExcel")
-    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
-    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
-        return super.importExcel(request, response, BusRoomBookingOrders.class);
-    }
-
 
 	 /**
 	  * 酒店预定订单-通过批次id查询批次订单信息
@@ -246,7 +235,7 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	 @ApiOperation(value="酒店预定订单-预约房间入住", notes="酒店预定订单-预约房间入住")
 	 @RequestMapping(value = "booking-to-live",method = RequestMethod.POST)
 	 public  Result<String> bookingRoomToLive(String bookingRoomId, @RequestBody List<BusLivingCustomer> customers,String hotelId) {
-		 return Result.OK("入住成功",service.bookingToLive(bookingRoomId, customers,hotelId,true,null,null,null));
+		 return Result.OK("入住成功",service.bookingToLive(bookingRoomId, customers,hotelId,true,null,null));
 	 }
 
 	 /**
@@ -273,6 +262,7 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	 	if(bookingOrderId == null || bookingOrderId.isEmpty()) throw new JeecgBootException("参数错误");
 	 	return Result.ok(service.getLivingOrderFee(bookingOrderId, isAllFee));
 	 }
+
 	 /**
 	  * 全部结账
 	  * @param bookingOrderId
@@ -284,7 +274,6 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	 	Boolean isOk = service.settleBillCheckOut(fees,bookingOrderId);
 	 	return Result.OK(isOk);
 	 }
-
 	 /**
 	  * 续住/提前
 	  * @return
@@ -411,6 +400,7 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	 public Result<Boolean> setLivingOrderFee(@RequestBody List<BusOrderFee> orders, String livingOrderId,String hotelId){
 	 	return Result.OK(service.setLivingOrderFee(orders,livingOrderId,hotelId));
 	 }
+
 	 /**
 	  * 退你麻痹单
 	  * @return
@@ -420,7 +410,6 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	 public Result<Boolean> 退你麻痹单(@RequestBody List<String> feeIds){
 		 return Result.OK(service.退你妈的单(feeIds));
 	 }
-
 	 /**
 	  * 添加联房
 	  * @return
@@ -489,15 +478,16 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 										   @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
 										   @RequestParam(name="startTime" ,required=false) @JsonFormat(pattern = "yyyy-MM-dd")  @DateTimeFormat(pattern="yyyy-MM-dd") DateTime startTime,
 										   @RequestParam(name="endTime" ,required=false) @JsonFormat(pattern = "yyyy-MM-dd")  @DateTimeFormat(pattern="yyyy-MM-dd") DateTime endTime,
-										   String thirdUserId, String keyw, Integer livingStatus,String hotelId,Integer type,Integer bookingStatus){
+										   String thirdUserId, String keyw, Integer livingStatus,String hotelId,Integer type,Integer bookingStatus, String layoutId, String customerType){
 	 	if(type == null) throw new JeecgBootException("参数错误");
 	 	if( type == 1 && livingStatus  == null ) throw new JeecgBootException("参数错误");
 	 	if(type == 2 && bookingStatus == null) throw new JeecgBootException("参数错误");
 		 Page<KeLiItemVo> page = new Page<KeLiItemVo>(pageNo, pageSize);
-	 	if(type == 1 ) return Result.OK(service.getLivingOrderKL(livingStatus,keyw,hotelId,thirdUserId,page, startTime, endTime));
+	 	if(type == 1 ) return Result.OK(service.getLivingOrderKL(livingStatus,keyw,hotelId,thirdUserId,layoutId,customerType, page, startTime, endTime));
 	 	if(type == 2) return  Result.OK(service.getBookingOrderKL(bookingStatus,keyw,hotelId,thirdUserId,page, startTime, endTime));
 	 	return  null;
 	 }
+
 	 /**
 	  * 修改订单信息
 	  * @param info 修改的信息
@@ -511,7 +501,6 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 
 	 }
 
-
 	 /**
 	  * 入住改价
 	  * @return
@@ -563,6 +552,7 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	 public  Result<Boolean> changeRoom(@RequestBody LivingContinueVo param) {
 		 return Result.OK(service.changeLivingRoom(param));
 	 }
+
 	 @ApiOperation(value="撤销", notes="撤销")
 	 @RequestMapping(value = "/reverse-living",method = RequestMethod.GET)
 	 public  Result<Boolean> reverseLiving(String livingOrderId,String hotelId) {
@@ -577,7 +567,6 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 //
 //		 return  Result.OK(busRoomBookingOrdersService.count(bookingOrderId, hotelId));
 //	 }
-
 	 @ApiOperation(value="是否可以单独结算", notes="联房数量")
 	 @RequestMapping(value = "/canOnlyPaySelf",method = RequestMethod.GET)
 	 public  Result<Boolean> canOnlyPaySelf(String bookingOrderId, String hotelId, String roomId) {
@@ -592,8 +581,6 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 		 return  Result.OK(onlyPaySelf);
 	 }
 
-
-
 	 @ApiOperation(value = "修改房间状态", notes = "修改房间状态")
 	 @GetMapping(value = "/changeState")
 	 public Result<String> changeState(BusRoomsLivingOrder roomsLivingOrder){
@@ -602,4 +589,84 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 		 return update ? Result.OK("修改房态成功") : Result.error("修改房态失败");
 	 }
 
+	 /**
+	  * 导出excel
+	  *
+	  * @param request
+	  * @param busRoomBookingOrders
+	  */
+	 //@RequiresPermissions("business:bus_room_booking_orders:exportXls")
+	 @RequestMapping(value = "/exportXls")
+	 public ModelAndView exportXls(HttpServletRequest request, BusRoomBookingOrders busRoomBookingOrders) {
+		 return super.exportXls(request, busRoomBookingOrders, BusRoomBookingOrders.class, "酒店预定订单");
+	 }
+
+	 /**
+	  * 通过excel导入数据
+	  *
+	  * @param request
+	  * @param response
+	  * @return
+	  */
+	 //@RequiresPermissions("business:bus_room_booking_orders:importExcel")
+	 @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+	 public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+		 return super.importExcel(request, response, BusRoomBookingOrders.class);
+	 }
+
+	 @Resource
+	 BusRoomBookingOrdersMapper baseMapper;
+
+	 @RequestMapping(value = "/exportXls2")
+	 public ModelAndView exportXls2(HttpServletRequest request,
+								   @RequestParam(name="startTime" ,required=false) @JsonFormat(pattern = "yyyy-MM-dd")  @DateTimeFormat(pattern="yyyy-MM-dd") DateTime startTime,
+								   @RequestParam(name="endTime" ,required=false) @JsonFormat(pattern = "yyyy-MM-dd")  @DateTimeFormat(pattern="yyyy-MM-dd") DateTime endTime,
+								   String thirdUserId, String keyw, Integer livingStatus,String hotelId,Integer type,Integer bookingStatus, String layoutId, String customerType) {
+		 Page<KeLiItemVo> page = new Page<>(1,9999999);
+		 IPage<KeLiItemVo> pRes = new Page<>();
+		 String title = "";
+		 if (type == 1){
+			 title = "入住单";
+			 pRes = baseMapper.getKeLiLiving(page,thirdUserId,hotelId,keyw,livingStatus, layoutId, customerType, startTime,endTime);
+			 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());
+				 e.setConsumerText(e.getYushou().subtract(e.getYuE()));
+			 });
+		 } else if (type == 2){
+			 title = "预约单";
+			 pRes = baseMapper.getKeBooking(page,thirdUserId,hotelId,keyw,bookingStatus,startTime,endTime);
+			 pRes.getRecords().forEach(e -> {
+				 e.setCustomerTypeText(CustomerTypeEnum.val(e.getCustomerType()).getTitle());
+				 e.setOTypeText(LivingTypeEnum.val(e.getOType()).getTitle());
+				 String status = "";
+				 if (Objects.equals(e.getBookingStatus(), BookingStatusTypeEnum.NORMAL.getKey())) {
+					 if (StrUtil.isNotEmpty(e.getLivingId())){
+						 status = CommonConstant.LIVING;
+					 } else {
+						 status = e.getArrivalTime().after(new Date()) ? CommonConstant.BOOKING : CommonConstant.WILL_EXPIRE;
+					 }
+				 } else{
+					 status = BookingStatusTypeEnum.val(e.getBookingStatus()).getTitle();
+				 }
+				 e.setStatusText(status);
+			 });
+		 }
+
+		 // Step.3 AutoPoi 导出Excel
+		 ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+		 //此处设置的filename无效 ,前端会重更新设置一下
+		 mv.addObject(NormalExcelConstants.FILE_NAME, title);
+		 mv.addObject(NormalExcelConstants.CLASS, KeLiItemVo.class);
+		 //update-begin--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
+		 ExportParams exportParams=new ExportParams(title + "报表", "导出人:" + 123, title);
+		 exportParams.setImageBasePath(upLoadPath);
+		 //update-end--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
+		 mv.addObject(NormalExcelConstants.PARAMS,exportParams);
+		 mv.addObject(NormalExcelConstants.DATA_LIST, pRes.getRecords());
+		 return mv;
+	 }
+
+
  }

+ 4 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/dto/BookingLayoutRoomsDto.java

@@ -8,6 +8,7 @@ import org.jeecg.modules.business.entity.BusRoomBookingOrders;
 import org.jeecg.modules.business.vo.BusLivingCustomerVo;
 import org.jeecg.modules.rooms.entity.CesHouseLongRentScheme;
 
+import java.math.BigDecimal;
 import java.util.List;
 
 @Data
@@ -18,11 +19,11 @@ public class BookingLayoutRoomsDto {
     @ApiModelProperty(value = "房间id,传入null/不传,表示未排房")
     private String roomId;
     @ApiModelProperty(value = "水表读数")
-    private Integer waterMeter;
+    private BigDecimal waterMeter;
     @ApiModelProperty(value = "电表读数")
-    private Integer energyMeter;
+    private BigDecimal energyMeter;
     @ApiModelProperty(value = "燃气读数")
-    private Integer gasMeter;
+    private BigDecimal gasMeter;
     @ApiModelProperty(value = "是否主房")
     private Boolean isMain;
     @ApiModelProperty(value = "同住人信息")

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

@@ -1,7 +1,6 @@
 package org.jeecg.modules.business.entity;
 
 import java.io.Serializable;
-import java.io.UnsupportedEncodingException;
 import java.util.Date;
 import java.math.BigDecimal;
 import java.util.List;
@@ -10,9 +9,9 @@ import com.baomidou.mybatisplus.annotation.*;
 import lombok.Data;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import org.jeecg.modules.business.vo.BusOrderFeeGoodsVo;
+import org.jeecg.modules.rooms.entity.CesHouseLongRentMeterLog;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.jeecgframework.poi.excel.annotation.Excel;
-import org.jeecg.common.aspect.annotation.Dict;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.EqualsAndHashCode;
@@ -140,7 +139,7 @@ public class BusOrderFee implements Serializable {
 
     private String returnFeeId;
     private Boolean returnItem;
-    @ApiModelProperty(value = "数量")
+    @ApiModelProperty(value = "商品冲账数量")
     private Integer returnNum;
     @ApiModelProperty(value = "预定id")
     private String bookingOrderId;
@@ -159,6 +158,9 @@ public class BusOrderFee implements Serializable {
     @TableField(exist = false)
     @ApiModelProperty(value = "关联商品信息")
     private BusOrderFeeGoodsVo feeGoodVo;
+    @TableField(exist = false)
+    @ApiModelProperty(value = "关联商品信息")
+    private CesHouseLongRentMeterLog longRentMeterLog;
 
     @TableField(exist = false)
     @ApiModelProperty(value = "原价")

+ 2 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/enums/BookingStatusTypeEnum.java

@@ -7,7 +7,8 @@ import java.util.List;
 
 public enum BookingStatusTypeEnum {
     NORMAL(1,"正常"),
-    CANCEL(2,"取消");
+    CANCEL(2,"取消"),
+    INVALID(3,"失效");
 
     Integer key;
 

+ 1 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/BusRoomBookingOrdersMapper.java

@@ -48,7 +48,7 @@ public interface BusRoomBookingOrdersMapper extends BaseMapper<BusRoomBookingOrd
 
     List<RiLiFangTaiVo> getRiliFangTai(String start, String end,String hotelId);
 
-    IPage<KeLiItemVo> getKeLiLiving(IPage<KeLiItemVo> page,String thirdUserId, String hotelId,String keyw,Integer status, Date startTime,Date endTime);
+    IPage<KeLiItemVo> getKeLiLiving(IPage<KeLiItemVo> page,String thirdUserId, String hotelId,String keyw,Integer status,String layoutId, String customerType, Date startTime,Date endTime);
     IPage<KeLiItemVo> getKeBooking(IPage<KeLiItemVo> page,String thirdUserId, String hotelId,String keyw,Integer status, Date startTime,Date endTime);
     @Select("SELECT o.id from bus_room_booking_orders o inner join bus_booking_rooms br on o.id = br.booking_orders_id inner join ces_room_layout l on l.id = br.room_layout_id where l.hotel_id = #{hotelId} and o.arrival_time >= now() and o.arrival_time <= DATE_ADD(o.arrival_time,interval 1 day)")
     List<BusRoomBookingOrders> countTodayYD(String hotelId);

+ 42 - 35
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/BusRoomBookingOrdersMapper.xml

@@ -5,12 +5,10 @@
 
     <select id="getTodayBookingOrder" resultType="org.jeecg.modules.business.dto.TodayBookingQueryDto">
         select o.id as booking_order_id,br.room_id from bus_booking_rooms br inner join
-                                    (
-                                        select id from bus_room_booking_orders where booking_status = 1 and DATE_FORMAT(arrival_time,'%Y-%m-%d') = DATE_FORMAT(ADDDATE(now(),INTERVAL 8 HOUR),'%Y-%m-%d')
-                                    ) as o on br.booking_orders_id = o.id
-        where
-            br.room_status &lt; 3 and
-         br.room_id in
+        (select id from bus_room_booking_orders where booking_status = 1
+         and DATE_FORMAT(arrival_time,'%Y-%m-%d') = DATE_FORMAT(ADDDATE(now(),INTERVAL 8 HOUR),'%Y-%m-%d'))
+        as o on br.booking_orders_id = o.id
+        where br.room_status &lt; 3 and br.room_id in
         <foreach collection="roomIds" item="roomId" open="(" close=")" separator=",">
             #{roomId}
         </foreach>
@@ -270,17 +268,25 @@ lo.booking_order_id
         <if test="thirdUserId != null and thirdUserId != ''">
             and o.third_login_user_id = #{thirdUserId}
         </if>
-        <if test="status == -1 or status == 1 or status == 2">
-            and  o.settle_type = #{status}
+        <if test="customerType != null and customerType != ''">
+            and o.customer_type = #{customerType}
         </if>
-        <if test="status == 2">
-            and  br.is_main = 1
+        <if test="layoutId != null and layoutId != ''">
+            and l.id = #{layoutId}
         </if>
-        <if test="status == 3">
-            -- 联防退房
-            and  (o.settle_type = 1 or o.settle_type = 2)
-            and is_union_settled = 1
+          /*正常入住 -1   已结: 1  先走未结: 2  联房退房: 3*/
+          /*-1,"正常入住"  1,"结账退房"  2,"未结退房"*/
+        <if test="status == -1 or status == 1 or status == 2">
+            and o.settle_type = #{status}
         </if>
+<!--        <if test="status == 2">-->
+<!--            and  br.is_main = 1-->
+<!--        </if>-->
+<!--        <if test="status == 3">-->
+<!--            &#45;&#45; 联防退房-->
+<!--            and  (o.settle_type = 1 or o.settle_type = 2)-->
+<!--            and is_union_settled = 1-->
+<!--        </if>-->
         <if test="keyw != null and keyw != ''" >
             and (
             cus.`name` like '%${keyw}%' or cus.phone like '%${keyw}%' or o.living_order_no like '%${keyw}%'
@@ -303,7 +309,9 @@ lo.booking_order_id
         cus.phone as customer_phone,
         o.customer_type,
         o.booking_type as o_type,
+        o.booking_status,
         l.`name` as layout_name,
+        brlo.id as living_id,
         concat(IFNULL(r.prefix,''),r.`name`) as room_name,
         o.arrival_time,
         o.due_out_time,
@@ -311,15 +319,9 @@ lo.booking_order_id
         0 as yushou,
         0 as yu_e
         from bus_room_booking_orders o
-        inner join bus_booking_rooms br
-        on o.id = br.booking_orders_id
-        /*2为已入住,已入住的找得到入住单*/
-        <if test="status == 1 or  status == 3">
-            and br.id not in (select booking_room_id from bus_rooms_living_order)
-        </if>
-        <if test="status == 2">
-            and br.id in (select booking_room_id from bus_rooms_living_order)
-        </if>
+        inner join bus_booking_rooms br on o.id = br.booking_orders_id
+
+        left join bus_rooms_living_order brlo on br.id = brlo.booking_room_id
         left join ces_rooms r
         on r.id = br.room_id and r.hotel_id = #{hotelId}
         left join ces_room_layout l
@@ -327,23 +329,28 @@ lo.booking_order_id
         inner join bus_customer cus
         on cus.id = o.contact_id
         where 1 = 1
-        <if test="thirdUserId != null and thirdUserId != ''">
-            and o.third_login_user_id = #{thirdUserId}
-        </if>
-        <if test="status == 1 or status == 2">
+        -- status: 1预定中 2已入住 3已取消 4已失效 5今日应到未到
+        <if test="status == 1 or status == 2  or status == 5">
             and o.booking_status = 1
         </if>
-          /*已取消*/
+        <if test="status == 1">
+            and (brlo.id is null or brlo.id = '') and o.due_out_time >= now()
+        </if>
+        <if test="status == 2">
+            and brlo.id is not null and brlo.id != ''
+        </if>
         <if test="status == 3">
             and o.booking_status = 2
         </if>
-        <if test="status==1">
-            -- 预定中
-            and (o.due_out_time >= now())
-        </if>
-        <if test="status==4">
+        <if test="status == 4">
             -- 已失效
-            and (o.due_out_time &lt;= now())
+            and o.booking_status = 3
+        </if>
+        <if test="status == 5">
+            and o.due_out_time &lt;= now()
+        </if>
+        <if test="thirdUserId != null and thirdUserId != ''">
+            and o.third_login_user_id = #{thirdUserId}
         </if>
         <if test="keyw != null and keyw != ''" >
             and (cus.`name` like '%${keyw}%' or cus.phone like '%${keyw}%' or o.booking_orders_no like '%${keyw}%')
@@ -354,6 +361,6 @@ lo.booking_order_id
         <if test="endTime != null">
             and o.arrival_time &lt;= #{endTime}
         </if>
-        GROUP BY o.id,r.id order by o.create_time desc
+        GROUP BY o.id,r.id,brlo.id order by o.create_time desc
     </select>
 </mapper>

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

@@ -8,6 +8,7 @@ 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;
 import org.jeecg.modules.rooms.entity.CesHouseLongRentScheme;
 import org.jeecg.modules.rooms.entity.CesRooms;
 
@@ -31,4 +32,6 @@ public interface IBusOrderFeeService extends IService<BusOrderFee> {
 
 
     void addBillFee(BusRoomsLivingOrder livingOrder, CesRooms room, CesHouseLongRentScheme longRentScheme,List<BusLivingLayoutDayPrice> livingRoomDayPrices);
+
+    Boolean addMeterFee(List<CesHouseLongRentCharge> longRentChargeList);
 }

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

@@ -3,10 +3,7 @@ package org.jeecg.modules.business.service;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import org.jeecg.modules.business.dto.BatchOrderSavaDto;
-import org.jeecg.modules.business.dto.BookingOrderSaveDto;
-import org.jeecg.modules.business.dto.UpdateOrderInfoDto;
-import org.jeecg.modules.business.dto.UpdateOrderPriceDto;
+import org.jeecg.modules.business.dto.*;
 import org.jeecg.modules.business.entity.*;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.business.vo.*;
@@ -45,7 +42,7 @@ public interface IBusRoomBookingOrdersService extends IService<BusRoomBookingOrd
     String batchOrderSave(BatchOrderSavaDto item);
 
     Boolean setBatchOrderStatus(BusBookingBatch batchOrder);
-    String bookingToLive(String bookingRoomId, List<BusLivingCustomer> customers, String hotelId,Boolean bookingLiving, BusRoomBookingOrders livingRoomOrderInfo, CesHouseLongRentScheme longRentScheme,List<BusLivingLayoutDayPrice> livingRoomDayPrices);
+    String bookingToLive(String bookingRoomId, List<BusLivingCustomer> customers, String hotelId, Boolean bookingLiving, BookingLayoutRoomsDto roomInfo, List<BusLivingLayoutDayPrice> livingRoomDayPrices);
 
     String customerLiving(BookingOrderSaveDto livingData, Boolean isTeam, String hotelId);
 
@@ -54,7 +51,6 @@ public interface IBusRoomBookingOrdersService extends IService<BusRoomBookingOrd
     List<BusOrderFee> getLivingOrderFee(String orderId, Boolean isAllFee);
 
     Boolean syncDayRoomFee(String hotelId);
-    Boolean syncDayRoomOrder(String hotelId);
     Boolean syncRoomOverTimeOrder(String hotelId);
     BigDecimal getOrderFeeTotal(String livingOrderId,String bookingOrderId);
     Boolean settleBillCheckOut(List<BusOrderFee> settleFees, String bookingOrderId);
@@ -68,7 +64,7 @@ public interface IBusRoomBookingOrdersService extends IService<BusRoomBookingOrd
 
     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(Integer status,String keyw,String hotelId,String thirdUserId, Page<KeLiItemVo> page, Date startTime,Date endTime);
+    IPage<KeLiItemVo> getLivingOrderKL(Integer status,String keyw,String hotelId,String thirdUserId,String layoutId, String customerType,Page<KeLiItemVo> page, Date startTime,Date endTime);
     IPage<KeLiItemVo> getBookingOrderKL(Integer status,String keyw,String hotelId,String thirdUserId, Page<KeLiItemVo> page, Date startTime,Date endTime);
     Boolean setLivingOrderFee(List<BusOrderFee> fees,String livingOrderId,String hotelId);
     Boolean unionOrder(String roomId,String targetRoomId, String bookingOrderId, String hotelId);
@@ -106,4 +102,6 @@ public interface IBusRoomBookingOrdersService extends IService<BusRoomBookingOrd
     List<LivingContinueVo> getContinueOrder(String livingOrderId, String hotelId);
 
     void addWillLeaveMess(String parameter);
+
+    void overTimerBooking(String hotelId);
 }

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

@@ -3,6 +3,8 @@ package org.jeecg.modules.business.service.impl;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.util.BooleanUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
@@ -24,13 +26,9 @@ import org.jeecg.modules.business.vo.BusOrderFeeGoodsVo;
 import org.jeecg.modules.business.vo.RoomOrderFeeVo;
 import org.jeecg.modules.kc.entity.KcDepositoryInGoods;
 import org.jeecg.modules.rooms.Enum.ChargeTypeEnum;
-import org.jeecg.modules.rooms.entity.CesGoods;
-import org.jeecg.modules.rooms.entity.CesHouseLongRentScheme;
-import org.jeecg.modules.rooms.entity.CesRoomLayout;
-import org.jeecg.modules.rooms.entity.CesRooms;
-import org.jeecg.modules.rooms.service.CesGoodsServiceImpl;
-import org.jeecg.modules.rooms.service.CesRoomLayoutServiceImpl;
-import org.jeecg.modules.rooms.service.ICesHouseLongRentSchemeService;
+import org.jeecg.modules.rooms.Enum.ReadTypeEnum;
+import org.jeecg.modules.rooms.entity.*;
+import org.jeecg.modules.rooms.service.*;
 import org.springframework.stereotype.Service;
 
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -72,7 +70,10 @@ public class BusOrderFeeServiceImpl extends ServiceImpl<BusOrderFeeMapper, BusOr
     private IBusLivingLayoutDayPriceService livingLayoutDayPriceService;
     @Resource
     private ICesHouseLongRentSchemeService longRentSchemeService;
-
+    @Resource
+    private CesRoomsServiceImpl roomsService;
+    @Resource
+    ICesHouseLongRentMeterLogService houseLongRentMeterLogService;
 
 
     @Override
@@ -334,7 +335,8 @@ public class BusOrderFeeServiceImpl extends ServiceImpl<BusOrderFeeMapper, BusOr
     public void addBillFee(BusRoomsLivingOrder livingOrder, CesRooms room, CesHouseLongRentScheme longRentScheme,List<BusLivingLayoutDayPrice> livingRoomDayPrices) {
         if (livingOrder.getLivingType() != 5){
             BigDecimal money = new BigDecimal(0);
-            Optional<BusLivingLayoutDayPrice> dayPrice = livingRoomDayPrices.stream().filter(e -> room.getId().equals(e.getRoomId()) && (DateUtils.formatDate(new Date())).equals(DateUtils.formatDate(e.getDayTime()))).findFirst();
+            Optional<BusLivingLayoutDayPrice> dayPrice = livingRoomDayPrices.stream().filter(e -> room.getId().equals(e.getRoomId())
+                    && (DateUtils.formatDate(new Date())).equals(DateUtils.formatDate(e.getDayTime()))).findFirst();
             if (dayPrice.isPresent()){
                 money = dayPrice.get().getPrice();
             } else {
@@ -356,7 +358,8 @@ public class BusOrderFeeServiceImpl extends ServiceImpl<BusOrderFeeMapper, BusOr
         } else {
             longRentSchemeService.addLivingScheme(longRentScheme, livingOrder.getId());
             longRentScheme.getHouseLongRentChargeList().forEach(e -> {
-                if (ChargeTypeEnum.DISPOSABLE.getKey().equals(e.getChargeType()) && !e.getIsMust() || ChargeTypeEnum.PERIODICITY.getKey().equals(e.getChargeType())){
+                if (ChargeTypeEnum.DISPOSABLE.getKey().equals(e.getChargeType()) && BooleanUtil.isFalse(e.getIsMust())
+                        || ChargeTypeEnum.PERIODICITY.getKey().equals(e.getChargeType())){
                     BusOrderFee dayOrderFee = new BusOrderFee();
                     dayOrderFee.setDayTime(new Date());
                     dayOrderFee.setCreateTime(new Date());
@@ -365,14 +368,12 @@ public class BusOrderFeeServiceImpl extends ServiceImpl<BusOrderFeeMapper, BusOr
                     roomName += roomName + room.getName();
                     dayOrderFee.setMoney(e.getMoney());
                     dayOrderFee.setSubjectType(FeeSubjectType.OTHER.getKey());
-                    if (e.getIsMust() != null && e.getIsMust()){
+                    if (ChargeTypeEnum.PERIODICITY.getKey().equals(e.getChargeType())) {
                         dayOrderFee.setMoney(e.getMoney().multiply(BigDecimal.valueOf(e.getNum())));
-                        if (ChargeTypeEnum.DISPOSABLE.getKey().equals(e.getChargeType())){
-                            dayOrderFee.setSubjectType(FeeSubjectType.MEI_RI_FANG_FEI.getKey());
-                        } else {
+                        if (e.getIsMust() != null && e.getIsMust()){
                             dayOrderFee.setSubjectType(FeeSubjectType.MEI_RI_FANG_FEI.getKey());
+                            dayOrderFee.setRemark(DateUtil.format(new Date(), "yyyy-MM") + e.getName());
                         }
-                        dayOrderFee.setRemark("【"+roomName + "】 "+ DateUtils.formatDateTime() + e.getName());
                     }
                     dayOrderFee.setFeeType(1);
                     dayOrderFee.setRoomId(room.getId());
@@ -384,4 +385,69 @@ public class BusOrderFeeServiceImpl extends ServiceImpl<BusOrderFeeMapper, BusOr
         }
 
     }
+
+    @Override
+    public Boolean addMeterFee(List<CesHouseLongRentCharge> longRentChargeList) {
+        if (CollUtil.isEmpty(longRentChargeList)){
+            return true;
+        }
+        CesRooms room = roomsService.getOne(Wrappers.<CesRooms>lambdaQuery()
+                .eq(CesRooms::getLivingOrderId, longRentChargeList.get(0).getLivingOrderId()).last("limit 1"));
+        List<BusOrderFee> orderFeeList = new ArrayList<>();
+        List<CesHouseLongRentMeterLog> longRentMeterLogList = new ArrayList<>();
+        longRentChargeList.forEach(e -> {
+            if (ChargeTypeEnum.WATER.getKey().equals(e.getChargeType())){
+                BigDecimal money = e.getMoney().multiply(e.getMeterRead().subtract(room.getWaterMeter()));
+                BusOrderFee orderFee = addFee(room, money, e);
+                CesHouseLongRentMeterLog meterLog = addMeterLog(orderFee, room, e);
+                room.setWaterMeter(e.getMeterRead());
+                orderFeeList.add(orderFee);
+                longRentMeterLogList.add(meterLog);
+            } else if (ChargeTypeEnum.ELECTRIC.getKey().equals(e.getChargeType())){
+                BigDecimal money = e.getMoney().multiply(e.getMeterRead().subtract(room.getEnergyMeter()));
+                room.setEnergyMeter(e.getMeterRead());
+                BusOrderFee orderFee = addFee(room, money, e);
+                CesHouseLongRentMeterLog meterLog = addMeterLog(orderFee, room, e);
+                orderFeeList.add(orderFee);
+                longRentMeterLogList.add(meterLog);
+            } else if (ChargeTypeEnum.GAS.getKey().equals(e.getChargeType())){
+                BigDecimal money = e.getMoney().multiply(e.getMeterRead().subtract(room.getGasMeter()));
+                room.setGasMeter(e.getMeterRead());
+                BusOrderFee orderFee = addFee(room, money, e);
+                CesHouseLongRentMeterLog meterLog = addMeterLog(orderFee, room, e);
+                orderFeeList.add(orderFee);
+                longRentMeterLogList.add(meterLog);
+            }
+        });
+        roomsService.updateById(room);
+        saveBatch(orderFeeList);
+        houseLongRentMeterLogService.saveBatch(longRentMeterLogList);
+        return true;
+    }
+
+    public BusOrderFee addFee(CesRooms room,BigDecimal money, CesHouseLongRentCharge charge){
+        BusOrderFee orderFee = new BusOrderFee();
+        orderFee.setId(String.valueOf(IdWorker.getId()));
+        orderFee.setMoney(money);
+        orderFee.setFeeType(1);
+        orderFee.setSubjectType(FeeSubjectType.SHUI_DIAN_MEI.getKey());
+        orderFee.setRemark(charge.getName());
+        orderFee.setLivingOrderId(room.getLivingOrderId());
+        orderFee.setPreferentialStatus(1);
+        orderFee.setDayTime(new Date());
+        orderFee.setRoomId(room.getId());
+        orderFee.setHotelId(room.getHotelId());
+        return orderFee;
+    }
+
+    public CesHouseLongRentMeterLog addMeterLog(BusOrderFee orderFee,CesRooms room, CesHouseLongRentCharge charge){
+        CesHouseLongRentMeterLog meterLog = new CesHouseLongRentMeterLog();
+        meterLog.setRoomId(room.getId());
+        meterLog.setOrderFeeId(orderFee.getId());
+        meterLog.setPrice(charge.getMoney());
+        meterLog.setReadType(ReadTypeEnum.WATER.getKey());
+        meterLog.setStartRead(room.getWaterMeter());
+        meterLog.setEndRead(charge.getMeterRead());
+        return meterLog;
+    }
 }

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

@@ -18,7 +18,6 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.SneakyThrows;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
-import org.checkerframework.checker.units.qual.C;
 import org.jeecg.common.api.dto.message.MessageDTO;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.exception.JeecgBootException;
@@ -32,7 +31,10 @@ import org.jeecg.modules.business.mapper.BusRoomBookingOrdersMapper;
 import org.jeecg.modules.business.service.*;
 import org.jeecg.modules.business.util.MxTools;
 import org.jeecg.modules.business.vo.*;
-import org.jeecg.modules.fw.entity.*;
+import org.jeecg.modules.fw.entity.FwRoomClean;
+import org.jeecg.modules.fw.entity.FwRoomExamine;
+import org.jeecg.modules.fw.entity.FwRoomLock;
+import org.jeecg.modules.fw.entity.FwRoomRepair;
 import org.jeecg.modules.fw.service.IFwRoomCleanService;
 import org.jeecg.modules.fw.service.IFwRoomExamineService;
 import org.jeecg.modules.fw.service.IFwRoomLockService;
@@ -41,6 +43,7 @@ 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.ChargeTypeEnum;
 import org.jeecg.modules.rooms.Enum.RoomStatusEnum;
 import org.jeecg.modules.rooms.Enum.TimeOutRuleEnum;
 import org.jeecg.modules.rooms.Vo.BookingRealtimeVo;
@@ -58,7 +61,6 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
-import java.io.Serializable;
 import java.math.BigDecimal;
 import java.text.DateFormat;
 import java.text.ParseException;
@@ -137,9 +139,6 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
     private CesGoodsServiceImpl cesGoodsServiceImpl;
 
     @Resource
-    private IBusAgreementOrderFeeService agreementOrderFeeService;
-
-    @Resource
     private IBusMarketAgreementUnitService marketAgreementUnitService;
 
     @Resource
@@ -165,6 +164,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
 
     @Resource
     private IBusCancelService cancelService;
+    @Autowired
+    private IBusParamPresetService busParamPresetService;
 
     @Autowired
     private RedisTemplate<String, Object> redisTemplate;
@@ -178,6 +179,13 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
     @Resource
     private IBusHotelService busHotelService;
 
+    @Resource
+    ICesHouseLongRentChargeService houseLongRentChargeService;
+    @Resource
+    ICesHouseLongRentMeterLogService houseLongRentMeterLogService;
+
+    @Resource
+    private SysBaseApiImpl sysBaseAPI;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -194,12 +202,12 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             item.getOrderInfo().setBookingOrdersNo("YD"+sdf.format(System.currentTimeMillis()));
         }
         // 检测是否时间安排上有冲突
-        List<String> roomIds = item.getRoomIds().stream().map(s->s.getRoomId()).collect(Collectors.toList());
+        List<String> roomIds = item.getRoomIds().stream().map(BookingLayoutRoomsDto::getRoomId).collect(Collectors.toList());
 
         if(item.getConfirm() == null || !item.getConfirm()){
-            if(roomIds.size() > 0) {
+            if(!roomIds.isEmpty()) {
                 List<BusBookingRooms> bookingRooms = baseMapper.conflictBookingTime(item.getOrderInfo().getArrivalTime(),item.getOrderInfo().getDueOutTime(),roomIds);
-                if(bookingRooms.size() > 0) {
+                if(!bookingRooms.isEmpty()) {
                     String roomNames = bookingRooms.stream().map(p->p.getRoomId()).collect(Collectors.joining("|"));
                     throw new JeecgBootException("房间["+roomNames+"]与预约时间有冲突");
                 }
@@ -255,7 +263,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 } else {
                     item.getOrderInfo().setContactId(customer.getId());
                 }
-            } else if(item.getLivingRoomDayPrices() != null && item.getLivingRoomDayPrices().size() > 0){
+            } else if(item.getLivingRoomDayPrices() != null && !item.getLivingRoomDayPrices().isEmpty()){
 
             } else if (item.getOrderInfo().getBookingType() == 5) {
 
@@ -276,7 +284,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                     throw new JeecgBootException("入住天数不能小于0");
 
             }
-            if(item.getRoomIds() == null || item.getRoomIds().size() == 0)
+            if(item.getRoomIds() == null || item.getRoomIds().isEmpty())
                 throw new JeecgBootException("请选择预定房间");
             if(hotelId == null || hotelId.isEmpty()) throw  new JeecgBootException("参数错误,酒店id");
             item.getOrderInfo().setHotelId(hotelId);
@@ -317,12 +325,12 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
 
             if (item.getOrderInfo().getBookingType() != 5){
                 // 处理预定每天的房型价格 Start
-                if(item.getLivingRoomDayPrices() != null && item.getLivingRoomDayPrices().size() > 0) {
+                if(item.getLivingRoomDayPrices() != null && !item.getLivingRoomDayPrices().isEmpty()) {
                     if(item.getLivingRoomDayPrices().stream().anyMatch(o->o.getPrice()==null || o.getDayTime() == null || o.getRoomId() == null))
                         throw new JeecgBootException("参数错误,请传入价格、日期、房型");
                     // 入住之后在save
                 } else {
-                    if(item.getLayoutDayPrices() == null || item.getLayoutDayPrices().size() == 0)
+                    if(item.getLayoutDayPrices() == null || item.getLayoutDayPrices().isEmpty())
                         throw new JeecgBootException("参数错误,对应房型当天价格必传");
                     if(item.getLayoutDayPrices().stream().anyMatch(o->o.getPrice()==null || o.getDayTime() == null || o.getRoomLayoutId() == null))
                         throw new JeecgBootException("参数错误,请传入价格、日期、房型");
@@ -333,7 +341,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                             g.setBookingType(BookingOrdersType.NORMAL.getKey());
                         }
                     });
-                    List<String> lList = item.getRoomIds().stream().map(w->w.getLayoutId()).collect(Collectors.toList());
+                    List<String> lList = item.getRoomIds().stream().map(BookingLayoutRoomsDto::getLayoutId).collect(Collectors.toList());
                     dayPriceService.saveBatch(item.getLayoutDayPrices().stream().filter(l->lList.contains(l.getRoomLayoutId())).collect(Collectors.toList()));
                 }
             }
@@ -348,7 +356,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                     List<BusTeam> existTeams = teamService.list(Wrappers.<BusTeam>query().eq("is_delete", 0).eq("hotel_id", hotelId)
                             .eq("rel_type",1)); // 1团队房,2联房
                     Integer sortIndex = 1;
-                    List<Integer> indexs = existTeams.stream().map(s->s.getSortIndex()).collect(Collectors.toList());
+                    List<Integer> indexs = existTeams.stream().map(BusTeam::getSortIndex).collect(Collectors.toList());
                     while(true){
                         Integer finalSortIndex = sortIndex;
                         if(indexs.stream().filter(s->s.equals(finalSortIndex)).count() == 0) {
@@ -369,6 +377,14 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                         addBusTeams(hotelId, bookingId);
                     }
                 }
+                redisTemplate.opsForZSet().remove("sys:cache:order:overTimerBooking", bookingId);
+            } else {
+                BusParamPreset paramPreset = busParamPresetService.getOne(Wrappers.<BusParamPreset>lambdaQuery().eq(BusParamPreset::getHotelId, hotelId));
+                Calendar calendar = Calendar.getInstance();
+                if (ObjectUtil.equals(paramPreset.getStatus(), 1)) {
+                    calendar.add(Calendar.MINUTE, paramPreset.getMinute());
+                }
+                redisTemplate.opsForZSet().add("sys:cache:order:overTimerBooking", bookingId, calendar.getTimeInMillis());
             }
             //</editor-fold>
             roomsService.getReserveRoom();
@@ -377,7 +393,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         } else if(item.getOrderInfo().getBookingOrdersType().equals(BookingOrdersType.TEAM.getKey())) {
             if(item.getOrderInfo().getTeamName() == null || item.getOrderInfo().getTeamName().isEmpty())
                 throw new JeecgBootException("请填写团队名称");
-            if(item.getBatchRooms() == null || item.getBatchRooms().size() == 0)
+            if(item.getBatchRooms() == null || item.getBatchRooms().isEmpty())
                 throw  new JeecgBootException("请添加批次信息");
             saveOrUpdate(item.getOrderInfo());
             item.getBatchRooms().forEach(c->{
@@ -392,7 +408,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                     if(c.getDayCount() == null || c.getDayCount() <= 0)
                         throw new JeecgBootException("入住天数不能小于0");
                 }
-                if(c.getRoomIds() == null || c.getRoomIds().size() == 0)
+                if(c.getRoomIds() == null || c.getRoomIds().isEmpty())
                     throw new JeecgBootException("请选择批次房间");
                 SimpleDateFormat sdfPc = new SimpleDateFormat("yyyyMMddHHmmssSSS");
                 c.setBatchNo("YDPC"+sdfPc.format(System.currentTimeMillis()));
@@ -543,7 +559,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             });
             result.setLivingRoomIds(livingRooms);
             //</editor-fold>
-            BusTeam team = teamService.getOne(Wrappers.<BusTeam>query().eq("booking_order_id",orderId).eq("is_delete",0));
+            BusTeam team = teamService.getOne(Wrappers.<BusTeam>query().eq("booking_order_id",orderId).eq("is_delete",0).last("limit 1"));
             if(team != null) {
                 result.setTeamTag(team.getSortIndex());
             }
@@ -1034,25 +1050,24 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String bookingToLive(String bookingRoomId, List<BusLivingCustomer> customers, String hotelId, Boolean bookingLiving,
-                                BusRoomBookingOrders livingRoomOrderInfo, CesHouseLongRentScheme longRentScheme, List<BusLivingLayoutDayPrice> livingRoomDayPrices) {
+                                BookingLayoutRoomsDto roomInfo, List<BusLivingLayoutDayPrice> livingRoomDayPrices) {
         BusBookingRooms bkRoom = bookingRoomsService.getById(bookingRoomId);
         if(bkRoom == null) throw  new JeecgBootException("关联房间不存在");
         BusRoomBookingOrders bookingOrders = getById(bkRoom.getBookingOrdersId());
         if(bookingOrders == null) throw new JeecgBootException("房间预约单不存在");
         LoginUser user = TokenUtils.getAuthUser();
-
         //<editor-fold desc="订单复制 -- 散客入住">
         BusRoomsLivingOrder livingOrder = null;
         if(bkRoom.getBookingType().equals(BookingOrdersType.NORMAL.getKey())) {
             //todo other
-            if(livingRoomOrderInfo != null) {
-                livingRoomOrderInfo.setId(bookingOrders.getId());
+            if(roomInfo.getRoomOrderInfo() != null) {
+                roomInfo.getRoomOrderInfo().setId(bookingOrders.getId());
                 // 设置为当前时间
-                livingRoomOrderInfo.setArrivalTime(new Date());
+                roomInfo.getRoomOrderInfo().setArrivalTime(new Date());
             } else {
-                livingRoomOrderInfo = bookingOrders;
+                roomInfo.setRoomOrderInfo(bookingOrders);
             }
-            livingOrder = copyBookingToAcceptOrder(livingRoomOrderInfo);
+            livingOrder = copyBookingToAcceptOrder(roomInfo.getRoomOrderInfo());
             livingOrder.setBookingRoomId(bookingRoomId);
         } else if(bkRoom.getBookingType().equals(BookingOrdersType.TEAM.getKey())) {
             BusBookingBatch batch = bookingBatchService.getById(bkRoom.getBookingBatchId());
@@ -1067,9 +1082,13 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
 
         livingOrder.setArrivalTime(new Date());// todo 这个地方的入住开始时间应该怎么算
         if(customers != null && !customers.isEmpty()) {
-            if (StrUtil.isEmpty(customers.get(0).getCustomerId())){
+            BusCustomer customer = customerService.getOne(Wrappers.<BusCustomer>query().eq("name",customers.get(0).getCustomerName())
+                    .eq("phone",customers.get(0).getPhone()));
+            if (customer == null){
                 long id = new Snowflake().nextId();
                 customers.get(0).setCustomerId(StrUtil.toString(id));
+            } else {
+                customers.get(0).setCustomerId(customer.getId());
             }
             livingOrder.setContactId(customers.get(0).getCustomerId());
         } else throw new JeecgBootException("请添加入住人信息");
@@ -1089,6 +1108,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         Integer roomStatus = roomsService.changeLivingRoomStatus(room.getRoomStatus(), room.getLastRoomStatus());
         room.setLastRoomStatus(room.getRoomStatus());
         room.setRoomStatus(roomStatus);
+        room.setWaterMeter(roomInfo.getWaterMeter());
+        room.setEnergyMeter(roomInfo.getEnergyMeter());
+        room.setGasMeter(roomInfo.getGasMeter());
         roomsService.updateById(room);
         bkRoom.setRoomStatus(RoomStatusEnum.LIVE_DIRTY.getKey());
         bookingRoomsService.updateById(bkRoom);
@@ -1134,7 +1156,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         //<editor-fold desc="todo:账单相关">
 //        if(bookingLiving != null && bookingLiving) {
 
-        feeService.addBillFee(livingOrder, room,longRentScheme,livingRoomDayPrices);
+        feeService.addBillFee(livingOrder, room,roomInfo.getLongRentScheme(),livingRoomDayPrices);
 
 //        }
 
@@ -1144,8 +1166,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             throw new JeecgBootException("未找到超时收费规则");
         }
         if (ObjectUtil.equals(LivingTypeEnum.ALL_DAY.getKey(), livingOrder.getLivingType())){
-            Calendar calendar = getRemindTime(livingOrder, cesAllDayPriceRule, livingRoomOrderInfo.getBookingType());
-            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+            Calendar calendar = getRemindTime(livingOrder, cesAllDayPriceRule, roomInfo.getRoomOrderInfo().getBookingType());
             redisTemplate.opsForZSet().add("overTimerOrder", livingOrder.getId(), calendar.getTimeInMillis());
         } else if (ObjectUtil.equals(LivingTypeEnum.HOURS_RENT.getKey(), livingOrder.getLivingType())){
             Calendar calendar = Calendar.getInstance();
@@ -1156,7 +1177,22 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         } else if(ObjectUtil.equals(LivingTypeEnum.LONG_RENT.getKey(), livingOrder.getLivingType())){
             Calendar calendar = Calendar.getInstance();
             calendar.setTime(livingOrder.getDueOutTime());
-            calendar.add(Calendar.DAY_OF_YEAR, -15);
+            calendar.add(Calendar.DAY_OF_YEAR, -7);
+            if (CollUtil.isEmpty(roomInfo.getLongRentScheme().getHouseLongRentChargeList())){
+                throw new JeecgBootException("未找到长租房收费项");
+            }
+            Optional<CesHouseLongRentCharge> chargeOptional = roomInfo.getLongRentScheme().getHouseLongRentChargeList().stream().filter(e -> e.getChargeType() == 2 && e.getIsMust()).findFirst();
+            if (!chargeOptional.isPresent()){
+                throw new JeecgBootException("未找到房租费项");
+            }
+            Integer cycle = chargeOptional.get().getNum();
+            Calendar nextCalendar = Calendar.getInstance();
+            nextCalendar.setTime(livingOrder.getArrivalTime());
+            calendar.setTime(livingOrder.getArrivalTime());
+            calendar.add(Calendar.MONTH, cycle);
+
+            log.info(DateUtil.format(calendar.getTime(),"yyyy-MM-dd"));
+            redisTemplate.opsForZSet().add("overTimerOrder", livingOrder.getId(), calendar.getTimeInMillis());
             redisTemplate.opsForZSet().add("sys:cache:message:willEndOrder", livingOrder.getId(), calendar.getTimeInMillis());
         }
         roomsService.getReserveRoom();
@@ -1183,8 +1219,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         }
         return calendar;
     }
-    @Resource
-    private SysBaseApiImpl sysBaseAPI;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String customerLiving(BookingOrderSaveDto livingData, Boolean isTeam, String hotelId) {
@@ -1258,8 +1293,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         List<BusLivingLayoutDayPrice> livingLayoutDayPrices = !livingOrderIds.isEmpty() ? livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
         .in("living_order_id",livingOrderIds)):new ArrayList<>();
         Map<String, List<BusLivingLayoutDayPrice>> livingDayPriceMap = livingLayoutDayPrices.stream().collect(Collectors.groupingBy(BusLivingLayoutDayPrice::getLivingOrderId));
-
-
+        List<CesHouseLongRentCharge> houseLongRentCharges = houseLongRentChargeService.list(Wrappers.<CesHouseLongRentCharge>lambdaQuery().in(CesHouseLongRentCharge::getLivingOrderId, livingOrderIds));
         List<BusTeam> teamOrders_all = teamService.list(Wrappers.<BusTeam>lambdaQuery().eq(BusTeam::getIsDelete, 0));
         List<String> booingIds = teamOrders_all.stream().map(BusTeam::getBookingOrderId).collect(Collectors.toList());
 //        List<BusBookingRooms> bookingRoomsList = bookingRoomsService.bookingRoomsDetail(Wrappers.<BusBookingRooms>lambdaQuery().in(BusBookingRooms::getBookingOrdersId, booingIds));
@@ -1334,6 +1368,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
 //                 vo.getLivingData().setPrice(
 //                         livingLayoutDayPrices.stream().filter(a->a.getLivingOrderId().equals(opLivingOrder.get().getId())).collect(Collectors.toList()));
                  vo.getLivingData().setPrice(livingDayPriceMap.get(opLivingOrder.get().getId()));
+                 List<CesHouseLongRentCharge> charges = houseLongRentCharges.stream().filter(charge -> livingOrder.getId().equals(charge.getLivingOrderId())).collect(Collectors.toList());
+                 vo.getLivingData().setLongRentChargeList(charges);
              }
             roomVos.add(vo);
         });
@@ -1393,6 +1429,17 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 queryWrapper.eq(BusOrderFee::getPreferentialStatus, 1);
             }
             List<BusOrderFee> orderFees = feeService.list(queryWrapper);
+            List<String> readMeterFeeIds = orderFees.stream().filter(e -> ObjectUtil.equals(
+                    e.getSubjectType(), FeeSubjectType.SHUI_DIAN_MEI.getKey())).map(BusOrderFee::getId).collect(Collectors.toList());
+            List<CesHouseLongRentMeterLog> longRentMeterLogs;
+            if (!readMeterFeeIds.isEmpty()){
+                // 水电燃气读表日志
+                longRentMeterLogs = houseLongRentMeterLogService.list(Wrappers
+                        .<CesHouseLongRentMeterLog>lambdaQuery().in(CesHouseLongRentMeterLog::getOrderFeeId, readMeterFeeIds));
+            } else {
+                longRentMeterLogs = new ArrayList<>();
+            }
+
             List<BusOrderFee> strikeBalanceFees = orderFees.stream().filter(e -> e.getReturnItem() && FeeType.CONSUME.getKey()
                     .equals(e.getFeeType())).collect(Collectors.toList());
             // 最终返回费用。当费用是商品消费时找出商品。消费的费用 需要处理掉 冲账的费用
@@ -1412,6 +1459,10 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                         Optional<BusOrderFeeGoodsVo> busOrderFeeGoodsVo = busOrderFeeGoodVos.stream()
                                 .filter(orderFeeGoodVo -> StrUtil.equals(orderFeeGoodVo.getOrderFeeId(), e.getId())).findFirst();
                         busOrderFeeGoodsVo.ifPresent(e::setFeeGoodVo);
+                    } else if (FeeSubjectType.SHUI_DIAN_MEI.getKey().equals(e.getSubjectType())){
+                        Optional<CesHouseLongRentMeterLog> houseLongRentMeterLogs = longRentMeterLogs.stream()
+                                .filter(meterLog -> StrUtil.equals(meterLog.getOrderFeeId(), e.getId())).findFirst();
+                        houseLongRentMeterLogs.ifPresent(e::setLongRentMeterLog);
                     }
                     orderFeeList.add(e);
                 }
@@ -1510,94 +1561,6 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
     }
 
 
-    @Override
-    public Boolean syncDayRoomOrder(String hotelId) {
-        List<CesRooms> hotelRooms = roomsService.list(Wrappers.<CesRooms>query().eq("hotel_id",hotelId).eq("invalid",false));
-        List<CesRooms> inLiveRooms = hotelRooms.stream().filter(s->s.getLivingOrderId() != null && !s.getLivingOrderId().isEmpty()
-                && (s.getRoomStatus().equals(RoomStatusEnum.LIVE_DIRTY.getKey()) || s.getRoomStatus().equals(RoomStatusEnum.LIVE_CLEAR.getKey()))).collect(Collectors.toList());
-        List<String> livingOrderIds = inLiveRooms.stream().map(s->s.getLivingOrderId()).collect(Collectors.toList());
-        List<BusRoomsLivingOrder> livingOrders = roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>query()
-                .in("id",livingOrderIds));
-        List<CesAllDayPriceRule> allDayPriceRules = allDayPriceRuleService.list();
-        Optional<CesAllDayPriceRule> opAllPrice = allDayPriceRules.stream().filter(a->a.getHotelId().equals(hotelId)).findFirst();
-        CesAllDayPriceRule allPrice;
-        if(!opAllPrice.isPresent()) {
-            allPrice = new CesAllDayPriceRule();
-            allPrice.setEndTime("16:00");
-        } else {
-            allPrice = opAllPrice.get();
-        }
-        livingOrders.forEach(s->{
-            try {
-                Date dueDate = DateUtils.parseDate(DateUtils.formatDate(s.getDueOutTime()),"yyyy-MM-dd");
-                Date currDate = DateUtils.parseDate(DateUtils.formatDate(new Date()),"yyyy-MM-dd");
-                if(dueDate.getTime() < currDate.getTime()){
-                    BusBookingRooms br = bookingRoomsService.getOne(Wrappers.<BusBookingRooms>query()
-                            .eq("id",s.getBookingRoomId()));
-                    if(br == null) return;
-                    CesRooms room =  roomsService.getById(br.getRoomId());
-                    if(room == null) return;
-                    CesRoomLayout layout = layoutService.getById(room.getLayoutId());
-                    if(layout == null) return;
-                    Date date = s.getDueOutTime();
-                    Calendar calendar = new GregorianCalendar();
-                    calendar.setTime(date);
-                    calendar.add(Calendar.DATE,1);
-                    s.setDueOutTime(calendar.getTime());
-                    roomsLivingOrderService.updateById(s);// 更新订单
-                    BusOrderFee dayOrderFee = new BusOrderFee();
-                    dayOrderFee.setDayTime(date);
-                    dayOrderFee.setCreateTime(new Date());
-
-                    dayOrderFee.setFeeType(1);
-                    dayOrderFee.setSubjectType(FeeSubjectType.MEI_RI_FANG_FEI.getKey());
-
-                    List<BusLivingLayoutDayPrice> dayPrices = livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
-                            .eq("living_order_id",s.getId()));
-                    Optional<BusLivingLayoutDayPrice> opPrice = dayPrices.stream().filter(a-> DateUtils.formatDate(a.getDayTime()).equals(s)).findFirst();
-                    if(!opPrice.isPresent()){
-                        BusLivingLayoutDayPrice nPrice = new BusLivingLayoutDayPrice();
-                        nPrice.setBookingRoomId(s.getBookingRoomId());
-                        try {
-                            nPrice.setDayTime(DateUtils.parseDate(DateUtils.formatDate(new Date()),"yyyy-MM-dd"));
-                        } catch (ParseException e) {
-                            e.printStackTrace();
-                        }
-                        nPrice.setRoomId(br.getRoomId());
-                        nPrice.setRoomLayoutId(room.getLayoutId());
-                        nPrice.setPrice(layout.getMarketPrice());
-                        nPrice.setLivingOrderId(s.getId());
-                        nPrice.setLivingType(s.getLivingType());
-                        livingLayoutDayPriceService.save(nPrice);
-                    }
-                    CesRooms orderRoom = inLiveRooms.stream().filter(a->a.getLivingOrderId().equals(s.getId())).findFirst().get();
-                    BigDecimal money = new BigDecimal(0);
-
-                    if(opPrice.isPresent()) {
-                        money = opPrice.get().getPrice();
-                    } else {
-                        money = layout.getMarketPrice();
-                    }
-
-                    dayOrderFee.setMoney(money);
-                    dayOrderFee.setRoomId(orderRoom.getId());
-                    String roomName = orderRoom.getPrefix() != null?orderRoom.getPrefix():"";
-                    roomName += roomName + orderRoom.getName();
-                    dayOrderFee.setRemark("【"+roomName + "】 "+ DateUtils.formatDate(date) + " 当日房费");
-                    dayOrderFee.setLivingOrderId(s.getId());
-                    dayOrderFee.setHotelId(hotelId);
-                    feeService.save(dayOrderFee);
-                }
-            } catch (ParseException e) {
-                e.printStackTrace();
-            }
-
-
-        });
-        return null;
-    }
-
-
     public Boolean syncRoomOverTimeOrder(String hotelId) {
         // 查询出当前时间内需要处理的超时订单
         Set<Object> set = redisTemplate.opsForZSet().rangeByScore("overTimerOrder", 0, Calendar.getInstance().getTimeInMillis());
@@ -1636,11 +1599,75 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 // 钟点房
             } else if(ObjectUtil.equals(2,optional.get().getBookingType())){
                 addHourFee(cesHourRoomRuleList, e, cesAllDayPriceRule);
+            } else if(ObjectUtil.equals(5,optional.get().getBookingType())) {
+                addLongRentFee(e);
             }
         });
         return null;
     }
 
+    public void addLongRentFee(BusRoomsLivingOrder livingOrder) {
+        BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
+        if (ObjectUtil.isEmpty(bookingroom)){
+            log.info("未找到订单{}对应的房间", livingOrder.getId());
+            return;
+        }
+        CesRooms room = roomsService.getById(bookingroom.getRoomId());
+        List<CesHouseLongRentCharge> list = houseLongRentChargeService.list(Wrappers.<CesHouseLongRentCharge>
+                lambdaQuery().eq(CesHouseLongRentCharge::getLivingOrderId, livingOrder.getId())
+                .eq(CesHouseLongRentCharge::getChargeType, ChargeTypeEnum.PERIODICITY.getKey()));
+        if (list.isEmpty()){
+            return;
+        }
+        Integer cycle = list.get(0).getNum();
+        List<BusOrderFee> orderFees = new ArrayList<>();
+        Calendar nowCalendar = Calendar.getInstance();
+        Calendar arriveCalendar = Calendar.getInstance();
+        arriveCalendar.setTime(livingOrder.getArrivalTime());
+        int year = nowCalendar.get(Calendar.YEAR) - arriveCalendar.get(Calendar.YEAR);
+        int month = nowCalendar.get(Calendar.MONTH) - arriveCalendar.get(Calendar.MONTH);
+        // 当前与入住时相距月份
+        int monthDiffer = year * 12 + month;
+        Calendar dueOutCalendar = Calendar.getInstance();
+        dueOutCalendar.setTime(livingOrder.getDueOutTime());
+        int allYear = dueOutCalendar.get(Calendar.YEAR) - arriveCalendar.get(Calendar.YEAR);
+        int allMonth = dueOutCalendar.get(Calendar.MONTH) - arriveCalendar.get(Calendar.MONTH);
+        // 总入住月份
+        int allMonthDiffer = allYear * 12 + allMonth;
+        if (monthDiffer >= allMonthDiffer){
+            return;
+        }
+        // 下一次收费月份
+        arriveCalendar.set(Calendar.YEAR, nowCalendar.get(Calendar.YEAR));
+        arriveCalendar.set(Calendar.MONTH, nowCalendar.get(Calendar.MONTH));
+        Integer nextMonthNum = allMonthDiffer - monthDiffer < cycle ? allMonthDiffer - monthDiffer : cycle;
+        arriveCalendar.add(Calendar.MONTH, nextMonthNum);
+        list.forEach(e -> {
+            BusOrderFee dayOrderFee = new BusOrderFee();
+            dayOrderFee.setDayTime(new Date());
+            dayOrderFee.setCreateTime(new Date());
+            dayOrderFee.setRemark(e.getName());
+            String roomName = room.getPrefix() != null? room.getPrefix():"";
+            roomName += roomName + room.getName();
+            dayOrderFee.setMoney(e.getMoney());
+            dayOrderFee.setSubjectType(FeeSubjectType.OTHER.getKey());
+            dayOrderFee.setMoney(e.getMoney().multiply(BigDecimal.valueOf(nextMonthNum)));
+            if (e.getIsMust() != null && e.getIsMust()){
+                dayOrderFee.setSubjectType(FeeSubjectType.MEI_RI_FANG_FEI.getKey());
+                dayOrderFee.setRemark(DateUtil.format(new Date(), "yyyy-MM") + e.getName());
+            }
+            dayOrderFee.setFeeType(1);
+            dayOrderFee.setRoomId(room.getId());
+            dayOrderFee.setLivingOrderId(livingOrder.getId());
+            dayOrderFee.setHotelId(room.getHotelId());
+            orderFees.add(dayOrderFee);
+        });
+        feeService.saveBatch(orderFees);
+        redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
+        redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(), arriveCalendar.getTimeInMillis());
+    }
+
+
     private void addHourFee(List<CesHourRoomRule> cesHourRoomRuleList, BusRoomsLivingOrder livingOrder, CesAllDayPriceRule cesAllDayPriceRule) {
         // TODO: 2023/10/24 钟点房超时收费
         Optional<CesHourRoomRule> ruleOptional = cesHourRoomRuleList.stream().filter(rule -> rule.getId().equals(livingOrder.getHourRoomId())).findFirst();
@@ -1658,8 +1685,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 return;
             }
             BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
+            // 转为全天房
             if (rule.getLimitTimeTransferAllDay() != 0 && overMinutes > rule.getLimitTimeTransferAllDay()){
-                // 转为全天房
                 Date arrivalTime = livingOrder.getArrivalTime();
                 Calendar arrivalCalendar = Calendar.getInstance();
                 arrivalCalendar.setTime(arrivalTime);
@@ -1672,8 +1699,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 Calendar enterCalendar = Calendar.getInstance();
                 DateTime enterTime = DateUtil.parse(cesAllDayPriceRule.getEnterTime(), "HH:mm");
                 enterCalendar.setTime(enterTime);
-                if (arrivalCalendar.get(Calendar.HOUR) > enterCalendar.get(Calendar.HOUR)
-                        || arrivalCalendar.get(Calendar.HOUR) == enterCalendar.get(Calendar.HOUR)
+                if (arrivalCalendar.get(Calendar.HOUR_OF_DAY) > enterCalendar.get(Calendar.HOUR_OF_DAY)
+                        || arrivalCalendar.get(Calendar.HOUR_OF_DAY) == enterCalendar.get(Calendar.HOUR_OF_DAY)
                         && arrivalCalendar.get(Calendar.MINUTE) > enterCalendar.get(Calendar.MINUTE)){
                     // 如果预抵时间在enterTime后面 则预离时间为隔天
                     leaveCalendar.add(Calendar.DAY_OF_YEAR, 1);
@@ -2362,8 +2389,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         return roomLivings;
     }
     @Override
-    public IPage<KeLiItemVo> getLivingOrderKL(Integer status,String keyw,String hotelId,String thirdUserId, Page<KeLiItemVo> page, Date startTime,Date endTime) {
-        IPage<KeLiItemVo> pRes = baseMapper.getKeLiLiving(page,thirdUserId,hotelId,keyw,status,startTime,endTime);
+    public IPage<KeLiItemVo> getLivingOrderKL(Integer status,String keyw,String hotelId,String thirdUserId,String layoutId,String customerType, Page<KeLiItemVo> page, Date startTime,Date endTime) {
+        IPage<KeLiItemVo> pRes = baseMapper.getKeLiLiving(page,thirdUserId,hotelId,keyw,status, layoutId,customerType, startTime,endTime);
         List<String> livingIds = pRes.getRecords().stream().map(s->s.getId()).collect(Collectors.toList());
         List<BusLivingLayoutDayPrice> prices = livingIds.size() >0? livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
         .in("living_order_id",livingIds).orderByAsc("day_time")) : new ArrayList<>();
@@ -2471,7 +2498,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         livingCustomer.setId(null);
         livingCustomer.setLivingOrderId(null);
         customers.add(livingCustomer);
-        String livingOrderId = bookingToLive(bookingRooms.getId(), customers,hotelId,null,null, null,null);
+        String livingOrderId = bookingToLive(bookingRooms.getId(), customers,hotelId,null, null,null);
 
         return true;
     }
@@ -3271,7 +3298,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             if(customers == null || customers.isEmpty()) throw new JeecgBootException("请添加客户信息");
 
             // 保存入住单,修改房间状态
-            String livingOrderId = bookingToLive(bkRoom.getId(), customers,hotelId,null, bkRoomItem.getRoomOrderInfo(),bkRoomItem.getLongRentScheme(), livingData.getLivingRoomDayPrices());
+            String livingOrderId = bookingToLive(bkRoom.getId(), customers,hotelId,null, bkRoomItem, livingData.getLivingRoomDayPrices());
             // 将预约时交的押金,放到主房
             if (bkRoom.getIsMain()){
                 LambdaUpdateWrapper<BusOrderFee> updateWrapper = new LambdaUpdateWrapper<>();
@@ -3774,5 +3801,31 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         });
     }
 
+    @Override
+    public void overTimerBooking(String hotelId) {
+        Set<Object> set = redisTemplate.opsForZSet().rangeByScore("sys:cache:order:overTimerBooking", 0, Calendar.getInstance().getTimeInMillis());
+        if (CollUtil.isEmpty(set)){
+            return;
+        }
+        List<BusRoomBookingOrders> bookingOrders = list(Wrappers.<BusRoomBookingOrders>lambdaQuery().in(BusRoomBookingOrders::getId, set)
+                .eq(BusRoomBookingOrders::getBookingStatus, BookingStatusTypeEnum.NORMAL.getKey()).eq(BusRoomBookingOrders::getHotelId, hotelId));
+        List<String> bookingIds = bookingOrders.stream().map(BusRoomBookingOrders::getId).collect(Collectors.toList());
+        if (bookingIds.isEmpty()){
+            return;
+        }
+        List<BusBookingRooms> bookingRoomsList = bookingRoomsService.list(Wrappers.<BusBookingRooms>lambdaQuery().in(BusBookingRooms::getBookingOrdersId, bookingIds));
+        Set<String> roomIds = bookingRoomsList.stream().map(BusBookingRooms::getRoomId).collect(Collectors.toSet());
+        if (!roomIds.isEmpty()){
+            List<CesRooms> cesRoomList = roomsService.list(Wrappers.<CesRooms>lambdaQuery().in(CesRooms::getId, roomIds).eq(CesRooms::getRoomStatus, RoomStatusEnum.RESERVE.getKey()));
+            cesRoomList.forEach(e -> e.setRoomStatus(e.getLastRoomStatus()));
+            roomsService.updateBatchById(cesRoomList);
+        }
+        bookingOrders.forEach(e -> {
+            e.setBookingStatus(BookingStatusTypeEnum.INVALID.getKey());
+            redisTemplate.opsForZSet().remove("sys:cache:order:overTimerBooking", e.getId());
+        });
+        updateBatchById(bookingOrders);
+    }
+
 
 }

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

@@ -3,6 +3,7 @@ package org.jeecg.modules.business.vo;
 import lombok.Data;
 import org.jeecg.modules.business.entity.BusBookingLayoutDayPrice;
 import org.jeecg.modules.business.entity.BusLivingLayoutDayPrice;
+import org.jeecgframework.poi.excel.annotation.Excel;
 
 import java.math.BigDecimal;
 import java.util.Date;
@@ -12,22 +13,42 @@ import java.util.List;
 public class KeLiItemVo {
     private String id;
     private String layoutId;
+    @Excel(name = "单号", width = 15)
     private String orderNo;
     private String bookingOrderId;
+    private String livingId;
     private String roomId;
+    @Excel(name = "客户名", width = 15)
     private String customerName;
     private Integer settleType;
+    @Excel(name = "电话", width = 15)
     private String customerPhone;
     private Integer customerType;
     private Integer oType;
+    private Integer bookingStatus;
+    @Excel(name = "房型", width = 15)
     private String layoutName;
+    @Excel(name = "房间号", width = 15)
     private String roomName;
+    @Excel(name = "预抵时间", width = 15,format = "yyyy-MM-dd HH:mm")
     private Date arrivalTime;
+    @Excel(name = "预离时间", width = 15,format = "yyyy-MM-dd HH:mm")
     private Date dueOutTime;
     private Integer isLiving;
     private Integer status;
+    @Excel(name = "收款合计", width = 15)
     private BigDecimal yushou;
+    @Excel(name = "余额", width = 15)
     private BigDecimal yuE;
     private List<BusLivingLayoutDayPrice> livingDayPrices;
     private List<BusBookingLayoutDayPrice> bookingDayPrices;
+
+    @Excel(name = "状态", width = 15)
+    private String statusText;
+    @Excel(name = "客户类型", width = 15)
+    private String customerTypeText;
+    @Excel(name = "入住类型", width = 15)
+    private String oTypeText;
+    @Excel(name = "消费", width = 15)
+    private BigDecimal consumerText;
 }

+ 1 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/LivingRoomOrderFeeJob.java

@@ -35,10 +35,9 @@ public class LivingRoomOrderFeeJob implements Job {
         Runnable runnable = () -> bookingOrdersService.syncRoomOverTimeOrder(parameter);
         Thread thread = new Thread(runnable);
         thread.start();
-
+        bookingOrdersService.overTimerBooking(parameter);
         fwLivingJxService.addJxMess(parameter);
 
         bookingOrdersService.addWillLeaveMess(parameter);
-//        bookingOrdersService.syncDayRoomOrder(parameter);
     }
 }

+ 52 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/Enum/ReadTypeEnum.java

@@ -0,0 +1,52 @@
+package org.jeecg.modules.rooms.Enum;
+
+import org.jeecg.common.system.vo.DictModel;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public enum ReadTypeEnum {
+    WATER(1,"水费"),
+    ELECTRIC(2,"电费"),
+    GAS(3,"燃气费");
+    Integer key;
+
+    String title;
+
+    ReadTypeEnum(Integer key, String title){
+        this.key = key;
+        this.title = title;
+    }
+    public Integer getKey() {
+        return key;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    /**
+     * 获取字典数据
+     * @return
+     */
+    public static List<DictModel> getDictList(){
+        List<DictModel> list = new ArrayList<>();
+        DictModel dictModel = null;
+        for(ReadTypeEnum e: ReadTypeEnum.values()){
+            dictModel = new DictModel();
+            dictModel.setValue(e.key.toString());
+            dictModel.setText(e.title);
+            list.add(dictModel);
+        }
+        return list;
+    }
+
+    public static ReadTypeEnum val(Integer key){
+        for(ReadTypeEnum bld: values()){
+            if(bld.key .equals(key)){
+                return bld;
+            }
+        }
+        return null;
+    }
+}

+ 2 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/Vo/LivingRealtimeVo.java

@@ -5,6 +5,7 @@ import org.jeecg.modules.business.entity.BusCustomer;
 import org.jeecg.modules.business.entity.BusLivingCustomer;
 import org.jeecg.modules.business.entity.BusLivingLayoutDayPrice;
 import org.jeecg.modules.business.entity.BusRoomsLivingOrder;
+import org.jeecg.modules.rooms.entity.CesHouseLongRentCharge;
 
 import java.util.List;
 
@@ -14,4 +15,5 @@ public class LivingRealtimeVo {
     private BusLivingCustomer livingCustomers;
     private BusCustomer customer;
     private List<BusLivingLayoutDayPrice> price;
+    private List<CesHouseLongRentCharge> longRentChargeList;
 }

+ 35 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/controller/CesHouseLongRentChargesController.java

@@ -1,4 +1,38 @@
 package org.jeecg.modules.rooms.controller;
 
-public class CesHouseLongRentChargesController {
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+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.system.base.controller.JeecgController;
+import org.jeecg.modules.rooms.entity.CesHouseLongRentCharge;
+import org.jeecg.modules.rooms.entity.CesHouseLongRentScheme;
+import org.jeecg.modules.rooms.service.ICesHouseLongRentChargeService;
+import org.jeecg.modules.rooms.service.ICesHouseLongRentSchemeService;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequestMapping("/rooms/houseLongRentCharges")
+@Api(tags = "ces_house_long_rent_charge")
+@Slf4j
+public class CesHouseLongRentChargesController  extends JeecgController<CesHouseLongRentCharge, ICesHouseLongRentChargeService> {
+
+    /**
+     * 获取长租订单费项
+     */
+    @AutoLog(value = "获取长租订单费项")
+    @ApiOperation(value="获取长租订单费项", notes="getMeterCharge")
+    @GetMapping("/getMeterCharge")
+    public Result<List<CesHouseLongRentCharge>> getMeterCharge(String livingOrderId) {
+        List<CesHouseLongRentCharge> houseLongRentChargeList = service.list(Wrappers.<CesHouseLongRentCharge>lambdaQuery()
+                .eq(CesHouseLongRentCharge::getLivingOrderId, livingOrderId));
+        return Result.ok(houseLongRentChargeList);
+    }
+
 }

+ 13 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/controller/CesHouseLongRentMeterLogController.java

@@ -0,0 +1,13 @@
+package org.jeecg.modules.rooms.controller;
+
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/rooms/houseLongRentMeterLog")
+@Api(tags = "ces_house_long_rent_meter_log")
+@Slf4j
+public class CesHouseLongRentMeterLogController {
+}

+ 0 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/controller/CesHousePriceSchemeController.java

@@ -166,9 +166,6 @@ public class CesHousePriceSchemeController extends JeecgController<CesHousePrice
 //        if (null==dto.getSort()||1>dto.getSort().intValue()){
 //            return Result.error("排序不能为空且不能小于1!");
 //        }
-        if(CustomerTypeEnum.val(dto.getGuestType()) == null){
-            throw new JeecgBootException("客人类型不正确");
-        }
         try{
             return cesHousePriceSchemeService.create(dto);
         }catch (Exception e){

+ 13 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/controller/CesRoomsController.java

@@ -260,6 +260,19 @@ public class CesRoomsController {
         return Result.OK("",dictModels);
     }
 
+    /**
+     * 根据id查询房间
+     */
+    @AutoLog(value = "根据id查询房间")
+    @ApiOperation(value="根据id查询房间", notes="save")
+    @GetMapping(value = "/getRoomById")
+    public Result<CesRooms> getRoomById(String roomId){
+        CesRooms room = roomsService.getOne(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getId, roomId).eq(CesRooms::getInvalid, false));
+        if (room == null){
+            return Result.error("未找到房间");
+        }
+        return Result.ok(room);
+    }
 
     /**
      * 保存房间

+ 2 - 2
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/entity/CesHouseLongRentCharge.java

@@ -1,5 +1,6 @@
 package org.jeecg.modules.rooms.entity;
 
+import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
 import org.apache.poi.hpsf.Decimal;
@@ -50,6 +51,5 @@ public class CesHouseLongRentCharge {
     private Boolean isDepositCustom;
 
     /**读表*/
-    private Decimal meterRead;
-
+    private BigDecimal meterRead;
 }

+ 32 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/entity/CesHouseLongRentMeterLog.java

@@ -0,0 +1,32 @@
+package org.jeecg.modules.rooms.entity;
+
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+@TableName("ces_house_long_rent_meter_log")
+@Data
+public class CesHouseLongRentMeterLog {
+
+    private String id;
+    /** 账单id*/
+    private String orderFeeId;
+    /** 房间id*/
+    private String roomId;
+    /** 单价*/
+    private BigDecimal price;
+    /** 读表类型*/
+    private Integer readType;
+    /** 起始读数*/
+    private BigDecimal startRead;
+    /** 本期读数*/
+    private BigDecimal endRead;
+    /** 逻辑删除*/
+    private Boolean invalid;
+    /** 创建时间*/
+    private Date createTime;
+
+
+}

+ 4 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/entity/CesRooms.java

@@ -12,6 +12,7 @@ import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 import lombok.experimental.Accessors;
+import org.apache.poi.hpsf.Decimal;
 
 /**
  * <p>
@@ -133,13 +134,13 @@ public class CesRooms extends Model<CesRooms> {
     private Integer lastRoomStatus;
 
     @ApiModelProperty(value = "水表读数")
-    private Integer waterMeter;
+    private BigDecimal waterMeter;
 
     @ApiModelProperty(value = "电表读数")
-    private Integer energyMeter;
+    private BigDecimal energyMeter;
 
     @ApiModelProperty(value = "燃气读数")
-    private Integer gasMeter;
+    private BigDecimal gasMeter;
 
     public static final String ID = "id";
 

+ 7 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/mapper/CesHouseLongRentMeterLogMapper.java

@@ -0,0 +1,7 @@
+package org.jeecg.modules.rooms.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.rooms.entity.CesHouseLongRentMeterLog;
+
+public interface CesHouseLongRentMeterLogMapper extends BaseMapper<CesHouseLongRentMeterLog> {
+}

+ 6 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/mapper/xml/CesHouseLongRentMeterLogMapper.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.rooms.mapper.CesHousePriceSchemeMapper">
+
+
+</mapper>

+ 45 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/CesRoomLayoutServiceImpl.java

@@ -2,29 +2,38 @@ package org.jeecg.modules.rooms.service;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.bean.copier.CopyOptions;
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.constant.CommonConstant;
+import org.jeecg.common.exception.JeecgBootException;
+import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.CommonUtils;
 import org.jeecg.common.util.TokenUtils;
 import org.jeecg.modules.business.entity.BusHotel;
+import org.jeecg.modules.business.entity.BusHousePriceSchemeLayout;
+import org.jeecg.modules.business.service.IBusHousePriceSchemeLayoutService;
 import org.jeecg.modules.business.service.impl.BusHotelServiceImpl;
 import org.jeecg.modules.rooms.DTO.CesRoomLayoutDto;
 import org.jeecg.modules.rooms.DTO.CesRoomLayoutRemoveDto;
 import org.jeecg.modules.rooms.DTO.CesRoomLayoutSearchDto;
 import org.jeecg.modules.rooms.Vo.CesRoomLayoutVo;
+import org.jeecg.modules.rooms.entity.CesHousePriceScheme;
 import org.jeecg.modules.rooms.entity.CesRoomLayout;
 import org.jeecg.modules.rooms.mapper.CesRoomLayoutMapper;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
+import java.sql.Time;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -46,6 +55,11 @@ public class CesRoomLayoutServiceImpl extends ServiceImpl<CesRoomLayoutMapper, C
     @Resource
     private BusHotelServiceImpl busHotelService;
 
+    @Resource
+    CesHousePriceSchemeServiceImpl housePriceSchemeService;
+    @Resource
+    IBusHousePriceSchemeLayoutService housePriceSchemeLayoutService;
+
 
     /**
      * @Desc: 分页查询房型数据
@@ -128,6 +142,32 @@ public class CesRoomLayoutServiceImpl extends ServiceImpl<CesRoomLayoutMapper, C
         cesRoomLayout.setState(true);//默认启用
         cesRoomLayout.setInvalid(false);
         cesRoomLayoutMapper.insert(cesRoomLayout);
+
+        List<CesHousePriceScheme> housePriceSchemeList = housePriceSchemeService.list(Wrappers.<CesHousePriceScheme>lambdaQuery()
+                .eq(CesHousePriceScheme::getHotelId, cesRoomLayoutDto.getHotelId()).eq(CesHousePriceScheme::getInvalid, CommonConstant.DEL_FLAG_0));
+
+        List<BusHousePriceSchemeLayout> housePriceSchemeLayouts = new ArrayList<>();
+        if (CollUtil.isNotEmpty(housePriceSchemeList)) {
+            LoginUser user = TokenUtils.getAuthUser();
+            housePriceSchemeList.forEach(item -> {
+                BusHousePriceSchemeLayout housePriceSchemeLayout = new BusHousePriceSchemeLayout();
+                housePriceSchemeLayout.setTenantId(user.getRelTenantIds());
+                housePriceSchemeLayout.setHotelId(cesRoomLayout.getHotelId());
+                housePriceSchemeLayout.setSchemeId(item.getId());
+                housePriceSchemeLayout.setLayoutId(cesRoomLayout.getId());
+                housePriceSchemeLayout.setMoney(cesRoomLayout.getMarketPrice());
+                housePriceSchemeLayout.setBreakfastNumber(0);
+                housePriceSchemeLayout.setLunchNumber(0);
+                housePriceSchemeLayout.setDinnerNumber(0);
+                housePriceSchemeLayout.setDelFlag(CommonConstant.DEL_FLAG_0);
+                Time time = Time.valueOf("15:00:00");
+                housePriceSchemeLayout.setDepartureTime(time);
+                housePriceSchemeLayouts.add(housePriceSchemeLayout);
+            });
+            housePriceSchemeLayoutService.saveBatch(housePriceSchemeLayouts);
+        }
+
+
         return Result.OK("操作成功!");
     }
 
@@ -160,6 +200,9 @@ public class CesRoomLayoutServiceImpl extends ServiceImpl<CesRoomLayoutMapper, C
      */
     @Transactional(rollbackFor = Exception.class)
     public Result removeRoomLayout(CesRoomLayoutRemoveDto roomLayoutDto){
+        if (roomLayoutDto.getRoomLayoutIds().isEmpty()){
+            throw new JeecgBootException("请选择房型");
+        }
         QueryWrapper<CesRoomLayout> queryWrapper = new QueryWrapper<>();
         queryWrapper.in(CesRoomLayout.ID, roomLayoutDto.getRoomLayoutIds());
         queryWrapper.eq(CesRoomLayout.TENANT_ID, TokenUtils.currentTenantId());
@@ -173,6 +216,8 @@ public class CesRoomLayoutServiceImpl extends ServiceImpl<CesRoomLayoutMapper, C
             v.setUpdateAt(LocalDateTime.now());
         });
         saveOrUpdateBatch(roomLayouts);
+        housePriceSchemeLayoutService.update(Wrappers.<BusHousePriceSchemeLayout>lambdaUpdate()
+                .in(BusHousePriceSchemeLayout::getLayoutId, roomLayoutDto.getRoomLayoutIds()).set(BusHousePriceSchemeLayout::getDelFlag, CommonConstant.DEL_FLAG_1));
         return Result.ok("删除成功!");
     }
 

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

@@ -499,7 +499,7 @@ public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> i
         } else {
             bookingRoomIds = new HashSet<>();
         }
-        List<String> idList = ids.stream().filter(e -> !bookingRoomIds.contains(e)).collect(Collectors.toList());
+        List<String> idList = ids.stream().filter(bookingRoomIds::contains).collect(Collectors.toList());
         UpdateWrapper<CesRooms> updateWrapper = new UpdateWrapper<>();
         if (idList.isEmpty()){
             return true;

+ 7 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/ICesHouseLongRentMeterLogService.java

@@ -0,0 +1,7 @@
+package org.jeecg.modules.rooms.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.rooms.entity.CesHouseLongRentMeterLog;
+
+public interface ICesHouseLongRentMeterLogService extends IService<CesHouseLongRentMeterLog> {
+}

+ 11 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/impl/CesHouseLongRentMeterLogServiceImpl.java

@@ -0,0 +1,11 @@
+package org.jeecg.modules.rooms.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.rooms.entity.CesHouseLongRentMeterLog;
+import org.jeecg.modules.rooms.mapper.CesHouseLongRentMeterLogMapper;
+import org.jeecg.modules.rooms.service.ICesHouseLongRentMeterLogService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class CesHouseLongRentMeterLogServiceImpl extends ServiceImpl<CesHouseLongRentMeterLogMapper, CesHouseLongRentMeterLog> implements ICesHouseLongRentMeterLogService {
+}