Просмотр исходного кода

fix 全天房 钟点房 代码 (钟点房未写完)

DESKTOP-B78GIPM\admin лет назад: 2
Родитель
Сommit
bb35115365
16 измененных файлов с 988 добавлено и 0 удалено
  1. 12 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/DTO/CesAllDayPriceRuleDto.java
  2. 27 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/DTO/CesHourRoomRuleDto.java
  3. 87 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/Enum/CouponEnums.java
  4. 32 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/Vo/CesHourRoomRuleVo.java
  5. 136 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/controller/CesAllDayPriceRuleController.java
  6. 26 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/controller/CesAllDayRuleMinuteController.java
  7. 61 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/controller/CesHourRoomRuleController.java
  8. 125 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/entity/CesAllDayPriceRule.java
  9. 104 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/entity/CesAllDayRuleMinute.java
  10. 149 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/entity/CesHourRoomRule.java
  11. 16 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/mapper/CesAllDayPriceRuleMapper.java
  12. 18 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/mapper/CesAllDayRuleMinuteMapper.java
  13. 16 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/mapper/CesHourRoomRuleMapper.java
  14. 64 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/CesAllDayPriceRuleServiceImpl.java
  15. 44 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/CesAllDayRuleMinuteServiceImpl.java
  16. 71 0
      jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/service/CesHourRoomRuleServiceImpl.java

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

@@ -0,0 +1,12 @@
+package org.jeecg.modules.rooms.DTO;
+
+import lombok.Data;
+import org.jeecg.modules.rooms.entity.CesAllDayPriceRule;
+import org.jeecg.modules.rooms.entity.CesAllDayRuleMinute;
+
+import java.util.List;
+
+@Data
+public class CesAllDayPriceRuleDto extends CesAllDayPriceRule {
+    List<CesAllDayRuleMinute> roomLayoutRules;
+}

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

@@ -0,0 +1,27 @@
+package org.jeecg.modules.rooms.DTO;
+
+import lombok.Data;
+import org.jeecg.common.api.dto.BasePage;
+
+/**
+ * <p>
+ * 租户房型列表查询后端接受前端参数DTO类
+ * </p>
+ *
+ * @author fendo
+ * @since 2023-03-01
+ */
+@Data
+public class CesHourRoomRuleDto extends BasePage {
+
+    /**
+     * 酒店ID
+     */
+    private String hotelId;
+
+    /**
+     * 钟点房名称
+     */
+    private String hourRoomName;
+
+}

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

@@ -126,4 +126,91 @@ public class CouponEnums {
 	}
 
 
+
+	/**
+	 * 全天放超时计费规则 枚举
+	 */
+	public static enum ALLDAYROOMRULETIMEOUT {
+		MINUTE(1,"按分钟加收费用"), HALF_DAY(2,"按半天房费收费"), NOTPAY(3,"不收房费");
+
+		int code = 0;
+		String value = "";
+
+		private ALLDAYROOMRULETIMEOUT(int code,String value){
+			this.code = code;
+			this.value = value;
+		}
+
+		public int code(){
+			return code;
+		}
+
+		public String getValue(){
+			return value;
+		}
+
+		//根据CODE获取类型
+		public static ALLDAYROOMRULETIMEOUT val(int vcode){
+			for(ALLDAYROOMRULETIMEOUT bld: values()){
+				if(bld.code == vcode){
+					return bld;
+				}
+			}
+			return NOTPAY;
+		}
+
+		public static ALLDAYROOMRULETIMEOUT val(String value){
+			for(ALLDAYROOMRULETIMEOUT bld : values()){
+				if(bld.value.equals(value)){
+					return bld;
+				}
+			}
+			return NOTPAY;
+		}
+	}
+
+	/**
+	 * 全天放超时计费规则细节:统一设置还是根据房型 枚举
+	 */
+	public static enum ALLDAYROOMRULETYPEDETAILS {
+		UNIFY(1,"统一设置"), LAYOUT(2,"根据房型设置");
+
+		int code = 0;
+		String value = "";
+
+		private ALLDAYROOMRULETYPEDETAILS(int code,String value){
+			this.code = code;
+			this.value = value;
+		}
+
+		public int code(){
+			return code;
+		}
+
+		public String getValue(){
+			return value;
+		}
+
+		//根据CODE获取类型
+		public static ALLDAYROOMRULETYPEDETAILS val(int vcode){
+			for(ALLDAYROOMRULETYPEDETAILS bld: values()){
+				if(bld.code == vcode){
+					return bld;
+				}
+			}
+			return LAYOUT;
+		}
+
+		public static ALLDAYROOMRULETYPEDETAILS val(String value){
+			for(ALLDAYROOMRULETYPEDETAILS bld : values()){
+				if(bld.value.equals(value)){
+					return bld;
+				}
+			}
+			return LAYOUT;
+		}
+	}
+
+
+
 }

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

@@ -0,0 +1,32 @@
+package org.jeecg.modules.rooms.Vo;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecg.modules.rooms.entity.CesHourRoomRule;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * <p>
+ * 钟点房计费规则Vo类
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-08
+ */
+@Data
+public class CesHourRoomRuleVo extends CesHourRoomRule {
+
+    /**
+     * 酒店名称
+     */
+    private String hotelName;
+
+}

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

@@ -0,0 +1,136 @@
+package org.jeecg.modules.rooms.controller;
+
+
+import cn.hutool.core.util.EnumUtil;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
+import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.Enum.ResultCode;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.modules.rooms.DTO.CesAllDayPriceRuleDto;
+import org.jeecg.modules.rooms.Enum.CouponEnums;
+import org.jeecg.modules.rooms.entity.CesAllDayPriceRule;
+import org.jeecg.modules.rooms.entity.CesAllDayRuleMinute;
+import org.jeecg.modules.rooms.service.CesAllDayPriceRuleServiceImpl;
+import org.jeecg.modules.rooms.service.CesAllDayRuleMinuteServiceImpl;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.List;
+
+/**
+ * <p>
+ * 全天房计费规则表 前端控制器
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-07
+ */
+@RestController
+@RequestMapping("/rooms/cesAllDayPriceRule")
+@Api(tags = "ces_all_day_price_rule")
+@Slf4j
+public class CesAllDayPriceRuleController  extends JeecgController<CesAllDayPriceRule, CesAllDayPriceRuleServiceImpl> {
+    @Resource
+    CesAllDayPriceRuleServiceImpl cesAllDayPriceRuleService;
+
+    @ApiOperation(value="全天房计费统一设置超时收费", notes="全天房计费统一设置超时收费")
+    @PostMapping(value = "/modify")
+    public Result modify(@RequestBody CesAllDayPriceRuleDto cesAllDayPriceRuleDto){
+        if (null==cesAllDayPriceRuleDto){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (StringUtils.isBlank(cesAllDayPriceRuleDto.getHotelId())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (StringUtils.isBlank(cesAllDayPriceRuleDto.getEnterTime())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (StringUtils.isBlank(cesAllDayPriceRuleDto.getLeaveTime())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (cesAllDayPriceRuleDto.getTimeOutRule().intValue()!= 0){
+            List<Object> codes = EnumUtil.getFieldValues(CouponEnums.ALLDAYROOMRULETIMEOUT.class, "code");
+            if(!codes.contains(cesAllDayPriceRuleDto.getTimeOutRule().intValue())){
+                return Result.error("参数不正确!请选择正确的收费类型!");
+            }
+        }else{
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (StringUtils.isBlank(cesAllDayPriceRuleDto.getEndTime())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (cesAllDayPriceRuleDto.getRuleType().intValue()!=0){
+            List<Object> codes = EnumUtil.getFieldValues(CouponEnums.ALLDAYROOMRULETYPEDETAILS.class, "code");
+            if (!codes.contains(cesAllDayPriceRuleDto.getTimeOutRule().intValue())){
+                return Result.error("参数不正确!请选择正确的收费规则!");
+            }
+        }else {
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        //按分钟收费验证逻辑
+        if(CouponEnums.ALLDAYROOMRULETIMEOUT.MINUTE.code() == cesAllDayPriceRuleDto.getTimeOutRule().intValue()){
+            //统一设置验证参数
+            if(CouponEnums.ALLDAYROOMRULETYPEDETAILS.UNIFY.code() == cesAllDayPriceRuleDto.getRuleType().intValue()){
+                //验证字段参数是否正确
+                if (null==cesAllDayPriceRuleDto.getMinute()||1>cesAllDayPriceRuleDto.getMinute().intValue()){
+                    return Result.error(ResultCode.PARAM_MISS);
+                }
+                if (null==cesAllDayPriceRuleDto.getPrice()||BigDecimal.ZERO.compareTo(cesAllDayPriceRuleDto.getPrice())>0){
+                    return Result.error(ResultCode.PARAM_MISS);
+                }
+                if (null==cesAllDayPriceRuleDto.getMoreThenMinute()||1>cesAllDayPriceRuleDto.getMoreThenMinute().intValue()){
+                    return Result.error(ResultCode.PARAM_MISS);
+                }
+                if (null==cesAllDayPriceRuleDto.getMoreThenPrice()||BigDecimal.ZERO.compareTo(cesAllDayPriceRuleDto.getMoreThenPrice())>0){
+                    return Result.error(ResultCode.PARAM_MISS);
+                }
+            }else if(CouponEnums.ALLDAYROOMRULETYPEDETAILS.LAYOUT.code() == cesAllDayPriceRuleDto.getRuleType().intValue()){ //房型数据 验证逻辑
+                List<CesAllDayRuleMinute>  roomlayout = cesAllDayPriceRuleDto.getRoomLayoutRules();
+                if(CollectionUtils.isEmpty(roomlayout)){
+                    return Result.error(ResultCode.PARAM_MISS,"按照房型配置数据不能为空!");
+                }
+                //循环去校验规则
+                for (CesAllDayRuleMinute v : roomlayout) {
+                    //写校验规则
+                    if (StringUtils.isBlank(v.getRoomLayoutId())){
+                        return Result.error(ResultCode.PARAM_MISS);
+                    }
+                    if (null==v.getMinute()||1>v.getMinute().intValue()){
+                        return Result.error(ResultCode.PARAM_MISS);
+                    }
+                    if (null==v.getPrice()||BigDecimal.ZERO.compareTo(v.getPrice())>0){
+                        return Result.error(ResultCode.PARAM_MISS);
+                    }
+                    if (null==v.getMoreThenMinute()||1>v.getMoreThenMinute().intValue()){
+                        return Result.error(ResultCode.PARAM_MISS);
+                    }
+                    if (null==v.getMoreThenPrice()||BigDecimal.ZERO.compareTo(v.getMoreThenPrice())>0){
+                        return Result.error(ResultCode.PARAM_MISS);
+                    }
+                }
+            }
+        }
+
+        if (StringUtils.isBlank(cesAllDayPriceRuleDto.getDayTime())||Integer.parseInt(cesAllDayPriceRuleDto.getDayTime())<0){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+
+        try{
+            return cesAllDayPriceRuleService.modifyWholeDayUnifyPrice(cesAllDayPriceRuleDto);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
+
+    }
+}
+

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

@@ -0,0 +1,26 @@
+package org.jeecg.modules.rooms.controller;
+
+
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.modules.rooms.entity.CesAllDayRuleMinute;
+import org.jeecg.modules.rooms.service.CesAllDayRuleMinuteServiceImpl;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * 全天房第2点按分钟收费按房型设置表 前端控制器
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-07
+ */
+@RestController
+@RequestMapping("/rooms/cesAllDayRuleMinute")
+@Slf4j
+public class CesAllDayRuleMinuteController   extends JeecgController<CesAllDayRuleMinute, CesAllDayRuleMinuteServiceImpl> {
+
+
+}
+

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

@@ -0,0 +1,61 @@
+package org.jeecg.modules.rooms.controller;
+
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.jeecg.common.Enum.ResultCode;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.modules.rooms.DTO.CesHourRoomRuleDto;
+import org.jeecg.modules.rooms.entity.CesHourRoomRule;
+import org.jeecg.modules.rooms.service.CesHourRoomRuleServiceImpl;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.annotation.Resource;
+
+/**
+ * <p>
+ * 钟点房计费规则表 前端控制器
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-08
+ */
+@RestController
+@RequestMapping("/rooms/cesHourRoomRule")
+@Api(tags = "ces_hour_room_rule")
+@Slf4j
+public class CesHourRoomRuleController extends JeecgController<CesHourRoomRule, CesHourRoomRuleServiceImpl> {
+
+    @Resource
+    CesHourRoomRuleServiceImpl cesHourRoomRuleService;
+
+    @ApiOperation(value="钟点房规则查询", notes="钟点房规则查询")
+    @GetMapping(value = "/list")
+    public Result list(CesHourRoomRuleDto cesHourRoomRuleDto){
+        if (ObjectUtils.isEmpty(cesHourRoomRuleDto)){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (0>=cesHourRoomRuleDto.getPageNo()){
+            return Result.error("页数不能小于等于0");
+        }
+        if (0>=cesHourRoomRuleDto.getPageSize()){
+            return Result.error("页码尺寸不能小于等于0");
+        }
+        if (StringUtils.isEmpty(cesHourRoomRuleDto.getHotelId())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        try{
+            return cesHourRoomRuleService.list(cesHourRoomRuleDto);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
+
+    }
+}
+

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

@@ -0,0 +1,125 @@
+package org.jeecg.modules.rooms.entity;
+
+import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 全天房计费规则表
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-07
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("ces_all_day_price_rule")
+public class CesAllDayPriceRule extends Model<CesAllDayPriceRule> {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    /**
+     * 酒店ID
+     */
+    private String hotelId;
+
+    /**
+     * 进店时间
+     */
+    private String enterTime;
+
+    /**
+     * 退房时间
+
+     */
+    private String leaveTime;
+
+    /**
+     * 1按分钟加收
+2 按半天房费加收
+3 不收房费
+     */
+    private Integer timeOutRule;
+
+    /**
+     * 1 统一设置  2 根据房型设置(只有在 规则为 1 的情况下生效 )  规则是2 在另外一个表中
+     */
+    private Integer ruleType;
+
+    /**
+     * 每隔n 分钟 (只有在 rule_type  == 1 情况下生效)
+     */
+
+    private Integer minute;
+
+    /**
+     * 收取费用(单位元)
+     */
+    private BigDecimal price;
+
+    /**
+     * 超过分钟
+     */
+    private Integer moreThenMinute;
+
+    /**
+     * 超过时间收费(单位元)
+     */
+    private BigDecimal moreThenPrice;
+
+    /**
+     * 直到 小时数 加收全天房费
+     */
+    private String endTime;
+
+    /**
+     * 全天房超过退房时间可以宽限时间(分钟)
+     */
+    private String dayTime;
+
+    /**
+     * 逻辑删除字段
+     */
+    private Boolean invalid;
+
+
+    public static final String ID = "id";
+
+    public static final String HOTEL_ID = "hotel_id";
+
+    public static final String ENTER_TIME = "enter_time";
+
+    public static final String LEAVE_TIME = "leave_time";
+
+    public static final String TIME_OUT_RULE = "time_out_rule";
+
+    public static final String RULE_TYPE = "rule_type";
+
+    public static final String MINUTE = "minute";
+
+    public static final String PRICE = "price";
+
+    public static final String MORE_THEN_MINUTE = "more_then_minute";
+
+    public static final String MORE_THEN_PRICE = "more_then_price";
+
+    public static final String END_TIME = "end_time";
+
+    public static final String DAY_TIME = "day_time";
+
+    public static final String INVALID = "invalid";
+
+    @Override
+    public Serializable pkVal() {
+        return this.id;
+    }
+
+}

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

@@ -0,0 +1,104 @@
+package org.jeecg.modules.rooms.entity;
+
+import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import java.time.LocalDateTime;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 全天房第2点按分钟收费按房型设置表
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-07
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("ces_all_day_rule_minute")
+public class CesAllDayRuleMinute extends Model<CesAllDayRuleMinute> {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    /**
+     * 酒店ID
+     */
+    private String hotelId;
+
+    /**
+     * 房型ID
+     */
+    private String roomLayoutId;
+
+    /**
+     * 每隔n 分钟 
+     */
+    private Integer minute;
+
+    /**
+     * 收取费用(元)
+     */
+    private BigDecimal price;
+
+    /**
+     * 超过分钟
+     */
+    private Integer moreThenMinute;
+
+    /**
+     * 超过时间收费(单位元)
+     */
+    private BigDecimal moreThenPrice;
+
+    /**
+     * 创建时间
+     */
+    @TableField("createAt")
+    private LocalDateTime createAt;
+
+    /**
+     * 修改时间
+     */
+    @TableField("updateAt")
+    private LocalDateTime updateAt;
+
+    /**
+     * 逻辑删除字段
+     */
+    private Boolean invalid;
+
+
+    public static final String ID = "id";
+
+    public static final String HOTEL_ID = "hotel_id";
+
+    public static final String ROOM_LAYOUT_ID = "room_layout_id";
+
+    public static final String MINUTE = "minute";
+
+    public static final String PRICE = "price";
+
+    public static final String MORE_THEN_MINUTE = "more_then_minute";
+
+    public static final String MORE_THEN_PRICE = "more_then_price";
+
+    public static final String CREATEAT = "createAt";
+
+    public static final String UPDATEAT = "updateAt";
+
+    public static final String INVALID = "invalid";
+
+    @Override
+    public Serializable pkVal() {
+        return this.id;
+    }
+
+}

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

@@ -0,0 +1,149 @@
+package org.jeecg.modules.rooms.entity;
+
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * <p>
+ * 钟点房计费规则
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-08
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("ces_hour_room_rule")
+public class CesHourRoomRule extends Model<CesHourRoomRule> {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    /**
+     * 酒店ID
+     */
+    private String hotelId;
+
+
+    /**
+     * 钟点房名称
+     */
+    private String hourRoomName;
+
+    /**
+     * 收费规则
+     */
+    private String rule;
+
+    /**
+     * 房型id
+     */
+    private List<String> layoutIds;
+
+    /**
+     * 开房后时间(分钟)
+     */
+    private String afterOpenRoom;
+
+    /**
+     * 开房后多少分钟内按多少元收取
+     */
+    private BigDecimal afterOpenRoomPay;
+
+    /**
+     * 超时时间(分钟)周期
+     */
+    private String exceedTime;
+
+    /**
+     * 每到一个超时周期收取费用(元)
+     */
+    private BigDecimal exceedPay;
+
+    /**
+     * 不到超时周期的超时时间(分钟)
+     */
+    private String notReachExceedTime;
+
+    /**
+     * 不到超时周期的超时收费(元)
+     */
+    private BigDecimal notReachExceedTimePay;
+
+    /**
+     * 最多封顶花费(元)如果为0则不封顶
+     */
+    private BigDecimal maxExtraPay;
+
+    /**
+     * 超过多少分钟转为全天房(0分钟则视为不转为全天房)
+     */
+    private String limitTimeTransferAllDay;
+
+    /**
+     * 创建时间
+     */
+    @TableField("createAt")
+    private LocalDateTime createAt;
+
+    /**
+     * 修改时间
+     */
+    @TableField("updateAt")
+    private LocalDateTime updateAt;
+
+    /**
+     * 逻辑删除字段
+     */
+    private Boolean invalid;
+
+
+    public static final String ID = "id";
+
+    public static final String HOTEL_ID = "hotel_id";
+
+    public static final String HOUR_ROOM_NAME = "hour_room_name";
+
+    public static final String RULE = "rule";
+
+    public static final String LAYOUT_IDS = "layout_ids";
+
+    public static final String AFTER_OPEN_ROOM = "after_open_room";
+
+    public static final String AFTER_OPEN_ROOM_PAY = "after_open_room_pay";
+
+    public static final String EXCEED_TIME = "exceed_time";
+
+    public static final String EXCEED_PAY = "exceed_pay";
+
+    public static final String NOT_REACH_EXCEED_TIME = "not_reach_exceed_time";
+
+    public static final String NOT_REACH_EXCEED_TIME_PAY = "not_reach_exceed_time_pay";
+
+    public static final String MAX_EXTRA_PAY = "max_extra_pay";
+
+    public static final String LIMIT_TIME_TRANSFER_ALL_DAY = "limit_time_transfer_all_day";
+
+    public static final String CREATEAT = "createAt";
+
+    public static final String UPDATEAT = "updateAt";
+
+    public static final String INVALID = "invalid";
+
+    @Override
+    public Serializable pkVal() {
+        return this.id;
+    }
+
+}

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

@@ -0,0 +1,16 @@
+package org.jeecg.modules.rooms.mapper;
+
+import org.jeecg.modules.rooms.entity.CesAllDayPriceRule;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 全天房计费规则表 Mapper 接口
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-07
+ */
+public interface CesAllDayPriceRuleMapper extends BaseMapper<CesAllDayPriceRule> {
+
+}

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

@@ -0,0 +1,18 @@
+package org.jeecg.modules.rooms.mapper;
+
+import org.jeecg.modules.rooms.entity.CesAllDayRuleMinute;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 全天房第2点按分钟收费按房型设置表 Mapper 接口
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-07
+ */
+public interface CesAllDayRuleMinuteMapper extends BaseMapper<CesAllDayRuleMinute> {
+
+
+
+}

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

@@ -0,0 +1,16 @@
+package org.jeecg.modules.rooms.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.rooms.entity.CesHourRoomRule;
+
+/**
+ * <p>
+ * 钟点房计费规则表 Mapper 接口
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-08
+ */
+public interface CesHourRoomRuleMapper extends BaseMapper<CesHourRoomRule> {
+
+}

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

@@ -0,0 +1,64 @@
+package org.jeecg.modules.rooms.service;
+
+import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.bean.copier.CopyOptions;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.rooms.DTO.CesAllDayPriceRuleDto;
+import org.jeecg.modules.rooms.Enum.CouponEnums;
+import org.jeecg.modules.rooms.entity.CesAllDayPriceRule;
+import org.jeecg.modules.rooms.entity.CesAllDayRuleMinute;
+import org.jeecg.modules.rooms.mapper.CesAllDayPriceRuleMapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import javax.transaction.Transactional;
+import java.time.LocalDateTime;
+import java.util.List;
+
+/**
+ * <p>
+ * 全天房计费规则表 服务实现类
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-07
+ */
+@Service
+public class CesAllDayPriceRuleServiceImpl extends ServiceImpl<CesAllDayPriceRuleMapper, CesAllDayPriceRule> implements IService<CesAllDayPriceRule> {
+
+    @Resource
+    CesAllDayPriceRuleMapper cesAllDayPriceRuleMapper;
+    @Resource
+    CesAllDayRuleMinuteServiceImpl cesAllDayRuleMinuteService;
+
+    @Transactional(rollbackOn = Exception.class)
+    public Result modifyWholeDayUnifyPrice(CesAllDayPriceRuleDto cesAllDayPriceRuleDto) {
+        CesAllDayPriceRule cesAllDayPriceRule = cesAllDayPriceRuleMapper.selectById(cesAllDayPriceRuleDto.getId());
+        if(ObjectUtils.isEmpty(cesAllDayPriceRule)){
+            cesAllDayPriceRule =  new CesAllDayPriceRule();
+        }
+        BeanUtil.copyProperties(cesAllDayPriceRuleDto,cesAllDayPriceRule, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
+        saveOrUpdate(cesAllDayPriceRule);
+        //分钟加收
+        if (CouponEnums.ALLDAYROOMRULETIMEOUT.MINUTE.code() == cesAllDayPriceRuleDto.getTimeOutRule().intValue()){
+            //按房型设置下
+            if(CouponEnums.ALLDAYROOMRULETYPEDETAILS.LAYOUT.code() == cesAllDayPriceRuleDto.getRuleType().intValue()){
+                //按房型规则插入
+                List<CesAllDayRuleMinute> roomLayoutRules = cesAllDayPriceRuleDto.getRoomLayoutRules();
+                roomLayoutRules.forEach(v -> {
+                    v.setHotelId(cesAllDayPriceRuleDto.getHotelId());
+                    v.setUpdateAt(LocalDateTime.now());
+                    if(StringUtils.isEmpty(v.getId())){
+                        v.setCreateAt(LocalDateTime.now());
+                    }
+                });
+                cesAllDayRuleMinuteService.saveOrUpdateBatch(roomLayoutRules);
+            }
+        }
+        return Result.ok("成功!");
+    }
+}

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

@@ -0,0 +1,44 @@
+package org.jeecg.modules.rooms.service;
+
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.apache.commons.lang3.StringUtils;
+import org.jeecg.modules.rooms.entity.CesAllDayRuleMinute;
+import org.jeecg.modules.rooms.mapper.CesAllDayRuleMinuteMapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ * 全天房第2点按分钟收费按房型设置表 服务实现类
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-07
+ */
+@Service
+public class CesAllDayRuleMinuteServiceImpl extends ServiceImpl<CesAllDayRuleMinuteMapper, CesAllDayRuleMinute> implements IService<CesAllDayRuleMinute> {
+
+
+    @Resource
+    private CesAllDayRuleMinuteMapper cesAllDayRuleMinuteMapper;
+
+    /**
+     * 根据酒店id 查询当前酒店全天房计费 房型规则
+     * @param hotelId
+     * @return
+     */
+    public List<CesAllDayRuleMinute> getRuleMinutesByHotelId(String hotelId){
+        if(StringUtils.isEmpty(hotelId)) return  new ArrayList<>();
+
+       List<CesAllDayRuleMinute> data =  cesAllDayRuleMinuteMapper.selectList(Wrappers.<CesAllDayRuleMinute>lambdaQuery()
+                .eq(CesAllDayRuleMinute::getHotelId,  hotelId)
+                .eq(CesAllDayRuleMinute::getInvalid, false)
+        );
+       return  data;
+    }
+}

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

@@ -0,0 +1,71 @@
+package org.jeecg.modules.rooms.service;
+
+import cn.hutool.core.bean.BeanUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.apache.commons.collections.map.HashedMap;
+import org.apache.commons.lang3.StringUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.business.entity.BusHotel;
+import org.jeecg.modules.business.service.impl.BusHotelServiceImpl;
+import org.jeecg.modules.rooms.DTO.CesHourRoomRuleDto;
+import org.jeecg.modules.rooms.Vo.CesHourRoomRuleVo;
+import org.jeecg.modules.rooms.entity.CesHourRoomRule;
+import org.jeecg.modules.rooms.mapper.CesHourRoomRuleMapper;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.Optional;
+import java.util.stream.Collectors;
+
+/**
+ * <p>
+ * 钟点房计费规则表 服务实现类
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-08
+ */
+@Service
+public class CesHourRoomRuleServiceImpl extends ServiceImpl<CesHourRoomRuleMapper, CesHourRoomRule> implements IService<CesHourRoomRule> {
+
+    @Resource
+    CesHourRoomRuleMapper cesHourRoomRuleMapper;
+    @Resource
+    BusHotelServiceImpl busHotelService;
+
+
+    public Result list(CesHourRoomRuleDto cesHourRoomRuleDto){
+
+        QueryWrapper<CesHourRoomRule> queryWrapper =new QueryWrapper<>();
+        queryWrapper.eq(CesHourRoomRule.HOTEL_ID,cesHourRoomRuleDto.getHotelId());
+        if (StringUtils.isNotEmpty(cesHourRoomRuleDto.getHourRoomName())){
+            queryWrapper.eq(CesHourRoomRule.HOUR_ROOM_NAME,cesHourRoomRuleDto.getHourRoomName());
+        }
+        queryWrapper.eq(CesHourRoomRule.INVALID,false);
+        queryWrapper.orderByDesc(CesHourRoomRule.UPDATEAT);
+        IPage<CesHourRoomRule> dataPage = cesHourRoomRuleMapper.selectPage(new Page<>(cesHourRoomRuleDto.getPageNo().intValue(),cesHourRoomRuleDto.getPageSize().intValue()),queryWrapper);
+        List<CesHourRoomRule> records = dataPage.getRecords();
+        List<String> hotelIds = records.stream().map(v-> v.getHotelId()).collect(Collectors.toList());
+
+        List<BusHotel> busHotels = busHotelService.findHotelsByIds(hotelIds);
+        List<CesHourRoomRuleVo> vos = new ArrayList<>();
+        records.forEach(v -> {
+            CesHourRoomRuleVo vo = new CesHourRoomRuleVo();
+            BeanUtil.copyProperties(v, vo);
+            Optional<BusHotel> busHotelOptional = busHotels.stream().filter(busHotel -> busHotel.getId().equals(v.getHotelId())).findFirst();
+            if(busHotelOptional.isPresent())  vo.setHotelName(busHotelOptional.get().getName());
+            vos.add(vo);
+        });
+        Map<String,Object> map = new HashedMap();
+        map.put("records",vos);
+        map.put("total",dataPage.getTotal());
+        return Result.OK(map);
+    }
+}