|
@@ -1,18 +1,26 @@
|
|
|
package cn.cslg.permission.service.qiaobi;
|
|
|
|
|
|
import cn.cslg.permission.common.model.Records;
|
|
|
+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.version.QiaoBiVersionVO;
|
|
|
+import cn.cslg.permission.common.model.vo.AppVipTypeVO;
|
|
|
+import cn.cslg.permission.common.model.vo.FunctionCodeTreeVO;
|
|
|
import cn.cslg.permission.common.utils.StringUtils;
|
|
|
+import cn.cslg.permission.domain.Function;
|
|
|
import cn.cslg.permission.domain.Personnel;
|
|
|
import cn.cslg.permission.domain.Version;
|
|
|
import cn.cslg.permission.domain.qiaobi.Goods;
|
|
|
import cn.cslg.permission.exception.ExceptionEnum;
|
|
|
import cn.cslg.permission.exception.XiaoShiException;
|
|
|
+import cn.cslg.permission.mapper.qiaobi.AppVipTypeMapper;
|
|
|
+import cn.cslg.permission.service.FunctionService;
|
|
|
import cn.cslg.permission.service.PersonnelService;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -24,6 +32,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
@@ -36,12 +45,22 @@ import java.util.stream.Collectors;
|
|
|
public class GoodsService extends ServiceImpl<GoodsMapper, Goods> {
|
|
|
@Autowired
|
|
|
private PersonnelService personnelService;
|
|
|
+ @Autowired
|
|
|
+ private FunctionService functionService;
|
|
|
+ @Autowired
|
|
|
+ private AppVipTypeService appVipTypeService;
|
|
|
+ @Autowired
|
|
|
+ private AppVipTypeMapper appVipTypeMapper;
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public Integer addGoods(GoodsAddDTO goodsAddDTO) {
|
|
|
Integer id = goodsAddDTO.getId();
|
|
|
Double price = goodsAddDTO.getPrice();
|
|
|
Integer goodCount = goodsAddDTO.getGoodCount();
|
|
|
+ Date startSaleTime = goodsAddDTO.getStartSaleTime();
|
|
|
+ if (startSaleTime == null) {
|
|
|
+ startSaleTime = new Date();
|
|
|
+ }
|
|
|
List<Integer> goodLimits = goodsAddDTO.getGoodLimits();
|
|
|
Integer goodUnit = goodsAddDTO.getGoodUnit();
|
|
|
String goodLimit = null;
|
|
@@ -59,6 +78,7 @@ public class GoodsService extends ServiceImpl<GoodsMapper, Goods> {
|
|
|
Goods goods = new Goods();
|
|
|
BeanUtils.copyProperties(goodsAddDTO, goods);
|
|
|
goods.setBuyLimit(goodLimit);
|
|
|
+
|
|
|
id = goods.getId();
|
|
|
}
|
|
|
return id;
|
|
@@ -106,16 +126,35 @@ public class GoodsService extends ServiceImpl<GoodsMapper, Goods> {
|
|
|
if (createIds != null && createIds.size() > 0) {
|
|
|
personnelList = personnelService.getPersonByIds(createIds);
|
|
|
}
|
|
|
+
|
|
|
+ List<Integer> vipIds = goodsList.stream().filter(item -> item.getGoodType().equals(1)).map(Goods::getGoodId).collect(Collectors.toList());
|
|
|
+ List<Integer> functionIds = goodsList.stream().filter(item -> item.getGoodType().equals(2)).map(Goods::getGoodId).collect(Collectors.toList());
|
|
|
+ List<Function> functionList = new ArrayList<>();
|
|
|
+ List<AppVipTypeVO> appVipTypeVOS = new ArrayList<>();
|
|
|
+ if (functionIds.size() > 0) {
|
|
|
+ functionList = functionService.getFuncListByIds(functionIds);
|
|
|
+ }
|
|
|
+ if (vipIds.size() > 0) {
|
|
|
+ QueryVipDTO queryVipDTO = new QueryVipDTO();
|
|
|
+ queryVipDTO.setIds(vipIds);
|
|
|
+ appVipTypeVOS = appVipTypeMapper.queryAppVipType(queryVipDTO);
|
|
|
+ appVipTypeService.loadAppVipTypeVO(appVipTypeVOS);
|
|
|
+ }
|
|
|
+
|
|
|
for (Goods goods : goodsList) {
|
|
|
GoodsQueryVO goodsQueryVO = new GoodsQueryVO();
|
|
|
String limits = goods.getBuyLimit();
|
|
|
Integer createId = goods.getId();
|
|
|
+ Integer goodType = goods.getGoodType();
|
|
|
+ Integer goodId = goods.getGoodId();
|
|
|
Personnel personnel = personnelList.stream().filter(item -> item.getId().equals(createId)).findFirst().orElse(null);
|
|
|
BeanUtils.copyProperties(goods, goodsQueryVO);
|
|
|
+
|
|
|
if (personnel != null) {
|
|
|
goodsQueryVO.setCreateName(personnel.getPersonnelName());
|
|
|
}
|
|
|
List<Integer> goodLimits = new ArrayList<>();
|
|
|
+
|
|
|
if (limits != null) {
|
|
|
String[] temStrs = StringUtils.split(limits, ",");
|
|
|
for (int i = 0; i < temStrs.length; i++) {
|
|
@@ -123,6 +162,21 @@ public class GoodsService extends ServiceImpl<GoodsMapper, Goods> {
|
|
|
}
|
|
|
goodsQueryVO.setGoodLimits(goodLimits);
|
|
|
}
|
|
|
+
|
|
|
+ if (goodType == 1) {
|
|
|
+ AppVipTypeVO appVipTypeVO = appVipTypeVOS.stream().filter(item -> item.getId().equals(goodId)).findFirst().orElse(null);
|
|
|
+ if (appVipTypeVO != null) {
|
|
|
+ goodsQueryVO.setVipMessage(appVipTypeVO);
|
|
|
+ }
|
|
|
+ } else if (goodType == 2) {
|
|
|
+ Function function = functionList.stream().filter(item -> item.getId().equals(goodId)).findFirst().orElse(null);
|
|
|
+ if(function!=null){
|
|
|
+ FunctionCodeTreeVO functionMessage = AssoFunctionModuleService.loadFunctionCodeTreeVO(function, null);
|
|
|
+ goodsQueryVO.setFunctionMessage(functionMessage);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
goodsQueryVOS.add(goodsQueryVO);
|
|
|
}
|
|
|
return goodsQueryVOS;
|
|
@@ -146,6 +200,16 @@ public class GoodsService extends ServiceImpl<GoodsMapper, Goods> {
|
|
|
return this.list(queryWrapper);
|
|
|
|
|
|
}
|
|
|
+
|
|
|
+ public List<Integer> updateGoodsStatus(GoodUpdateStatusDTO goodUpdateStatusDTO) {
|
|
|
+ List<Integer> ids = goodUpdateStatusDTO.getIds();
|
|
|
+ Integer status = goodUpdateStatusDTO.getStatus();
|
|
|
+ LambdaUpdateWrapper<Goods> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(Goods::getStatus, status);
|
|
|
+ updateWrapper.in(Goods::getId, ids);
|
|
|
+ this.update(updateWrapper);
|
|
|
+ return ids;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|