Sfoglia il codice sorgente

同步订单费用 根据全天房计费规则自动续房
日历房态,新增字段

覃浩 2 anni fa
parent
commit
25bfa085c6

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

@@ -20,6 +20,7 @@ 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.BusBookingBatch;
 import org.jeecg.modules.business.entity.BusLivingCustomer;
 import org.jeecg.modules.business.entity.BusOrderFee;
@@ -455,8 +456,8 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 	  */
 	 @ApiOperation(value="酒店预定订单-入住改价", notes="酒店预定订单-入住改价")
 	 @RequestMapping(value = "/update-order-price",method = RequestMethod.POST)
-	 public Result<Boolean> updateOrderPrice(Integer type,@RequestBody UpdateOrderInfoDto info) {
-		 return Result.OK(service.updateOrderInfo(type,info));
+	 public Result<Boolean> updateOrderPrice(@RequestBody UpdateOrderPriceDto info) {
+		 return Result.OK(service.updateOrderPrice(info));
 	 }
 
 
@@ -470,4 +471,5 @@ public class BusRoomBookingOrdersController extends JeecgController<BusRoomBooki
 
 
 
+
  }

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

@@ -13,7 +13,8 @@ public enum FeeSubjectType {
     YOU_HUI(4,"优惠金额"),
     JIE_ZHANG(5,"结账收款"),
     SHANG_PIN(6,"商品"),
-    DIAN_PIN(7,"点餐");
+    DIAN_PIN(7,"点餐"),
+    YE_SHEN_FANG_FEI(8,"夜审房费");
 
     Integer key;
 

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

@@ -129,6 +129,7 @@ cus.id as customer_id,cus.`name` as customer_name,lo.arrival_time,lo.due_out_tim
         select * from
         (
             select lo.id as order_id,
+            lo.booking_order_id,
             lo.arrival_time,lo.due_out_time, l.market_price,l.`name` as layout_name,
             r.id as room_id,b.id as floor_id,cus.`name` as customer_name, cus.phone as customer_phone,
             sum(if(fee.fee_type = 1,fee.money,0)) as xiaofei,
@@ -165,6 +166,7 @@ cus.id as customer_id,cus.`name` as customer_name,lo.arrival_time,lo.due_out_tim
             union all
 
             select lo.id as order_id,
+            lo.id as booking_order_id,
             lo.arrival_time,lo.due_out_time, l.market_price,l.`name` as layout_name,
             r.id as room_id,b.id as floor_id,cus.`name` as customer_name, cus.phone as customer_phone,
             0 as xiaofei,

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

@@ -6,13 +6,11 @@ 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.BusBookingBatch;
-import org.jeecg.modules.business.entity.BusLivingCustomer;
-import org.jeecg.modules.business.entity.BusOrderFee;
-import org.jeecg.modules.business.entity.BusRoomBookingOrders;
+import org.jeecg.modules.business.entity.*;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.business.vo.*;
 import org.jeecg.modules.rooms.Vo.FloorBuildingRoomVo;
+import org.jeecg.modules.rooms.entity.CesAllDayPriceRule;
 import org.jeecg.modules.rooms.entity.CesRooms;
 
 import java.math.BigDecimal;
@@ -70,5 +68,7 @@ public interface IBusRoomBookingOrdersService extends IService<BusRoomBookingOrd
     RiLiFangTaiResultVo riliFangTai(String start, String end, String hotelId);
     Boolean updateOrderInfo(Integer type, UpdateOrderInfoDto info);
     Boolean updateOrderPrice(UpdateOrderPriceDto info);
+    void syncDayOrderFee();
+    void syncDayOrderFeeItem(BusRoomsLivingOrder order, CesAllDayPriceRule allDayRule);
 
 }

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

@@ -20,9 +20,11 @@ import org.jeecg.modules.rooms.Enum.RoomStatusEnum;
 import org.jeecg.modules.rooms.Vo.BookingRealtimeVo;
 import org.jeecg.modules.rooms.Vo.FloorBuildingRoomVo;
 import org.jeecg.modules.rooms.Vo.LivingRealtimeVo;
+import org.jeecg.modules.rooms.entity.CesAllDayPriceRule;
 import org.jeecg.modules.rooms.entity.CesRoomBuildingFloor;
 import org.jeecg.modules.rooms.entity.CesRoomLayout;
 import org.jeecg.modules.rooms.entity.CesRooms;
+import org.jeecg.modules.rooms.service.CesAllDayPriceRuleServiceImpl;
 import org.jeecg.modules.rooms.service.CesRoomBuildingFloorServiceImpl;
 import org.jeecg.modules.rooms.service.CesRoomLayoutServiceImpl;
 import org.jeecg.modules.rooms.service.CesRoomsServiceImpl;
@@ -97,6 +99,9 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
     @Resource
     private CesRoomBuildingFloorServiceImpl buildingFloorService;
 
+    @Resource
+    private CesAllDayPriceRuleServiceImpl allDayPriceRuleService;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String bookingOrderSave(BookingOrderSaveDto item, Boolean isTeam) {
@@ -1633,6 +1638,83 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
         roomsLivingOrderService.updateBatchById(needMergeLivingOrders);
         return true;
     }
+    @Override
+    public void syncDayOrderFee() {
+        // 扫描每个订单,生成夜审房费,如果当日没有退房,并且没有生成当日房费,
+        // 则生成新的每日房费,生成的房费以门市价为准,
+        // 如果超过全天放计费的重算全天放时间,需要更改该订单的预离时间,自动续为全天房 //
+        // 未结账的房间集合
+        List<BusRoomsLivingOrder> unSettledLivings = roomsLivingOrderService.list(Wrappers.<BusRoomsLivingOrder>query()
+         .eq("settle_type", SettleTypeEnum.UN_LEAVE.getKey()));
+        List<CesAllDayPriceRule> allDayPriceRules = allDayPriceRuleService.list();
+        unSettledLivings.forEach(s->{
+            Optional<CesAllDayPriceRule> opAllPrice = allDayPriceRules.stream().filter(a->a.getHotelId().equals(s.getHotelId())).findFirst();
+            CesAllDayPriceRule allPrice;
+            if(!opAllPrice.isPresent()) {
+                allPrice = new CesAllDayPriceRule();
+                allPrice.setEndTime("16:00");
+            } else {
+                allPrice = opAllPrice.get();
+            }
+            syncDayOrderFeeItem(s,allPrice);
+        });
+
+    }
+
+    @SneakyThrows
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void syncDayOrderFeeItem(BusRoomsLivingOrder order, CesAllDayPriceRule allDayRule) {
+        List<String> dayStrs = MxTools.findEveryDay(DateUtils.formatTime(order.getArrivalTime()),
+                DateUtils.formatTime(new Date()));
+        BusBookingRooms bookingRoom = bookingRoomsService.getById(order.getBookingRoomId());
+        CesRooms room = roomsService.getById(bookingRoom.getRoomId());
+        CesRoomLayout layout = layoutService.getById(room.getLayoutId());
+        if(bookingRoom == null || room == null || layout == null) return;
+        List<BusLivingLayoutDayPrice> dayPrices = livingLayoutDayPriceService.list(Wrappers.<BusLivingLayoutDayPrice>query()
+                .eq("living_order_id",order.getId()).eq("booking_room_id",order.getBookingRoomId()));
+        List<BusOrderFee> dayFees = feeService.list(Wrappers.<BusOrderFee>query()
+                .eq("living_order_id",order.getId()).eq("room_id",room.getId()).eq("subject_type",FeeSubjectType.MEI_RI_FANG_FEI.getKey()));
+
+        // 如果预离时间小于当天 全天房退房时间,默认16:00,则根据全天规则续房为全天房
+        if(order.getDueOutTime().getTime() < DateUtils.parseDatetime(DateUtils.formatDate(new Date())+" " + allDayRule.getEndTime()).getTime()) {
+            Date orderLeave = order.getDueOutTime();
+//            orderLeave.
+        }
+        dayStrs.forEach(s->{
+            Optional<BusLivingLayoutDayPrice> opPrice = dayPrices.stream().filter(a-> DateUtils.formatDate(a.getDayTime()).equals(s)).findFirst();
+            if(!opPrice.isPresent()){
+                BusLivingLayoutDayPrice nPrice = new BusLivingLayoutDayPrice();
+                nPrice.setBookingRoomId(order.getBookingRoomId());
+                nPrice.setDayTime(DateUtils.parseDatetime(s));
+                nPrice.setRoomId(bookingRoom.getRoomId());
+                nPrice.setRoomLayoutId(room.getLayoutId());
+                nPrice.setPrice(layout.getMarketPrice());
+                nPrice.setLivingOrderId(order.getId());
+                livingLayoutDayPriceService.save(nPrice);
+            }
+            Optional<BusOrderFee> opFee = dayFees.stream().filter(a->DateUtils.formatDate(a.getDayTime()).equals(s)).findFirst();
+            if(!opFee.isPresent()) {
+                BusOrderFee nFee = new BusOrderFee();
+                nFee.setMoney(layout.getMarketPrice());
+                nFee.setCustorerOrderRemark("每日房费");
+                nFee.setAllowCouponscash(false);
+                nFee.setSubjectType(FeeSubjectType.MEI_RI_FANG_FEI.getKey());
+                nFee.setHotelId(order.getHotelId());
+                nFee.setCreateTime(new Date());
+                nFee.setDayTime(DateUtils.parseDatetime(s));
+                nFee.setRoomId(room.getId());
+                nFee.setFeeType(1);
+                nFee.setPreferentialStatus(1);
+                nFee.setLivingOrderId(order.getId());
+                if(DateUtils.parseDatetime(s).getTime() < new Date().getTime()) {
+                    nFee.setCustorerOrderRemark("夜审房费");
+                    nFee.setSubjectType(FeeSubjectType.YE_SHEN_FANG_FEI.getKey());
+                }
+                feeService.save(nFee);
+            }
+        });
+    }
 
 
     String getBookingRoomHotelId(BusBookingRooms bookingRoom) {

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

@@ -12,6 +12,7 @@ public class RiLiFangTaiVo {
     private String floorId;
     private String roomId;
     private String orderId;
+    private String bookingOrderId;
     @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm")
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
     private Date arrivalTime;