|
|
@@ -0,0 +1,131 @@
|
|
|
+package org.jeecg.modules.rooms.service;
|
|
|
+
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.bean.copier.CopyOptions;
|
|
|
+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 org.apache.commons.collections.map.HashedMap;
|
|
|
+import org.apache.commons.lang3.ObjectUtils;
|
|
|
+import org.jeecg.common.Enum.CouponEnums;
|
|
|
+import org.jeecg.common.api.vo.Result;
|
|
|
+import org.jeecg.modules.rooms.DTO.CesRoomLayoutDto;
|
|
|
+import org.jeecg.modules.rooms.DTO.CesRoomLayoutPriceDto;
|
|
|
+import org.jeecg.modules.rooms.DTO.CesRoomLayoutPriceSearchDto;
|
|
|
+import org.jeecg.modules.rooms.entity.CesRoomLayoutPrice;
|
|
|
+import org.jeecg.modules.rooms.mapper.CesRoomLayoutPriceMapper;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author fendo
|
|
|
+ * @since 2023-03-06
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class CesRoomLayoutPriceServiceImpl extends ServiceImpl<CesRoomLayoutPriceMapper, CesRoomLayoutPrice> implements IService<CesRoomLayoutPrice> {
|
|
|
+ @Resource
|
|
|
+ private CesRoomLayoutPriceMapper roomLayoutPriceMapper;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询某家酒店下某个房型的房间价格管理数据
|
|
|
+ * @param searchDto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Result list(CesRoomLayoutPriceSearchDto searchDto){
|
|
|
+ QueryWrapper<CesRoomLayoutPrice> queryWrapper =new QueryWrapper<>();
|
|
|
+ queryWrapper.eq(CesRoomLayoutPrice.HOTELID,searchDto.getHotelId());
|
|
|
+ queryWrapper.eq(CesRoomLayoutPrice.LAYOUTID,searchDto.getRoomLayoutId());
|
|
|
+ queryWrapper.eq(CesRoomLayoutPrice.TYPE,searchDto.getType().intValue());
|
|
|
+ queryWrapper.eq(CesRoomLayoutPrice.INVALID,false);
|
|
|
+
|
|
|
+ queryWrapper.orderByDesc(CesRoomLayoutPrice.CREATEAT);
|
|
|
+ IPage<CesRoomLayoutPrice> dataPage = roomLayoutPriceMapper.selectPage(new Page<>(searchDto.getPageNo().intValue(),searchDto.getPageSize().intValue()),queryWrapper);
|
|
|
+ Map<String,Object> map = new HashedMap();
|
|
|
+ map.put("recoreds",dataPage.getRecords());
|
|
|
+ map.put("total",dataPage.getTotal());
|
|
|
+ return Result.OK(map);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 创建房型价格
|
|
|
+ * @param roomLayoutPriceDto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public Result createRoomLayoutPrice(CesRoomLayoutPriceDto roomLayoutPriceDto){
|
|
|
+ CesRoomLayoutPrice roomLayoutPrice = new CesRoomLayoutPrice();
|
|
|
+ roomLayoutPrice.setHotelId(roomLayoutPriceDto.getHotelId());
|
|
|
+ roomLayoutPrice.setLayoutId(roomLayoutPriceDto.getLayoutId());
|
|
|
+ roomLayoutPrice.setName(roomLayoutPriceDto.getName());
|
|
|
+ roomLayoutPrice.setOprice(roomLayoutPriceDto.getOprice());//原价
|
|
|
+ roomLayoutPrice.setIntegral(roomLayoutPriceDto.getIntegral().intValue());//积分
|
|
|
+ roomLayoutPrice.setIsVip(roomLayoutPriceDto.getIsVip().intValue() == 1 ? true:false);
|
|
|
+ roomLayoutPrice.setNum(roomLayoutPriceDto.getNum());
|
|
|
+ roomLayoutPrice.setPrice(roomLayoutPriceDto.getPrice());//价格
|
|
|
+ roomLayoutPrice.setPrepay(roomLayoutPriceDto.getPrepay().intValue() == 1 ? true:false);//是否预支付
|
|
|
+ roomLayoutPrice.setCreateAt(LocalDateTime.now());
|
|
|
+ roomLayoutPrice.setUpdateAt(LocalDateTime.now());
|
|
|
+ roomLayoutPrice.setType(roomLayoutPriceDto.getType());
|
|
|
+ roomLayoutPrice.setInvalid(false);
|
|
|
+
|
|
|
+ roomLayoutPriceMapper.insert(roomLayoutPrice);
|
|
|
+
|
|
|
+ if(roomLayoutPriceDto.getIsVip().intValue() == CouponEnums.TRUEORFALSE.TRUE.code()){
|
|
|
+
|
|
|
+ }
|
|
|
+ return Result.ok("创建成功");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改房型
|
|
|
+ * @param roomLayoutPriceDto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Result modifyRoomLayoutPrice(CesRoomLayoutPriceDto roomLayoutPriceDto){
|
|
|
+ CesRoomLayoutPrice roomLayoutPrice = roomLayoutPriceMapper.selectById(roomLayoutPriceDto.getId());
|
|
|
+ if(ObjectUtils.isEmpty(roomLayoutPrice)) return Result.error("价格管理数据未找到!");
|
|
|
+
|
|
|
+ BeanUtil.copyProperties(roomLayoutPriceDto,roomLayoutPrice, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
|
|
|
+ roomLayoutPrice.setIsVip(roomLayoutPriceDto.getIsVip().intValue() == 1? true:false);
|
|
|
+ roomLayoutPrice.setPrepay(roomLayoutPriceDto.getPrepay().intValue() == 1 ? true:false);//是否预支付
|
|
|
+ roomLayoutPrice.setUpdateAt(LocalDateTime.now());
|
|
|
+ roomLayoutPriceMapper.updateById(roomLayoutPrice);
|
|
|
+ return Result.ok("修改成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除房型价格数据
|
|
|
+ * @param roomLayoutPriceDto
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Result deleteRoomLayoutPrice(CesRoomLayoutPriceDto roomLayoutPriceDto){
|
|
|
+ CesRoomLayoutPrice roomLayoutPrice = roomLayoutPriceMapper.selectById(roomLayoutPriceDto.getId());
|
|
|
+ if(ObjectUtils.isEmpty(roomLayoutPrice)) return Result.error("价格管理数据未找到!");
|
|
|
+ roomLayoutPrice.setUpdateAt(LocalDateTime.now());
|
|
|
+ roomLayoutPrice.setInvalid(true);
|
|
|
+ roomLayoutPriceMapper.updateById(roomLayoutPrice);
|
|
|
+ return Result.ok("删除成功!");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|