|
|
@@ -1,14 +1,20 @@
|
|
|
package com.sckw.product.service;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.model.constant.Global;
|
|
|
+import com.sckw.core.model.vo.TableBottom;
|
|
|
import com.sckw.core.model.vo.TableStatisticRes;
|
|
|
+import com.sckw.core.model.vo.TableTop;
|
|
|
import com.sckw.core.utils.BeanUtils;
|
|
|
import com.sckw.core.utils.CollectionUtils;
|
|
|
+import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
+import com.sckw.excel.utils.DateUtil;
|
|
|
import com.sckw.excel.utils.EasyExcelUtil;
|
|
|
import com.sckw.product.dao.KwpGoodsMapper;
|
|
|
+import com.sckw.product.enums.GoodsStatusEnum;
|
|
|
import com.sckw.product.model.*;
|
|
|
import com.sckw.product.model.vo.req.*;
|
|
|
import com.sckw.product.model.vo.res.BuildingMaterialsMarketList;
|
|
|
@@ -21,10 +27,8 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @desc: 商品service
|
|
|
@@ -54,7 +58,7 @@ public class KwpGoodsService {
|
|
|
Long entId = LoginUserHolder.getEntId();
|
|
|
//添加商品信息
|
|
|
KwpGoods goods = BeanUtils.copyProperties(addGoodsParam, KwpGoods.class);
|
|
|
- goods.setEntId(entId).setStatus(0);
|
|
|
+ goods.setEntId(entId).setStatus(GoodsStatusEnum.TAKE_OFF_SHELVES.getCode());
|
|
|
kwpGoodsMapper.insert(goods);
|
|
|
addGoodsOtherInfo(goods.getId(), addGoodsParam);
|
|
|
}
|
|
|
@@ -71,7 +75,7 @@ public class KwpGoodsService {
|
|
|
Long entId = LoginUserHolder.getEntId();
|
|
|
//添加商品信息
|
|
|
KwpGoods goods = BeanUtils.copyProperties(addGoodsParam, KwpGoods.class);
|
|
|
- goods.setEntId(entId).setShelfTime(new Date()).setStatus(1);
|
|
|
+ goods.setEntId(entId).setShelfTime(new Date()).setStatus(GoodsStatusEnum.PUT_ON_SHELVES.getCode());
|
|
|
kwpGoodsMapper.insert(goods);
|
|
|
addGoodsOtherInfo(goods.getId(), addGoodsParam);
|
|
|
}
|
|
|
@@ -132,25 +136,21 @@ public class KwpGoodsService {
|
|
|
* @return: com.sckw.product.model.vo.res.GoodsDetail
|
|
|
*/
|
|
|
public GoodsDetail detail(Long id) {
|
|
|
- Long entId = LoginUserHolder.getEntId();
|
|
|
- LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(KwpGoods::getId, id);
|
|
|
- KwpGoods goods = getGoods(wrapper);
|
|
|
+ KwpGoods goods = getGoodsById(id);
|
|
|
if (Objects.isNull(goods)) {
|
|
|
throw new BusinessException("当前商品信息为空!");
|
|
|
}
|
|
|
GoodsDetail detail = BeanUtils.copyProperties(goods, GoodsDetail.class);
|
|
|
-
|
|
|
-
|
|
|
+ //商品图片信息
|
|
|
List<KwpGoodsImage> goodsImages = kwpGoodsImageService.getByGoodsId(id);
|
|
|
List<GoodsImages> images = BeanUtils.copyToList(goodsImages, GoodsImages.class);
|
|
|
-
|
|
|
+ //商品价格段信息
|
|
|
List<KwpGoodsPriceRange> priceRanges = kwpGoodsPriceRangeService.getByGoodsId(id);
|
|
|
List<GoodsPriceRanges> ranges = BeanUtils.copyToList(priceRanges, GoodsPriceRanges.class);
|
|
|
-
|
|
|
+ //商品属性信息
|
|
|
List<KwpGoodsAttribute> attributesList = kwpGoodsAttributeService.getByGoodsId(id);
|
|
|
List<GoodsAttributes> attributes = BeanUtils.copyToList(attributesList, GoodsAttributes.class);
|
|
|
-
|
|
|
+ //商品地址信息
|
|
|
KwpGoodsAddress goodsAddress = kwpGoodsAddressService.getByGoodsId(id);
|
|
|
AddressInfo addressInfo = BeanUtils.copyProperties(goodsAddress, AddressInfo.class);
|
|
|
|
|
|
@@ -159,61 +159,244 @@ public class KwpGoodsService {
|
|
|
return detail;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * @desc: 分页查询商品信息
|
|
|
+ * @desc: 更新商品信息
|
|
|
* @author: yzc
|
|
|
- * @date: 2023-07-05 11:58
|
|
|
- * @Param params:
|
|
|
- * @return: java.util.List<com.sckw.product.model.vo.res.GoodsList>
|
|
|
+ * @date: 2023-07-06 8:50
|
|
|
+ * @Param param:
|
|
|
+ * @return: void
|
|
|
*/
|
|
|
- public List<GoodsList> select(SelectGoodsListParam params) {
|
|
|
- return null;
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void update(UpdateGoodsParam param) {
|
|
|
+ if (Objects.equals(param.getStatus(), GoodsStatusEnum.PUT_ON_SHELVES.getCode())) {
|
|
|
+ judgeParameters(param);
|
|
|
+ }
|
|
|
+ KwpGoods kwpGoods = getGoodsById(param.getId());
|
|
|
+ if (Objects.isNull(kwpGoods)) {
|
|
|
+ throw new BusinessException("当前商品不存在!");
|
|
|
+ }
|
|
|
+ if (Objects.equals(kwpGoods.getStatus(), GoodsStatusEnum.PUT_ON_SHELVES.getCode())) {
|
|
|
+ throw new BusinessException("当前商品为上架状态,不可修改!");
|
|
|
+ }
|
|
|
+ KwpGoods goods = BeanUtils.copyProperties(param, KwpGoods.class);
|
|
|
+ if (Objects.equals(param.getStatus(), GoodsStatusEnum.PUT_ON_SHELVES.getCode())) {
|
|
|
+ goods.setShelfTime(new Date());
|
|
|
+ }
|
|
|
+ kwpGoodsMapper.updateById(goods);
|
|
|
+ updateGoodsOtherInfo(param);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @desc: 统计查询
|
|
|
+ * @desc: 更新商品其他信息
|
|
|
* @author: yzc
|
|
|
- * @date: 2023-07-05 17:55
|
|
|
+ * @date: 2023-07-06 14:53
|
|
|
+ * @Param param:
|
|
|
+ * @return: void
|
|
|
+ */
|
|
|
+ private void updateGoodsOtherInfo(UpdateGoodsParam param) {
|
|
|
+ Long goodsId = param.getId();
|
|
|
+ //更新商品地址信息
|
|
|
+ kwpGoodsAddressService.delByGoodsId(goodsId);
|
|
|
+ KwpGoodsAddress address = BeanUtils.copyProperties(param.getAddressInfo(), KwpGoodsAddress.class);
|
|
|
+ address.setGoodsId(goodsId);
|
|
|
+ kwpGoodsAddressService.insert(address);
|
|
|
+
|
|
|
+ //更新商品属性信息
|
|
|
+ kwpGoodsAttributeService.delByGoodsId(goodsId);
|
|
|
+ if (CollectionUtils.isNotEmpty(param.getAttributes())) {
|
|
|
+ List<KwpGoodsAttribute> list = new ArrayList<>(param.getAttributes().size());
|
|
|
+ param.getAttributes().forEach(e -> {
|
|
|
+ KwpGoodsAttribute attribute = BeanUtils.copyProperties(e, KwpGoodsAttribute.class);
|
|
|
+ attribute.setGoodsId(goodsId);
|
|
|
+ list.add(attribute);
|
|
|
+ });
|
|
|
+ kwpGoodsAttributeService.insertBatch(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新商品图片信息
|
|
|
+ kwpGoodsImageService.delByGoodsId(goodsId);
|
|
|
+ if (CollectionUtils.isNotEmpty(param.getImages())) {
|
|
|
+ List<KwpGoodsImage> list = new ArrayList<>(param.getImages().size());
|
|
|
+ param.getImages().forEach(e -> {
|
|
|
+ KwpGoodsImage image = BeanUtils.copyProperties(e, KwpGoodsImage.class);
|
|
|
+ image.setGoodsId(goodsId);
|
|
|
+ list.add(image);
|
|
|
+ });
|
|
|
+ kwpGoodsImageService.insertBatch(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新商品价格梯度信息
|
|
|
+ kwpGoodsPriceRangeService.delByGoodsId(goodsId);
|
|
|
+ if (CollectionUtils.isNotEmpty(param.getPriceRanges())) {
|
|
|
+ List<KwpGoodsPriceRange> list = new ArrayList<>(param.getPriceRanges().size());
|
|
|
+ param.getPriceRanges().forEach(e -> {
|
|
|
+ KwpGoodsPriceRange priceRange = BeanUtils.copyProperties(e, KwpGoodsPriceRange.class);
|
|
|
+ priceRange.setGoodsId(goodsId);
|
|
|
+ list.add(priceRange);
|
|
|
+ });
|
|
|
+ kwpGoodsPriceRangeService.insertBatch(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc: 参数校验
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-07-06 14:33
|
|
|
+ * @Param param:
|
|
|
+ * @return: void
|
|
|
+ */
|
|
|
+ private void judgeParameters(UpdateGoodsParam param) {
|
|
|
+ if (StringUtils.isBlank(param.getName())) {
|
|
|
+ throw new BusinessException("商品名称不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(param.getTypeId())) {
|
|
|
+ throw new BusinessException("商品类型不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(param.getUnit())) {
|
|
|
+ throw new BusinessException("计量单位不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(param.getSpec())) {
|
|
|
+ throw new BusinessException("规格尺寸不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(param.getAmount())) {
|
|
|
+ throw new BusinessException("库存数量不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(param.getTaxRate())) {
|
|
|
+ throw new BusinessException("发票税率不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(param.getTrading())) {
|
|
|
+ throw new BusinessException("交易方式不能为空!");
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isEmpty(param.getPriceRanges())) {
|
|
|
+ throw new BusinessException("价格梯度不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(param.getSupplyEntId())) {
|
|
|
+ throw new BusinessException("供应企业不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(param.getAddressInfo())) {
|
|
|
+ throw new BusinessException("地址信息不能为空!");
|
|
|
+ }
|
|
|
+ if (Objects.isNull(param.getManager())) {
|
|
|
+ throw new BusinessException("客户经理不能为空!");
|
|
|
+ }
|
|
|
+ if (StringUtils.isBlank(param.getAmount())) {
|
|
|
+ throw new BusinessException("商品缩略图不能为空!");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc: 分页查询商品信息
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-07-05 11:58
|
|
|
* @Param params:
|
|
|
- * @return: com.sckw.core.model.vo.TableRes
|
|
|
+ * @return: java.util.List<com.sckw.product.model.vo.res.GoodsList>
|
|
|
*/
|
|
|
- public TableStatisticRes statistic(GoodsListParam params) {
|
|
|
- return null;
|
|
|
+ public List<GoodsList> select(ExportGoodsListParam params) {
|
|
|
+ List<Long> ids = params.getIds();
|
|
|
+ List<KwpGoods> goodsLists;
|
|
|
+ if (CollectionUtils.isEmpty(ids)) {
|
|
|
+ goodsLists = getGoodsLists(params);
|
|
|
+ } else {
|
|
|
+ LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(KwpGoods::getId, ids).eq(KwpGoods::getEntId, LoginUserHolder.getEntId()).eq(KwpGoods::getDelFlag, Global.NO);
|
|
|
+ goodsLists = kwpGoodsMapper.selectList(wrapper);
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isEmpty(goodsLists)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ List<GoodsList> result = new ArrayList<>(goodsLists.size());
|
|
|
+ List<Long> goodsIds = goodsLists.stream().map(KwpGoods::getId).toList();
|
|
|
+ //地址信息
|
|
|
+ Map<Long, KwpGoodsAddress> addressMap = kwpGoodsAddressService.getByGoodsIds(goodsIds)
|
|
|
+ .stream().collect(Collectors.toMap(KwpGoodsAddress::getGoodsId, e -> e, (k1, k2) -> k1));
|
|
|
+ //价格梯度信息
|
|
|
+ Map<Long, List<KwpGoodsPriceRange>> priceRangeMap = kwpGoodsPriceRangeService.getByGoodsIds(goodsIds)
|
|
|
+ .stream().collect(Collectors.groupingBy(KwpGoodsPriceRange::getGoodsId));
|
|
|
+
|
|
|
+ goodsLists.forEach(e -> {
|
|
|
+ Long id = e.getId();
|
|
|
+ GoodsList goodsList = BeanUtils.copyProperties(e, GoodsList.class);
|
|
|
+ goodsList.setAddress(Objects.isNull(addressMap.get(id)) ? null : addressMap.get(id).getDetailAddress());
|
|
|
+ List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(id);
|
|
|
+ goodsList.setHighestPrice(CollectionUtils.isEmpty(priceRanges) ? null : priceRanges.get(priceRanges.size() - 1).getPrice());
|
|
|
+ goodsList.setLowestPrice(CollectionUtils.isEmpty(priceRanges) ? null : priceRanges.get(0).getPrice());
|
|
|
+ result.add(goodsList);
|
|
|
+ });
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @desc: 条件获取商品信息
|
|
|
+ * @desc: 商品表格列表查询
|
|
|
* @author: yzc
|
|
|
- * @date: 2023-07-05 14:25
|
|
|
- * @Param wrapper:
|
|
|
- * @return: com.sckw.product.model.KwpGoods
|
|
|
+ * @date: 2023-07-07 9:09
|
|
|
+ * @Param params:
|
|
|
+ * @return: java.util.List<com.sckw.product.model.KwpGoods>
|
|
|
*/
|
|
|
- public KwpGoods getGoods(LambdaQueryWrapper<KwpGoods> wrapper) {
|
|
|
- LambdaQueryWrapper<KwpGoods> last = wrapper.eq(KwpGoods::getEntId, LoginUserHolder.getEntId())
|
|
|
- .eq(KwpGoods::getDelFlag, Global.NO).last("LIMIT 1");
|
|
|
- return kwpGoodsMapper.selectOne(last);
|
|
|
+ private List<KwpGoods> getGoodsLists(GoodsListParam params) {
|
|
|
+ LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.like(StringUtils.isNotBlank(params.getKeywords()), KwpGoods::getName, params.getKeywords())
|
|
|
+ .ge(Objects.nonNull(params.getStartCreateTime()), KwpGoods::getCreateTime, params.getStartCreateTime())
|
|
|
+ .le(Objects.nonNull(params.getEndCreateTime()), KwpGoods::getCreateTime, params.getEndCreateTime())
|
|
|
+ .in(CollectionUtils.isNotEmpty(params.getTradings()), KwpGoods::getTrading, params.getTradings())
|
|
|
+ .in(CollectionUtils.isNotEmpty(params.getTypeIds()), KwpGoods::getTypeId, params.getTypeIds())
|
|
|
+ .in(CollectionUtils.isNotEmpty(params.getStatus()), KwpGoods::getStatus, params.getStatus())
|
|
|
+ .eq(KwpGoods::getEntId, LoginUserHolder.getEntId()).eq(KwpGoods::getDelFlag, Global.NO).orderByDesc(KwpGoods::getCreateTime);
|
|
|
+ List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
|
|
|
+ return CollectionUtils.emptyIfNull(list);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * @desc: 商品下拉列表
|
|
|
+ * @desc: 统计查询
|
|
|
* @author: yzc
|
|
|
- * @date: 2023-07-06 8:45
|
|
|
+ * @date: 2023-07-05 17:55
|
|
|
* @Param params:
|
|
|
- * @return: java.util.List<com.sckw.product.model.vo.res.GoodsDropList>
|
|
|
+ * @return: com.sckw.core.model.vo.TableRes
|
|
|
*/
|
|
|
- public List<GoodsDropList> dropList(GoodsDropListReq params) {
|
|
|
- return null;
|
|
|
+ public TableStatisticRes statistic(GoodsListParam params) {
|
|
|
+ TableStatisticRes res = new TableStatisticRes();
|
|
|
+ List<KwpGoods> goodsList = getGoodsLists(params);
|
|
|
+ Map<Integer, List<KwpGoods>> map = goodsList.stream().collect(Collectors.groupingBy(KwpGoods::getStatus));
|
|
|
+ List<TableTop> tableTops = new ArrayList<>();
|
|
|
+ GoodsStatusEnum.getSortList().forEach(e -> {
|
|
|
+ List<KwpGoods> list = map.get(e.getCode());
|
|
|
+ int total = CollectionUtils.isEmpty(list) ? 0 : list.size();
|
|
|
+ TableTop tableTop = new TableTop();
|
|
|
+ tableTop.setName(e.getMsg()).setValue(e.getCode()).setTotal(total);
|
|
|
+ tableTops.add(tableTop);
|
|
|
+ });
|
|
|
+ TableBottom tableBottom = new TableBottom();
|
|
|
+ tableBottom.setTotal(CollectionUtils.isEmpty(goodsList) ? 0 : goodsList.size());
|
|
|
+ res.setTableTops(tableTops).setTableBottom(tableBottom);
|
|
|
+ return res;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @desc: 更新商品信息
|
|
|
+ * @desc: 导出
|
|
|
* @author: yzc
|
|
|
- * @date: 2023-07-06 8:50
|
|
|
- * @Param updateGoodsParam:
|
|
|
+ * @date: 2023-07-06 9:07
|
|
|
+ * @Param params:
|
|
|
* @return: void
|
|
|
*/
|
|
|
- public void update(UpdateGoodsParam updateGoodsParam) {
|
|
|
-
|
|
|
+ public void export(ExportGoodsListParam params) {
|
|
|
+ List<GoodsList> goodsLists = select(params);
|
|
|
+ List<GoodsListExport> list = new ArrayList<>();
|
|
|
+ goodsLists.forEach(e -> {
|
|
|
+ GoodsListExport export = BeanUtils.copyProperties(e, GoodsListExport.class);
|
|
|
+ export.setStatus(GoodsStatusEnum.getNameByCode(e.getStatus()))
|
|
|
+ .setType("砂石").setTaxRate(String.valueOf(e.getTaxRate())).setAmount(String.valueOf(e.getAmount()))
|
|
|
+ .setTrading("线下付款").setHighestPrice(String.valueOf(e.getHighestPrice()))
|
|
|
+ .setLowestPrice(String.valueOf(e.getLowestPrice())).setAddedTime(DateUtil.getDateTime(e.getAddedTime()))
|
|
|
+ .setShelfTime(DateUtil.getDateTime(e.getShelfTime()));
|
|
|
+ list.add(export);
|
|
|
+ });
|
|
|
+ try {
|
|
|
+ EasyExcelUtil.writeSingleExcel("商品列表信息", "sheet1", list, GoodsListExport.class);
|
|
|
+ } catch (IOException e) {
|
|
|
+ throw new BusinessException("导出商品列表异常", e.getMessage());
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -224,7 +407,17 @@ public class KwpGoodsService {
|
|
|
* @return: void
|
|
|
*/
|
|
|
public void batchPutOnShelves(List<Long> ids) {
|
|
|
-
|
|
|
+ LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(KwpGoods::getId, ids).in(KwpGoods::getStatus, 0, 2)
|
|
|
+ .eq(KwpGoods::getEntId, LoginUserHolder.getEntId()).eq(KwpGoods::getDelFlag, Global.NO);
|
|
|
+ List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
|
|
|
+ if (!Objects.equals(ids.size(), list.size())) {
|
|
|
+ throw new BusinessException("上架操作仅针对“已下架”“草稿”状态的单据");
|
|
|
+ }
|
|
|
+ LambdaUpdateWrapper<KwpGoods> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).set(KwpGoods::getAddedTime, new Date())
|
|
|
+ .in(KwpGoods::getId, ids);
|
|
|
+ kwpGoodsMapper.update(null, updateWrapper);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -235,7 +428,17 @@ public class KwpGoodsService {
|
|
|
* @return: void
|
|
|
*/
|
|
|
public void batchTakeOffShelves(List<Long> ids) {
|
|
|
-
|
|
|
+ LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(KwpGoods::getId, ids).eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode())
|
|
|
+ .eq(KwpGoods::getEntId, LoginUserHolder.getEntId()).eq(KwpGoods::getDelFlag, Global.NO);
|
|
|
+ List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
|
|
|
+ if (!Objects.equals(ids.size(), list.size())) {
|
|
|
+ throw new BusinessException("下架操作仅针对“已上架”状态的单据");
|
|
|
+ }
|
|
|
+ LambdaUpdateWrapper<KwpGoods> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(KwpGoods::getStatus, GoodsStatusEnum.TAKE_OFF_SHELVES.getCode()).set(KwpGoods::getShelfTime, new Date())
|
|
|
+ .in(KwpGoods::getId, ids);
|
|
|
+ kwpGoodsMapper.update(null, updateWrapper);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -246,34 +449,69 @@ public class KwpGoodsService {
|
|
|
* @return: void
|
|
|
*/
|
|
|
public void batchDelete(List<Long> ids) {
|
|
|
-
|
|
|
+ LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.in(KwpGoods::getId, ids).in(KwpGoods::getStatus, 0, 2)
|
|
|
+ .eq(KwpGoods::getEntId, LoginUserHolder.getEntId()).eq(KwpGoods::getDelFlag, Global.NO);
|
|
|
+ List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
|
|
|
+ if (!Objects.equals(ids.size(), list.size())) {
|
|
|
+ throw new BusinessException("删除操作仅针对“已下架”“草稿”状态的单据");
|
|
|
+ }
|
|
|
+ LambdaUpdateWrapper<KwpGoods> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(KwpGoods::getDelFlag, Global.YES).in(KwpGoods::getId, ids);
|
|
|
+ kwpGoodsMapper.update(null, updateWrapper);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * @desc: 导出
|
|
|
+ * @desc: 建材市场分页查询
|
|
|
* @author: yzc
|
|
|
- * @date: 2023-07-06 9:07
|
|
|
+ * @date: 2023-07-06 9:38
|
|
|
* @Param params:
|
|
|
- * @return: void
|
|
|
+ * @return: java.util.List<com.sckw.product.model.vo.res.BuildingMaterialsMarketList>
|
|
|
*/
|
|
|
- public void export(GoodsListParam params) {
|
|
|
+ public List<BuildingMaterialsMarketList> buildingMaterialsMarketList(BuildingMaterialsMarketListParam params) {
|
|
|
|
|
|
- List<GoodsListExport> list = new ArrayList<>();
|
|
|
- try {
|
|
|
- EasyExcelUtil.writeSingleExcel("商品列表信息", "sheet1", list, GoodsListExport.class);
|
|
|
- } catch (IOException e) {
|
|
|
- throw new BusinessException("导出商品列表异常", e.getMessage());
|
|
|
- }
|
|
|
+
|
|
|
+ return null;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
- * @desc: 建材市场分页查询
|
|
|
+ * @desc: 商品下拉列表
|
|
|
* @author: yzc
|
|
|
- * @date: 2023-07-06 9:38
|
|
|
+ * @date: 2023-07-06 8:45
|
|
|
* @Param params:
|
|
|
- * @return: java.util.List<com.sckw.product.model.vo.res.BuildingMaterialsMarketList>
|
|
|
+ * @return: java.util.List<com.sckw.product.model.vo.res.GoodsDropList>
|
|
|
*/
|
|
|
- public List<BuildingMaterialsMarketList> buildingMaterialsMarketList(BuildingMaterialsMarketListParam params) {
|
|
|
- return null;
|
|
|
+ public List<GoodsDropList> dropList(GoodsDropListReq params) {
|
|
|
+ LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.like(StringUtils.isNotBlank(params.getName()),KwpGoods::getName, params.getName())
|
|
|
+ .eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode())
|
|
|
+ .eq(KwpGoods::getDelFlag, Global.NO).orderByDesc(KwpGoods::getAddedTime);
|
|
|
+ List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ List<GoodsDropList> result = new ArrayList<>();
|
|
|
+ list.forEach(e->{
|
|
|
+ GoodsDropList goodsDropList = BeanUtils.copyProperties(e, GoodsDropList.class);
|
|
|
+ goodsDropList.setSupplyEnt("供应企业");
|
|
|
+ result.add(goodsDropList);
|
|
|
+ });
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc: 根据商品id获取商品信息
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-07-05 14:25
|
|
|
+ * @Param id:
|
|
|
+ * @return: com.sckw.product.model.KwpGoods
|
|
|
+ */
|
|
|
+ public KwpGoods getGoodsById(Long id) {
|
|
|
+ LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ LambdaQueryWrapper<KwpGoods> last = wrapper.eq(KwpGoods::getId, id).eq(KwpGoods::getEntId, LoginUserHolder.getEntId())
|
|
|
+ .eq(KwpGoods::getDelFlag, Global.NO).last("LIMIT 1");
|
|
|
+ return kwpGoodsMapper.selectOne(last);
|
|
|
}
|
|
|
}
|