Browse Source

修改文档问题

许智捷 2 years ago
parent
commit
b1c6ce3cfd
23 changed files with 541 additions and 269 deletions
  1. 39 35
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusHotelController.java
  2. 1 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusHousePriceSchemeLayoutController.java
  3. 1 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusOrderFeeController.java
  4. 6 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/dto/BookingLayoutRoomsDto.java
  5. 2 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/BusOrderFee.java
  6. 35 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/enums/LivingTypeEnum.java
  7. 3 4
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/BusRoomBookingOrdersMapper.java
  8. 11 12
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/BusRoomBookingOrdersMapper.xml
  9. 2 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IBusRoomBookingOrdersService.java
  10. 3 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IBusSchemeLayoutDailyPriceService.java
  11. 23 26
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusOrderFeeServiceImpl.java
  12. 235 126
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusRoomBookingOrdersServiceImpl.java
  13. 88 6
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusSchemeLayoutDailyPriceServiceImpl.java
  14. 1 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/vo/KeLiItemVo.java
  15. 5 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/fw/controller/FwRoomCleanController.java
  16. 3 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/quartz/job/LivingRoomOrderFeeJob.java
  17. 14 51
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/controller/CesRoomsController.java
  18. 4 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/entity/CesHouseLongRentCharge.java
  19. 14 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/entity/CesRooms.java
  20. 15 3
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/CesRoomBuildingFloorServiceImpl.java
  21. 16 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/CesRoomsServiceImpl.java
  22. 11 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysAnnouncementController.java
  23. 9 4
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysAnnouncementSendController.java

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

@@ -1,58 +1,40 @@
 package org.jeecg.modules.business.controller;
 
-import java.math.BigDecimal;
-import java.text.ParseException;
-import java.util.*;
-import java.util.stream.Collectors;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.net.URLDecoder;
-import javax.annotation.Resource;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
+import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import org.apache.shiro.SecurityUtils;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
 import org.jeecg.common.constant.CommonConstant;
 import org.jeecg.common.exception.JeecgBootException;
+import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.common.system.query.QueryGenerator;
 import org.jeecg.common.system.util.JwtUtil;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.TokenUtils;
-import org.jeecg.common.util.oConvertUtils;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.metadata.IPage;
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import lombok.extern.slf4j.Slf4j;
-
-import org.jeecg.modules.base.service.BaseCommonService;
 import org.jeecg.modules.business.entity.*;
 import org.jeecg.modules.business.service.*;
-import org.jeecg.modules.business.service.impl.BusCancelServiceImpl;
 import org.jeecg.modules.business.util.MapUtil;
 import org.jeecg.modules.rooms.DTO.CesAllDayPriceRuleDto;
+import org.jeecg.modules.rooms.entity.CesHousePriceScheme;
 import org.jeecg.modules.rooms.service.CesAllDayPriceRuleServiceImpl;
+import org.jeecg.modules.rooms.service.CesHousePriceSchemeServiceImpl;
 import org.jeecg.modules.system.entity.SysTenant;
-import org.jeecg.modules.system.entity.SysUser;
 import org.jeecg.modules.system.service.ISysTenantService;
-import org.jeecgframework.poi.excel.ExcelImportUtil;
-import org.jeecgframework.poi.excel.def.NormalExcelConstants;
-import org.jeecgframework.poi.excel.entity.ExportParams;
-import org.jeecgframework.poi.excel.entity.ImportParams;
-import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
-import org.jeecg.common.system.base.controller.JeecgController;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
-import org.springframework.web.multipart.MultipartFile;
-import org.springframework.web.multipart.MultipartHttpServletRequest;
 import org.springframework.web.servlet.ModelAndView;
-import com.alibaba.fastjson.JSON;
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import org.jeecg.common.aspect.annotation.AutoLog;
-import org.apache.shiro.authz.annotation.RequiresPermissions;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.math.BigDecimal;
+import java.util.*;
 
  /**
  * @Description: bus_hotel
@@ -109,6 +91,8 @@ public class BusHotelController extends JeecgController<BusHotel, IBusHotelServi
 	 private IBusParamXcxRoomService busParamXcxRoomService;
 	 @Resource
 	 CesAllDayPriceRuleServiceImpl cesAllDayPriceRuleService;
+	 @Resource
+	 CesHousePriceSchemeServiceImpl housePriceSchemeService;
 
 	/**
 	 * 分页列表查询
@@ -509,7 +493,27 @@ public class BusHotelController extends JeecgController<BusHotel, IBusHotelServi
 		cesAllDayPriceRuleDto.setDayTime("30");
 		cesAllDayPriceRuleDto.setInvalid(false);
 		cesAllDayPriceRuleService.modifyWholeDayUnifyPrice(cesAllDayPriceRuleDto);
+
+		List<CesHousePriceScheme> priceSchemeList = new ArrayList<>(3);
+		CesHousePriceScheme priceScheme = new CesHousePriceScheme();
+		CesHousePriceScheme weekScheme = new CesHousePriceScheme();
+		CesHousePriceScheme holidayScheme = new CesHousePriceScheme();
+		priceSchemeList.add(priceScheme);
+		priceSchemeList.add(weekScheme);
+		priceSchemeList.add(holidayScheme);
+		priceScheme.setSchemeType(0);
+		priceScheme.setCheckInTime(0);
+		priceScheme.setValidTime(0);
+		priceScheme.setOpen(1);
+		priceScheme.setHotelId(busHotel.getId());
+		BeanUtil.copyProperties(priceScheme, weekScheme);
+		weekScheme.setSchemeType(1);
+		BeanUtil.copyProperties(priceScheme, holidayScheme);
+		weekScheme.setSchemeType(2);
+		housePriceSchemeService.saveBatch(priceSchemeList);
+
 		return Result.OK("添加成功!");
+
 	}
 
 	/**

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

@@ -194,6 +194,7 @@ public class BusHousePriceSchemeLayoutController extends JeecgController<BusHous
 		 return Result.OK(cesHousePriceSchemes);
 	 }
 
+
 	/**
 	 *   添加
 	 */

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

@@ -222,6 +222,7 @@ public class BusOrderFeeController extends JeecgController<BusOrderFee, IBusOrde
 	 public Result<List<BusOrderFee>> refundList(@RequestBody List<String> livingOrderIds) {
 		 LambdaQueryWrapper<BusOrderFee> qw = new LambdaQueryWrapper<>();
 		 qw.eq(BusOrderFee::getFeeType, FeeType.COLLECTION.getKey());
+		 qw.eq(BusOrderFee::getPreferentialStatus, 1);
 		 qw.in(CollUtil.isNotEmpty(livingOrderIds), BusOrderFee::getLivingOrderId, livingOrderIds);
 		 List<BusOrderFee> orderFees = busOrderFeeService.list(qw);
 		 return Result.OK(orderFees);

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

@@ -17,6 +17,12 @@ public class BookingLayoutRoomsDto {
     private String layoutId;
     @ApiModelProperty(value = "房间id,传入null/不传,表示未排房")
     private String roomId;
+    @ApiModelProperty(value = "水表读数")
+    private Integer waterMeter;
+    @ApiModelProperty(value = "电表读数")
+    private Integer energyMeter;
+    @ApiModelProperty(value = "燃气读数")
+    private Integer gasMeter;
     @ApiModelProperty(value = "是否主房")
     private Boolean isMain;
     @ApiModelProperty(value = "同住人信息")

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

@@ -146,6 +146,8 @@ public class BusOrderFee implements Serializable {
     private String bookingOrderId;
     @ApiModelProperty(value = "预定押金")
     private Boolean bookingYj;
+    @ApiModelProperty(value = "是超时费用")
+    private Boolean isOverTime;
 
 
     @ApiModelProperty(value = "每天价格")

+ 35 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/enums/LivingTypeEnum.java

@@ -0,0 +1,35 @@
+package org.jeecg.modules.business.enums;
+
+public enum LivingTypeEnum {
+
+//    1,全天;2时租;3自用;4免费;5长租
+    ALL_DAY(1,"全天"),
+    HOURS_RENT(2,"时租"),
+    PERSONAL(3,"自用"),
+    FREE(4,"免费"),
+    LONG_RENT(5,"长租");
+    Integer key;
+
+    String title;
+
+    LivingTypeEnum(Integer key, String title){
+        this.key = key;
+        this.title = title;
+    }
+    public Integer getKey() {
+        return key;
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public static LivingTypeEnum val(Integer key){
+        for(LivingTypeEnum team: values()){
+            if(team.key .equals(key)){
+                return team;
+            }
+        }
+        return null;
+    }
+}

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

@@ -87,13 +87,12 @@ public interface BusRoomBookingOrdersMapper extends BaseMapper<BusRoomBookingOrd
             "where bbr.id = #{bookingRoomId}) ")
     List<LivingContinueVo> findBookingOrderByRoom(String bookingRoomId, Date nowDate, Date dueOutTime);
 
-    @Select("<script>SELECT brbo.id,cr.name from bus_booking_rooms bbr \n" +
+    @Select("<script>SELECT brbo.id,cr.name,brbo.arrival_time, brbo.due_out_time  from bus_booking_rooms bbr \n" +
             "left join ces_rooms cr on cr.id = bbr.room_id \n" +
             "left Join bus_room_booking_orders brbo  on bbr.booking_orders_id = brbo.id\n" +
             "where \n" +
             "brbo.booking_status = 1 and bbr.room_status != 4\n" +
-            "AND (( brbo.arrival_time &lt;= #{startOf} AND brbo.due_out_time &gt;= #{startOf} ) \n" +
-            "OR ( brbo.arrival_time &lt;= #{endOf} AND brbo.due_out_time &gt;= #{endOf} )) \n" +
+            "AND brbo.arrival_time &lt;= #{endOf} AND brbo.due_out_time &gt;= #{startOf} \n" +
             "and cr.id in " +
             "<foreach collection='roomIds' item='id' open='(' separator=',' close=')'> " +
             "#{id} " +
@@ -104,7 +103,7 @@ public interface BusRoomBookingOrdersMapper extends BaseMapper<BusRoomBookingOrd
     @Select("select brlo.*, cr.name as room_name,cr.id as room_id, bc.name as customer_name, cr.layout_id \n" +
             "from bus_rooms_living_order brlo \n" +
             "inner join ces_rooms cr on cr.living_order_id = brlo.id \n" +
-            "inner join bus_customer bc on brlo.contact_id = bc.id " +
+            "left join bus_customer bc on brlo.contact_id = bc.id " +
             "where brlo.booking_order_id = #{ bookingOrderId } and brlo.hotel_id = #{ hotelId }")
     List<LivingContinueVo> getContinueOrder(String bookingOrderId, String hotelId);
 }

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

@@ -122,8 +122,7 @@ lo.booking_order_id
       and lo.settle_type != 1
 	AND l.invalid = 0
 	AND r.invalid = 0
-	and ((lo.arrival_time >= #{start} and lo.arrival_time &lt;=#{end}) or
-	 (lo.due_out_time >= #{start} and lo.due_out_time &lt;=#{end}))
+	AND lo.arrival_time &lt;=#{end} and lo.due_out_time &gt;= #{start}
     group by l.id,DATE_FORMAT(lo.due_out_time,'%Y-%m-%d'),lo.id,r.id
     UNION ALL
 
@@ -141,8 +140,7 @@ lo.booking_order_id
 --       and brlo.settle_type != 1
     AND l.invalid = 0
 	AND r.invalid = 0
-	and ((lo.arrival_time >= #{start} and lo.arrival_time &lt;=#{end}) or
-	 (lo.due_out_time >= #{start} and lo.due_out_time &lt;=#{end}))
+    AND lo.arrival_time &lt;=#{end} and lo.due_out_time &gt;= #{start}
     and br.id not in (
         select booking_room_id from bus_rooms_living_order
     )
@@ -191,8 +189,8 @@ lo.booking_order_id
             on cus.id = lo.contact_id
             where
             r.hotel_id = #{hotelId}
-            and ((lo.arrival_time >= #{start} and lo.arrival_time &lt;=#{end}) or
-	 (lo.due_out_time >= #{start} and lo.due_out_time &lt;=#{end}))
+
+            AND lo.arrival_time &lt;=#{end} and lo.due_out_time &gt;= #{start}
             GROUP BY lo.id,r.id
 
             union all
@@ -226,9 +224,7 @@ lo.booking_order_id
             on cus.id = lo.contact_id
             where
             r.hotel_id = #{hotelId}
-            and ((lo.arrival_time >= #{start} and lo.arrival_time &lt;=#{end}) or
-	 (lo.due_out_time >= #{start} and lo.due_out_time &lt;=#{end}))
-
+            AND lo.arrival_time &lt;=#{end} and lo.due_out_time &gt;= #{start}
             GROUP BY lo.id,r.id
 
 
@@ -317,10 +313,13 @@ lo.booking_order_id
         from bus_room_booking_orders o
         inner join bus_booking_rooms br
         on o.id = br.booking_orders_id
-        and br.id
         /*2为已入住,已入住的找得到入住单*/
-        <if test="status == 1 or  status == 3"> not </if>
-         in (select booking_room_id from bus_rooms_living_order)
+        <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>
         left join ces_rooms r
         on r.id = br.room_id and r.hotel_id = #{hotelId}
         left join ces_room_layout l

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

@@ -104,4 +104,6 @@ public interface IBusRoomBookingOrdersService extends IService<BusRoomBookingOrd
     Boolean payPortionFee(List<String> feeIds);
 
     List<LivingContinueVo> getContinueOrder(String livingOrderId, String hotelId);
+
+    void addWillLeaveMess(String parameter);
 }

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

@@ -1,8 +1,10 @@
 package org.jeecg.modules.business.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.business.entity.BusRoomsLivingOrder;
 import org.jeecg.modules.business.entity.BusSchemeLayoutDailyPrice;
 
+import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
 
@@ -16,4 +18,5 @@ public interface IBusSchemeLayoutDailyPriceService extends IService<BusSchemeLay
 
     List<BusSchemeLayoutDailyPrice> getDailyPrice(String schemeLayoutId, Date realDate);
 
+    BigDecimal getOneDayPrice(String roomLayoutId, BusRoomsLivingOrder livingOrder, Date date);
 }

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

@@ -349,40 +349,37 @@ public class BusOrderFeeServiceImpl extends ServiceImpl<BusOrderFeeMapper, BusOr
             dayOrderFee.setFeeType(1);
             dayOrderFee.setSubjectType(FeeSubjectType.MEI_RI_FANG_FEI.getKey());
             dayOrderFee.setRoomId(room.getId());
-            String roomName = room.getPrefix() != null? room.getPrefix():"";
-            roomName += roomName + room.getName();
-            dayOrderFee.setRemark("【"+roomName + "】 "+ DateUtils.formatDateTime() + " 当日房费");
+            dayOrderFee.setRemark(DateUtils.formatDate(new Date(), "MM-dd") +  " 房费");
             dayOrderFee.setLivingOrderId(livingOrder.getId());
             dayOrderFee.setHotelId(room.getHotelId());
             save(dayOrderFee);
         } else {
             longRentSchemeService.addLivingScheme(longRentScheme, livingOrder.getId());
             longRentScheme.getHouseLongRentChargeList().forEach(e -> {
-                if (!ChargeTypeEnum.DISPOSABLE.getKey().equals(e.getChargeType()) && !ChargeTypeEnum.PERIODICITY.getKey().equals(e.getChargeType())){
-                    return;
-                }
-                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());
-                if (e.getIsMust() != null && e.getIsMust()){
-                    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 {
-                        dayOrderFee.setSubjectType(FeeSubjectType.MEI_RI_FANG_FEI.getKey());
+                if (ChargeTypeEnum.DISPOSABLE.getKey().equals(e.getChargeType()) && !e.getIsMust() || ChargeTypeEnum.PERIODICITY.getKey().equals(e.getChargeType())){
+                    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());
+                    if (e.getIsMust() != null && e.getIsMust()){
+                        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 {
+                            dayOrderFee.setSubjectType(FeeSubjectType.MEI_RI_FANG_FEI.getKey());
+                        }
+                        dayOrderFee.setRemark("【"+roomName + "】 "+ DateUtils.formatDateTime() + e.getName());
                     }
-                    dayOrderFee.setRemark("【"+roomName + "】 "+ DateUtils.formatDateTime() + e.getName());
+                    dayOrderFee.setFeeType(1);
+                    dayOrderFee.setRoomId(room.getId());
+                    dayOrderFee.setLivingOrderId(livingOrder.getId());
+                    dayOrderFee.setHotelId(room.getHotelId());
+                    save(dayOrderFee);
                 }
-                dayOrderFee.setFeeType(1);
-                dayOrderFee.setRoomId(room.getId());
-                dayOrderFee.setLivingOrderId(livingOrder.getId());
-                dayOrderFee.setHotelId(room.getHotelId());
-                save(dayOrderFee);
             });
         }
 

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

@@ -1,6 +1,8 @@
 package org.jeecg.modules.business.service.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.lang.Snowflake;
 import cn.hutool.core.util.BooleanUtil;
 import cn.hutool.core.util.ObjectUtil;
@@ -16,6 +18,7 @@ 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;
@@ -29,10 +32,7 @@ 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.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.entity.*;
 import org.jeecg.modules.fw.service.IFwRoomCleanService;
 import org.jeecg.modules.fw.service.IFwRoomExamineService;
 import org.jeecg.modules.fw.service.IFwRoomLockService;
@@ -58,6 +58,7 @@ 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;
@@ -98,6 +99,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
     private IBusLivingLayoutDayPriceService livingLayoutDayPriceService;
 
     @Resource
+    IBusSchemeLayoutDailyPriceService schemeLayoutDailyPriceService;
+
+    @Resource
     private IBusTeamService teamService;
 
     @Resource
@@ -639,7 +643,6 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             if(!item.getOrderInfo().getBookingType().equals(CheckInTypeEnum.HOUR_TIME.getKey())) {
                 if(item.getOrderInfo().getDayCount() == null || item.getOrderInfo().getDayCount() <= 0)
                     throw new JeecgBootException("入住天数不能小于0");
-
             }
 
             if(item.getRoomIds() == null || item.getRoomIds().size() == 0)
@@ -654,9 +657,11 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             // todo 判定是否有安排冲突的房间
             List<String> roomIds = item.getRoomIds().stream().map(BusBookingRooms::getRoomId).collect(Collectors.toList());
             List<BusRoomBookingOrders> clashOrder = baseMapper.findBookingOrder(roomIds, item.getOrderInfo().getArrivalTime(), item.getOrderInfo().getDueOutTime());
-            long clashCount = clashOrder.stream().filter(e -> !StrUtil.equals(e.getId(), order.getId())).count();
-            if (clashCount > 0){
-                throw new JeecgBootException("房间预约有冲突");
+            List<BusRoomBookingOrders> endClashOrder = clashOrder.stream().filter(e -> !StrUtil.equals(e.getId(), order.getId())).collect(Collectors.toList());
+            if (!endClashOrder.isEmpty()){
+                String arrivalTime = DateUtil.format(clashOrder.get(0).getArrivalTime(), "YYYY-MM-dd");
+                String dueOutTime = DateUtil.format(clashOrder.get(0).getDueOutTime(), "YYYY-MM-dd");
+                throw new JeecgBootException( "房间" + arrivalTime + "~" + dueOutTime + "有预约");
             }
 
             //这里不能直接删除  先查询预订单有没有入住记录,如果房间有入住,那么入住过的记录则不能删除
@@ -1081,8 +1086,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         CesRooms room = roomsService.getById(bkRoom.getRoomId());
         if(room==null) throw new JeecgBootException("房间不存在");
         room.setLivingOrderId(livingOrder.getId());
-        room.setRoomStatus(RoomStatusEnum.LIVE_CLEAR.getKey());
-        room.setLastRoomStatus(RoomStatusEnum.LIVE_CLEAR.getKey());
+        Integer roomStatus = roomsService.changeLivingRoomStatus(room.getRoomStatus(), room.getLastRoomStatus());
+        room.setLastRoomStatus(room.getRoomStatus());
+        room.setRoomStatus(roomStatus);
         roomsService.updateById(room);
         bkRoom.setRoomStatus(RoomStatusEnum.LIVE_DIRTY.getKey());
         bookingRoomsService.updateById(bkRoom);
@@ -1132,38 +1138,26 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
 
 //        }
 
-        /*添加消息通知*/
-        BusHotel busHotel = busHotelService.getById(room.getHotelId());
-        LambdaQueryWrapper<SysUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
-        lambdaQueryWrapper.eq(SysUser::getDelFlag, 0);
-        lambdaQueryWrapper.eq(SysUser::getRelTenantIds, busHotel.getTenantId());
-        List<SysUser> sysUsers = sysUserService.list(lambdaQueryWrapper);
-        String userIds = "";
-        for (SysUser sysUser : sysUsers) {
-            userIds += sysUser.getUsername() + ",";
-        }
-        if (!userIds.isEmpty()) {
-            MessageDTO messageDTO = new MessageDTO();
-            messageDTO.setFromUser("");
-            messageDTO.setToUser(userIds);
-            messageDTO.setTenantId(busHotel.getTenantId());
-            messageDTO.setTitle(room.getPrefix() + room.getName() + "房间被入住-" + DateUtils.formatDate(new Date()));
-            messageDTO.setContent(room.getPrefix() + room.getName() + "房间被入住-" + DateUtils.formatDate(new Date()));
-            messageDTO.setCategory(CommonConstant.MSG_CATEGORY_1);
-            messageDTO.setMsgCategoryDetail(CommonConstant.MSG_ORDER);
-            sysBaseAPI.sendSysAnnouncement(messageDTO);
-        }
 
         CesAllDayPriceRule cesAllDayPriceRule =  allDayPriceRuleService.getOne(Wrappers.<CesAllDayPriceRule>lambdaQuery().eq(CesAllDayPriceRule::getHotelId,hotelId).eq(CesAllDayPriceRule::getInvalid,false));
         if(ObjectUtils.isEmpty(cesAllDayPriceRule)) {
             throw new JeecgBootException("未找到超时收费规则");
         }
-        if (livingOrder.getLivingType() != 5){
+        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");
             redisTemplate.opsForZSet().add("overTimerOrder", livingOrder.getId(), calendar.getTimeInMillis());
-        } else {
-
+        } else if (ObjectUtil.equals(LivingTypeEnum.HOURS_RENT.getKey(), livingOrder.getLivingType())){
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(livingOrder.getDueOutTime());
+            calendar.add(Calendar.MINUTE, -30);
+            redisTemplate.opsForZSet().add("sys:cache:message:willEndOrder", livingOrder.getId(), calendar.getTimeInMillis());
+            redisTemplate.opsForZSet().add("overTimerOrder", livingOrder.getId(), livingOrder.getDueOutTime().getTime());
+        } 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);
+            redisTemplate.opsForZSet().add("sys:cache:message:willEndOrder", livingOrder.getId(), calendar.getTimeInMillis());
         }
         roomsService.getReserveRoom();
         //</editor-fold>
@@ -1203,7 +1197,8 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         }
         // 查看房间预约情况
         List<BusRoomBookingOrders> clashOrder = baseMapper.findBookingOrder(roomIds, livingData.getOrderInfo().getArrivalTime(), livingData.getOrderInfo().getDueOutTime());
-        if (!clashOrder.isEmpty()){
+        long count = clashOrder.stream().filter(e -> !StrUtil.equals(e.getId(), livingData.getOrderInfo().getId())).count();
+        if (count > 0) {
             throw new JeecgBootException("房间已被预约");
         }
         // 是预约单先将预约单与房间关联删掉。因为原来这个接口是自己入住的接口,后来预定也要调这个接口,只能先将预定时添加的BusRoomBookingOrders关联表删掉,重新进行关联
@@ -1245,29 +1240,33 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
 //        List<String> bookingOrderIds = rooms.stream().map(s->s.getBookingOrderId()).collect(Collectors.toList());
         // 这里只获取当天预约的房间预约单,而非上面的那种情况,即:ces_rooms 表中的booking_order_id作废
         List<TodayBookingQueryDto> roomBookingOrders = baseMapper.getTodayBookingOrder(rooms.stream().map(s->s.getId()).collect(Collectors.toList()));
-        List<String> bookingOrderIds = roomBookingOrders.stream().map(s->s.getBookingOrderId()).collect(Collectors.toList());
-        List<String> livingOrderIds = rooms.stream().map(s->s.getLivingOrderId()).collect(Collectors.toList());
-        List<BusRoomBookingOrders> bookingOrders = bookingOrderIds.size() > 0 ?
+        List<String> bookingOrderIds = roomBookingOrders.stream().map(TodayBookingQueryDto::getBookingOrderId).collect(Collectors.toList());
+        List<String> livingOrderIds = rooms.stream().map(CesRooms::getLivingOrderId).collect(Collectors.toList());
+        List<BusRoomBookingOrders> bookingOrders = !bookingOrderIds.isEmpty() ?
                 this.list(Wrappers.<BusRoomBookingOrders>query().in("id",bookingOrderIds))
                 :new ArrayList<>();
-        List<BusBookingLayoutDayPrice> bookingLayoutDayPrices =bookingOrderIds.size() > 0? dayPriceService.list(Wrappers.<BusBookingLayoutDayPrice>query()
+        List<BusBookingLayoutDayPrice> bookingLayoutDayPrices = !bookingOrderIds.isEmpty() ? dayPriceService.list(Wrappers.<BusBookingLayoutDayPrice>query()
         .in("booking_order_id",bookingOrderIds)):new ArrayList<>();
-        List<String> bookingCusIds = bookingOrders.stream().map(s->s.getContactId()).collect(Collectors.toList());
-        List<BusCustomer> bookingCustomers =bookingCusIds.size() > 0? customerService.list(Wrappers.<BusCustomer>query()
+        List<String> bookingCusIds = bookingOrders.stream().map(BusRoomBookingOrders::getContactId).collect(Collectors.toList());
+        List<BusCustomer> bookingCustomers = !bookingCusIds.isEmpty() ? customerService.list(Wrappers.<BusCustomer>query()
         .in("id",bookingCusIds)):new ArrayList<>();
-        List<BusRoomsLivingOrder> livingOrders =livingOrderIds.size() > 0? roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>query()
+        List<BusRoomsLivingOrder> livingOrders = !livingOrderIds.isEmpty() ? roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>query()
         .in("id",livingOrderIds)):new ArrayList<>();
-        List<BusLivingCustomer> livingCustomers =livingOrderIds.size() > 0? livingCustomerService.list(Wrappers.<BusLivingCustomer>query()
+        List<BusLivingCustomer> livingCustomers = !livingOrderIds.isEmpty() ? livingCustomerService.list(Wrappers.<BusLivingCustomer>query()
         .in("living_order_id",livingOrderIds)):new ArrayList<>();
-        List<BusLivingLayoutDayPrice> livingLayoutDayPrices =livingOrderIds.size()>0? livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
+        // 每日房价
+        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<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));
         List<BusBookingRooms> bookingRoomsList = bookingRoomsService.bookingRoomsDetail(booingIds);
-
+        List<BusOrderFee> fees = feeService.list(Wrappers.<BusOrderFee>query()
+                .in("living_order_id",livingOrderIds));
+        Map<String, List<BusOrderFee>> feesMap = fees.stream().collect(Collectors.groupingBy(BusOrderFee::getLivingOrderId));
         rooms.forEach(s-> {
             FloorBuildingRoomVo vo = new FloorBuildingRoomVo();
             vo.setRoomId(s.getId());
@@ -1307,7 +1306,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
              Optional<BusRoomsLivingOrder> opLivingOrder=livingOrders.stream().filter(a->a.getId().equals(s.getLivingOrderId())).findFirst();
              if(opLivingOrder.isPresent()) {
                  BusRoomsLivingOrder livingOrder = opLivingOrder.get();
-                 Map<String,BigDecimal> feeMap = getRoomOrderFees(livingOrder.getId());
+                 Map<String,BigDecimal> feeMap = getRoomOrderFees(livingOrder.getId(), feesMap);
                  livingOrder.setXiaoFei(feeMap.get("xf"));
                  livingOrder.setShouKuan(feeMap.get("sk"));
                  livingOrder.setDeposit(feeMap.get("yj"));
@@ -1332,15 +1331,17 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                  vo.getLivingData().setLivingOrder(livingOrder);
                  Optional<BusLivingCustomer> opLivingCustomer = livingCustomers.stream().filter(a->a.getLivingOrderId().equals(opLivingOrder.get().getId())).findFirst();
                  opLivingCustomer.ifPresent(busLivingCustomer -> vo.getLivingData().setLivingCustomers(busLivingCustomer));
-                 vo.getLivingData().setPrice(
-                         livingLayoutDayPrices.stream().filter(a->a.getLivingOrderId().equals(opLivingOrder.get().getId())).collect(Collectors.toList())
-                 );
+//                 vo.getLivingData().setPrice(
+//                         livingLayoutDayPrices.stream().filter(a->a.getLivingOrderId().equals(opLivingOrder.get().getId())).collect(Collectors.toList()));
+                 vo.getLivingData().setPrice(livingDayPriceMap.get(opLivingOrder.get().getId()));
              }
             roomVos.add(vo);
         });
+
         return roomVos;
     }
 
+
     private Integer getLivingDayCount(BusRoomsLivingOrder order) {
         Calendar calendarBeijian = new GregorianCalendar();
         calendarBeijian.setTime(order.getDueOutTime());
@@ -1350,9 +1351,11 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
        return  count == 0 ? 1:count;
     }
 
-    private Map<String, BigDecimal> getRoomOrderFees(String livingOrderId) {
-        List<BusOrderFee> fees = feeService.list(Wrappers.<BusOrderFee>query()
-        .eq("living_order_id",livingOrderId));
+    private Map<String, BigDecimal> getRoomOrderFees(String livingOrderId, Map<String, List<BusOrderFee>> feesMap) {
+        List<BusOrderFee> fees = feesMap.get(livingOrderId);
+        if (fees.isEmpty()){
+            return new HashMap<>();
+        }
         List<BusOrderFee> xiaofeiList = fees.stream().filter(s->s.getFeeType().equals(1)).collect(Collectors.toList());
         List<BusOrderFee> shoukuanList = fees.stream().filter(s->s.getFeeType().equals(2)).collect(Collectors.toList());
         List<BusOrderFee> depositList = shoukuanList.stream().filter(s->ObjectUtil.equals(s.getSubjectType(),"1")).collect(Collectors.toList());
@@ -1495,7 +1498,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 dayOrderFee.setRoomId(orderRoom.getId());
                 String roomName = orderRoom.getPrefix() != null?orderRoom.getPrefix():"";
                 roomName += roomName + orderRoom.getName();
-                dayOrderFee.setRemark("【"+roomName + "】 "+ DateUtils.formatDate(new Date()) + " 当日房费");
+                dayOrderFee.setRemark(DateUtils.formatDate(new Date(), "MM-dd") + "房费");
                 dayOrderFee.setLivingOrderId(s.getId());
                 dayOrderFee.setHotelId(hotelId);
                 feeService.save(dayOrderFee);
@@ -1607,18 +1610,21 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         }
         LambdaQueryWrapper<BusRoomsLivingOrder> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.in(BusRoomsLivingOrder::getId,set);
+        queryWrapper.eq(BusRoomsLivingOrder::getHotelId,hotelId);
         List<BusRoomsLivingOrder> livingOrderList = roomsLivingOrderService.list(queryWrapper);
+        List<String> bookingIds = livingOrderList.stream().map(BusRoomsLivingOrder::getBookingOrderId).collect(Collectors.toList());
+        if (bookingIds.isEmpty()){
+            return true;
+        }
+        List<CesHourRoomRule> cesHourRoomRuleList = hourRoomRuleService.list(Wrappers.<CesHourRoomRule>lambdaQuery().eq(CesHourRoomRule::getHotelId, hotelId));
+        List<BusRoomBookingOrders> bookingOrders = list(Wrappers.<BusRoomBookingOrders>lambdaQuery().in(BusRoomBookingOrders::getId, bookingIds));
         livingOrderList.forEach(e -> {
-            BusRoomBookingOrders roomBookingOrder = getById(e.getBookingOrderId());
-            if (ObjectUtil.isEmpty(roomBookingOrder)){
+            Optional<BusRoomBookingOrders> optional = bookingOrders.stream().filter(ele -> ele.getId().equals(e.getBookingOrderId())).findFirst();
+            if (!optional.isPresent()){
                 return;
             }
-            List<CesRooms> cesRooms = roomsService.list(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getLivingOrderId, e.getId()));
-            if (CollUtil.isNotEmpty(cesRooms)){
-                System.out.println(cesRooms.get(0).getName());
-            }
             // 全天房
-            if (ObjectUtil.equals(1,roomBookingOrder.getBookingType())){
+            if (ObjectUtil.equals(1,optional.get().getBookingType())){
                 // 如果房间超时是按分钟加收费用
                 if (TimeOutRuleEnum.ADD_BY_MINUTE.getKey().equals(cesAllDayPriceRule.getTimeOutRule())){
                     addByMinute(e, cesAllDayPriceRule);
@@ -1628,14 +1634,110 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                     notAdd(e, cesAllDayPriceRule);
                 }
                 // 钟点房
-            } else if(ObjectUtil.equals(2,roomBookingOrder.getBookingType())){
-                // TODO: 2023/10/24 钟点房超时收费
+            } else if(ObjectUtil.equals(2,optional.get().getBookingType())){
+                addHourFee(cesHourRoomRuleList, e, cesAllDayPriceRule);
             }
         });
+        return null;
+    }
 
+    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();
+        ruleOptional.ifPresent(rule -> {
+            Calendar nowCalendar = Calendar.getInstance();
+            Calendar nextCalendar = Calendar.getInstance();
+            nextCalendar.setTime(livingOrder.getDueOutTime());
+            Integer overMinutes = Math.round((nowCalendar.getTimeInMillis() - nextCalendar.getTimeInMillis()) / (1000 * 60 ));
+            if (overMinutes <= 0){
+                return;
+            }
+            BusBookingRooms bookingroom = bookingRoomsService.getById(livingOrder.getBookingRoomId());
+            if (ObjectUtil.isEmpty(bookingroom)){
+                log.info("未找到订单{}对应的房间", livingOrder.getId());
+                return;
+            }
+            BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
+            if (rule.getLimitTimeTransferAllDay() != 0 && overMinutes > rule.getLimitTimeTransferAllDay()){
+                // 转为全天房
+                Date arrivalTime = livingOrder.getArrivalTime();
+                Calendar arrivalCalendar = Calendar.getInstance();
+                arrivalCalendar.setTime(arrivalTime);
+                DateTime leaveTime = DateUtil.parse(cesAllDayPriceRule.getLeaveTime(), "HH:mm");
+                Calendar leaveCalendar = Calendar.getInstance();
+                leaveCalendar.setTime(leaveTime);
+                leaveCalendar.set(Calendar.YEAR, arrivalCalendar.get(Calendar.YEAR));
+                leaveCalendar.set(Calendar.MONTH, arrivalCalendar.get(Calendar.MONTH));
+                leaveCalendar.set(Calendar.DAY_OF_MONTH, arrivalCalendar.get(Calendar.DAY_OF_MONTH));
+                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)
+                        && arrivalCalendar.get(Calendar.MINUTE) > enterCalendar.get(Calendar.MINUTE)){
+                    // 如果预抵时间在enterTime后面 则预离时间为隔天
+                    leaveCalendar.add(Calendar.DAY_OF_YEAR, 1);
+                }
+                livingOrder.setDueOutTime(leaveCalendar.getTime());
+                livingOrder.setLivingType(LivingTypeEnum.ALL_DAY.getKey());
+                List<BusOrderFee> busOrderFees = feeService.list(Wrappers.<BusOrderFee>lambdaQuery()
+                        .eq(BusOrderFee::getLivingOrderId, livingOrder.getId()).eq(BusOrderFee::getSubjectType, FeeSubjectType.MEI_RI_FANG_FEI.getKey()));
+                Optional<BusOrderFee> orderFee = busOrderFees.stream().filter(e -> !e.getIsOverTime()).findFirst();
+
+                // 修改房费为全天房费
+                orderFee.ifPresent(e -> {
+                    BusLivingLayoutDayPrice dayPrice = livingLayoutDayPriceService.getOne(Wrappers.<BusLivingLayoutDayPrice>lambdaQuery()
+                            .eq(BusLivingLayoutDayPrice::getLivingOrderId, livingOrder.getId())
+                            .eq(BusLivingLayoutDayPrice::getDayTime, DateUtils.formatDate(livingOrder.getArrivalTime())).last("limit 1"));
+                    BigDecimal money = schemeLayoutDailyPriceService.getOneDayPrice(bookingroom.getRoomLayoutId(), livingOrder, new Date());
+                    e.setMoney(money);
+                    feeService.updateById(e);
+                    if (dayPrice != null){
+                        dayPrice.setPrice(money);
+                        livingLayoutDayPriceService.updateById(dayPrice);
+                    }
+                });
+                // 删除超时收费项
+                Optional<BusOrderFee> overTimeFee = busOrderFees.stream().filter(BusOrderFee::getIsOverTime).findFirst();
+                overTimeFee.ifPresent(e -> {
+                    feeService.removeById(e.getId());
+                });
+                roomsLivingOrderService.updateById(livingOrder);
+                leaveCalendar.add(Calendar.MINUTE, Integer.parseInt(cesAllDayPriceRule.getDayTime()));
+                redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
+                redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(),leaveCalendar.getTimeInMillis());
+                return;
+            }
+            //已经超时的 不足时间
+            Integer minutesDiff = overMinutes % rule.getExceedTime();
+            // 超出 超时时间 的数量
+            Integer minutesDiffNum = (int) Math.floor(overMinutes / rule.getExceedTime());
+            // 不足时间 数量
+            Integer moreThenMinuteDiffNum = (int) Math.floor(minutesDiff / rule.getNotReachExceedTime());
+            // 加上下一次不足时间 >= 超出时间,用超出时间
+            if (minutesDiff + rule.getNotReachExceedTime() > rule.getExceedTime()){
+                Integer newOverTime = rule.getExceedTime() * (minutesDiffNum + 1);
+                nextCalendar.add(Calendar.MINUTE, newOverTime);
+            }else {
+                nextCalendar.add(Calendar.MINUTE, rule.getNotReachExceedTime());
+            }
+            log.info("钟点房{}今日超时分钟{},超时时间数量{},不足时间数量{}",livingOrder.getId(),overMinutes,minutesDiffNum,moreThenMinuteDiffNum);
+            BigDecimal money = rule.getExceedPay().multiply(BigDecimal.valueOf(minutesDiffNum))
+                    .add(rule.getNotReachExceedTimePay().multiply(BigDecimal.valueOf(moreThenMinuteDiffNum)));
+            // 有上限,且金额超过当前上限
+            if (rule.getMaxExtraPay().compareTo(new BigDecimal(0)) != 0 && rule.getMaxExtraPay().compareTo(money) < 0){
+                money = rule.getMaxExtraPay();
+            }
+            fee.setMoney(money);
+            fee.setDayTime(nowCalendar.getTime());
+            redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
 
-
-        return null;
+            SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+            log.info(format.format(nextCalendar.getTime()));
+            redisTemplate.opsForZSet().add("overTimerOrder",livingOrder.getId(),nextCalendar.getTimeInMillis());
+            // 添加超时房费
+            feeService.saveOrUpdate(fee);
+        });
     }
 
     /**
@@ -1680,6 +1782,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         }else {
             nextCalendar.add(Calendar.MINUTE, cesAllDayPriceRule.getMoreThenMinute());
         }
+//        log.info(DateUtil.format(nextCalendar.getTime(), "yyyy-MM-dd HH:mm"));
 
         log.info("{}今日超时分钟{},超时时间数量{},不足时间数量{}",livingOrder.getId(),overMinutes,minutesDiffNum,moreThenMinuteDiffNum);
 
@@ -1695,14 +1798,13 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             // 如果下一次增加收费时间大于 全天收费时间 设置
         }else {
             // 如果满足全天收费要求,预离时间增加1天
-            CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
-
-            BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
+            BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, bookingroom.getRoomLayoutId());
             fee.setMoney(dayPrice.getPrice());
             fee.setDayTime(date);
             // 获取每天超时时间,如果超过预离时间,修改预离时间
             nextCalendar = getNextCalendar(livingOrder, nowCalendar,cesAllDayPriceRule);
             fee.setRemark(DateUtils.formatDate(nowCalendar.getTime(), "MM-dd") + "房费");
+            fee.setIsOverTime(false);
         }
         // 移除处理过的时间订单,添加订单下一次超时的时间戳
         redisTemplate.opsForZSet().remove("overTimerOrder",livingOrder.getId());
@@ -1721,19 +1823,19 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             log.info("未找到订单{}对应的房间", livingOrder.getId());
             return;
         }
-        CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
         // 查询当天房间超时消费
         BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
         // 需要支付完整费用时间的最后时间
         Date endTime = getFullFeeTime(date, cesAllDayPriceRule);
+        BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, bookingroom.getRoomLayoutId());
         if (nextCalendar.getTime().compareTo(endTime) < 0){
             // 超时收取半天费用
-            fee.setMoney(layout.getMarketPrice().divide(new BigDecimal(2)));
+            fee.setMoney(dayPrice.getPrice().divide(new BigDecimal(2)));
             nextCalendar.setTime(endTime);
         } else {
             // 添加每日房费
-            BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
             fee.setMoney(dayPrice.getPrice());
+            fee.setIsOverTime(false);
             // 获取每天超时时间,如果超过预离时间,修改预离时间
             nextCalendar = getNextCalendar(livingOrder, nowCalendar,cesAllDayPriceRule);
         }
@@ -1752,15 +1854,15 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             log.info("未找到订单{}对应的房间", livingOrder.getId());
             return;
         }
-        CesRoomLayout layout = layoutService.getById(bookingroom.getRoomLayoutId());
         // 查询当天房间超时消费
         BusOrderFee fee = getOverTimeFee(livingOrder, bookingroom);
         // 需要支付完整费用时间的最后时间
         Date endTime = getFullFeeTime(date, cesAllDayPriceRule);
         if (nextCalendar.getTime().compareTo(endTime) >= 0){
             // 添加每日房费
-            BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, layout.getMarketPrice());
+            BusLivingLayoutDayPrice dayPrice = addDayPrice(livingOrder, bookingroom, bookingroom.getRoomLayoutId());
             fee.setMoney(dayPrice.getPrice());
+            fee.setIsOverTime(false);
             // 获取每天超时时间,如果超过预离时间,修改预离时间
             nextCalendar = getNextCalendar(livingOrder, nowCalendar,cesAllDayPriceRule);
         }
@@ -1770,11 +1872,13 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         feeService.saveOrUpdate(fee);
     }
 
-    public BusLivingLayoutDayPrice addDayPrice(BusRoomsLivingOrder livingOrder, BusBookingRooms bookingroom, BigDecimal money){
+    public BusLivingLayoutDayPrice addDayPrice(BusRoomsLivingOrder livingOrder, BusBookingRooms bookingroom, String layoutId){
         List<BusLivingLayoutDayPrice> dayPrices = livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
                 .eq("living_order_id",livingOrder.getId()));
         Optional<BusLivingLayoutDayPrice> opPrice = dayPrices.stream().filter(a-> DateUtils.formatDate(a.getDayTime()).equals(DateUtils.formatDate(livingOrder.getDueOutTime()))).findFirst();
         if(!opPrice.isPresent()){
+            // 根据房价方案查询价格
+            BigDecimal money = schemeLayoutDailyPriceService.getOneDayPrice(layoutId, livingOrder, new Date());
             BusLivingLayoutDayPrice nPrice = new BusLivingLayoutDayPrice();
             nPrice.setBookingRoomId(livingOrder.getBookingRoomId());
             try {
@@ -1782,6 +1886,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             } catch (ParseException e) {
                 e.printStackTrace();
             }
+
             nPrice.setRoomId(bookingroom.getRoomId());
             nPrice.setRoomLayoutId(bookingroom.getRoomLayoutId());
             nPrice.setPrice(money);
@@ -1794,14 +1899,15 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
     }
 
     public BusOrderFee getOverTimeFee(BusRoomsLivingOrder livingOrder, BusBookingRooms bookingroom){
-        Calendar nowCalendar = Calendar.getInstance();
-        nowCalendar.set(Calendar.HOUR_OF_DAY, 0);
-        nowCalendar.set(Calendar.MINUTE, 0);
-        nowCalendar.set(Calendar.SECOND, 0);
-        nowCalendar.set(Calendar.MILLISECOND, 0);
+//        Calendar nowCalendar = Calendar.getInstance();
+//        nowCalendar.set(Calendar.HOUR_OF_DAY, 0);
+//        nowCalendar.set(Calendar.MINUTE, 0);
+//        nowCalendar.set(Calendar.SECOND, 0);
+//        nowCalendar.set(Calendar.MILLISECOND, 0);
         List<BusOrderFee> feeList = feeService.list(Wrappers.<BusOrderFee>lambdaQuery()
                 .eq(BusOrderFee::getLivingOrderId, livingOrder.getId()).eq(BusOrderFee::getPreferentialStatus, 1)
-                .eq(BusOrderFee::getSubjectType, FeeSubjectType.MEI_RI_FANG_FEI.getKey()).ge(BusOrderFee::getCreateTime, nowCalendar.getTime()));
+                .eq(BusOrderFee::getSubjectType, FeeSubjectType.MEI_RI_FANG_FEI.getKey()).eq(BusOrderFee::getIsOverTime, true)
+                .orderByDesc(BusOrderFee::getCreateTime));
         if (CollUtil.isNotEmpty(feeList)) {
             return feeList.get(0);
         }
@@ -1815,6 +1921,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         fee.setFeeType(FeeType.CONSUME.getKey());
         fee.setRoomId(bookingroom.getRoomId());
         fee.setRemark("超时房费");
+        fee.setIsOverTime(true);
         return fee;
     }
 
@@ -3189,54 +3296,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                     if(FeeSubjectType.val(s.getSubjectType()) == null) {
                         throw new JeecgBootException("收款项目不存在,请核对后操作");
                     }
-//                    BusRoomPayType payType = payTypeService.getById(s.getPayType());
-//                    if (payType == null){
-//                        throw new JeecgBootException("支付方式不存在");
-//                    }
-//                    if("会员卡".equals(payType.getName())){
-//                        BusMemberBalanceLog memberBalanceLog = new BusMemberBalanceLog();
-//                        if (user.getRelTenantIds() != null && !user.getRelTenantIds().isEmpty()) {
-//                            memberBalanceLog.setTenantId(user.getRelTenantIds());
-//                        } else {
-//                            throw new JeecgBootException("当前登录人租户信息错误");
-//                        }
-//                        memberBalanceLog.setWithhold(s.getMoney());
-//                        memberBalanceLog.setMoney(BigDecimal.valueOf(0));
-//                        memberBalanceLog.setMemberId(livingData.getOrderInfo().getVipCustomerId());
-//                        memberBalanceLog.setHotelId(livingData.getOrderInfo().getHotelId());
-//                        memberBalanceLog.setType(2);
-//                        memberBalanceLog.setOrderFeeId(s.getId());
-//                        memberBalanceLogService.saveBalance(memberBalanceLog);
-//                    }
                 });
-//                if(!findRoomFees.isEmpty()) feeService.saveBatch(findRoomFees);
-//                // 处理协议单位记账
-//                findRoomFees.forEach(s->{
-//                    if(payTypes.stream().anyMatch(k->k.getId().equals(s.getPayType()) && k.getName().equals("单位记账")) ) {
-//                        BusAgreementOrderFee agreementOrderFee = new BusAgreementOrderFee();
-//                        if(s.getAgreementUnitId() == null || s.getAgreementUnitId().isEmpty()) throw new JeecgBootException("请选择协议单位");
-//                        BusMarketAgreementUnit unit = marketAgreementUnitService.getById(s.getAgreementUnitId());
-//                        if(unit == null) throw new JeecgBootException("协议单位未找到");
-//                        if(unit.getBookkStatus() != null && unit.getBookkStatus().equals(1)) throw new JeecgBootException("不允许该单位记账");
-//                        BigDecimal usedAmount;
-//                        if(unit.getAmountUsed() == null) usedAmount = new BigDecimal(0);
-//                        else usedAmount = unit.getAmountUsed();
-//                        double incrementBalance = (usedAmount.add(s.getMoney())).doubleValue();
-//                        // 记账限额超出,返回异常结果!
-//                        if(unit.getBookkeeping() != null && !unit.getBookkeeping().equals(new BigDecimal(0)) && unit.getBookkeeping().doubleValue() < incrementBalance)
-//                            throw new JeecgBootException("记账超额!记账单位限额为"+unit.getBookkeeping().doubleValue()+",已使用"+usedAmount.doubleValue());
-//                        agreementOrderFee.setAgreementUnitId(s.getAgreementUnitId());
-//                        agreementOrderFee.setOrderFeeId(s.getId());
-//                        agreementOrderFee.setCreatedTime(new Date());
-//                        agreementOrderFee.setCreateUserId(user != null ?user.getId():"");
-//                        agreementOrderFee.setSettleStatus(1);
-//                        agreementOrderFeeService.save(agreementOrderFee);
-//                        // 更新已使用的记账
-//                        unit.setAmountUsed(new BigDecimal(incrementBalance));
-//                        unit.setUpdateTime(new Date());
-//                        marketAgreementUnitService.updateById(unit);
-//                    }
-//                });
                 feeService.collectionBatch(findRoomFees, hotelId);
             }
 
@@ -3296,6 +3356,7 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         livingOrder.setTeamName(bkOrder.getTeamName());
         livingOrder.setTeamTypeDicId(bkOrder.getTeamTypeDicId());
         livingOrder.setRoomPriceSlnId(bkOrder.getRoomPriceSlnId());
+        livingOrder.setLongSchemeId(bkOrder.getLongSchemeId());
         livingOrder.setLeaderName(bkOrder.getLeaderName());
         livingOrder.setPublicConsumeFee(bkOrder.getPublicConsumeFee());
         livingOrder.setPublicMeetingFee(bkOrder.getPublicMeetingFee());
@@ -3665,5 +3726,53 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
 
     }
 
+    @Override
+    public void addWillLeaveMess(String parameter) {
+        BusHotel busHotel = busHotelService.getById(parameter);
+        if (busHotel == null){
+            log.info("通过id{}未找到酒店", parameter);
+            return;
+        }
+        Set<Object> set = redisTemplate.opsForZSet().rangeByScore("sys:cache:message:willEndOrder", 0, Calendar.getInstance().getTimeInMillis());
+        if (CollUtil.isEmpty(set)){
+            return;
+        }
+        List<CesRooms> cesRooms = roomsService.list(Wrappers.<CesRooms>lambdaQuery().in(CesRooms::getLivingOrderId, set).eq(CesRooms::getHotelId, parameter));
+        if (cesRooms.isEmpty()){
+            return;
+        }
+        List<BusRoomsLivingOrder> roomsLivingOrders = roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>lambdaQuery()
+                .in(BusRoomsLivingOrder::getId, set).eq(BusRoomsLivingOrder::getHotelId, parameter));
+        LambdaQueryWrapper<SysUser> lambdaQueryWrapper = new LambdaQueryWrapper<>();
+        lambdaQueryWrapper.eq(SysUser::getDelFlag, 0);
+        lambdaQueryWrapper.eq(SysUser::getRelTenantIds, busHotel.getTenantId());
+        List<SysUser> sysUsers = sysUserService.list(lambdaQueryWrapper);
+        String userIds = "";
+        for (SysUser sysUser : sysUsers) {
+            userIds += sysUser.getUsername() + ",";
+        }
+        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+        String finalUserIds = userIds;
+        set.forEach(e -> {
+            Optional<BusRoomsLivingOrder> orderOptional = roomsLivingOrders.stream().filter(ele -> ele.getId().equals(e)).findFirst();
+            Optional<CesRooms> roomsOptional = cesRooms.stream().filter(ele -> ele.getLivingOrderId().equals(e)).findFirst();
+            if (orderOptional.isPresent() && roomsOptional.isPresent()){
+                    /*添加消息通知*/
+                String mesStr = roomsOptional.get().getPrefix() == null ? "" : roomsOptional.get().getPrefix()
+                        + roomsOptional.get().getName() + "房间 " + LivingTypeEnum.val(orderOptional.get().getLivingType()).getTitle() + "即将到达预离时间";
+                MessageDTO messageDTO = new MessageDTO();
+                messageDTO.setFromUser("");
+                messageDTO.setToUser(finalUserIds);
+                messageDTO.setTenantId(busHotel.getTenantId());
+                messageDTO.setTitle(mesStr);
+                messageDTO.setContent(mesStr);
+                messageDTO.setCategory(CommonConstant.MSG_CATEGORY_1);
+                messageDTO.setMsgCategoryDetail(CommonConstant.MSG_ROOM);
+                sysBaseAPI.sendSysAnnouncement(messageDTO);
+                redisTemplate.opsForZSet().remove("sys:cache:message:willEndOrder", e);
+            }
+        });
+    }
+
 
 }

+ 88 - 6
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusSchemeLayoutDailyPriceServiceImpl.java

@@ -1,15 +1,23 @@
 package org.jeecg.modules.business.service.impl;
 
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.fasterxml.jackson.annotation.JsonFormat;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.RedisUtil;
 import org.jeecg.common.util.TokenUtils;
 import org.jeecg.modules.business.entity.BusHousePriceSchemeLayout;
+import org.jeecg.modules.business.entity.BusRoomsLivingOrder;
 import org.jeecg.modules.business.entity.BusSchemeLayoutDailyPrice;
 import org.jeecg.modules.business.mapper.BusSchemeLayoutDailyPriceMapper;
 import org.jeecg.modules.business.service.IBusHousePriceSchemeLayoutService;
 import org.jeecg.modules.business.service.IBusSchemeLayoutDailyPriceService;
+import org.jeecg.modules.rooms.entity.CesHousePriceScheme;
+import org.jeecg.modules.rooms.service.CesHousePriceSchemeServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.format.annotation.DateTimeFormat;
 import org.springframework.stereotype.Service;
@@ -17,11 +25,14 @@ import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.web.bind.annotation.RequestParam;
 
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.sql.Timestamp;
 import java.text.SimpleDateFormat;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.List;
+import java.time.LocalDate;
+import java.time.LocalTime;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 房价方案-每日房价表
@@ -34,6 +45,10 @@ public class BusSchemeLayoutDailyPriceServiceImpl extends ServiceImpl<BusSchemeL
 
     @Autowired
     private IBusHousePriceSchemeLayoutService busHousePriceSchemeLayoutService;
+    @Resource
+    private CesHousePriceSchemeServiceImpl housePriceSchemeService;
+    @Resource
+    private RedisUtil redisUtil;
 
     @Override
     public List<BusSchemeLayoutDailyPrice> getDailyPrice(String schemeLayoutId, Date realDate) {
@@ -95,8 +110,75 @@ public class BusSchemeLayoutDailyPriceServiceImpl extends ServiceImpl<BusSchemeL
         return newList;
     }
 
-    public static List<Date> findDates(Date dBegin, Date dEnd)
-    {
+    @Override
+    public BigDecimal getOneDayPrice(String layoutId, BusRoomsLivingOrder livingOrder, Date date) {
+        LambdaQueryWrapper<CesHousePriceScheme> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(CesHousePriceScheme::getHotelId,livingOrder.getHotelId());
+        queryWrapper.eq(CesHousePriceScheme::getInvalid,false);
+        queryWrapper.eq(CesHousePriceScheme::getOpen,1);
+        queryWrapper.and(e -> e.le(CesHousePriceScheme::getValidStartTime, LocalDate.now())
+                .ge(CesHousePriceScheme::getValidEndTime, LocalDate.now()).or().eq(CesHousePriceScheme::getValidTime, 0));
+        List<CesHousePriceScheme> cesHousePriceSchemes = housePriceSchemeService.list(queryWrapper);
+
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.set(Calendar.HOUR_OF_DAY, 0);
+        calendar.set(Calendar.MINUTE, 0);
+        calendar.set(Calendar.SECOND, 0);
+        calendar.set(Calendar.MILLISECOND, 0);
+
+        Optional<CesHousePriceScheme> schemeOptional = cesHousePriceSchemes.stream().filter(e -> e.getId().equals(livingOrder.getRoomPriceSlnId())).findFirst();
+        if (schemeOptional.isPresent()) {
+            return getMoney(layoutId, livingOrder.getRoomPriceSlnId(), calendar.getTime());
+        }
+        // 节假日方案
+        Optional<CesHousePriceScheme> holidaySchemeOptional = cesHousePriceSchemes.stream().filter(e -> e.getSchemeType() == 2).findFirst();
+        if (holidaySchemeOptional.isPresent()){
+            String holidayStr = holidaySchemeOptional.get().getHoliday();
+            String[] holidayArr = holidayStr.split(",");
+            for (String s : holidayArr) {
+                String[] holidays = s.split("~");
+                DateTime start = DateUtil.parse(holidays[0], "yyyy-MM-dd");
+                DateTime end = DateUtil.parse(holidays[1], "yyyy-MM-dd");
+                if (start.isBefore(new Date()) && end.isAfter(new Date())){
+                    return getMoney(layoutId, holidaySchemeOptional.get().getId(),calendar.getTime());
+                }
+            }
+        }
+        // 周末方案
+        Optional<CesHousePriceScheme> weekSchemeOptional = cesHousePriceSchemes.stream().filter(e -> e.getSchemeType() == 1).findFirst();
+        if (weekSchemeOptional.isPresent()){
+            String weekStr = weekSchemeOptional.get().getWeekend();
+            String[] weekArr = weekStr.split(",");
+            int week = calendar.get(Calendar.DAY_OF_WEEK) - 1;
+            String todayWeek = (week == 0 ? 7 : week)  + "";
+            boolean contains = Arrays.asList(weekArr).contains(todayWeek);
+            if (contains){
+                return getMoney(layoutId, weekSchemeOptional.get().getId(),calendar.getTime());
+            }
+        }
+        // 平日方案
+        Optional<CesHousePriceScheme> normalSchemeOptional = cesHousePriceSchemes.stream().filter(e -> e.getSchemeType() == 0).findFirst();
+        return getMoney(layoutId, normalSchemeOptional.get().getId(), calendar.getTime());
+    }
+
+    public BigDecimal getMoney(String layoutId, String schemeId, Date date){
+        BusHousePriceSchemeLayout housePriceSchemeLayout = busHousePriceSchemeLayoutService.getOne(Wrappers
+                .<BusHousePriceSchemeLayout>lambdaQuery().eq(BusHousePriceSchemeLayout::getLayoutId, layoutId)
+                .eq(BusHousePriceSchemeLayout::getSchemeId, schemeId).last("limit 1"));
+        if (housePriceSchemeLayout == null) {
+            return null;
+        }
+        BusSchemeLayoutDailyPrice dailyPrice = getOne(Wrappers.<BusSchemeLayoutDailyPrice>lambdaQuery()
+                .eq(BusSchemeLayoutDailyPrice::getSchemeLayoutId, housePriceSchemeLayout)
+                .eq(BusSchemeLayoutDailyPrice::getDate, date).last("limit 1"));
+        if (dailyPrice != null) {
+            return dailyPrice.getMoney();
+        }
+        return housePriceSchemeLayout.getMoney();
+    }
+
+    public static List<Date> findDates(Date dBegin, Date dEnd){
         List lDate = new ArrayList();
         lDate.add(dBegin);
         Calendar calBegin = Calendar.getInstance();

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

@@ -25,6 +25,7 @@ public class KeLiItemVo {
     private Date arrivalTime;
     private Date dueOutTime;
     private Integer isLiving;
+    private Integer status;
     private BigDecimal yushou;
     private BigDecimal yuE;
     private List<BusLivingLayoutDayPrice> livingDayPrices;

+ 5 - 1
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/fw/controller/FwRoomCleanController.java

@@ -214,7 +214,9 @@ public class FwRoomCleanController extends JeecgController<FwRoomClean, IFwRoomC
 			if (ObjectUtils.isEmpty(cesRooms)) {
 				return Result.error("房间不存在");
 			}
-			if (!cesRooms.getRoomStatus().equals(RoomStatusEnum.EMPTY_DIRTY.getKey()) && !cesRooms.getRoomStatus().equals(RoomStatusEnum.LIVE_DIRTY.getKey())) {
+			if (!cesRooms.getRoomStatus().equals(RoomStatusEnum.EMPTY_DIRTY.getKey())
+					&& !cesRooms.getRoomStatus().equals(RoomStatusEnum.LIVE_DIRTY.getKey())
+					&& !cesRooms.getRoomStatus().equals(RoomStatusEnum.RESERVE.getKey())) {
 				return Result.error("房间不是脏房状态不可以置干净");
 			}
 			fwRoomClean.setHotelId(dto.getHotelId());
@@ -233,6 +235,8 @@ public class FwRoomCleanController extends JeecgController<FwRoomClean, IFwRoomC
 					} else if (cesRooms.getRoomStatus().equals(RoomStatusEnum.LIVE_DIRTY.getKey())) {
 						cesRooms.setLastRoomStatus(RoomStatusEnum.LIVE_CLEAR.getKey());
 						cesRooms.setRoomStatus(RoomStatusEnum.LIVE_CLEAR.getKey());
+					} else if (cesRooms.getRoomStatus().equals(RoomStatusEnum.RESERVE.getKey())){
+						cesRooms.setLastRoomStatus(RoomStatusEnum.EMPTY_CLEAR.getKey());
 					}
 					cesRoomsService.updateById(cesRooms);
 				}

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

@@ -17,7 +17,7 @@ import javax.annotation.Resource;
  * todo : 基本逻辑fix 待优化处理
  */
 @Slf4j
-class LivingRoomOrderFeeJob implements Job {
+public class LivingRoomOrderFeeJob implements Job {
 
     private String parameter;
 
@@ -37,6 +37,8 @@ class LivingRoomOrderFeeJob implements Job {
         thread.start();
 
         fwLivingJxService.addJxMess(parameter);
+
+        bookingOrdersService.addWillLeaveMess(parameter);
 //        bookingOrdersService.syncDayRoomOrder(parameter);
     }
 }

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

@@ -6,6 +6,7 @@ import cn.hutool.core.date.DateTime;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.EnumUtil;
 import cn.hutool.core.util.ObjectUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -137,44 +138,38 @@ public class CesRoomsController {
 
     @ApiOperation(value="实时房态-房间列表", notes="实时房态")
     @GetMapping(value = "/realtime-rooms")
-    public Result getHotelRooms(@RequestParam Map params){
+    public Result<List<FloorWithBuildingVo>> getHotelRooms(@RequestParam Map params){
         Object hotelId = params.get("hotelId");
         if(null != hotelId) {
             List<FloorWithBuildingVo> floors = buildingFloorService.getHotelFloors(hotelId.toString());
             List<String> ids = floors.stream().map(s->s.getId()).collect(Collectors.toList());
             List<CesRoomLayout> layouts = layoutService.list(Wrappers.<CesRoomLayout>query().eq("hotel_id",hotelId.toString()).eq("invalid", false));
             // todo: 待更改。
-            List<CesRooms> allRooms =ids.size() > 0 ?  roomsService.list(Wrappers.<CesRooms>query().eq("invalid",false).in("floor_id",ids)): null;
-            if(allRooms == null || allRooms.size() == 0) {
+            List<CesRooms> allRooms = !ids.isEmpty() ?  roomsService.list(Wrappers.<CesRooms>query().eq("invalid",false).in("floor_id",ids)): null;
+            if(allRooms == null || allRooms.isEmpty()) {
                 return Result.ok(new ArrayList());
             }
             List<FloorBuildingRoomVo> otherInfos = bookingOrdersService.getRealtimeInfo(allRooms);
-            List<String> bookingOrderIds = new ArrayList<>();
-            otherInfos.forEach(c->{
-                if(c.getLivingData().getLivingOrder() != null) {
-                    bookingOrderIds.add(c.getLivingData().getLivingOrder().getBookingOrderId());
-                }
-                if(c.getBookingData().getBookingOrder() != null) {
-                    bookingOrderIds.add(c.getBookingData().getBookingOrder().getId());
-                }
-            });
             List<FwRoomLock> unLockeds = fwRoomLockService.list(Wrappers.<FwRoomLock>query().eq("hotel_id",hotelId));
             List<FwRoomRepair> unRepairs = fwRoomRepairService.list(Wrappers.<FwRoomRepair>query().eq("hotel_id",hotelId).eq("status",1));
-            List<BusTeam> teamOrders_all =bookingOrderIds.size() >0? teamService.list(Wrappers.<BusTeam>query().in("booking_order_id",bookingOrderIds).eq("is_delete", 0)):new ArrayList<>();
-//            List<BusTeam> teamOrders = teamOrders_all.stream().filter(sb->sb.getRelType().equals(1)).collect(Collectors.toList());
-//            List<BusTeam> relOrders = teamOrders_all.stream().filter(sb->sb.getRelType().equals(2)).collect(Collectors.toList());
+
             floors.forEach(s-> {
                 List<CesRooms> floorRooms = allRooms.stream().filter(a->a.getFloorId().equals(s.getId())).collect(Collectors.toList());
                 List<FloorBuildingRoomVo> roomInfos = new ArrayList<>();
                 floorRooms.forEach(a -> {
                     FloorBuildingRoomVo roomVo = new FloorBuildingRoomVo();
-                    Optional<FloorBuildingRoomVo> opFindRoomVo = otherInfos.stream().filter(p->p.getRoomId().equals(a.getId())).findFirst();
+                    //房型
                     Optional<CesRoomLayout> opLayout = layouts.stream().filter(c-> c.getId().equals(a.getLayoutId())).findFirst();
                     if(!opLayout.isPresent()) return; // 没有房型的房间给他去掉
-                    //房型
                     roomVo.setLayout(opLayout.get());
                     //房间
                     roomVo.setRoomInfo(a);
+                    // 订单
+                    Optional<FloorBuildingRoomVo> opFindRoomVo = otherInfos.stream().filter(p->p.getRoomId().equals(a.getId())).findFirst();
+                    if(opFindRoomVo.isPresent()) {
+                        roomVo.setLivingData(opFindRoomVo.get().getLivingData());
+                        roomVo.setBookingData(opFindRoomVo.get().getBookingData());
+                    }
                     // 维修房
                     if(a.getRoomStatus().equals(RoomStatusEnum.IN_SERVICE.getKey())){
                         Optional<FwRoomRepair> optionalFwRoomRepair = unRepairs.stream().filter(u->u.getRoomId().equals(a.getId())).findFirst();
@@ -197,40 +192,6 @@ public class CesRoomsController {
                             roomVo.setLockInfo(optionalFwRoomLock.get());
                         }
                     }
-                    if(opFindRoomVo.isPresent()) {
-                        roomVo.setLivingData(opFindRoomVo.get().getLivingData());
-                        if(opFindRoomVo.get().getBookingData().getBookingOrder() != null) {
-                            BusRoomBookingOrders bookingOrders = opFindRoomVo.get().getBookingData().getBookingOrder();
-                            Optional<BusTeam> opTeam = teamOrders_all.stream().filter(r->r.getBookingOrderId().equals(bookingOrders.getId())).findFirst();
-                            if(opTeam.isPresent()) {
-                                BusTeam t = opTeam.get();
-                                if(t.getRelType().equals(1)) {
-                                    opFindRoomVo.get().getBookingData().getBookingOrder().setIsTeam(true);
-                                    opFindRoomVo.get().getBookingData().getBookingOrder().setTeamTag("团"+t.getSortIndex());
-                                } else {
-//                                    opFindRoomVo.get().getBookingData().getBookingOrder().setIsRel(true);
-//                                    opFindRoomVo.get().getBookingData().getBookingOrder().setRelTag("联"+t.getSortIndex());
-                                }
-
-                            }
-                        }
-                        if(opFindRoomVo.get().getLivingData().getLivingOrder() != null) {
-                            BusRoomsLivingOrder livingOrder = opFindRoomVo.get().getLivingData().getLivingOrder();
-                            Optional<BusTeam> opTeam = teamOrders_all.stream().filter(r->r.getBookingOrderId().equals(livingOrder.getBookingOrderId())).findFirst();
-                            if(opTeam.isPresent()) {
-                                BusTeam t = opTeam.get();
-                                if(t.getRelType().equals(1)) {
-                                    opFindRoomVo.get().getLivingData().getLivingOrder().setIsTeam(true);
-                                    opFindRoomVo.get().getLivingData().getLivingOrder().setTeamTag("团"+opTeam.get().getSortIndex());
-                                } else {
-                                    opFindRoomVo.get().getLivingData().getLivingOrder().setIsRel(true);
-                                    opFindRoomVo.get().getLivingData().getLivingOrder().setRelTag("联"+opTeam.get().getSortIndex());
-                                }
-
-                            }
-                        }
-                        roomVo.setBookingData(opFindRoomVo.get().getBookingData());
-                    }
                     roomInfos.add(roomVo);
                 });
                 s.setRooms(roomInfos);
@@ -465,6 +426,8 @@ public class CesRoomsController {
                 } else if (cesRooms.getRoomStatus().equals(RoomStatusEnum.LIVE_CLEAR.getKey())) {
                     cesRooms.setLastRoomStatus(RoomStatusEnum.LIVE_DIRTY.getKey());
                     cesRooms.setRoomStatus(RoomStatusEnum.LIVE_DIRTY.getKey());
+                } else if (cesRooms.getRoomStatus().equals(RoomStatusEnum.RESERVE.getKey())){
+                    cesRooms.setLastRoomStatus(RoomStatusEnum.EMPTY_DIRTY.getKey());
                 }
                 roomsService.updateById(cesRooms);
             }

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

@@ -2,6 +2,7 @@ package org.jeecg.modules.rooms.entity;
 
 import com.baomidou.mybatisplus.annotation.TableName;
 import lombok.Data;
+import org.apache.poi.hpsf.Decimal;
 
 import java.math.BigDecimal;
 import java.util.Date;
@@ -48,4 +49,7 @@ public class CesHouseLongRentCharge {
     /**是自定义押金*/
     private Boolean isDepositCustom;
 
+    /**读表*/
+    private Decimal meterRead;
+
 }

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

@@ -132,6 +132,14 @@ public class CesRooms extends Model<CesRooms> {
     @ApiModelProperty(value = "上次房态")
     private Integer lastRoomStatus;
 
+    @ApiModelProperty(value = "水表读数")
+    private Integer waterMeter;
+
+    @ApiModelProperty(value = "电表读数")
+    private Integer energyMeter;
+
+    @ApiModelProperty(value = "燃气读数")
+    private Integer gasMeter;
 
     public static final String ID = "id";
 
@@ -163,6 +171,12 @@ public class CesRooms extends Model<CesRooms> {
 
     public static final String INVALID = "invalid";
 
+    public static final String WATER_METER = "water_meter";
+
+    public static final String ENERGY_METER = "energy_meter";
+
+    public static final String GAS_METER = "gas_meter";
+
     @Override
     public Serializable pkVal() {
         return this.id;

+ 15 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/CesRoomBuildingFloorServiceImpl.java

@@ -5,6 +5,7 @@ import cn.hutool.core.collection.CollectionUtil;
 import cn.hutool.core.lang.tree.Tree;
 import cn.hutool.core.lang.tree.TreeNode;
 import cn.hutool.core.lang.tree.TreeUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@@ -15,8 +16,11 @@ import org.jeecg.modules.rooms.DTO.CesRoomBuildingFloorDto;
 import org.jeecg.modules.rooms.Enum.CouponEnums;
 import org.jeecg.modules.rooms.Vo.FloorWithBuildingVo;
 import org.jeecg.modules.rooms.entity.CesRoomBuildingFloor;
+import org.jeecg.modules.rooms.entity.CesRooms;
 import org.jeecg.modules.rooms.mapper.CesRoomBuildingFloorMapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.rooms.mapper.CesRoomsMapper;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -38,6 +42,10 @@ public class CesRoomBuildingFloorServiceImpl extends ServiceImpl<CesRoomBuilding
     @Resource
     private CesRoomBuildingFloorMapper buildingFloorMapper;
 
+    @Resource
+//    private CesRoomsServiceImpl cesroomsService;
+    CesRoomsMapper cesRoomsMapper;
+
     /**
      * 获取楼栋楼层树
      * @param hotelId
@@ -120,13 +128,17 @@ public class CesRoomBuildingFloorServiceImpl extends ServiceImpl<CesRoomBuilding
         CesRoomBuildingFloor  cesRoomBuildingFloor =  buildingFloorMapper.selectById(floorDto.getId());
         if(ObjectUtils.isEmpty(cesRoomBuildingFloor)) return Result.error("该楼层或者楼栋未找到!");
 
-       List<CesRoomBuildingFloor> children = buildingFloorMapper.selectList(Wrappers.<CesRoomBuildingFloor>lambdaQuery()
+        List<CesRoomBuildingFloor> children = buildingFloorMapper.selectList(Wrappers.<CesRoomBuildingFloor>lambdaQuery()
                 .eq(CesRoomBuildingFloor::getParentId,cesRoomBuildingFloor.getId())
                 .eq(CesRoomBuildingFloor::getInvalid,false)
         );
 
-       if(!ObjectUtils.isEmpty(children)) return Result.error("该楼栋下还有楼栋数据,请全部删除后再删除楼栋!");
-
+        if(!ObjectUtils.isEmpty(children)) return Result.error("该楼栋下还有楼栋数据,请全部删除后再删除楼栋!");
+        long count = cesRoomsMapper.selectCount(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getFloorId, floorDto.getId())
+                    .eq(CesRooms::getInvalid, false));
+        if (count > 0) {
+            return Result.error("该楼栋下还有房间,请先删除房间!");
+        }
         cesRoomBuildingFloor.setInvalid(true);
         cesRoomBuildingFloor.setUpdateAt(LocalDateTime.now());
         buildingFloorMapper.updateById(cesRoomBuildingFloor);

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

@@ -3,6 +3,7 @@ package org.jeecg.modules.rooms.service;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.bean.copier.CopyOptions;
 import cn.hutool.core.collection.CollectionUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -200,6 +201,10 @@ public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> i
     public Result deleteOne(String id) {
         CesRooms rooms = roomsMapper.selectOne(Wrappers.<CesRooms>lambdaQuery().eq(CesRooms::getId, id).eq(CesRooms::getInvalid, false));
         if (ObjectUtils.isEmpty(rooms)) return Result.ok("删除成功!");
+        CesRooms cesRoom = getById(id);
+        if (StrUtil.isNotEmpty(cesRoom.getLivingOrderId())){
+            return Result.error("房间下有居住订单,不能删除");
+        }
         rooms.setInvalid(true);
         rooms.setUpdateAt(LocalDateTime.now());
         roomsMapper.updateById(rooms);
@@ -503,4 +508,15 @@ public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> i
         return update(updateWrapper);
     }
 
+    public Integer changeLivingRoomStatus(Integer status, Integer lastStatus) {
+        if (RoomStatusEnum.EMPTY_CLEAR.getKey().equals(status)) {
+            return RoomStatusEnum.LIVE_CLEAR.getKey();
+        } else if (RoomStatusEnum.EMPTY_DIRTY.getKey().equals(status)){
+            return RoomStatusEnum.LIVE_DIRTY.getKey();
+        } else if (RoomStatusEnum.RESERVE.getKey().equals(status)) {
+            return changeLivingRoomStatus(lastStatus, RoomStatusEnum.EMPTY_DIRTY.getKey());
+        } else {
+            throw new JeecgBootException("当前状态不可入住");
+        }
+    }
 }

+ 11 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysAnnouncementController.java

@@ -1,10 +1,12 @@
 package org.jeecg.modules.system.controller;
 
+import cn.hutool.core.collection.CollUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 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.jeecg.dingtalk.api.core.response.Response;
 import lombok.extern.slf4j.Slf4j;
@@ -21,8 +23,11 @@ import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.RedisUtil;
 import org.jeecg.common.util.TokenUtils;
 import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.business.entity.BusRoomsLivingOrder;
 import org.jeecg.modules.message.enums.RangeDateEnum;
 import org.jeecg.modules.message.websocket.WebSocket;
+import org.jeecg.modules.rooms.entity.CesRooms;
+import org.jeecg.modules.rooms.service.CesRoomsServiceImpl;
 import org.jeecg.modules.system.entity.SysAnnouncement;
 import org.jeecg.modules.system.entity.SysAnnouncementSend;
 import org.jeecg.modules.system.service.ISysAnnouncementSendService;
@@ -38,6 +43,7 @@ import org.jeecgframework.poi.excel.entity.ImportParams;
 import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Lazy;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.http.HttpStatus;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -80,6 +86,11 @@ public class SysAnnouncementController {
 	@Lazy
 	private RedisUtil redisUtil;
 
+	@Autowired
+	private RedisTemplate<String, Object> redisTemplate;
+	@Autowired
+	private CesRoomsServiceImpl roomsService;
+
 	/**
 	  * 分页列表查询
 	 * @param sysAnnouncement

+ 9 - 4
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/system/controller/SysAnnouncementSendController.java

@@ -5,6 +5,7 @@ import java.util.Date;
 
 import javax.servlet.http.HttpServletRequest;
 
+import cn.hutool.core.util.StrUtil;
 import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.constant.CommonConstant;
@@ -198,14 +199,18 @@ public class SysAnnouncementSendController {
 	public Result<SysAnnouncementSend> editById(@RequestBody JSONObject json) {
 		Result<SysAnnouncementSend> result = new Result<SysAnnouncementSend>();
 		String anntId = json.getString("anntId");
+		String[] ids = anntId.split(",");
 		LoginUser sysUser = (LoginUser)SecurityUtils.getSubject().getPrincipal();
 		String userId = sysUser.getId();
-		LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new UpdateWrapper().lambda();
+		if (userId.isEmpty()){
+			return result.error500("未找到消息");
+		}
+		LambdaUpdateWrapper<SysAnnouncementSend> updateWrapper = new LambdaUpdateWrapper<>();
 		updateWrapper.set(SysAnnouncementSend::getReadFlag, CommonConstant.HAS_READ_FLAG);
 		updateWrapper.set(SysAnnouncementSend::getReadTime, new Date());
-		updateWrapper.last("where annt_id ='"+anntId+"' and user_id ='"+userId+"'");
-		SysAnnouncementSend announcementSend = new SysAnnouncementSend();
-		sysAnnouncementSendService.update(announcementSend, updateWrapper);
+		updateWrapper.eq(SysAnnouncementSend::getUserId, userId);
+		updateWrapper.in(SysAnnouncementSend::getAnntId, (Object[]) ids);
+		sysAnnouncementSendService.update(updateWrapper);
 		result.setSuccess(true);
 		return result;
 	}