shenzhongzheng 2 yıl önce
ebeveyn
işleme
f2ffab69af

+ 119 - 3
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/rooms/controller/CesGoodsUnitController.java

@@ -1,9 +1,23 @@
 package org.jeecg.modules.rooms.controller;
 
 
-import org.springframework.web.bind.annotation.RequestMapping;
+import cn.hutool.core.collection.CollectionUtil;
+import io.swagger.annotations.ApiOperation;
+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.modules.rooms.DTO.CesGoodsUnitDto;
+import org.jeecg.modules.rooms.DTO.CesGoodsUnitSearchDto;
+import org.jeecg.modules.rooms.DTO.CesRoomLayoutRemoveDto;
+import org.jeecg.modules.rooms.service.CesGoodsUnitServiceImpl;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.stereotype.Controller;
+import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -13,9 +27,111 @@ import org.springframework.stereotype.Controller;
  * @author Claude
  * @since 2023-03-08
  */
-@Controller
+@RestController
 @RequestMapping("/rooms/cesGoodsUnit")
 public class CesGoodsUnitController {
 
+    @Resource
+    private CesGoodsUnitServiceImpl cesGoodsUnitService;
+
+
+    /***
+     * 查询单位
+     * @param dto
+     * @return
+     */
+    @ApiOperation(value="查询单位", notes="查询单位")
+    @GetMapping(value = "/list")
+    public Result list(CesGoodsUnitSearchDto dto){
+        if(StringUtils.isBlank(dto.getHotelId())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if(dto.getPageNo().intValue() <= 0){
+            return Result.error("页数不能小于等于0");
+        }
+        if(dto.getPageSize().intValue() < 10){
+            return Result.error("分页条数不能小于10");
+        }
+        try{
+            return cesGoodsUnitService.list(dto);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
+    }
+
+    @AutoLog(value = "创建单位")
+    @ApiOperation(value="创建单位", notes="创建单位")
+    @PostMapping(value = "/save")
+    public Result create(@RequestBody CesGoodsUnitDto dto){
+        if(StringUtils.isBlank(dto.getHotelId())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if(StringUtils.isBlank(dto.getName())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if(dto.getState() == null){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        try{
+            return  cesGoodsUnitService.create(dto);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
+    }
+
+    @AutoLog(value = "修改单位")
+    @ApiOperation(value="修改单位", notes="修改单位")
+    @PutMapping(value = "/modify")
+    public Result modifyCesRoomLayout(@RequestBody CesGoodsUnitDto dto){
+        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.getName())){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        if(dto.getState() == null){
+            return Result.error(ResultCode.PARAM_MISS);
+        }
+        try{
+            return  cesGoodsUnitService.modify(dto);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
+    }
+
+
+    @AutoLog(value = "删除单位")
+    @ApiOperation(value="删除单位", notes="删除单位")
+    @DeleteMapping(value = "/remove")
+    public Result remove(String id){
+        if(StringUtils.isBlank(id)){
+            return Result.error(ResultCode.PARAM_MISS,"数据ID 必传!");
+        }
+        try{
+            return  cesGoodsUnitService.delete(id);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
+    }
+
+    @AutoLog(value = "批量删除单位")
+    @ApiOperation(value="批量删除单位", notes="批量删除单位")
+    @PostMapping(value = "/deleteBatch")
+    public Result deleteBatch(String idsStr){
+        if(StringUtils.isBlank(idsStr)){
+            return Result.error(ResultCode.PARAM_MISS,"数据IDStr 必传!");
+        }
+        try{
+            List<String> ids = Arrays.stream(idsStr.split(",")).collect(Collectors.toList());
+            return  cesGoodsUnitService.deleteBatch(ids);
+        }catch (Exception e){
+            return Result.error(e.getMessage());
+        }
+    }
+
+
 }
 

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

@@ -39,7 +39,6 @@ public class CesRoomLayoutMemberPriceController extends JeecgController<CesRoomL
         @Resource
         private  CesRoomLayoutMemberPriceServiceImpl memberPriceService;
 
-
         @AutoLog(value = "获取会员等级价格")
         @ApiOperation(value="获取会员等级价格", notes="获取会员等级价格")
         @GetMapping(value = "/getListByParentId")

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

@@ -99,8 +99,12 @@ public class CesRoomLayoutPriceServiceImpl extends ServiceImpl<CesRoomLayoutPric
             List<CesRoomLayoutMemberPrice> memberPriceList = new ArrayList<>();
             memberPriceEntities.forEach(v -> {
                 CesRoomLayoutMemberPrice memberPrice = new CesRoomLayoutMemberPrice();
-                BeanUtil.copyProperties(v,memberPrice);
+                memberPrice.setHotelId(roomLayoutPriceDto.getHotelId());
+                memberPrice.setLayoutId(roomLayoutPriceDto.getLayoutId());
+                memberPrice.setLevelId(v.getLevelId());
                 memberPrice.setParentId(parentId);
+                memberPrice.setLdiscount(v.getLdiscount());
+                memberPrice.setDiscount(v.getDiscount());
                 memberPrice.setCreateAt(LocalDateTime.now());
                 memberPrice.setUpdateAt(LocalDateTime.now());
                 memberPrice.setInvalid(false);
@@ -130,7 +134,7 @@ public class CesRoomLayoutPriceServiceImpl extends ServiceImpl<CesRoomLayoutPric
         if(roomLayoutPriceDto.getIsVip().intValue() == CouponEnums.TRUEORFALSE.TRUE.code()){
             //修改 或者创建 会员折扣数据
             List<CesRoomLayoutMemberInfoPriceDto> memberPriceEntities = roomLayoutPriceDto.getMemberPriceEntities();
-            //查询现有的会员则扣
+
             List<CesRoomLayoutMemberPrice> memberPriceList = new ArrayList<>();
             memberPriceEntities.forEach(v -> {
                 CesRoomLayoutMemberPrice memberPrice = new CesRoomLayoutMemberPrice();
@@ -150,6 +154,9 @@ public class CesRoomLayoutPriceServiceImpl extends ServiceImpl<CesRoomLayoutPric
                 memberPriceList.add(memberPrice);
             });
             memberPriceService.saveOrUpdateBatch(memberPriceList);
+        }else{
+            //查询现有会员等级价格
+            //TODO:删除之前的会员等级价格
         }
         return Result.ok("修改成功!");
     }