shenzhongzheng 2 년 전
부모
커밋
328c15ceca

+ 7 - 0
jeecg-module-system/jeecg-system-biz/src/main/java/org/jeecg/modules/business/service/impl/BusMarketMemberServiceImpl.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.business.service.impl;
 
 
 import cn.hutool.core.collection.CollectionUtil;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.business.entity.BusMarketMember;
@@ -46,4 +47,10 @@ public class BusMarketMemberServiceImpl extends ServiceImpl<BusMarketMemberMappe
         });
         return Result.ok(vos);
     }
+
+    public List<BusMarketMember> getByIds(List<String> ids,String hotelId){
+        if(CollectionUtil.isEmpty(ids) || StringUtils.isBlank(hotelId)) return new ArrayList<>();
+        List<BusMarketMember> list =  busMarketMemberMapper.selectList(Wrappers.<BusMarketMember>lambdaQuery().in(BusMarketMember::getId,ids).eq(BusMarketMember::getHotelId,hotelId));
+        return list;
+    }
 }

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

@@ -0,0 +1,9 @@
+package org.jeecg.modules.rooms.Vo;
+
+import lombok.Data;
+import org.jeecg.modules.rooms.entity.CesRoomLayoutMemberPrice;
+
+@Data
+public class LayoutMemberPriceVo  extends CesRoomLayoutMemberPrice {
+    private String memberName;
+}

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

@@ -30,7 +30,8 @@ import javax.annotation.Resource;
 @RequestMapping("/rooms/cesHourRoomRule")
 @Api(tags = "ces_hour_room_rule")
 @Slf4j
-public class CesHourRoomRuleController extends JeecgController<CesHourRoomRule, CesHourRoomRuleServiceImpl> {
+public class
+CesHourRoomRuleController extends JeecgController<CesHourRoomRule, CesHourRoomRuleServiceImpl> {
 
     @Resource
     CesHourRoomRuleServiceImpl cesHourRoomRuleService;

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

@@ -2,17 +2,26 @@ 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.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.entity.CesRoomLayout;
 import org.jeecg.modules.rooms.entity.CesRoomLayoutMemberPrice;
 import org.jeecg.modules.rooms.service.CesRoomLayoutMemberPriceServiceImpl;
 import org.jeecg.modules.rooms.service.CesRoomLayoutServiceImpl;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.annotation.Resource;
+
 /**
  * <p>
  * 房型会员价格 记录表 前端控制器
@@ -26,7 +35,25 @@ import org.springframework.web.bind.annotation.RestController;
 @Api(tags="ces_room_layout_member_price")
 @Slf4j
 public class CesRoomLayoutMemberPriceController extends JeecgController<CesRoomLayoutMemberPrice, CesRoomLayoutMemberPriceServiceImpl> {
+        @Resource
+        private  CesRoomLayoutMemberPriceServiceImpl memberPriceService;
 
 
+        @AutoLog(value = "获取会员等级价格")
+        @ApiOperation(value="获取会员等级价格", notes="获取会员等级价格")
+        @GetMapping(value = "/getListByParentId")
+        public Result getListByParentId(String parentId,String hotelId){
+            if(StringUtils.isBlank(parentId)){
+                return Result.error(ResultCode.PARAM_MISS);
+            }
+            if(StringUtils.isBlank(hotelId)){
+                return Result.error(ResultCode.PARAM_MISS);
+            }
+            try{
+               return   memberPriceService.getListByHotelIdAndParentId(parentId,hotelId);
+            }catch (Exception e){
+                return Result.error(e.getMessage());
+            }
+        }
 }
 

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

@@ -1,6 +1,8 @@
 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.core.toolkit.ObjectUtils;
@@ -20,6 +22,7 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.time.LocalDateTime;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -61,8 +64,8 @@ public class CesGoodsUnitServiceImpl extends ServiceImpl<CesGoodsUnitMapper, Ces
      * @return
      */
     public Result create(CesGoodsUnitDto dto){
-       CesGoodsUnit unit =  cesGoodsUnitMapper.selectOne(Wrappers.<CesGoodsUnit>lambdaQuery().eq(CesGoodsUnit::getInvalid,false).eq(CesGoodsUnit::getName,dto.getName()));
-       if(!ObjectUtils.isEmpty(unit)) return Result.error("已存在相同名称的单位!");
+        CesGoodsUnit unit =  cesGoodsUnitMapper.selectOne(Wrappers.<CesGoodsUnit>lambdaQuery().eq(CesGoodsUnit::getInvalid,false).eq(CesGoodsUnit::getName,dto.getName()));
+        if(!ObjectUtils.isEmpty(unit)) return Result.error("已存在相同名称的单位!");
         CesGoodsUnit cesGoodsUnit = new CesGoodsUnit();
         BeanUtil.copyProperties(dto,cesGoodsUnit);
         cesGoodsUnit.setCreateAt(LocalDateTime.now());
@@ -73,5 +76,54 @@ public class CesGoodsUnitServiceImpl extends ServiceImpl<CesGoodsUnitMapper, Ces
     }
 
 
+    /**
+     * 修改
+     * @param dto
+     * @return
+     */
+    public Result modify(CesGoodsUnitDto dto){
+        CesGoodsUnit unit = cesGoodsUnitMapper.selectById(dto.getId());
+        if(ObjectUtils.isEmpty(unit)) return Result.error("数据未找到!");
+
+        BeanUtil.copyProperties(dto,unit, CopyOptions.create().setIgnoreNullValue(true).setIgnoreError(true));
+        unit.setUpdateAt(LocalDateTime.now());
+        cesGoodsUnitMapper.updateById(unit);
+        return Result.OK("修改成功!");
+    }
+
+
+    /**
+     * 删除单个
+     * @param id
+     * @return
+     */
+    public Result delete(String id){
+        CesGoodsUnit unit = cesGoodsUnitMapper.selectById(id);
+        if(ObjectUtils.isEmpty(unit)) return Result.error("数据未找到!");
+
+        unit.setUpdateAt(LocalDateTime.now());
+        unit.setInvalid(true);
+        cesGoodsUnitMapper.updateById(unit);
+        return Result.OK("删除成功!");
+    }
+
+
+    /**
+     * 批量删除
+     * @param ids
+     * @return
+     */
+    public Result deleteBatch(List<String> ids){
+        List<CesGoodsUnit> units = cesGoodsUnitMapper.selectList(Wrappers.<CesGoodsUnit>lambdaQuery().in(CesGoodsUnit::getId,ids).eq(CesGoodsUnit::getInvalid,false));
+        if(CollectionUtil.isEmpty(units)) return Result.error("数据未找到!");
+
+        units.forEach(unit -> {
+            unit.setUpdateAt(LocalDateTime.now());
+            unit.setInvalid(true);
+        });
+        saveOrUpdateBatch(units);
+        return Result.OK("删除成功!");
+    }
+
 }
 

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

@@ -1,8 +1,13 @@
 package org.jeecg.modules.rooms.service;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.modules.business.entity.BusMarketMember;
+import org.jeecg.modules.business.service.impl.BusMarketMemberServiceImpl;
+import org.jeecg.modules.rooms.Vo.LayoutMemberPriceVo;
 import org.jeecg.modules.rooms.entity.CesRoomLayoutMemberPrice;
 import org.jeecg.modules.rooms.mapper.CesRoomLayoutMemberPriceMapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
@@ -11,6 +16,8 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Optional;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -26,14 +33,43 @@ public class CesRoomLayoutMemberPriceServiceImpl extends ServiceImpl<CesRoomLayo
     @Resource
     private CesRoomLayoutMemberPriceMapper cesRoomLayoutMemberPriceMapper;
 
+    @Resource
+    private BusMarketMemberServiceImpl marketMemberService;
+
 
     public List<CesRoomLayoutMemberPrice> getListByParentId(String parentId){
         if(StringUtils.isBlank(parentId)) return new ArrayList<>();
         List<CesRoomLayoutMemberPrice> list = cesRoomLayoutMemberPriceMapper.selectList(Wrappers.<CesRoomLayoutMemberPrice>lambdaQuery()
                 .eq(CesRoomLayoutMemberPrice::getParentId,parentId)
                 .eq(CesRoomLayoutMemberPrice::getInvalid,false));
+
         return list;
     }
 
 
+    /**
+     * 获取会员等级数据
+     * @param parentId
+     * @param hotelId
+     * @return
+     */
+    public Result getListByHotelIdAndParentId(String parentId,String hotelId){
+        List<CesRoomLayoutMemberPrice> list = cesRoomLayoutMemberPriceMapper.selectList(Wrappers.<CesRoomLayoutMemberPrice>lambdaQuery()
+                .eq(CesRoomLayoutMemberPrice::getParentId,parentId)
+                .eq(CesRoomLayoutMemberPrice::getHotelId,hotelId)
+                .eq(CesRoomLayoutMemberPrice::getInvalid,false));
+        List<String> memberIds = list.stream().map(v -> v.getId()).collect(Collectors.toList());
+        List<BusMarketMember> marketMembers = marketMemberService.getByIds(memberIds,hotelId);
+        List<LayoutMemberPriceVo> vos = new ArrayList<>();
+        list.forEach(v -> {
+            LayoutMemberPriceVo vo = new LayoutMemberPriceVo();
+            BeanUtil.copyProperties(v,vo);
+            Optional<BusMarketMember> marketMemberOptional =  marketMembers.stream().filter(c -> c.getId().equals(v.getLevelId())).findFirst();
+            if(marketMemberOptional.isPresent())  vo.setMemberName(marketMemberOptional.get().getName());
+            vos.add(vo);
+        });
+        return Result.OK(vos);
+    }
+
+
 }

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

@@ -8,6 +8,7 @@ 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.apache.commons.lang3.StringUtils;
 import org.jeecg.common.Enum.CouponEnums;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.modules.rooms.DTO.CesRoomLayoutMemberInfoPriceDto;
@@ -127,16 +128,28 @@ public class CesRoomLayoutPriceServiceImpl extends ServiceImpl<CesRoomLayoutPric
         roomLayoutPrice.setUpdateAt(LocalDateTime.now());
         roomLayoutPriceMapper.updateById(roomLayoutPrice);
         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();
-                BeanUtil.copyProperties(v,memberPrice);
+                if(!StringUtils.isBlank(v.getId())){
+                    memberPrice.setId(v.getId());
+                }else{
+                    memberPrice.setHotelId(roomLayoutPriceDto.getHotelId());
+                    memberPrice.setLayoutId(roomLayoutPriceDto.getLayoutId());
+                    memberPrice.setParentId(roomLayoutPrice.getId());
+                    memberPrice.setLevelId(v.getLevelId());
+                    memberPrice.setInvalid(false);
+                    memberPrice.setCreateAt(LocalDateTime.now());
+                }
+                memberPrice.setLdiscount(v.getLdiscount());
+                memberPrice.setDiscount(v.getDiscount());
                 memberPrice.setUpdateAt(LocalDateTime.now());
                 memberPriceList.add(memberPrice);
             });
-            memberPriceService.updateBatchById(memberPriceList);
+            memberPriceService.saveOrUpdateBatch(memberPriceList);
         }
         return Result.ok("修改成功!");
     }