Преглед на файлове

钟点房价格规则补全及房型service加了getRoomLayoutsByHotelId方法 贺姜乐

DESKTOP-B78GIPM\admin преди 2 години
родител
ревизия
d85f324af6

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

@@ -5,7 +5,7 @@ import org.jeecg.common.api.dto.BasePage;
 
 /**
  * <p>
- * 租户房型列表查询后端接受前端参数DTO类
+ * 钟点房计费规则查询DTO类
  * </p>
  *
  * @author fendo

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

@@ -0,0 +1,18 @@
+package org.jeecg.modules.rooms.DTO;
+
+import lombok.Data;
+import org.jeecg.common.api.dto.BasePage;
+import org.jeecg.modules.rooms.entity.CesHourRoomRule;
+
+/**
+ * <p>
+ * 钟点房计费规则新增修改,关联房型等通用DTO类
+ * </p>
+ *
+ * @author fendo
+ * @since 2023-03-01
+ */
+@Data
+public class CesHourRoomRuleModifyDto extends CesHourRoomRule {
+
+}

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

@@ -1,17 +1,8 @@
 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>
@@ -29,4 +20,6 @@ public class CesHourRoomRuleVo extends CesHourRoomRule {
      */
     private String hotelName;
 
+
+
 }

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

@@ -8,15 +8,20 @@ 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.aspect.annotation.AutoLog;
 import org.jeecg.common.system.base.controller.JeecgController;
 import org.jeecg.modules.rooms.DTO.CesHourRoomRuleDto;
+import org.jeecg.modules.rooms.DTO.CesHourRoomRuleModifyDto;
 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 org.jeecg.modules.rooms.service.CesRoomLayoutServiceImpl;
+import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * <p>
@@ -34,6 +39,8 @@ public class CesHourRoomRuleController extends JeecgController<CesHourRoomRule,
 
     @Resource
     CesHourRoomRuleServiceImpl cesHourRoomRuleService;
+    @Resource
+    CesRoomLayoutServiceImpl cesRoomLayoutService;
 
     @ApiOperation(value="钟点房规则查询", notes="钟点房规则查询")
     @GetMapping(value = "/list")
@@ -47,7 +54,7 @@ public class CesHourRoomRuleController extends JeecgController<CesHourRoomRule,
         if (0>=cesHourRoomRuleDto.getPageSize()){
             return Result.error("页码尺寸不能小于等于0");
         }
-        if (StringUtils.isEmpty(cesHourRoomRuleDto.getHotelId())){
+        if (StringUtils.isBlank(cesHourRoomRuleDto.getHotelId())){
             return Result.error(ResultCode.PARAM_MISS);
         }
         try{
@@ -55,7 +62,157 @@ public class CesHourRoomRuleController extends JeecgController<CesHourRoomRule,
         }catch (Exception e){
             return Result.error(e.getMessage());
         }
+    }
+
+    @ApiOperation(value="显示关联房型", notes="显示关联房型")
+    @GetMapping(value = "/listLayout")
+    public Result listLayout(String hotelId){
+        if (StringUtils.isBlank(hotelId)){
+            return Result.error("房型ID必要!");
+        }
+        try{
+            return cesRoomLayoutService.getRoomLayoutsByHotelId(hotelId);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
+    }
+
 
+    @AutoLog(value = "新增钟点房规则")
+    @ApiOperation(value="新增钟点房规则", notes="新增钟点房规则")
+    @PostMapping(value = "/save")
+    public Result save(@RequestBody CesHourRoomRuleModifyDto dto){
+        if (ObjectUtils.isEmpty(dto)){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (StringUtils.isBlank(dto.getHotelId())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (StringUtils.isBlank(dto.getHourRoomName())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (null==dto.getAfterOpenRoom()||0>=dto.getAfterOpenRoom()){
+            return Result.error("开房后时间为空或小于等于0!");
+        }
+        if (null==dto.getAfterOpenRoomPay()||BigDecimal.ZERO.compareTo(dto.getAfterOpenRoomPay())>0){
+            return Result.error("开房后花费为空或小于0!");
+        }
+        if (null==dto.getExceedTime()||0>=dto.getExceedTime()){
+            return Result.error("超过时间为空或小于等于0!");
+        }
+        if (null==dto.getExceedPay()||BigDecimal.ZERO.compareTo(dto.getExceedPay())>0){
+            return Result.error("超时花费为空或小于0!");
+        }
+        if (null==dto.getNotReachExceedTime()||0>=dto.getNotReachExceedTime()){
+            return Result.error("未达超时周期时间为空或小于等于0!");
+        }
+        if (null==dto.getNotReachExceedTimePay()||BigDecimal.ZERO.compareTo(dto.getNotReachExceedTimePay())>0){
+            return Result.error("未达超市周期花费为空或小于0!");
+        }
+        if (null==dto.getMaxExtraPay()||BigDecimal.ZERO.compareTo(dto.getMaxExtraPay())>0){
+            return Result.error("封顶花费为空或小于0!");
+        }
+        if (null==dto.getLimitTimeTransferAllDay()||0>dto.getLimitTimeTransferAllDay()){
+            return Result.error("超时转全天时间为空或小于0!");
+        }
+        try{
+            return cesHourRoomRuleService.create(dto);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
+    }
+
+    @AutoLog(value = "修改钟点房规则")
+    @ApiOperation(value="修改钟点房规则", notes="修改钟点房规则")
+    @PostMapping(value = "/modify")
+    public Result modify(@RequestBody CesHourRoomRuleModifyDto dto){
+        if (ObjectUtils.isEmpty(dto)){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if(StringUtils.isBlank(dto.getId())){
+            return Result.error(ResultCode.PARAM_MISS,"数据ID必传!");
+        }
+        if (StringUtils.isBlank(dto.getHotelId())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (StringUtils.isBlank(dto.getHourRoomName())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (null==dto.getAfterOpenRoom()||0>=dto.getAfterOpenRoom()){
+            return Result.error("开房后时间为空或小于等于0!");
+        }
+        if (null==dto.getAfterOpenRoomPay()||BigDecimal.ZERO.compareTo(dto.getAfterOpenRoomPay())>0){
+            return Result.error("开房后花费为空或小于0!");
+        }
+        if (null==dto.getExceedTime()||0>=dto.getExceedTime()){
+            return Result.error("超过时间为空或小于等于0!");
+        }
+        if (null==dto.getExceedPay()||BigDecimal.ZERO.compareTo(dto.getExceedPay())>0){
+            return Result.error("超时花费为空或小于0!");
+        }
+        if (null==dto.getNotReachExceedTime()||0>=dto.getNotReachExceedTime()){
+            return Result.error("未达超时周期时间为空或小于等于0!");
+        }
+        if (null==dto.getNotReachExceedTimePay()||BigDecimal.ZERO.compareTo(dto.getNotReachExceedTimePay())>0){
+            return Result.error("未达超市周期花费为空或小于0!");
+        }
+        if (null==dto.getMaxExtraPay()||BigDecimal.ZERO.compareTo(dto.getMaxExtraPay())>0){
+            return Result.error("封顶花费为空或小于0!");
+        }
+        if (null==dto.getLimitTimeTransferAllDay()||0>dto.getLimitTimeTransferAllDay()){
+            return Result.error("超时转全天时间为空或小于0!");
+        }
+        try{
+            return cesHourRoomRuleService.modify(dto);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
+    }
+
+    @AutoLog(value = "钟点房规则关联房型")
+    @ApiOperation(value="钟点房规则关联房型", notes="钟点房规则关联房型")
+    @PostMapping(value = "/relate")
+    public Result relate(@RequestBody CesHourRoomRuleModifyDto dto){
+        if (ObjectUtils.isEmpty(dto)){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (StringUtils.isBlank(dto.getId())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        try{
+            return cesHourRoomRuleService.relateLayout(dto);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
+    }
+
+    @AutoLog(value = "批量删除钟点房计费规则")
+    @ApiOperation(value="批量删除钟点房计费规则", notes="批量删除钟点房计费规则")
+    @DeleteMapping(value = "/batchDelete")
+    public Result batchDelete(@RequestParam String idStr){
+        if(StringUtils.isBlank(idStr)){
+            return Result.error(ResultCode.PARAM_MISS,"数据IDSTR必传!");
+        }
+        try{
+            List<String> ids = Stream.of(idStr.split(",")).collect(Collectors.toList());
+            return  cesHourRoomRuleService.batchDelete(ids);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
+    }
+
+    @AutoLog(value = "删除一条钟点房计费规则")
+    @ApiOperation(value="删除一条钟点房计费规则", notes="删除一条钟点房计费规则")
+    @DeleteMapping(value = "/delete")
+    public Result delete(@RequestParam String id){
+        if(StringUtils.isBlank(id)){
+            return Result.error(ResultCode.PARAM_MISS,"数据ID必传!");
+        }
+        try{
+            return  cesHourRoomRuleService.deleteOne(id);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
     }
 }
 

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

@@ -10,7 +10,6 @@ import lombok.experimental.Accessors;
 import java.io.Serializable;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
-import java.util.List;
 
 /**
  * <p>
@@ -49,12 +48,12 @@ public class CesHourRoomRule extends Model<CesHourRoomRule> {
     /**
      * 房型id
      */
-    private List<String> layoutIds;
+    private String layoutIds;
 
     /**
      * 开房后时间(分钟)
      */
-    private String afterOpenRoom;
+    private Integer afterOpenRoom;
 
     /**
      * 开房后多少分钟内按多少元收取
@@ -64,7 +63,7 @@ public class CesHourRoomRule extends Model<CesHourRoomRule> {
     /**
      * 超时时间(分钟)周期
      */
-    private String exceedTime;
+    private Integer exceedTime;
 
     /**
      * 每到一个超时周期收取费用(元)
@@ -74,7 +73,7 @@ public class CesHourRoomRule extends Model<CesHourRoomRule> {
     /**
      * 不到超时周期的超时时间(分钟)
      */
-    private String notReachExceedTime;
+    private Integer notReachExceedTime;
 
     /**
      * 不到超时周期的超时收费(元)
@@ -89,7 +88,7 @@ public class CesHourRoomRule extends Model<CesHourRoomRule> {
     /**
      * 超过多少分钟转为全天房(0分钟则视为不转为全天房)
      */
-    private String limitTimeTransferAllDay;
+    private Integer limitTimeTransferAllDay;
 
     /**
      * 创建时间

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

@@ -1,23 +1,29 @@
 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 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.ObjectUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.CommonUtils;
 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.DTO.CesHourRoomRuleModifyDto;
 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.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
@@ -46,7 +52,8 @@ public class CesHourRoomRuleServiceImpl extends ServiceImpl<CesHourRoomRuleMappe
         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());
+            //处理百分号 mybatis plus bug 查询 % 出现全量数据
+            queryWrapper.like(CesHourRoomRule.HOUR_ROOM_NAME, CommonUtils.escapeChar(cesHourRoomRuleDto.getHourRoomName()));
         }
         queryWrapper.eq(CesHourRoomRule.INVALID,false);
         queryWrapper.orderByDesc(CesHourRoomRule.UPDATEAT);
@@ -54,7 +61,7 @@ public class CesHourRoomRuleServiceImpl extends ServiceImpl<CesHourRoomRuleMappe
         List<CesHourRoomRule> records = dataPage.getRecords();
         List<String> hotelIds = records.stream().map(v-> v.getHotelId()).collect(Collectors.toList());
 
-        List<BusHotel> busHotels = busHotelService.findHotelsByIds(hotelIds);
+        List<BusHotel> busHotels = busHotelService.findHotelsByIds(hotelIds.stream().distinct().collect(Collectors.toList()));
         List<CesHourRoomRuleVo> vos = new ArrayList<>();
         records.forEach(v -> {
             CesHourRoomRuleVo vo = new CesHourRoomRuleVo();
@@ -68,4 +75,67 @@ public class CesHourRoomRuleServiceImpl extends ServiceImpl<CesHourRoomRuleMappe
         map.put("total",dataPage.getTotal());
         return Result.OK(map);
     }
+
+    public Result create(CesHourRoomRuleModifyDto dto) {
+        //新增时默认没有关联任何房型
+        dto.setCreateAt(LocalDateTime.now());
+        dto.setUpdateAt(LocalDateTime.now());
+        dto.setInvalid(false);
+        cesHourRoomRuleMapper.insert(dto);
+        return Result.ok("创建成功!");
+    }
+
+    public Result modify(CesHourRoomRuleModifyDto dto) {
+        CesHourRoomRule cesHourRoomRule = cesHourRoomRuleMapper.selectOne(new QueryWrapper<CesHourRoomRule>()
+                .eq(CesHourRoomRule.ID, dto.getId())
+                .eq(CesHourRoomRule.INVALID, false));
+        if (ObjectUtils.isEmpty(cesHourRoomRule)){
+            return Result.ok("数据未找到!");
+        }
+        BeanUtil.copyProperties(dto,cesHourRoomRule, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
+        cesHourRoomRule.setUpdateAt(LocalDateTime.now());
+        cesHourRoomRuleMapper.updateById(cesHourRoomRule);
+        return Result.ok("修改成功!");
+    }
+
+    public Result batchDelete(List<String> ids) {
+        List<CesHourRoomRule> cesHourRoomRules = cesHourRoomRuleMapper.selectBatchIds(ids);
+        if (CollectionUtil.isEmpty(cesHourRoomRules)){
+            //查不到证明已经被删除过了
+            return Result.ok("删除成功!");
+        }
+        cesHourRoomRules.forEach(v->{
+            v.setUpdateAt(LocalDateTime.now());
+            v.setInvalid(true);
+        });
+        saveOrUpdateBatch(cesHourRoomRules);
+        return Result.ok("删除成功!");
+    }
+
+    public Result deleteOne(String id) {
+        CesHourRoomRule cesHourRoomRule = cesHourRoomRuleMapper.selectOne(new QueryWrapper<CesHourRoomRule>()
+                .eq(CesHourRoomRule.ID, id)
+                .eq(CesHourRoomRule.INVALID, false));
+        if (ObjectUtils.isEmpty(cesHourRoomRule)){
+            return Result.ok("删除成功!");
+        }
+        cesHourRoomRule.setUpdateAt(LocalDateTime.now());
+        cesHourRoomRule.setInvalid(true);
+        cesHourRoomRuleMapper.updateById(cesHourRoomRule);
+        return  Result.ok("删除成功!");
+    }
+
+
+    public Result relateLayout(CesHourRoomRuleModifyDto dto) {
+        CesHourRoomRule cesHourRoomRule = cesHourRoomRuleMapper.selectOne(new QueryWrapper<CesHourRoomRule>()
+                .eq(CesHourRoomRule.ID, dto.getId())
+                .eq(CesHourRoomRule.INVALID, false));
+        if (ObjectUtils.isEmpty(cesHourRoomRule)){
+            return Result.error("该钟点房规则不存在!");
+        }
+        cesHourRoomRule.setLayoutIds(dto.getLayoutIds());
+        cesHourRoomRule.setUpdateAt(LocalDateTime.now());
+        cesHourRoomRuleMapper.updateById(cesHourRoomRule);
+        return Result.OK("关联房型成功!");
+    }
 }

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

@@ -224,6 +224,19 @@ public class CesRoomLayoutServiceImpl extends ServiceImpl<CesRoomLayoutMapper, C
     }
 
 
+    /**
+     * 根据酒店ID 查询所有房型
+     * @param hotelId
+     * @return
+     */
+    public Result getRoomLayoutsByHotelId(String hotelId){
+
+        List<CesRoomLayout> cesRoomLayouts = cesRoomLayoutMapper.selectList(new QueryWrapper<CesRoomLayout>()
+                .eq(CesRoomLayout.HOTEL_ID, hotelId)
+                .eq(CesRoomLayout.INVALID,false));
+        return Result.OK(cesRoomLayouts);
+
+    }