Kaynağa Gözat

房价方案 贺姜乐

DESKTOP-B78GIPM\admin 2 yıl önce
ebeveyn
işleme
545c304368

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

@@ -0,0 +1,17 @@
+package org.jeecg.modules.rooms.DTO;
+
+import lombok.Data;
+import org.jeecg.modules.rooms.entity.CesHousePriceScheme;
+
+/**
+ * <p>
+ * 房价方案新增修改等通用DTO类
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-09
+ */
+@Data
+public class CesHousePriceSchemeDto extends CesHousePriceScheme {
+
+}

+ 27 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/DTO/CesHousePriceSchemeSearchDto.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 Claude
+ * @since 2023-03-09
+ */
+@Data
+public class CesHousePriceSchemeSearchDto extends BasePage {
+
+    /**
+     * 酒店ID
+     */
+    private String hotelId;
+
+    /**
+     * 参数名称
+     */
+    private String paramName;
+
+}

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

@@ -0,0 +1,18 @@
+package org.jeecg.modules.rooms.Vo;
+
+import lombok.Data;
+import org.jeecg.modules.rooms.entity.CesHousePriceScheme;
+
+
+/**
+ * <p>
+ * 房价方案Vo类
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-09
+ */
+@Data
+public class CesHousePriceSchemeVo extends CesHousePriceScheme {
+
+}

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

@@ -0,0 +1,147 @@
+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.aspect.annotation.AutoLog;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.modules.rooms.DTO.CesHourRoomRuleModifyDto;
+import org.jeecg.modules.rooms.DTO.CesHousePriceSchemeDto;
+import org.jeecg.modules.rooms.DTO.CesHousePriceSchemeSearchDto;
+import org.jeecg.modules.rooms.entity.CesHousePriceScheme;
+import org.jeecg.modules.rooms.service.CesHousePriceSchemeServiceImpl;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
+/**
+ * <p>
+ * 房价方案 前端控制器
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-09
+ */
+@RestController
+@RequestMapping("/rooms/cesHousePriceScheme")
+@Api(tags = "ces_house_price_scheme")
+@Slf4j
+public class CesHousePriceSchemeController extends JeecgController<CesHousePriceScheme, CesHousePriceSchemeServiceImpl> {
+
+    @Resource
+    CesHousePriceSchemeServiceImpl cesHousePriceSchemeService;
+
+    @ApiOperation(value="房价方案查询", notes="房价方案查询")
+    @GetMapping(value = "/list")
+    public Result list(CesHousePriceSchemeSearchDto dto){
+        if (ObjectUtils.isEmpty(dto)){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (0>=dto.getPageNo()){
+            return Result.error("页数不能小于等于0");
+        }
+        if (0>=dto.getPageSize()){
+            return Result.error("页码尺寸不能小于等于0");
+        }
+        if (StringUtils.isBlank(dto.getHotelId())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        try{
+            return cesHousePriceSchemeService.list(dto);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
+    }
+
+    @AutoLog(value = "新增房价方案")
+    @ApiOperation(value="新增房价方案", notes="新增房价方案")
+    @PostMapping(value = "/save")
+    public Result save(@RequestBody CesHousePriceSchemeDto dto){
+        if (ObjectUtils.isEmpty(dto)){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (StringUtils.isBlank(dto.getPriceScheme())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (StringUtils.isBlank(dto.getSimpleCode())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (StringUtils.isBlank(dto.getNumber())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (null==dto.getGuestSource()){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (null==dto.getGuestType()){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (null==dto.getCheckInTime()){
+            return Result.error(ResultCode.PARAM_MISS);
+        }else{
+            if (1==dto.getCheckInTime().intValue()){
+                //如果入住时间为时间段,就要判断时间的非空
+                if (null==dto.getStartTime()){ return Result.error(ResultCode.PARAM_MISS); }
+                if (null==dto.getEndTime()){ return Result.error(ResultCode.PARAM_MISS); }
+            }
+        }
+        if (null==dto.getValidTime()){
+            return Result.error(ResultCode.PARAM_MISS);
+        }else{
+            if (1==dto.getValidTime().intValue()){
+                //如果有效期为时间段,就要判断时间的非空
+                if (null==dto.getValidStartTime()){ return Result.error(ResultCode.PARAM_MISS); }
+                if (null==dto.getValidEndTime()){ return Result.error(ResultCode.PARAM_MISS); }
+            }
+        }
+        if (null==dto.getOpen()||(0!=dto.getOpen().intValue()&&1!=dto.getOpen().intValue())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if (null==dto.getSort()||1>dto.getSort().intValue()){
+            return Result.error("排序不能为空且不能小于1!");
+        }
+        try{
+            return cesHousePriceSchemeService.create(dto);
+        }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  cesHousePriceSchemeService.deleteOne(id);
+        }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  cesHousePriceSchemeService.batchDelete(ids);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
+    }
+
+}
+

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

@@ -0,0 +1,174 @@
+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.time.LocalDateTime;
+
+/**
+ * <p>
+ * 房价方案
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-09
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@TableName("ces_house_price_scheme")
+public class CesHousePriceScheme extends Model<CesHousePriceScheme> {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    /**
+     * 酒店ID
+     */
+    private String hotelId;
+
+    /**
+     * 房价方案
+     */
+    private String priceScheme;
+
+    /**
+     * 简码
+     */
+    private String simpleCode;
+
+    /**
+     * 编号
+     */
+    private String number;
+
+    /**
+     * 客人来源
+     */
+    private Integer guestSource;
+
+    /**
+     * 客人类型
+     */
+    private Integer guestType;
+
+    /**
+     * 入住时间(0代表无限制,1代表时间段)
+     */
+    private Integer checkInTime;
+
+    /**
+     * 入住开始时间
+     */
+    private LocalDateTime startTime;
+
+    /**
+     * 入住结束时间
+     */
+    private LocalDateTime endTime;
+
+    /**
+     * 周末假日(1代表星期一,2代表星期二直到星期日以此类推)
+     */
+    private String weekend;
+
+    /**
+     * 节假日(选择一个或多个时间)
+     */
+    private String holiday;
+
+    /**
+     * 有效期(0代表无限制,1代表时间段)
+     */
+    private Integer validTime;
+
+    /**
+     * 有效期开始时间
+     */
+    private LocalDateTime validStartTime;
+
+    /**
+     * 有效期结束时间
+     */
+    private LocalDateTime validEndTime;
+
+    /**
+     * 是否开启(1代表开启,0代表关闭)
+     */
+    private Integer open;
+
+    /**
+     * 排序
+     */
+    private Integer sort;
+
+    /**
+     * 创建时间
+     */
+    @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 PRICE_SCHEME = "price_scheme";
+
+    public static final String SIMPLE_CODE = "simple_code";
+
+    public static final String NUMBER = "number";
+
+    public static final String GUEST_SOURCE = "guest_source";
+
+    public static final String GUEST_TYPE = "guest_type";
+
+    public static final String CHECK_IN_TIME = "check_in_time";
+
+    public static final String START_TIME = "start_time";
+
+    public static final String END_TIME = "end_time";
+
+    public static final String WEEKEND = "weekend";
+
+    public static final String HOLIDAY = "holiday";
+
+    public static final String VALID_TIME = "valid_time";
+
+    public static final String VALID_START_TIME = "valid_start_time";
+
+    public static final String VALID_END_TIME = "valid_end_time";
+
+    public static final String OPEN = "open";
+
+    public static final String SORT = "sort";
+
+    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/CesHousePriceSchemeMapper.java

@@ -0,0 +1,16 @@
+package org.jeecg.modules.rooms.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.rooms.entity.CesHousePriceScheme;
+
+/**
+ * <p>
+ * 房价方案 Mapper 接口
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-09
+ */
+public interface CesHousePriceSchemeMapper extends BaseMapper<CesHousePriceScheme> {
+
+}

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

@@ -0,0 +1,111 @@
+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.rooms.DTO.CesHousePriceSchemeDto;
+import org.jeecg.modules.rooms.DTO.CesHousePriceSchemeSearchDto;
+import org.jeecg.modules.rooms.Vo.CesHousePriceSchemeVo;
+import org.jeecg.modules.rooms.entity.CesHourRoomRule;
+import org.jeecg.modules.rooms.entity.CesHousePriceScheme;
+import org.jeecg.modules.rooms.mapper.CesHousePriceSchemeMapper;
+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;
+
+/**
+ * <p>
+ * 房价方案 服务实现类
+ * </p>
+ *
+ * @author Claude
+ * @since 2023-03-09
+ */
+@Service
+public class CesHousePriceSchemeServiceImpl extends ServiceImpl<CesHousePriceSchemeMapper, CesHousePriceScheme> implements IService<CesHousePriceScheme> {
+
+    @Resource
+    CesHousePriceSchemeMapper cesHousePriceSchemeMapper;
+
+    public Result list(CesHousePriceSchemeSearchDto dto) {
+        QueryWrapper<CesHousePriceScheme> queryWrapper = new QueryWrapper<>();
+        queryWrapper.eq(CesHousePriceScheme.HOTEL_ID,dto.getHotelId());
+        if (StringUtils.isNotEmpty(dto.getParamName())){
+            //处理百分号 mybatis plus bug 查询 % 出现全量数据
+            //四个字段只要有一个模糊对应传来的参数名称就能查出来
+            queryWrapper.and(wrapper->wrapper
+                    .like(CesHousePriceScheme.SIMPLE_CODE, CommonUtils.escapeChar(dto.getParamName()))
+                    .or()
+                    .like(CesHousePriceScheme.NUMBER, CommonUtils.escapeChar(dto.getParamName()))
+                    .or()
+                    .like(CesHousePriceScheme.PRICE_SCHEME, CommonUtils.escapeChar(dto.getParamName()))
+                    .or()
+                    .like(CesHousePriceScheme.GUEST_TYPE,CommonUtils.escapeChar(dto.getParamName())));
+        }
+        queryWrapper.eq(CesHousePriceScheme.INVALID,false);
+        queryWrapper.orderByAsc(CesHousePriceScheme.SORT);
+        IPage<CesHousePriceScheme> dataPage = cesHousePriceSchemeMapper.selectPage(new Page<>(dto.getPageNo().intValue(),dto.getPageSize().intValue()),queryWrapper);
+        List<CesHousePriceScheme> records = dataPage.getRecords();
+        List<CesHousePriceSchemeVo> vos = new ArrayList<>();
+        records.forEach(v->{
+            CesHousePriceSchemeVo vo = new CesHousePriceSchemeVo();
+            BeanUtil.copyProperties(v, vo);
+            vos.add(vo);
+        });
+        Map<String,Object> map = new HashedMap();
+        map.put("records",vos);
+        map.put("total",dataPage.getTotal());
+        return Result.OK(map);
+    }
+
+    public Result create(CesHousePriceSchemeDto dto) {
+        dto.setCreateAt(LocalDateTime.now());
+        dto.setUpdateAt(LocalDateTime.now());
+        dto.setInvalid(false);
+        CesHousePriceScheme cesHousePriceScheme = new CesHousePriceScheme();
+        BeanUtil.copyProperties(dto,cesHousePriceScheme);
+        cesHousePriceSchemeMapper.insert(cesHousePriceScheme);
+        return Result.ok("创建成功!");
+    }
+
+    public Result deleteOne(String id) {
+        CesHousePriceScheme cesHousePriceScheme = cesHousePriceSchemeMapper.selectOne(new QueryWrapper<CesHousePriceScheme>()
+                .eq(CesHousePriceScheme.ID, id)
+                .eq(CesHousePriceScheme.INVALID, false));
+        if (ObjectUtils.isEmpty(cesHousePriceScheme)){
+            return Result.ok("删除成功!");
+        }
+        cesHousePriceScheme.setUpdateAt(LocalDateTime.now());
+        cesHousePriceScheme.setInvalid(true);
+        cesHousePriceSchemeMapper.updateById(cesHousePriceScheme);
+        return  Result.ok("删除成功!");
+    }
+
+    public Result batchDelete(List<String> ids) {
+        List<CesHousePriceScheme> cesHousePriceSchemes = cesHousePriceSchemeMapper.selectBatchIds(ids);
+        if (CollectionUtil.isEmpty(cesHousePriceSchemes)){
+            //查不到证明已经被删除过了
+            return Result.ok("删除成功!");
+        }
+        cesHousePriceSchemes.forEach(v->{
+            v.setUpdateAt(LocalDateTime.now());
+            v.setInvalid(true);
+        });
+        saveOrUpdateBatch(cesHousePriceSchemes);
+        return Result.ok("删除成功!");
+    }
+}