|
@@ -1,24 +1,27 @@
|
|
package cn.cslg.permission.service.qiaobi;
|
|
package cn.cslg.permission.service.qiaobi;
|
|
|
|
|
|
import cn.cslg.permission.common.model.Records;
|
|
import cn.cslg.permission.common.model.Records;
|
|
|
|
+import cn.cslg.permission.common.model.common.CommonVO;
|
|
import cn.cslg.permission.common.model.dto.QueryVipDTO;
|
|
import cn.cslg.permission.common.model.dto.QueryVipDTO;
|
|
-import cn.cslg.permission.common.model.qiaobi.goods.GoodUpdateStatusDTO;
|
|
|
|
-import cn.cslg.permission.common.model.qiaobi.goods.GoodsAddDTO;
|
|
|
|
-import cn.cslg.permission.common.model.qiaobi.goods.GoodsQueryDTO;
|
|
|
|
-import cn.cslg.permission.common.model.qiaobi.goods.GoodsQueryVO;
|
|
|
|
|
|
+import cn.cslg.permission.common.model.qiaobi.goods.*;
|
|
import cn.cslg.permission.common.model.qiaobi.version.QiaoBiVersionVO;
|
|
import cn.cslg.permission.common.model.qiaobi.version.QiaoBiVersionVO;
|
|
import cn.cslg.permission.common.model.vo.AppVipTypeVO;
|
|
import cn.cslg.permission.common.model.vo.AppVipTypeVO;
|
|
import cn.cslg.permission.common.model.vo.FunctionCodeTreeVO;
|
|
import cn.cslg.permission.common.model.vo.FunctionCodeTreeVO;
|
|
|
|
+import cn.cslg.permission.common.utils.LoginUtils;
|
|
import cn.cslg.permission.common.utils.StringUtils;
|
|
import cn.cslg.permission.common.utils.StringUtils;
|
|
import cn.cslg.permission.domain.Function;
|
|
import cn.cslg.permission.domain.Function;
|
|
import cn.cslg.permission.domain.Personnel;
|
|
import cn.cslg.permission.domain.Personnel;
|
|
import cn.cslg.permission.domain.Version;
|
|
import cn.cslg.permission.domain.Version;
|
|
|
|
+import cn.cslg.permission.domain.qiaobi.AppVipType;
|
|
import cn.cslg.permission.domain.qiaobi.Goods;
|
|
import cn.cslg.permission.domain.qiaobi.Goods;
|
|
|
|
+import cn.cslg.permission.domain.sys.SysDictItem;
|
|
import cn.cslg.permission.exception.ExceptionEnum;
|
|
import cn.cslg.permission.exception.ExceptionEnum;
|
|
import cn.cslg.permission.exception.XiaoShiException;
|
|
import cn.cslg.permission.exception.XiaoShiException;
|
|
import cn.cslg.permission.mapper.qiaobi.AppVipTypeMapper;
|
|
import cn.cslg.permission.mapper.qiaobi.AppVipTypeMapper;
|
|
import cn.cslg.permission.service.FunctionService;
|
|
import cn.cslg.permission.service.FunctionService;
|
|
import cn.cslg.permission.service.PersonnelService;
|
|
import cn.cslg.permission.service.PersonnelService;
|
|
|
|
+import cn.cslg.permission.service.SysDictItemService;
|
|
|
|
+import cn.cslg.permission.service.common.LoadService;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
@@ -28,12 +31,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import cn.cslg.permission.mapper.qiaobi.GoodsMapper;
|
|
import cn.cslg.permission.mapper.qiaobi.GoodsMapper;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.BeanUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
|
-import java.util.Date;
|
|
|
|
-import java.util.List;
|
|
|
|
|
|
+import java.util.*;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -48,9 +50,23 @@ public class GoodsService extends ServiceImpl<GoodsMapper, Goods> {
|
|
@Autowired
|
|
@Autowired
|
|
private FunctionService functionService;
|
|
private FunctionService functionService;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ @Lazy
|
|
private AppVipTypeService appVipTypeService;
|
|
private AppVipTypeService appVipTypeService;
|
|
@Autowired
|
|
@Autowired
|
|
private AppVipTypeMapper appVipTypeMapper;
|
|
private AppVipTypeMapper appVipTypeMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private GoodByLimitService goodByLimitService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private MarketStrategyService marketStrategyService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private LoadService loadService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysDictItemService sysDictItemService;
|
|
|
|
+ private static String GOOD_TYPE_KEY = "GOOD_TYPE";
|
|
|
|
+ private static String GOOD_UNIT_KEY = "GOOD_UNIT";
|
|
|
|
+ private static String GOOD_STATUS_KEY = "GOOD_STATUS";
|
|
|
|
+ @Autowired
|
|
|
|
+ private LoginUtils loginUtils;
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|
|
public Integer addGoods(GoodsAddDTO goodsAddDTO) {
|
|
public Integer addGoods(GoodsAddDTO goodsAddDTO) {
|
|
@@ -59,38 +75,58 @@ public class GoodsService extends ServiceImpl<GoodsMapper, Goods> {
|
|
Integer goodCount = goodsAddDTO.getGoodCount();
|
|
Integer goodCount = goodsAddDTO.getGoodCount();
|
|
Date startSaleTime = goodsAddDTO.getStartSaleTime();
|
|
Date startSaleTime = goodsAddDTO.getStartSaleTime();
|
|
if (startSaleTime == null) {
|
|
if (startSaleTime == null) {
|
|
- startSaleTime = new Date();
|
|
|
|
|
|
+ goodsAddDTO.setStartSaleTime(new Date());
|
|
}
|
|
}
|
|
List<Integer> goodLimits = goodsAddDTO.getGoodLimits();
|
|
List<Integer> goodLimits = goodsAddDTO.getGoodLimits();
|
|
|
|
+ List<Integer> goodStrategies = goodsAddDTO.getGoodStrategies();
|
|
Integer goodUnit = goodsAddDTO.getGoodUnit();
|
|
Integer goodUnit = goodsAddDTO.getGoodUnit();
|
|
String goodLimit = null;
|
|
String goodLimit = null;
|
|
if (goodLimits != null && goodLimits.size() > 0) {
|
|
if (goodLimits != null && goodLimits.size() > 0) {
|
|
goodLimit = StringUtils.join(goodLimits, ",");
|
|
goodLimit = StringUtils.join(goodLimits, ",");
|
|
}
|
|
}
|
|
|
|
+ String goodStrategy = null;
|
|
|
|
+ if (goodStrategies != null && goodStrategies.size() > 0) {
|
|
|
|
+ goodStrategy = StringUtils.join(goodStrategies, ",");
|
|
|
|
+ }
|
|
if (id != null) {
|
|
if (id != null) {
|
|
- UpdateWrapper<Goods> updateWrapper = new UpdateWrapper<>();
|
|
|
|
- updateWrapper.set("PRICE", price);
|
|
|
|
- updateWrapper.set("GOOD_COUNT", goodCount);
|
|
|
|
- updateWrapper.set("GOOD_LIMIT", goodLimit);
|
|
|
|
- updateWrapper.set("GOOD_UNIT", goodUnit);
|
|
|
|
|
|
+ LambdaUpdateWrapper<Goods> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
|
+ updateWrapper.set(Goods::getStartSaleTime, goodsAddDTO.getStartSaleTime());
|
|
|
|
+ updateWrapper.set(Goods::getGoodType, goodsAddDTO.getGoodType());
|
|
|
|
+ updateWrapper.set(Goods::getExpireTime, goodsAddDTO.getExpireTime());
|
|
|
|
+ updateWrapper.set(Goods::getGoodName, goodsAddDTO.getGoodName());
|
|
|
|
+ updateWrapper.set(Goods::getStatus, goodsAddDTO.getStatus());
|
|
|
|
+ updateWrapper.set(Goods::getBuyLimit, goodLimit);
|
|
|
|
+ updateWrapper.set(Goods::getGoodCount, goodCount);
|
|
|
|
+ updateWrapper.set(Goods::getGoodStrategy, goodStrategy);
|
|
|
|
+ updateWrapper.set(Goods::getPrice, price);
|
|
|
|
+ updateWrapper.set(Goods::getRemark, goodsAddDTO.getRemark());
|
|
|
|
+ updateWrapper.set(Goods::getGoodId, goodsAddDTO.getGoodId());
|
|
|
|
+ updateWrapper.set(Goods::getGoodUnit, goodUnit);
|
|
|
|
+ updateWrapper.eq(Goods::getId, id);
|
|
this.update(updateWrapper);
|
|
this.update(updateWrapper);
|
|
} else {
|
|
} else {
|
|
Goods goods = new Goods();
|
|
Goods goods = new Goods();
|
|
BeanUtils.copyProperties(goodsAddDTO, goods);
|
|
BeanUtils.copyProperties(goodsAddDTO, goods);
|
|
goods.setBuyLimit(goodLimit);
|
|
goods.setBuyLimit(goodLimit);
|
|
-
|
|
|
|
|
|
+ goods.setGoodStrategy(goodStrategy);
|
|
|
|
+ goods.setCreateId(loginUtils.getId());
|
|
|
|
+ goods.insert();
|
|
id = goods.getId();
|
|
id = goods.getId();
|
|
}
|
|
}
|
|
return id;
|
|
return id;
|
|
}
|
|
}
|
|
|
|
|
|
public Records queryGoods(GoodsQueryDTO goodsQueryDTO) {
|
|
public Records queryGoods(GoodsQueryDTO goodsQueryDTO) {
|
|
|
|
+ Date date = new Date();
|
|
Records records = new Records();
|
|
Records records = new Records();
|
|
Long current = goodsQueryDTO.getCurrent();
|
|
Long current = goodsQueryDTO.getCurrent();
|
|
Long size = goodsQueryDTO.getSize();
|
|
Long size = goodsQueryDTO.getSize();
|
|
|
|
+ Integer id = goodsQueryDTO.getIds();
|
|
String goodName = goodsQueryDTO.getGoodName();
|
|
String goodName = goodsQueryDTO.getGoodName();
|
|
Integer goodType = goodsQueryDTO.getGoodType();
|
|
Integer goodType = goodsQueryDTO.getGoodType();
|
|
|
|
+ Integer vipId = goodsQueryDTO.getVipId();
|
|
Integer status = goodsQueryDTO.getStatus();
|
|
Integer status = goodsQueryDTO.getStatus();
|
|
|
|
+ Integer vipLevel = goodsQueryDTO.getVipLevel();
|
|
LambdaQueryWrapper<Goods> queryWrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<Goods> queryWrapper = new LambdaQueryWrapper<>();
|
|
if (goodName != null) {
|
|
if (goodName != null) {
|
|
queryWrapper.like(Goods::getGoodName, goodName);
|
|
queryWrapper.like(Goods::getGoodName, goodName);
|
|
@@ -98,9 +134,45 @@ public class GoodsService extends ServiceImpl<GoodsMapper, Goods> {
|
|
if (goodType != null) {
|
|
if (goodType != null) {
|
|
queryWrapper.eq(Goods::getGoodType, goodType);
|
|
queryWrapper.eq(Goods::getGoodType, goodType);
|
|
}
|
|
}
|
|
|
|
+ if (vipId != null) {
|
|
|
|
+ queryWrapper.eq(Goods::getGoodType, 1);
|
|
|
|
+ queryWrapper.eq(Goods::getGoodId, vipId);
|
|
|
|
+ }
|
|
|
|
+ if (vipLevel != null) {
|
|
|
|
+ queryWrapper.eq(Goods::getGoodType, 1);
|
|
|
|
+ LambdaQueryWrapper<AppVipType> queryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper1.gt(AppVipType::getVipLevel, vipLevel);
|
|
|
|
+ List<AppVipType> appVipTypes = appVipTypeService.list(queryWrapper1);
|
|
|
|
+ if (appVipTypes.size() == 0) {
|
|
|
|
+ queryWrapper.eq(Goods::getGoodId, -1);
|
|
|
|
+ } else {
|
|
|
|
+ List<Integer> vipTypeIds = appVipTypes.stream().map(AppVipType::getTenantVipTypeId).collect(Collectors.toList());
|
|
|
|
+ queryWrapper.in(Goods::getGoodId, vipTypeIds);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if (status != null) {
|
|
if (status != null) {
|
|
- queryWrapper.eq(Goods::getStatus, status);
|
|
|
|
|
|
+ switch (status) {
|
|
|
|
+ case 0:
|
|
|
|
+ queryWrapper.eq(Goods::getStatus, status);
|
|
|
|
+ break;
|
|
|
|
+ case 2:
|
|
|
|
+ queryWrapper.and(i -> i.lt(Goods::getStartSaleTime, date).eq(Goods::getStatus, 1).and(t -> t.isNull(Goods::getExpireTime).or().gt(Goods::getExpireTime, date)));
|
|
|
|
+ break;
|
|
|
|
+ case 3:
|
|
|
|
+ queryWrapper.and(i -> i.gt(Goods::getStartSaleTime, date).eq(Goods::getStatus, 1));
|
|
|
|
+ break;
|
|
|
|
+ case 4:
|
|
|
|
+ queryWrapper.and(i -> i.lt(Goods::getExpireTime, date).eq(Goods::getStatus, 1));
|
|
|
|
+ break;
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ if (id != null) {
|
|
|
|
+ queryWrapper.eq(Goods::getId, id);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ queryWrapper.orderByDesc(Goods::getCreateTime);
|
|
List<Goods> goods = new ArrayList<>();
|
|
List<Goods> goods = new ArrayList<>();
|
|
if (current != null && size != null) {
|
|
if (current != null && size != null) {
|
|
IPage<Goods> goodsIPage = this.page(new Page<>(current, size), queryWrapper);
|
|
IPage<Goods> goodsIPage = this.page(new Page<>(current, size), queryWrapper);
|
|
@@ -118,7 +190,7 @@ public class GoodsService extends ServiceImpl<GoodsMapper, Goods> {
|
|
|
|
|
|
public List<GoodsQueryVO> loadGoodsQueryVO(List<Goods> goodsList) {
|
|
public List<GoodsQueryVO> loadGoodsQueryVO(List<Goods> goodsList) {
|
|
List<GoodsQueryVO> goodsQueryVOS = new ArrayList<>();
|
|
List<GoodsQueryVO> goodsQueryVOS = new ArrayList<>();
|
|
- if (goodsQueryVOS == null || goodsQueryVOS.size() == 0) {
|
|
|
|
|
|
+ if (goodsList == null || goodsList.size() == 0) {
|
|
return goodsQueryVOS;
|
|
return goodsQueryVOS;
|
|
}
|
|
}
|
|
List<Integer> createIds = goodsList.stream().map(Goods::getCreateId).collect(Collectors.toList());
|
|
List<Integer> createIds = goodsList.stream().map(Goods::getCreateId).collect(Collectors.toList());
|
|
@@ -144,6 +216,7 @@ public class GoodsService extends ServiceImpl<GoodsMapper, Goods> {
|
|
for (Goods goods : goodsList) {
|
|
for (Goods goods : goodsList) {
|
|
GoodsQueryVO goodsQueryVO = new GoodsQueryVO();
|
|
GoodsQueryVO goodsQueryVO = new GoodsQueryVO();
|
|
String limits = goods.getBuyLimit();
|
|
String limits = goods.getBuyLimit();
|
|
|
|
+ String strategies = goods.getGoodStrategy();
|
|
Integer createId = goods.getId();
|
|
Integer createId = goods.getId();
|
|
Integer goodType = goods.getGoodType();
|
|
Integer goodType = goods.getGoodType();
|
|
Integer goodId = goods.getGoodId();
|
|
Integer goodId = goods.getGoodId();
|
|
@@ -154,7 +227,7 @@ public class GoodsService extends ServiceImpl<GoodsMapper, Goods> {
|
|
goodsQueryVO.setCreateName(personnel.getPersonnelName());
|
|
goodsQueryVO.setCreateName(personnel.getPersonnelName());
|
|
}
|
|
}
|
|
List<Integer> goodLimits = new ArrayList<>();
|
|
List<Integer> goodLimits = new ArrayList<>();
|
|
-
|
|
|
|
|
|
+ List<Integer> goodStrategies = new ArrayList<>();
|
|
if (limits != null) {
|
|
if (limits != null) {
|
|
String[] temStrs = StringUtils.split(limits, ",");
|
|
String[] temStrs = StringUtils.split(limits, ",");
|
|
for (int i = 0; i < temStrs.length; i++) {
|
|
for (int i = 0; i < temStrs.length; i++) {
|
|
@@ -162,6 +235,14 @@ public class GoodsService extends ServiceImpl<GoodsMapper, Goods> {
|
|
}
|
|
}
|
|
goodsQueryVO.setGoodLimits(goodLimits);
|
|
goodsQueryVO.setGoodLimits(goodLimits);
|
|
}
|
|
}
|
|
|
|
+ if (strategies != null) {
|
|
|
|
+ String[] temStrs = StringUtils.split(strategies, ",");
|
|
|
|
+ for (int i = 0; i < temStrs.length; i++) {
|
|
|
|
+ goodStrategies.add(Integer.parseInt(temStrs[i]));
|
|
|
|
+ }
|
|
|
|
+ goodsQueryVO.setGoodStrategyIds(goodStrategies);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
if (goodType == 1) {
|
|
if (goodType == 1) {
|
|
AppVipTypeVO appVipTypeVO = appVipTypeVOS.stream().filter(item -> item.getId().equals(goodId)).findFirst().orElse(null);
|
|
AppVipTypeVO appVipTypeVO = appVipTypeVOS.stream().filter(item -> item.getId().equals(goodId)).findFirst().orElse(null);
|
|
@@ -170,15 +251,17 @@ public class GoodsService extends ServiceImpl<GoodsMapper, Goods> {
|
|
}
|
|
}
|
|
} else if (goodType == 2) {
|
|
} else if (goodType == 2) {
|
|
Function function = functionList.stream().filter(item -> item.getId().equals(goodId)).findFirst().orElse(null);
|
|
Function function = functionList.stream().filter(item -> item.getId().equals(goodId)).findFirst().orElse(null);
|
|
- if(function!=null){
|
|
|
|
|
|
+ if (function != null) {
|
|
FunctionCodeTreeVO functionMessage = AssoFunctionModuleService.loadFunctionCodeTreeVO(function, null);
|
|
FunctionCodeTreeVO functionMessage = AssoFunctionModuleService.loadFunctionCodeTreeVO(function, null);
|
|
goodsQueryVO.setFunctionMessage(functionMessage);
|
|
goodsQueryVO.setFunctionMessage(functionMessage);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
goodsQueryVOS.add(goodsQueryVO);
|
|
goodsQueryVOS.add(goodsQueryVO);
|
|
}
|
|
}
|
|
|
|
+ this.loadGoodsQueryVOLimits(goodsQueryVOS);
|
|
|
|
+ this.loadGoodsQueryVOStatus(goodsQueryVOS);
|
|
|
|
+ loadService.loadCommonVO(goodsQueryVOS);
|
|
return goodsQueryVOS;
|
|
return goodsQueryVOS;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -210,6 +293,105 @@ public class GoodsService extends ServiceImpl<GoodsMapper, Goods> {
|
|
this.update(updateWrapper);
|
|
this.update(updateWrapper);
|
|
return ids;
|
|
return ids;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public List<GoodsQueryVO> loadGoodsQueryVOLimits(List<GoodsQueryVO> goodsQueryVOS) {
|
|
|
|
+ List<Integer> limitIds = new ArrayList<>();
|
|
|
|
+ List<Integer> strategyIds = new ArrayList<>();
|
|
|
|
+ for (GoodsQueryVO goodsQueryVO : goodsQueryVOS) {
|
|
|
|
+ List<Integer> temLimitIds = goodsQueryVO.getGoodLimits();
|
|
|
|
+ List<Integer> temStrategyIds = goodsQueryVO.getGoodStrategyIds();
|
|
|
|
+ if (temLimitIds != null && temLimitIds.size() > 0) {
|
|
|
|
+ limitIds.addAll(temLimitIds);
|
|
|
|
+ }
|
|
|
|
+ if (temStrategyIds != null && temStrategyIds.size() > 0) {
|
|
|
|
+ strategyIds.addAll(temStrategyIds);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ List<GoodByLimitVO> goodByLimitVOS = new ArrayList<>();
|
|
|
|
+ List<MarketStrategyVO> marketStrategyVOS = new ArrayList<>();
|
|
|
|
+ if (limitIds != null && limitIds.size() > 0) {
|
|
|
|
+ goodByLimitVOS = goodByLimitService.queryAllGoodLimit(limitIds);
|
|
|
|
+ }
|
|
|
|
+ if (strategyIds != null && strategyIds.size() > 0) {
|
|
|
|
+ marketStrategyVOS = marketStrategyService.queryMarketStrategy(strategyIds);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (GoodsQueryVO goodsQueryVO : goodsQueryVOS) {
|
|
|
|
+ List<Integer> temLimitIds = goodsQueryVO.getGoodLimits();
|
|
|
|
+ List<Integer> temStrategyIds = goodsQueryVO.getGoodStrategyIds();
|
|
|
|
+ if (temLimitIds != null && temLimitIds.size() > 0) {
|
|
|
|
+ List<GoodByLimitVO> temLimitVOs = goodByLimitVOS.stream().filter(item -> temLimitIds.contains(item.getId())).collect(Collectors.toList());
|
|
|
|
+ goodsQueryVO.setGoodByLimitVos(temLimitVOs);
|
|
|
|
+ }
|
|
|
|
+ if (temStrategyIds != null && temStrategyIds.size() > 0) {
|
|
|
|
+ List<MarketStrategyVO> temMarketStrategyVOs = marketStrategyVOS.stream().filter(item -> temLimitIds.contains(item.getId())).collect(Collectors.toList());
|
|
|
|
+ goodsQueryVO.setGoodStrategyVos(temMarketStrategyVOs);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return goodsQueryVOS;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<GoodsQueryVO> loadGoodsQueryVOStatus(List<GoodsQueryVO> goodsQueryVOS) {
|
|
|
|
+ List<String> sysDictNames = new ArrayList<>();
|
|
|
|
+ sysDictNames.add(GOOD_STATUS_KEY);
|
|
|
|
+ sysDictNames.add(GOOD_TYPE_KEY);
|
|
|
|
+ sysDictNames.add(GOOD_UNIT_KEY);
|
|
|
|
+ List<SysDictItem> sysDictItems = sysDictItemService.querySysDictItemsByGroup(sysDictNames);
|
|
|
|
+ for (GoodsQueryVO goodsQueryVO : goodsQueryVOS) {
|
|
|
|
+ Integer goodUnit = goodsQueryVO.getGoodUnit();
|
|
|
|
+ Integer goodType = goodsQueryVO.getGoodType();
|
|
|
|
+ Integer goodStatus = goodsQueryVO.getStatus();
|
|
|
|
+ Date now = new Date();
|
|
|
|
+ Date expireTime = goodsQueryVO.getExpireTime();
|
|
|
|
+ Date startSaleTime = goodsQueryVO.getStartSaleTime();
|
|
|
|
+ if (goodUnit != null) {
|
|
|
|
+ SysDictItem sysDictItem = sysDictItems.stream().filter(item -> item.getDictParentKey().equals(GOOD_UNIT_KEY) && item.getDictChildValue().equals(goodUnit.toString())).findFirst().orElse(null);
|
|
|
|
+ if (sysDictItem != null) {
|
|
|
|
+ goodsQueryVO.setGoodUnitStr(sysDictItem.getDictChildLabel());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (goodType != null) {
|
|
|
|
+ SysDictItem sysDictItem = sysDictItems.stream().filter(item -> item.getDictParentKey().equals(GOOD_TYPE_KEY) && item.getDictChildValue().equals(goodType.toString())).findFirst().orElse(null);
|
|
|
|
+ if (sysDictItem != null) {
|
|
|
|
+ goodsQueryVO.setGoodTypeStr(sysDictItem.getDictChildLabel());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (goodStatus != null) {
|
|
|
|
+ if (goodStatus == 1) {
|
|
|
|
+ if (now.compareTo(startSaleTime) >= 0) {
|
|
|
|
+ if (expireTime == null || expireTime.compareTo(now) > 0) {
|
|
|
|
+ goodStatus = 2;
|
|
|
|
+ } else {
|
|
|
|
+ goodStatus = 4;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ goodStatus = 3;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ String finalStatus = goodStatus.toString();
|
|
|
|
+ SysDictItem sysDictItem = sysDictItems.stream().filter(item -> item.getDictParentKey().equals(GOOD_STATUS_KEY) && item.getDictChildValue().equals(finalStatus)).findFirst().orElse(null);
|
|
|
|
+ if (sysDictItem != null) {
|
|
|
|
+ goodsQueryVO.setStatusStr(sysDictItem.getDictChildLabel());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ return goodsQueryVOS;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public List<Goods> queryGoodsByGoodIds(List<Integer> ids, Integer type) {
|
|
|
|
+ if (ids == null || ids.size() == 0) {
|
|
|
|
+ return new ArrayList<>();
|
|
|
|
+ }
|
|
|
|
+ LambdaQueryWrapper<Goods> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ queryWrapper.in(Goods::getId, ids).eq(Goods::getGoodType, type);
|
|
|
|
+ return this.list(queryWrapper);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|