|
|
@@ -30,7 +30,9 @@ import com.sckw.product.model.vo.res.*;
|
|
|
import com.sckw.redis.constant.RedisConstant;
|
|
|
import com.sckw.redis.utils.RedissonUtils;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
+import com.sckw.system.api.RemoteUserService;
|
|
|
import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
+import com.sckw.system.api.model.dto.res.KwsUserResDto;
|
|
|
import com.sckw.system.api.model.dto.res.SysDictResDto;
|
|
|
import com.sckw.system.api.model.dto.res.UserCacheResDto;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
@@ -58,6 +60,9 @@ public class KwpGoodsService {
|
|
|
@DubboReference(version = "2.0.0", group = "design", check = false)
|
|
|
private RemoteSystemService remoteSystemService;
|
|
|
|
|
|
+ @DubboReference(version = "2.0.0", group = "design", check = false)
|
|
|
+ private RemoteUserService remoteUserService;
|
|
|
+
|
|
|
@DubboReference(version = "2.0.0", group = "design", check = false)
|
|
|
private PayCenterDubboService payCenterDubboService;
|
|
|
|
|
|
@@ -77,38 +82,38 @@ public class KwpGoodsService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void addDraft(AddGoodsDraftParam param) {
|
|
|
- Long entId = LoginUserHolder.getEntId();
|
|
|
//添加商品信息
|
|
|
KwpGoods goods = BeanUtils.copyProperties(param, KwpGoods.class);
|
|
|
- if (Objects.nonNull(param.getAddressInfo())) {
|
|
|
- Integer cityCode = param.getAddressInfo().getCityCode();
|
|
|
- goods.setAreaCode(cityCode);
|
|
|
+ AddressInfo address = param.getAddressInfo();
|
|
|
+ if (Objects.nonNull(address)) {
|
|
|
+ goods.setAreaCode(address.getCityCode()).setAddressName(address.getName());
|
|
|
}
|
|
|
- goods.setEntId(entId).setStatus(GoodsStatusEnum.SAVED.getCode());
|
|
|
+ goods.setEntId(LoginUserHolder.getEntId()).setStatus(GoodsStatusEnum.SAVED.getCode());
|
|
|
kwpGoodsMapper.insert(goods);
|
|
|
- AddGoodsParam addGoodsParam = BeanUtils.copyProperties(param, AddGoodsParam.class);
|
|
|
- addGoodsOtherInfo(goods.getId(), addGoodsParam);
|
|
|
+ //添加商品其他信息
|
|
|
+ addGoodsOtherInfo(goods.getId(), BeanUtils.copyProperties(param, AddGoodsParam.class));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* @desc: 添加上架商品
|
|
|
* @author: yzc
|
|
|
* @date: 2023-07-03 9:30
|
|
|
- * @Param addGoodsParam:
|
|
|
+ * @Param param:
|
|
|
* @return: void
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public void addShelves(AddGoodsParam addGoodsParam) {
|
|
|
- if (addGoodsParam.getTrading().startsWith("1") && Objects.isNull(addGoodsParam.getAdvancePrice())) {
|
|
|
- throw new BusinessException("交易方式为预付款时,预付款最低限额不能为空!");
|
|
|
+ public void addShelves(AddGoodsParam param) {
|
|
|
+ if (Objects.equals(param.getPrepaidLimit(), 1) && Objects.isNull(param.getAdvancePrice())) {
|
|
|
+ throw new BusinessException("设置预付限额时,预付款最低限额不能为空!");
|
|
|
}
|
|
|
- Long entId = LoginUserHolder.getEntId();
|
|
|
//添加商品信息
|
|
|
- KwpGoods goods = BeanUtils.copyProperties(addGoodsParam, KwpGoods.class);
|
|
|
- Integer cityCode = addGoodsParam.getAddressInfo().getCityCode();
|
|
|
- goods.setCode(NumberUtils.createRandomVcode()).setAreaCode(cityCode).setEntId(entId).setAddedTime(new Date()).setStatus(GoodsStatusEnum.PUT_ON_SHELVES.getCode());
|
|
|
+ KwpGoods goods = BeanUtils.copyProperties(param, KwpGoods.class);
|
|
|
+ AddressInfo address = param.getAddressInfo();
|
|
|
+ goods.setCode(NumberUtils.createRandomVcode()).setAreaCode(address.getCityCode()).setAddressName(address.getName())
|
|
|
+ .setEntId(LoginUserHolder.getEntId()).setAddedTime(new Date()).setStatus(GoodsStatusEnum.PUT_ON_SHELVES.getCode());
|
|
|
kwpGoodsMapper.insert(goods);
|
|
|
- addGoodsOtherInfo(goods.getId(), addGoodsParam);
|
|
|
+ //添加商品其他信息
|
|
|
+ addGoodsOtherInfo(goods.getId(), param);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -181,7 +186,11 @@ public class KwpGoodsService {
|
|
|
if (Objects.nonNull(managerInfo)) {
|
|
|
detail.setManagerName(managerInfo.getName()).setManagerPhone(managerInfo.getPhone());
|
|
|
}
|
|
|
- detail.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), detail.getGoodsType())).setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), detail.getTrading())).setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), detail.getUnit())).setTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), detail.getTaxRate())).setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(detail.getStatus())));
|
|
|
+ detail.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), detail.getGoodsType()))
|
|
|
+ .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), detail.getUnit()))
|
|
|
+ .setTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), detail.getTaxRate()))
|
|
|
+ .setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(detail.getStatus())))
|
|
|
+ .setPrepaidLimitLabel(Objects.equals(detail.getPrepaidLimit(), 1) ? "是" : "否");
|
|
|
//商品图片信息
|
|
|
List<KwpGoodsImage> goodsImages = kwpGoodsImageService.getByGoodsId(id);
|
|
|
List<GoodsImagesDetail> images = BeanUtils.copyToList(goodsImages, GoodsImagesDetail.class);
|
|
|
@@ -216,16 +225,18 @@ public class KwpGoodsService {
|
|
|
if (Objects.isNull(goods)) {
|
|
|
throw new BusinessException("当前商品不存在!");
|
|
|
}
|
|
|
- if (Objects.equals(goods.getStatus(), GoodsStatusEnum.PUT_ON_SHELVES.getCode()) || Objects.equals(goods.getStatus(), GoodsStatusEnum.TAKE_OFF_SHELVES.getCode())) {
|
|
|
+ if (Objects.equals(goods.getStatus(), GoodsStatusEnum.PUT_ON_SHELVES.getCode()) ||
|
|
|
+ Objects.equals(goods.getStatus(), GoodsStatusEnum.TAKE_OFF_SHELVES.getCode())) {
|
|
|
judgeParameters(param);
|
|
|
- if (Objects.equals(goods.getStatus(), GoodsStatusEnum.PUT_ON_SHELVES.getCode()) && goods.getAmount().compareTo(param.getAmount()) != 0) {
|
|
|
+ if (Objects.equals(goods.getStatus(), GoodsStatusEnum.PUT_ON_SHELVES.getCode()) &&
|
|
|
+ goods.getAmount().compareTo(param.getAmount()) != 0) {
|
|
|
throw new BusinessException("上架商品不可修改库存数量!");
|
|
|
}
|
|
|
}
|
|
|
BeanUtils.copyProperties(param, goods);
|
|
|
- if (Objects.nonNull(param.getAddressInfo())) {
|
|
|
- Integer cityCode = param.getAddressInfo().getCityCode();
|
|
|
- goods.setAreaCode(cityCode);
|
|
|
+ AddressInfo address = param.getAddressInfo();
|
|
|
+ if (Objects.nonNull(address)) {
|
|
|
+ goods.setAreaCode(address.getCityCode()).setAddressName(address.getName());
|
|
|
}
|
|
|
kwpGoodsMapper.updateById(goods);
|
|
|
updateGoodsOtherInfo(param);
|
|
|
@@ -311,11 +322,11 @@ public class KwpGoodsService {
|
|
|
if (StringUtils.isBlank(param.getTaxRate())) {
|
|
|
throw new BusinessException("发票税率不能为空!");
|
|
|
}
|
|
|
- if (StringUtils.isBlank(param.getTrading())) {
|
|
|
- throw new BusinessException("交易方式不能为空!");
|
|
|
+ if (Objects.isNull(param.getPrepaidLimit())) {
|
|
|
+ throw new BusinessException("是否设置预付限额不能为空!");
|
|
|
}
|
|
|
- if (param.getTrading().startsWith("1") && Objects.isNull(param.getAdvancePrice())) {
|
|
|
- throw new BusinessException("交易方式为预付款时,预付款最低限额不能为空!");
|
|
|
+ if (Objects.equals(param.getPrepaidLimit(), 1) && Objects.isNull(param.getAdvancePrice())) {
|
|
|
+ throw new BusinessException("设置预付限额时,预付款最低限额不能为空!");
|
|
|
}
|
|
|
|
|
|
List<GoodsAttributes> attributes = param.getAttributes();
|
|
|
@@ -352,7 +363,7 @@ public class KwpGoodsService {
|
|
|
throw new BusinessException("含税价最低为零!");
|
|
|
}
|
|
|
if (Objects.isNull(e.getSort())) {
|
|
|
- throw new BusinessException("梯度顺序不能为空!");
|
|
|
+ throw new BusinessException("价格梯度顺序不能为空!");
|
|
|
}
|
|
|
});
|
|
|
AddressInfo address = param.getAddressInfo();
|
|
|
@@ -398,103 +409,18 @@ public class KwpGoodsService {
|
|
|
* @Param params:
|
|
|
* @return: java.util.List<com.sckw.product.model.vo.res.GoodsList>
|
|
|
*/
|
|
|
- public PageResult select(SelectGoodsListParam params, Boolean isPage) {
|
|
|
- IPage<KwpGoods> goodsIpage = getGoodsLists(params, isPage);
|
|
|
- List<KwpGoods> goodsLists = goodsIpage.getRecords();
|
|
|
- if (CollectionUtils.isEmpty(goodsLists)) {
|
|
|
+ public PageResult select(SelectGoodsListParam params) {
|
|
|
+ LambdaQueryWrapper<KwpGoods> wrapper = buildWrapper(BeanUtils.copyProperties(params, ExportStatisticGoodsListParam.class));
|
|
|
+ Page<KwpGoods> page = new Page<>(params.getPage(), params.getPageSize());
|
|
|
+ IPage<KwpGoods> goodsIpage = kwpGoodsMapper.selectPage(page, wrapper);
|
|
|
+ List<KwpGoods> list = goodsIpage.getRecords();
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
return PageResult.build(params.getPage(), params.getPageSize(), goodsIpage.getTotal(), Collections.emptyList());
|
|
|
}
|
|
|
- List<GoodsList> result = new ArrayList<>(goodsLists.size());
|
|
|
- List<Long> goodsIds = new ArrayList<>(goodsLists.size());
|
|
|
- List<Long> supplyEntIds = new ArrayList<>(goodsLists.size());
|
|
|
- List<Long> userIds = new ArrayList<>();
|
|
|
- goodsLists.forEach(e -> {
|
|
|
- goodsIds.add(e.getId());
|
|
|
- if (Objects.nonNull(e.getSupplyEntId())) {
|
|
|
- supplyEntIds.add(e.getSupplyEntId());
|
|
|
- }
|
|
|
- if (Objects.nonNull(e.getManager())) {
|
|
|
- userIds.add(e.getManager());
|
|
|
- }
|
|
|
- if (Objects.nonNull(e.getCreateBy())) {
|
|
|
- userIds.add(e.getCreateBy());
|
|
|
- }
|
|
|
- });
|
|
|
- //地址信息
|
|
|
- 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));
|
|
|
- //用户信息
|
|
|
- List<UserCacheResDto> userList = remoteSystemService.queryUserCacheByIds(userIds);
|
|
|
- Map<Long, UserCacheResDto> userMap = userList.stream().collect(Collectors.toMap(UserCacheResDto::getId, e -> e, (k1, k2) -> k1));
|
|
|
- //供应企业信息
|
|
|
- List<EntCacheResDto> entList = new ArrayList<>();
|
|
|
- if (CollectionUtils.isNotEmpty(supplyEntIds)) {
|
|
|
- entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
|
|
|
- }
|
|
|
- Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
|
|
|
- goodsLists.forEach(e -> {
|
|
|
- Long id = e.getId();
|
|
|
- GoodsList goodsList = BeanUtils.copyProperties(e, GoodsList.class);
|
|
|
- UserCacheResDto manager = userMap.get(e.getManager());
|
|
|
- UserCacheResDto createUser = userMap.get(e.getCreateBy());
|
|
|
- goodsList.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(goodsList.getStatus()))).setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), goodsList.getGoodsType())).setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), goodsList.getUnit())).setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), goodsList.getTrading())).setTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), goodsList.getTaxRate())).setManageName(Objects.nonNull(manager) ? manager.getName() : null).setPhone(Objects.nonNull(manager) ? manager.getPhone() : null).setSupplyEnt(Objects.nonNull(entMap.get(e.getSupplyEntId())) ? entMap.get(e.getSupplyEntId()) : null).setAddress(Objects.isNull(addressMap.get(id)) ? null : addressMap.get(id).getName()).setCreateByName(Objects.nonNull(createUser) ? createUser.getName() : null);
|
|
|
- List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(id);
|
|
|
- goodsList.setHighestPrice(CollectionUtils.isEmpty(priceRanges) ? null : priceRanges.get(priceRanges.size() - 1).getPrice()).setLowestPrice(CollectionUtils.isEmpty(priceRanges) ? null : priceRanges.get(0).getPrice());
|
|
|
- result.add(goodsList);
|
|
|
- });
|
|
|
+ List<GoodsList> result = buildGoodLists(list);
|
|
|
return PageResult.build(params.getPage(), params.getPageSize(), goodsIpage.getTotal(), result);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @desc: 商品表格列表查询
|
|
|
- * @author: yzc
|
|
|
- * @date: 2023-07-07 9:09
|
|
|
- * @Param params:
|
|
|
- * @return: java.util.List<com.sckw.product.model.KwpGoods>
|
|
|
- */
|
|
|
- private IPage<KwpGoods> getGoodsLists(SelectGoodsListParam params, Boolean isPage) {
|
|
|
- LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
- if (StringUtils.isNotBlank(params.getIds())) {
|
|
|
- List<Long> ids = StringUtils.splitStrToList(params.getIds(), ",", Long.class);
|
|
|
- wrapper.in(KwpGoods::getId, ids);
|
|
|
- } else {
|
|
|
- if (Objects.nonNull(params.getEndCreateTime())) {
|
|
|
- wrapper.le(KwpGoods::getCreateTime, DateUtil.offsetDay(params.getEndCreateTime(), 1));
|
|
|
- }
|
|
|
- wrapper.ge(Objects.nonNull(params.getStartCreateTime()), KwpGoods::getCreateTime, params.getStartCreateTime()).eq(StringUtils.isNotBlank(params.getTrading()), KwpGoods::getTrading, params.getTrading()).eq(Objects.nonNull(params.getStatus()) && isPage, KwpGoods::getStatus, params.getStatus());
|
|
|
- if (StringUtils.isNotBlank(params.getGoodsType()) && StringUtils.isNotBlank(params.getGoodsTypeValue())) {
|
|
|
- List<SysDictResDto> goodsTypeList = remoteSystemService.queryDictBottom(params.getGoodsType(), params.getGoodsTypeValue());
|
|
|
- if (CollectionUtils.isNotEmpty(goodsTypeList)) {
|
|
|
- List<String> goodsTypes = goodsTypeList.stream().map(SysDictResDto::getValue).toList();
|
|
|
- wrapper.in(KwpGoods::getGoodsType, goodsTypes);
|
|
|
- }
|
|
|
- }
|
|
|
- if (StringUtils.isNotBlank(params.getKeywords())) {
|
|
|
- //目前只模糊匹配商品名称
|
|
|
-// List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByName(params.getKeywords());
|
|
|
-// List<Long> entIds = entList.stream().map(EntCacheResDto::getId).toList();
|
|
|
-// if (CollectionUtils.isEmpty(entIds)) {
|
|
|
-// wrapper.like(KwpGoods::getName, params.getKeywords());
|
|
|
-// } else {
|
|
|
-// wrapper.and(e -> e.in(KwpGoods::getSupplyEntId, entIds).or().like(KwpGoods::getName, params.getKeywords()));
|
|
|
-// }
|
|
|
- wrapper.like(KwpGoods::getName, params.getKeywords());
|
|
|
- }
|
|
|
- }
|
|
|
- wrapper.eq(KwpGoods::getEntId, LoginUserHolder.getEntId()).eq(KwpGoods::getDelFlag, Global.NO).orderByDesc(KwpGoods::getCreateTime);
|
|
|
- IPage<KwpGoods> goodsIpage = new Page<>();
|
|
|
- if (isPage) {
|
|
|
- Page<KwpGoods> page = new Page<>(params.getPage(), params.getPageSize());
|
|
|
- goodsIpage = kwpGoodsMapper.selectPage(page, wrapper);
|
|
|
- } else {
|
|
|
- List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
|
|
|
- goodsIpage.setRecords(list);
|
|
|
- }
|
|
|
- return goodsIpage;
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
/**
|
|
|
* @desc: 统计查询
|
|
|
* @author: yzc
|
|
|
@@ -502,9 +428,10 @@ public class KwpGoodsService {
|
|
|
* @Param params:
|
|
|
* @return: com.sckw.core.model.vo.TableStatisticRes
|
|
|
*/
|
|
|
- public TableStatisticRes statistic(GoodsListParam params) {
|
|
|
+ public TableStatisticRes statistic(StatisticGoodsListParam params) {
|
|
|
TableStatisticRes res = new TableStatisticRes();
|
|
|
- List<KwpGoods> goodsList = getGoodsLists(BeanUtils.copyProperties(params, SelectGoodsListParam.class), false).getRecords();
|
|
|
+ LambdaQueryWrapper<KwpGoods> wrapper = buildWrapper(BeanUtils.copyProperties(params, ExportStatisticGoodsListParam.class));
|
|
|
+ List<KwpGoods> goodsList = kwpGoodsMapper.selectList(wrapper);
|
|
|
Map<Integer, List<KwpGoods>> map = goodsList.stream().collect(Collectors.groupingBy(KwpGoods::getStatus));
|
|
|
List<TableTop> tableTops = new ArrayList<>();
|
|
|
TableTop all = new TableTop();
|
|
|
@@ -530,13 +457,14 @@ public class KwpGoodsService {
|
|
|
* @Param params:
|
|
|
* @return: void
|
|
|
*/
|
|
|
- public List<GoodsListExport> export(ExportGoodsListParam params) {
|
|
|
- PageResult pageResult = select(BeanUtils.copyProperties(params, SelectGoodsListParam.class), false);
|
|
|
- List<GoodsList> goodsLists = pageResult.getList();
|
|
|
+ public List<GoodsListExport> export(ExportStatisticGoodsListParam params) {
|
|
|
+ LambdaQueryWrapper<KwpGoods> wrapper = buildWrapper(params);
|
|
|
+ List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
|
|
|
+ List<GoodsList> goodsLists = buildGoodLists(list);
|
|
|
if (CollectionUtils.isEmpty(goodsLists)) {
|
|
|
return Collections.emptyList();
|
|
|
}
|
|
|
- List<GoodsListExport> list = new ArrayList<>();
|
|
|
+ List<GoodsListExport> result = new ArrayList<>();
|
|
|
AtomicInteger i = new AtomicInteger(1);
|
|
|
goodsLists.forEach(e -> {
|
|
|
GoodsListExport export = BeanUtils.copyProperties(e, GoodsListExport.class);
|
|
|
@@ -547,10 +475,116 @@ public class KwpGoodsService {
|
|
|
.setAddedTime(Objects.isNull(e.getAddedTime()) ? null : DateUtil.getDateTime(e.getAddedTime()))
|
|
|
.setShelfTime(Objects.isNull(e.getShelfTime()) ? null : DateUtil.getDateTime(e.getShelfTime()))
|
|
|
.setCreateTime(Objects.isNull(e.getCreateTime()) ? null : DateUtil.getDateTime(e.getCreateTime()));
|
|
|
- list.add(export);
|
|
|
+ result.add(export);
|
|
|
});
|
|
|
- return list;
|
|
|
+ return result;
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * @desc: 构建查询条件
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-08-10 15:36
|
|
|
+ * @Param params:
|
|
|
+ * @return: com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper<com.sckw.product.model.KwpGoods>
|
|
|
+ */
|
|
|
+ private LambdaQueryWrapper<KwpGoods> buildWrapper(ExportStatisticGoodsListParam params) {
|
|
|
+ LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ if (StringUtils.isNotBlank(params.getIds())) {
|
|
|
+ List<Long> ids = StringUtils.splitStrToList(params.getIds(), ",", Long.class);
|
|
|
+ wrapper.in(KwpGoods::getId, ids);
|
|
|
+ } else {
|
|
|
+ if (Objects.nonNull(params.getEndCreateTime())) {
|
|
|
+ wrapper.ge(KwpGoods::getCreateTime, params.getStartCreateTime());
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(params.getEndCreateTime())) {
|
|
|
+ wrapper.le(KwpGoods::getCreateTime, params.getEndCreateTime());
|
|
|
+ }
|
|
|
+ wrapper.eq(Objects.nonNull(params.getSupplyEntId()), KwpGoods::getSupplyEntId, params.getSupplyEntId())
|
|
|
+ .eq(Objects.nonNull(params.getPrepaidLimit()), KwpGoods::getPrepaidLimit, params.getPrepaidLimit())
|
|
|
+ .eq(Objects.nonNull(params.getStatus()), KwpGoods::getStatus, params.getStatus());
|
|
|
+ if (StringUtils.isNotBlank(params.getGoodsType()) && StringUtils.isNotBlank(params.getGoodsTypeValue())) {
|
|
|
+ List<SysDictResDto> goodsTypeList = remoteSystemService.queryDictBottom(params.getGoodsType(), params.getGoodsTypeValue());
|
|
|
+ if (CollectionUtils.isNotEmpty(goodsTypeList)) {
|
|
|
+ List<String> goodsTypes = goodsTypeList.stream().map(SysDictResDto::getValue).toList();
|
|
|
+ wrapper.in(KwpGoods::getGoodsType, goodsTypes);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String keywords = params.getKeywords();
|
|
|
+ if (StringUtils.isNotBlank(keywords)) {
|
|
|
+ //模糊匹配商品名称、仓储地址、客户经理
|
|
|
+ List<KwsUserResDto> managers = remoteUserService.getUserByName(keywords);
|
|
|
+ if (CollectionUtils.isEmpty(managers)) {
|
|
|
+ wrapper.and(e -> e.like(KwpGoods::getName, keywords).or().like(KwpGoods::getAddressName, keywords));
|
|
|
+ } else {
|
|
|
+ List<Long> managerIds = managers.stream().map(KwsUserResDto::getId).toList();
|
|
|
+ wrapper.and(e -> e.like(KwpGoods::getName, keywords).or().like(KwpGoods::getAddressName, keywords)
|
|
|
+ .or().in(KwpGoods::getManager, managerIds));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ wrapper.eq(KwpGoods::getEntId, LoginUserHolder.getEntId()).eq(KwpGoods::getDelFlag, Global.NO).orderByDesc(KwpGoods::getCreateTime);
|
|
|
+ return wrapper;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @desc: 构建商品列表
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-08-10 15:35
|
|
|
+ * @Param list:
|
|
|
+ * @return: java.util.List<com.sckw.product.model.vo.res.GoodsList>
|
|
|
+ */
|
|
|
+ private List<GoodsList> buildGoodLists(List<KwpGoods> list) {
|
|
|
+ List<GoodsList> result = new ArrayList<>(list.size());
|
|
|
+ List<Long> goodsIds = new ArrayList<>(list.size());
|
|
|
+ List<Long> supplyEntIds = new ArrayList<>(list.size());
|
|
|
+ List<Long> userIds = new ArrayList<>();
|
|
|
+ list.forEach(e -> {
|
|
|
+ goodsIds.add(e.getId());
|
|
|
+ if (Objects.nonNull(e.getSupplyEntId())) {
|
|
|
+ supplyEntIds.add(e.getSupplyEntId());
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(e.getManager())) {
|
|
|
+ userIds.add(e.getManager());
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(e.getCreateBy())) {
|
|
|
+ userIds.add(e.getCreateBy());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ //地址信息
|
|
|
+ Map<Long, String> addressMap = kwpGoodsAddressService.getByGoodsIds(goodsIds).stream()
|
|
|
+ .collect(Collectors.toMap(KwpGoodsAddress::getGoodsId, KwpGoodsAddress::getName, (k1, k2) -> k1));
|
|
|
+ //价格梯度信息
|
|
|
+ Map<Long, List<KwpGoodsPriceRange>> priceRangeMap = kwpGoodsPriceRangeService.getByGoodsIds(goodsIds).stream()
|
|
|
+ .collect(Collectors.groupingBy(KwpGoodsPriceRange::getGoodsId));
|
|
|
+ //用户信息
|
|
|
+ Map<Long, UserCacheResDto> userMap = remoteSystemService.queryUserCacheMapByIds(userIds);
|
|
|
+ //供应企业信息
|
|
|
+ List<EntCacheResDto> entList = new ArrayList<>();
|
|
|
+ if (CollectionUtils.isNotEmpty(supplyEntIds)) {
|
|
|
+ entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
|
|
|
+ }
|
|
|
+ Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
|
|
|
+ list.forEach(e -> {
|
|
|
+ Long id = e.getId();
|
|
|
+ GoodsList goodsList = BeanUtils.copyProperties(e, GoodsList.class);
|
|
|
+ UserCacheResDto manager = userMap.get(e.getManager());
|
|
|
+ UserCacheResDto createUser = userMap.get(e.getCreateBy());
|
|
|
+ goodsList.setStatusLabel(DictEnum.getLabel(DictTypeEnum.GOODS_STATUS.getType(), String.valueOf(goodsList.getStatus())))
|
|
|
+ .setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), goodsList.getGoodsType()))
|
|
|
+ .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), goodsList.getUnit()))
|
|
|
+ .setTaxRateLabel(DictEnum.getLabel(DictTypeEnum.TAX_RATE.getType(), goodsList.getTaxRate()))
|
|
|
+ .setPrepaidLimitLabel(Objects.equals(e.getPrepaidLimit(), 1) ? "是" : "否")
|
|
|
+ .setAddress(addressMap.get(id)).setSupplyEnt(entMap.get(e.getSupplyEntId()))
|
|
|
+ .setManageName(Objects.nonNull(manager) ? manager.getName() : null)
|
|
|
+ .setPhone(Objects.nonNull(manager) ? manager.getPhone() : null)
|
|
|
+ .setCreateByName(Objects.nonNull(createUser) ? createUser.getName() : null);
|
|
|
+ List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(id);
|
|
|
+ if (CollectionUtils.isNotEmpty(priceRanges)) {
|
|
|
+ goodsList.setHighestPrice(priceRanges.get(priceRanges.size() - 1).getPrice()).setLowestPrice(priceRanges.get(0).getPrice());
|
|
|
+ }
|
|
|
+ result.add(goodsList);
|
|
|
+ });
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -613,7 +647,8 @@ public class KwpGoodsService {
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
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);
|
|
|
+ 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("删除操作仅针对“已下架”“草稿”状态的单据");
|
|
|
@@ -639,6 +674,7 @@ public class KwpGoodsService {
|
|
|
public PageResult buildingMaterialsMarketList(BuildingMaterialsMarketListParam params) {
|
|
|
Page<KwpGoods> page = new Page<>(params.getPage(), params.getPageSize());
|
|
|
LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).eq(KwpGoods::getDelFlag, Global.NO);
|
|
|
if (StringUtils.isNotBlank(params.getGoodsType()) && StringUtils.isNotBlank(params.getGoodsTypeValue())) {
|
|
|
List<SysDictResDto> goodsTypeList = remoteSystemService.queryDictBottom(params.getGoodsType(), params.getGoodsTypeValue());
|
|
|
if (CollectionUtils.isNotEmpty(goodsTypeList)) {
|
|
|
@@ -646,7 +682,6 @@ public class KwpGoodsService {
|
|
|
wrapper.in(KwpGoods::getGoodsType, goodsTypes);
|
|
|
}
|
|
|
}
|
|
|
- wrapper.in(CollectionUtils.isNotEmpty(params.getTradings()), KwpGoods::getTrading, params.getTradings()).eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).eq(KwpGoods::getDelFlag, Global.NO);
|
|
|
if (Objects.nonNull(params.getAreaCode()) && Objects.nonNull(params.getAreaLevel())) {
|
|
|
switch (params.getAreaLevel()) {
|
|
|
case 1 ->
|
|
|
@@ -665,7 +700,6 @@ public class KwpGoodsService {
|
|
|
wrapper.like(KwpGoods::getName, params.getKeywords());
|
|
|
}
|
|
|
}
|
|
|
- wrapper.orderByDesc(KwpGoods::getCreateTime);
|
|
|
Page<KwpGoods> kwpGoodsPage = kwpGoodsMapper.selectPage(page, wrapper);
|
|
|
List<KwpGoods> list = kwpGoodsPage.getRecords();
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
@@ -676,12 +710,16 @@ public class KwpGoodsService {
|
|
|
List<Long> supplyEntIds = new ArrayList<>(list.size());
|
|
|
list.forEach(e -> {
|
|
|
goodsIds.add(e.getId());
|
|
|
- supplyEntIds.add(e.getSupplyEntId());
|
|
|
+ if (Objects.nonNull(e.getSupplyEntId())) {
|
|
|
+ supplyEntIds.add(e.getSupplyEntId());
|
|
|
+ }
|
|
|
});
|
|
|
//地址信息
|
|
|
- Map<Long, KwpGoodsAddress> addressMap = kwpGoodsAddressService.getByGoodsIds(goodsIds).stream().collect(Collectors.toMap(KwpGoodsAddress::getGoodsId, e -> e, (k1, k2) -> k1));
|
|
|
+ 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));
|
|
|
+ Map<Long, List<KwpGoodsPriceRange>> priceRangeMap = kwpGoodsPriceRangeService.getByGoodsIds(goodsIds).stream()
|
|
|
+ .collect(Collectors.groupingBy(KwpGoodsPriceRange::getGoodsId));
|
|
|
//供应企业信息
|
|
|
List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByIds(supplyEntIds);
|
|
|
Map<Long, String> entMap = entList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
|
|
|
@@ -690,7 +728,12 @@ public class KwpGoodsService {
|
|
|
BuildingMaterialsMarketList materials = BeanUtils.copyProperties(e, BuildingMaterialsMarketList.class);
|
|
|
KwpGoodsAddress address = addressMap.get(e.getId());
|
|
|
List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(e.getId());
|
|
|
- materials.setAddressName(Objects.isNull(address) ? null : address.getCityName()).setDetailAddress(Objects.isNull(address) ? null : address.getDetailAddress()).setPrice(CollectionUtils.isEmpty(priceRanges) ? null : priceRanges.get(0).getPrice()).setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType())).setTradingLabel(DictEnum.getLabel(DictTypeEnum.TRADE_TYPE.getType(), e.getTrading())).setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), e.getUnit())).setSupplyEnt(entMap.get(e.getSupplyEntId()));
|
|
|
+ materials.setGoodsTypeLabel(DictEnum.getLabel(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), e.getGoodsType()))
|
|
|
+ .setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), e.getUnit()))
|
|
|
+ .setAddressName(Objects.isNull(address) ? null : address.getCityName())
|
|
|
+ .setDetailAddress(Objects.isNull(address) ? null : address.getDetailAddress())
|
|
|
+ .setPrice(CollectionUtils.isEmpty(priceRanges) ? null : priceRanges.get(0).getPrice())
|
|
|
+ .setSupplyEnt(entMap.get(e.getSupplyEntId()));
|
|
|
result.add(materials);
|
|
|
});
|
|
|
return PageResult.build(params.getPage(), params.getPageSize(), kwpGoodsPage.getTotal(), result);
|
|
|
@@ -712,7 +755,9 @@ public class KwpGoodsService {
|
|
|
}
|
|
|
wrapper.eq(KwpGoods::getSupplyEntId, params.getSupplyEntId());
|
|
|
}
|
|
|
- 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);
|
|
|
+ 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();
|
|
|
@@ -738,7 +783,8 @@ public class KwpGoodsService {
|
|
|
*/
|
|
|
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");
|
|
|
+ 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);
|
|
|
}
|
|
|
|
|
|
@@ -799,13 +845,14 @@ public class KwpGoodsService {
|
|
|
*/
|
|
|
public BigDecimal maxPurchaseNum(MaxPurchaseNumParam param) {
|
|
|
LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
- LambdaQueryWrapper<KwpGoods> last = wrapper.eq(KwpGoods::getId, param.getGoodsId()).eq(KwpGoods::getDelFlag, Global.NO).eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).last("LIMIT 1");
|
|
|
+ LambdaQueryWrapper<KwpGoods> last = wrapper.eq(KwpGoods::getId, param.getGoodsId()).eq(KwpGoods::getDelFlag, Global.NO)
|
|
|
+ .eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).last("LIMIT 1");
|
|
|
KwpGoods goods = kwpGoodsMapper.selectOne(last);
|
|
|
if (Objects.isNull(goods)) {
|
|
|
throw new BusinessException("商品不存在或已下架!");
|
|
|
}
|
|
|
BigDecimal amount = goods.getAmount();
|
|
|
- if (!goods.getTrading().startsWith("1")) {
|
|
|
+ if (!param.getTrading().startsWith("1")) {
|
|
|
return amount;
|
|
|
}
|
|
|
if (Objects.isNull(param.getProcureEntId()) || Objects.isNull(param.getSupplyEntId())) {
|
|
|
@@ -823,7 +870,7 @@ public class KwpGoodsService {
|
|
|
log.error("供应单位:{}找不到对应一级企业信息", param.getSupplyEntId());
|
|
|
throw new BusinessException("供应单位一级企业信息不存在!");
|
|
|
}
|
|
|
- R<List<WalletDto>> wallet = payCenterDubboService.wallet(procure.getId(), ChannelEnum.getByCode(goods.getTrading()), supply.getId());
|
|
|
+ R<List<WalletDto>> wallet = payCenterDubboService.wallet(procure.getId(), ChannelEnum.getByCode(param.getTrading()), supply.getId());
|
|
|
if (Objects.isNull(wallet) || Objects.equals(wallet.getCode(), 0)) {
|
|
|
throw new BusinessException("校验预付钱包异常,请联系管理员!");
|
|
|
}
|