Parcourir la source

继续完善预约单流程
新增预约单时:
1、房型每天房价流程增加
2、关联的房间逻辑修改,传入roomId为空则记录为未排房
3、添加字段说明

qh il y a 2 ans
Parent
commit
8c8aacba8e
16 fichiers modifiés avec 229 ajouts et 13 suppressions
  1. 21 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/controller/BusBookingLayoutDayPriceController.java
  2. 6 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/dto/BookingBatchRoomsDto.java
  3. 17 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/dto/BookingLayoutRoomsDto.java
  4. 10 3
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/dto/BookingOrderSaveDto.java
  5. 48 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/BusBookingLayoutDayPrice.java
  6. 5 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/entity/BusBookingRooms.java
  7. 7 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/BusBookingLayoutDayPriceMapper.java
  8. 5 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/mapper/xml/BusBookingLayoutDayPriceMapper.xml
  9. 2 1
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IBusBookingBatchService.java
  10. 7 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/IBusBookingLayoutDayPriceService.java
  11. 11 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusBookingLayoutDayPriceServiceImpl.java
  12. 38 2
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusRoomBookingOrdersServiceImpl.java
  13. 5 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/DTO/CanUseRequestParamDto.java
  14. 12 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/entity/CesRoomLayout.java
  15. 0 2
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/mapper/CesRoomsMapper.java
  16. 35 4
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/CesRoomsServiceImpl.java

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

@@ -0,0 +1,21 @@
+package org.jeecg.modules.business.controller;
+
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.modules.business.entity.BusBookingLayoutDayPrice;
+import org.jeecg.modules.business.entity.BusBookingRooms;
+import org.jeecg.modules.business.service.IBusBookingLayoutDayPriceService;
+import org.jeecg.modules.business.service.IBusBookingRoomsService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+
+@Api(tags="预定订单关联每天房价")
+@RestController
+@RequestMapping("/business/busBookingLayoutDayPrice")
+@Slf4j
+public class BusBookingLayoutDayPriceController extends JeecgController<BusBookingLayoutDayPrice, IBusBookingLayoutDayPriceService> {
+
+}

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

@@ -1,13 +1,18 @@
 package org.jeecg.modules.business.dto;
 
 import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
 import org.jeecg.modules.business.entity.BusBookingBatch;
+import org.jeecg.modules.business.entity.BusBookingLayoutDayPrice;
 
 import java.util.List;
 
 @Data
 public class BookingBatchRoomsDto extends BusBookingBatch {
     @TableField(exist = false)
-    private List<String> roomIds;
+    private List<BookingLayoutRoomsDto> roomIds;
+    @ApiModelProperty(value = "房型每天价格 ,1 散客预定 每天房价传入这个必传")
+    @TableField(exist = false)
+    private List<BusBookingLayoutDayPrice> layoutDayPrices;
 }

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

@@ -0,0 +1,17 @@
+package org.jeecg.modules.business.dto;
+
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import javax.validation.constraints.NotNull;
+
+@Data
+@ApiModel(value="预定房间和房型参数", description="预定房间和房型参数")
+public class BookingLayoutRoomsDto {
+    @ApiModelProperty(value = "房型ID")
+    @NotNull(message = "房型必传")
+    private String layoutId;
+    @ApiModelProperty(value = "房间id,传入null/不传,表示未排房")
+    private String roomId;
+}

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

@@ -1,6 +1,8 @@
 package org.jeecg.modules.business.dto;
 
+import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
+import org.jeecg.modules.business.entity.BusBookingLayoutDayPrice;
 import org.jeecg.modules.business.entity.BusRoomBookingOrders;
 
 import java.util.List;
@@ -8,9 +10,14 @@ import java.util.List;
 @Data
 public class BookingOrderSaveDto  {
     private BusRoomBookingOrders orderInfo;
-    // 散客预定 走这个
-    private List<String> roomIds;
-    // 如果是团队预定 走这个
+    /**
+     *散客预定 走这个
+     **/
+    @ApiModelProperty(value = "散客预定 走这个,关联的房间id")
+    private List<BookingLayoutRoomsDto> roomIds;
+    @ApiModelProperty(value = "房型每天价格 ,1 散客预定 每天房价传入这个必传")
+    private List<BusBookingLayoutDayPrice> layoutDayPrices;
+    @ApiModelProperty(value = "如果是团队预定,关联房间ID和房型每天价格 走这个参数")
     private List<BookingBatchRoomsDto> batchRooms;
     // 联系人名称
     private String contactName;

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

@@ -0,0 +1,48 @@
+package org.jeecg.modules.business.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+@Data
+@TableName("bus_booking_layout_day_price")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="bus_booking_layout_day_price", description="预约单选定房型下每天房价")
+public class BusBookingLayoutDayPrice implements Serializable {
+    /**key*/
+    @TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "key")
+    private String id;
+    /**这个房价是那天的*/
+    @ApiModelProperty(value = "这个房价是那天的",required = true)
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern="yyyy-MM-dd")
+    private Date dayTime;
+    /**定义的价格是多少*/
+    @ApiModelProperty(value = "定义的价格是多少",required = true)
+    private BigDecimal price;
+    /**关联的预约单id*/
+    @ApiModelProperty(value = "关联的预约单id")
+    private String bookingOrderId;
+    /**1散客2团队*/
+    @ApiModelProperty(value = "1散客2团队",required = true)
+    private Integer bookingType;
+    /**团队类型下,关联的批次id*/
+    @ApiModelProperty(value = "团队类型下,关联的批次id")
+    private String batchId;
+    /**房型id*/
+    @ApiModelProperty(value = "房型id")
+    private String roomLayoutId;
+}

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

@@ -52,4 +52,9 @@ public class BusBookingRooms implements Serializable {
 	@Excel(name = "1散客2团队", width = 15)
     @ApiModelProperty(value = "1散客2团队")
     private Integer bookingType;
+    /**layoutId房型id*/
+    @Excel(name = "layoutId房型id", width = 15)
+    @ApiModelProperty(value = "layoutId房型id")
+    private String roomLayoutId;
+
 }

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

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

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

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

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

@@ -2,6 +2,7 @@ package org.jeecg.modules.business.service;
 
 import org.jeecg.modules.business.entity.BusBookingBatch;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.business.entity.BusBookingLayoutDayPrice;
 
 /**
  * @Description: 团队预定批次
@@ -9,6 +10,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * @Date:   2023-03-25
  * @Version: V1.0
  */
-public interface IBusBookingBatchService extends IService<BusBookingBatch> {
+public interface IBusBookingBatchService extends IService<BusBookingLayoutDayPrice> {
 
 }

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

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

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

@@ -0,0 +1,11 @@
+package org.jeecg.modules.business.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.business.entity.BusBookingLayoutDayPrice;
+import org.jeecg.modules.business.mapper.BusBookingLayoutDayPriceMapper;
+import org.jeecg.modules.business.service.IBusBookingBatchService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class BusBookingLayoutDayPriceServiceImpl extends ServiceImpl<BusBookingLayoutDayPriceMapper, BusBookingLayoutDayPrice> implements IBusBookingBatchService {
+}

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

@@ -12,6 +12,7 @@ import org.jeecg.modules.business.enums.BookingOrdersType;
 import org.jeecg.modules.business.enums.CheckInTypeEnum;
 import org.jeecg.modules.business.enums.CustomerTypeEnum;
 import org.jeecg.modules.business.mapper.BusRoomBookingOrdersMapper;
+import org.jeecg.modules.business.service.IBusBookingLayoutDayPriceService;
 import org.jeecg.modules.business.service.IBusRoomBookingOrdersService;
 import org.jeecg.modules.rooms.service.CesRoomsServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -20,6 +21,7 @@ import org.springframework.stereotype.Service;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.annotation.Resource;
 import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.util.ArrayList;
@@ -43,6 +45,10 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
 
     @Autowired
     private BusBookingBatchServiceImpl bookingBatchService;
+
+    @Resource
+    private IBusBookingLayoutDayPriceService dayPriceService;
+
     @Override
     @Transactional(rollbackFor = Exception.class)
     public String bookingOrderSave(BookingOrderSaveDto item) {
@@ -103,11 +109,26 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
             item.getRoomIds().forEach(c->{
                 BusBookingRooms bookingRoomsItem = new BusBookingRooms();
                 bookingRoomsItem.setBookingOrdersId(bookingId);
-                bookingRoomsItem.setRoomId(c);
+                bookingRoomsItem.setRoomId(c.getRoomId());
+                bookingRoomsItem.setRoomLayoutId(c.getLayoutId());
                 bookingRoomsItem.setBookingType(1);
                 bookingRooms.add(bookingRoomsItem);
             });
             bookingRoomsService.saveBatch(bookingRooms);
+
+            // 处理预定每天的房型价格 Start
+            if(item.getLayoutDayPrices() == null || item.getLayoutDayPrices().size() == 0)
+                throw new JeecgBootException("参数错误,对应房型当天价格必传");
+            if(item.getLayoutDayPrices().stream().anyMatch(o->o.getPrice()==null || o.getDayTime() == null || o.getRoomLayoutId() == null))
+                throw new JeecgBootException("参数错误,请传入价格、日期、房型");
+            item.getLayoutDayPrices().forEach(g->{
+                g.setBookingOrderId(item.getOrderInfo().getId());
+                g.setBookingType(BookingOrdersType.NORMAL.getKey());
+            });
+            dayPriceService.saveBatch(item.getLayoutDayPrices());
+            // 处理预定每天的房型价格 End
+
+
             return item.getOrderInfo().getBookingOrdersNo();
             // 团队预定
         } else if(item.getOrderInfo().getBookingOrdersType().equals(BookingOrdersType.TEAM.getKey())) {
@@ -137,13 +158,28 @@ public class BusRoomBookingOrdersServiceImpl extends ServiceImpl<BusRoomBookingO
                 List<BusBookingRooms> batchBookingRooms = new ArrayList<>();
                 c.getRoomIds().forEach(s-> {
                     BusBookingRooms bookingRoomItem = new BusBookingRooms();
-                    bookingRoomItem.setRoomId(s);
+                    bookingRoomItem.setRoomId(s.getRoomId());
+                    bookingRoomItem.setRoomLayoutId(s.getLayoutId());
                     bookingRoomItem.setBookingType(2);
                     bookingRoomItem.setBookingBatchId(batchItem.getId());
                     bookingRoomItem.setBookingOrdersId(item.getOrderInfo().getId());
                     batchBookingRooms.add(bookingRoomItem);
                 });
                 bookingRoomsService.saveBatch(batchBookingRooms);
+                // 以上处理批次关联的房间
+
+                //批次中处理每天房型价格 Start
+                if(c.getLayoutDayPrices() == null || c.getLayoutDayPrices().size() == 0)
+                    throw new JeecgBootException("参数错误,批次中对应房型当天价格必传");
+                if(c.getLayoutDayPrices().stream().anyMatch(o->o.getPrice()==null || o.getDayTime() == null || o.getRoomLayoutId() == null))
+                    throw new JeecgBootException("参数错误,批次中请传入价格、日期、房型");
+                c.getLayoutDayPrices().forEach(g->{
+                    g.setBookingOrderId(item.getOrderInfo().getId());
+                    g.setBookingType(BookingOrdersType.TEAM.getKey());
+                    g.setBatchId(batchItem.getId());
+                });
+                dayPriceService.saveBatch(c.getLayoutDayPrices());
+                //批次中处理每天房型价格 End
             });
             return item.getOrderInfo().getBookingOrdersNo();
         } else { // not exist type

+ 5 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/DTO/CanUseRequestParamDto.java

@@ -15,5 +15,10 @@ public class CanUseRequestParamDto {
     @DateTimeFormat(pattern="yyyy-MM-dd HH:mm")
     private Date endOf;
     private String hotelId;
+    // 钟点房房价规则ID
+    private String hourRoomRuleId;
+    // 预约类型 1,全天房,2钟点房
+    private Integer bookingType;
+
 
 }

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

@@ -167,6 +167,18 @@ public class CesRoomLayout extends Model<CesRoomLayout> {
      */
     private String cancelBeforeTime;
 
+    /**
+     * 优惠价 根据全天房和钟点房计费规则来定
+     */
+    @TableField(exist = false)
+    private BigDecimal favPrice;
+
+    /**
+     * 是否支持钟点房计费规则
+     */
+    @TableField(exist = false)
+    private Boolean isSupportHourRule;
+
 
     public static final String ID = "id";
 

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

@@ -26,8 +26,6 @@ public interface CesRoomsMapper extends BaseMapper<CesRooms> {
             "\tand\n" +
             "\tinvalid = 0\n" +
             "\tand \n" +
-            "\tstate = 1\n" +
-            "\tand \n" +
             "\tid NOT IN (\n" +
             "\tSELECT DISTINCT\n" +
             "\t\tbr.room_id \n" +

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

@@ -17,7 +17,10 @@ import org.apache.commons.collections.map.HashedMap;
 import org.apache.commons.lang3.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.exception.JeecgBootException;
 import org.jeecg.modules.business.entity.BusHotel;
+import org.jeecg.modules.business.enums.BookingOrdersType;
+import org.jeecg.modules.business.enums.CheckInTypeEnum;
 import org.jeecg.modules.business.service.impl.BusHotelServiceImpl;
 import org.jeecg.modules.rooms.DTO.*;
 import org.jeecg.modules.rooms.Enum.CouponEnums;
@@ -25,14 +28,13 @@ import org.jeecg.modules.rooms.Enum.RoomStatusEnum;
 import org.jeecg.modules.rooms.Vo.CanUseBuildingRoomsVo;
 import org.jeecg.modules.rooms.Vo.CanUseResultVo;
 import org.jeecg.modules.rooms.Vo.CesRoomsVo;
-import org.jeecg.modules.rooms.entity.CesRoomBuildingFloor;
-import org.jeecg.modules.rooms.entity.CesRoomLayout;
-import org.jeecg.modules.rooms.entity.CesRooms;
+import org.jeecg.modules.rooms.entity.*;
 import org.jeecg.modules.rooms.mapper.CesRoomsMapper;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import javax.transaction.Transactional;
+import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -60,6 +62,12 @@ public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> i
     @Resource
     private CesRoomLayoutServiceImpl layoutService;
 
+    @Resource
+    private CesAllDayPriceRuleServiceImpl allDayPriceRuleService;
+
+    @Resource
+    private CesHourRoomRuleServiceImpl hourRoomRuleService;
+
     /**
      * 查询房间
      * @param dto
@@ -258,10 +266,33 @@ public class CesRoomsServiceImpl extends ServiceImpl<CesRoomsMapper, CesRooms> i
        List<CanUseResultVo> results = new ArrayList<>();
        List<CesRoomBuildingFloor> floors = allBuildingFloors.stream().filter(s->!s.getParentId().equals("0")).collect(Collectors.toList());
 
-       layouts.forEach(s-> {
+        BigDecimal hourPrice = null;
+        List<String> relationHourRoomLayoutIds = new ArrayList<>();
+      if(param.getBookingType().equals(CheckInTypeEnum.HOUR_TIME.getKey())) {
+           if(param.getHourRoomRuleId()==null)
+               throw new JeecgBootException("参数错误");
+           CesHourRoomRule hourRoomRule = hourRoomRuleService.getById(param.getHourRoomRuleId());
+           if(hourRoomRule == null) throw new JeecgBootException("钟点房计费规则未找到");
+           if(hourRoomRule.getLayoutIds()!=null && !hourRoomRule.getLayoutIds().isEmpty()){
+               relationHourRoomLayoutIds.addAll(Arrays.stream(hourRoomRule.getLayoutIds().split(",")).collect(Collectors.toList()));
+           }
+
+           hourPrice = hourRoomRule.getAfterOpenRoomPay();
+        }
+        BigDecimal finalHourPrice = hourPrice;
+        layouts.forEach(s-> {
            CanUseResultVo item = new CanUseResultVo();
            List<CanUseBuildingRoomsVo> floorVos = new ArrayList<>();
            final Integer[] canUseRoomCount = {0};
+           // 钟点房和全天房计费方案取到对应的价格
+           if(param.getBookingType().equals(CheckInTypeEnum.ALL_DAYS.getKey())) {
+              s.setFavPrice(s.getMarketPrice());
+           } else if(param.getBookingType().equals(CheckInTypeEnum.HOUR_TIME.getKey())) {
+               // 判定是否支持房价方案
+               s.setIsSupportHourRule(relationHourRoomLayoutIds.stream().anyMatch(p->p.equals(s.getId())));
+               s.setFavPrice(finalHourPrice);
+           } else
+               s.setFavPrice(null);
            floors.forEach(c->{
                CanUseBuildingRoomsVo floorRoomsVo  = new CanUseBuildingRoomsVo();
                List<CesRooms> floorRooms = allRooms.stream().filter(e->e.getFloorId().equals(c.getId())).collect(Collectors.toList());