|
|
@@ -166,6 +166,37 @@ public class KwpGoodsService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * @desc: 获取商品详情
|
|
|
+ * @author: yzc
|
|
|
+ * @date: 2023-08-15 14:28
|
|
|
+ * @Param id:
|
|
|
+ * @return: com.sckw.product.model.vo.res.GoodsDetail
|
|
|
+ */
|
|
|
+ public GoodsDetail getDetail(Long id) {
|
|
|
+ GoodsDetail detail = detail(id);
|
|
|
+ LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
+ wrapper.eq(KwpGoods::getGoodsType, detail.getGoodsType()).eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode())
|
|
|
+ .eq(KwpGoods::getDelFlag, Global.NO).ne(KwpGoods::getId, id).last("LIMIT 4");
|
|
|
+ List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ return detail;
|
|
|
+ }
|
|
|
+ List<Long> goodsIds = list.stream().map(KwpGoods::getId).toList();
|
|
|
+ Map<Long, List<KwpGoodsPriceRange>> map = kwpGoodsPriceRangeService.getByGoodsIds(goodsIds).stream()
|
|
|
+ .collect(Collectors.groupingBy(KwpGoodsPriceRange::getGoodsId));
|
|
|
+ List<RecommendGoods> recommendGoodsList = new ArrayList<>();
|
|
|
+ list.forEach(e -> {
|
|
|
+ RecommendGoods recommendGoods = BeanUtils.copyProperties(e, RecommendGoods.class);
|
|
|
+ List<KwpGoodsPriceRange> prices = map.get(recommendGoods.getId());
|
|
|
+ recommendGoods.setUnitLabel(DictEnum.getLabel(DictTypeEnum.UNIT_TYPE.getType(), recommendGoods.getUnit()))
|
|
|
+ .setPrice(CollectionUtils.isNotEmpty(prices) ? prices.get(0).getPrice() : null);
|
|
|
+ recommendGoodsList.add(recommendGoods);
|
|
|
+ });
|
|
|
+ detail.setRecommendGoodsList(recommendGoodsList);
|
|
|
+ return detail;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @desc: 获取商品详情
|
|
|
* @author: yzc
|
|
|
@@ -179,9 +210,15 @@ public class KwpGoodsService {
|
|
|
throw new BusinessException("当前商品不存在!");
|
|
|
}
|
|
|
GoodsDetail detail = BeanUtils.copyProperties(goods, GoodsDetail.class);
|
|
|
- List<EntCacheResDto> entCacheList = remoteSystemService.queryEntCacheByIds(Arrays.asList(detail.getEntId(), detail.getSupplyEntId()));
|
|
|
- Map<Long, String> entMap = entCacheList.stream().collect(Collectors.toMap(EntCacheResDto::getId, EntCacheResDto::getFirmName, (k1, k2) -> k1));
|
|
|
- detail.setEnt(entMap.get(detail.getEntId())).setSupplyEnt(entMap.get(detail.getSupplyEntId()));
|
|
|
+ Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntCacheMapByIds(Arrays.asList(detail.getEntId(), detail.getSupplyEntId()));
|
|
|
+ EntCacheResDto ent = entMap.get(detail.getEntId());
|
|
|
+ if (Objects.nonNull(ent)) {
|
|
|
+ detail.setEnt(ent.getFirmName()).setEntBusiness(ent.getBusiness()).setEntAddress(ent.getCityName());
|
|
|
+ }
|
|
|
+ EntCacheResDto supplyEnt = entMap.get(detail.getSupplyEntId());
|
|
|
+ if (Objects.nonNull(supplyEnt)) {
|
|
|
+ detail.setEntAddress(supplyEnt.getFirmName());
|
|
|
+ }
|
|
|
UserCacheResDto managerInfo = remoteSystemService.queryUserCacheById(detail.getManager());
|
|
|
if (Objects.nonNull(managerInfo)) {
|
|
|
detail.setManagerName(managerInfo.getName()).setManagerPhone(managerInfo.getPhone());
|
|
|
@@ -858,7 +895,7 @@ public class KwpGoodsService {
|
|
|
throw new BusinessException("商品不存在或已下架!");
|
|
|
}
|
|
|
BigDecimal amount = goods.getAmount();
|
|
|
- if (!param.getTrading().startsWith("1")) {
|
|
|
+ if (Objects.isNull(param.getTrading()) || !param.getTrading().startsWith("1")) {
|
|
|
return amount;
|
|
|
}
|
|
|
if (Objects.isNull(param.getProcureEntId()) || Objects.isNull(param.getSupplyEntId())) {
|