|
@@ -1,12 +1,16 @@
|
|
|
package com.sckw.product.service;
|
|
package com.sckw.product.service;
|
|
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
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.metadata.IPage;
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.google.common.collect.Lists;
|
|
import com.google.common.collect.Lists;
|
|
|
|
|
+import com.sckw.contract.api.RemoteContractService;
|
|
|
|
|
+import com.sckw.contract.api.model.vo.TradeContractGoodsDto;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
import com.sckw.core.exception.BusinessException;
|
|
import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.exception.CustomPromptException;
|
|
import com.sckw.core.exception.CustomPromptException;
|
|
@@ -17,21 +21,21 @@ import com.sckw.core.model.page.PageResult;
|
|
|
import com.sckw.core.model.vo.TableBottom;
|
|
import com.sckw.core.model.vo.TableBottom;
|
|
|
import com.sckw.core.model.vo.TableStatisticRes;
|
|
import com.sckw.core.model.vo.TableStatisticRes;
|
|
|
import com.sckw.core.model.vo.TableTop;
|
|
import com.sckw.core.model.vo.TableTop;
|
|
|
-import com.sckw.core.utils.BeanUtils;
|
|
|
|
|
-import com.sckw.core.utils.CollectionUtils;
|
|
|
|
|
-import com.sckw.core.utils.FileUtils;
|
|
|
|
|
-import com.sckw.core.utils.StringUtils;
|
|
|
|
|
|
|
+import com.sckw.core.utils.*;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.excel.utils.DateUtil;
|
|
import com.sckw.excel.utils.DateUtil;
|
|
|
import com.sckw.fleet.api.RemoteFleetService;
|
|
import com.sckw.fleet.api.RemoteFleetService;
|
|
|
import com.sckw.fleet.api.model.vo.TmsTruckAxleNumVO;
|
|
import com.sckw.fleet.api.model.vo.TmsTruckAxleNumVO;
|
|
|
|
|
+import com.sckw.order.api.dubbo.TradeOrderInfoService;
|
|
|
|
|
+import com.sckw.order.api.model.OrderSaleVo;
|
|
|
import com.sckw.payment.api.dubbo.PayCenterDubboService;
|
|
import com.sckw.payment.api.dubbo.PayCenterDubboService;
|
|
|
import com.sckw.payment.api.model.constant.ChannelEnum;
|
|
import com.sckw.payment.api.model.constant.ChannelEnum;
|
|
|
import com.sckw.payment.api.model.dto.WalletDto;
|
|
import com.sckw.payment.api.model.dto.WalletDto;
|
|
|
import com.sckw.payment.api.model.dto.common.R;
|
|
import com.sckw.payment.api.model.dto.common.R;
|
|
|
import com.sckw.product.api.model.GoodsNumStsParam;
|
|
import com.sckw.product.api.model.GoodsNumStsParam;
|
|
|
import com.sckw.product.dao.KwpGoodsMapper;
|
|
import com.sckw.product.dao.KwpGoodsMapper;
|
|
|
|
|
+import com.sckw.product.dao.KwpGoodsViewLogMapper;
|
|
|
import com.sckw.product.enums.GoodsStatusEnum;
|
|
import com.sckw.product.enums.GoodsStatusEnum;
|
|
|
import com.sckw.product.model.*;
|
|
import com.sckw.product.model.*;
|
|
|
import com.sckw.product.model.vo.req.*;
|
|
import com.sckw.product.model.vo.req.*;
|
|
@@ -45,7 +49,6 @@ import com.sckw.stream.model.UserInfo;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
import com.sckw.system.api.RemoteUserService;
|
|
import com.sckw.system.api.RemoteUserService;
|
|
|
import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
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.SysDictResDto;
|
|
|
import com.sckw.system.api.model.dto.res.UserCacheResDto;
|
|
import com.sckw.system.api.model.dto.res.UserCacheResDto;
|
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
import jakarta.servlet.http.HttpServletRequest;
|
|
@@ -54,12 +57,15 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.cloud.stream.function.StreamBridge;
|
|
import org.springframework.cloud.stream.function.StreamBridge;
|
|
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
import java.math.RoundingMode;
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -84,8 +90,15 @@ public class KwpGoodsService {
|
|
|
@DubboReference(version = "1.0.0", group = "design", check = false)
|
|
@DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
private RemoteFleetService remoteFleetService;
|
|
private RemoteFleetService remoteFleetService;
|
|
|
|
|
|
|
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
|
|
+ private TradeOrderInfoService tradeOrderInfoService;
|
|
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
|
|
+ private RemoteContractService remoteContractService;
|
|
|
|
|
+
|
|
|
|
|
|
|
|
private final KwpGoodsMapper kwpGoodsMapper;
|
|
private final KwpGoodsMapper kwpGoodsMapper;
|
|
|
|
|
+ private final KwpGoodsViewLogMapper kwpGoodsViewLogMapper;
|
|
|
|
|
+ private final KwpGoodsViewLogService kwpGoodsViewLogService;
|
|
|
private final KwpGoodsAddressService kwpGoodsAddressService;
|
|
private final KwpGoodsAddressService kwpGoodsAddressService;
|
|
|
private final KwpGoodsAttributeService kwpGoodsAttributeService;
|
|
private final KwpGoodsAttributeService kwpGoodsAttributeService;
|
|
|
private final KwpGoodsImageService kwpGoodsImageService;
|
|
private final KwpGoodsImageService kwpGoodsImageService;
|
|
@@ -93,7 +106,8 @@ public class KwpGoodsService {
|
|
|
private final KwpGoodsUnitService kwpGoodsUnitService;
|
|
private final KwpGoodsUnitService kwpGoodsUnitService;
|
|
|
private final StreamBridge streamBridge;
|
|
private final StreamBridge streamBridge;
|
|
|
private final KwpGoodsRepository kwpGoodsRepository;
|
|
private final KwpGoodsRepository kwpGoodsRepository;
|
|
|
-
|
|
|
|
|
|
|
+ private final RedisTemplate<String, Object> redisTemplate;
|
|
|
|
|
+ private final KwpSearchLogService kwpSearchLogService;
|
|
|
@Value("${goods.url.list.pc}")
|
|
@Value("${goods.url.list.pc}")
|
|
|
private String pcGoodsListUrl;
|
|
private String pcGoodsListUrl;
|
|
|
@Value("${goods.url.list.app}")
|
|
@Value("${goods.url.list.app}")
|
|
@@ -212,6 +226,88 @@ public class KwpGoodsService {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public GoodsDetailVo getDetail2(Long id, String keywords, Integer source, HttpServletRequest request) {
|
|
|
|
|
+ KwpGoods goods = kwpGoodsMapper.selectById(id);
|
|
|
|
|
+ if (Objects.isNull(goods)) {
|
|
|
|
|
+ throw new BusinessException("当前商品不存在!");
|
|
|
|
|
+ }
|
|
|
|
|
+ GoodsDetailVo detail = BeanUtils.copyProperties(goods, GoodsDetailVo.class);
|
|
|
|
|
+ GoodsEntInfo goodsEntInfo = new GoodsEntInfo();
|
|
|
|
|
+
|
|
|
|
|
+ kwpGoodsViewLogService.saveLog(id, detail.getName(), detail.getGoodsType(), keywords, source, request);
|
|
|
|
|
+
|
|
|
|
|
+ Map<Long, EntCacheResDto> entMap = remoteSystemService.queryEntCacheMapByIds(Arrays.asList(detail.getEntId(), goods.getSupplyEntId()));
|
|
|
|
|
+// EntCacheResDto ent = entMap.get(detail.getEntId());
|
|
|
|
|
+// if (Objects.nonNull(ent)) {
|
|
|
|
|
+// goodsEntInfo.setEnt(ent.getFirmName());
|
|
|
|
|
+// goodsEntInfo.setEntHead(ent.getHead());
|
|
|
|
|
+// goodsEntInfo.setEntBusiness(ent.getBusiness());
|
|
|
|
|
+// goodsEntInfo.setEntAddress(ent.getCityName());
|
|
|
|
|
+// }
|
|
|
|
|
+ EntCacheResDto supplyEnt = entMap.get(goods.getSupplyEntId());
|
|
|
|
|
+ if (Objects.nonNull(supplyEnt)) {
|
|
|
|
|
+ goodsEntInfo.setEnt(supplyEnt.getFirmName());
|
|
|
|
|
+ goodsEntInfo.setEntHead(supplyEnt.getHead());
|
|
|
|
|
+ goodsEntInfo.setEntBusiness(supplyEnt.getBusiness());
|
|
|
|
|
+ goodsEntInfo.setEntAddress(supplyEnt.getCityName());
|
|
|
|
|
+ goodsEntInfo.setContacts(supplyEnt.getContacts());
|
|
|
|
|
+ goodsEntInfo.setPhone(supplyEnt.getPhone());
|
|
|
|
|
+ }
|
|
|
|
|
+ UserCacheResDto managerInfo = remoteSystemService.queryUserCacheById(detail.getManager());
|
|
|
|
|
+ if (Objects.nonNull(managerInfo)) {
|
|
|
|
|
+ detail.setManagerName(managerInfo.getName());
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
|
|
|
|
|
+ DictTypeEnum.UNIT_TYPE.getType(),
|
|
|
|
|
+ DictTypeEnum.TAX_RATE.getType(),
|
|
|
|
|
+ DictTypeEnum.GOODS_STATUS.getType(),
|
|
|
|
|
+ DictTypeEnum.ADDRESS_TYPE.getType()));
|
|
|
|
|
+ Map<String, String> productNameMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
|
|
+ Map<String, String> unitMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
|
|
+ Map<String, String> goodsStatusMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
|
|
+ Map<String, String> addressMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(dict)) {
|
|
|
|
|
+ productNameMap = dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
|
|
|
|
|
+ unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
|
|
|
|
|
+ goodsStatusMap = dict.get(DictTypeEnum.GOODS_STATUS.getType());
|
|
|
|
|
+ addressMap = dict.get(DictTypeEnum.ADDRESS_TYPE.getType());
|
|
|
|
|
+ }
|
|
|
|
|
+ List<SysDictResDto> types = remoteSystemService.queryDictFrontAll(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), detail.getGoodsType());
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(types)) {
|
|
|
|
|
+ detail.setGoodsTypes(types.stream().map(SysDictResDto::getValue).toList())
|
|
|
|
|
+ .setGoodsTypeLabels(String.join(Global.RIGHT_SLASH, types.stream().map(SysDictResDto::getLabel).toList()));
|
|
|
|
|
+ }
|
|
|
|
|
+ detail.setGoodsTypeLabel(CollectionUtils.isNotEmpty(productNameMap) ? productNameMap.get(detail.getGoodsType()) : null)
|
|
|
|
|
+ .setUnitLabel(CollectionUtils.isNotEmpty(unitMap) ? unitMap.get(detail.getUnit()) : null)
|
|
|
|
|
+ .setStatusLabel(CollectionUtils.isNotEmpty(goodsStatusMap) ? goodsStatusMap.get(String.valueOf(detail.getStatus())) : null);
|
|
|
|
|
+ //商品图片信息
|
|
|
|
|
+ if (Objects.nonNull(goods.getThumb())) {
|
|
|
|
|
+ detail.setThumb(goods.getThumb());
|
|
|
|
|
+ }
|
|
|
|
|
+ List<KwpGoodsImage> goodsImages = kwpGoodsImageService.getByGoodsId(id);
|
|
|
|
|
+ List<GoodsImagesDetail> images = BeanUtils.copyToList(goodsImages, GoodsImagesDetail.class);
|
|
|
|
|
+ //商品价格
|
|
|
|
|
+ List<KwpGoodsPriceRange> priceRanges = kwpGoodsPriceRangeService.getByGoodsId(id);
|
|
|
|
|
+ BigDecimal price = Optional.ofNullable(priceRanges)
|
|
|
|
|
+ .filter(list -> !list.isEmpty())
|
|
|
|
|
+ .map(list -> list.get(0))
|
|
|
|
|
+ .map(KwpGoodsPriceRange::getPrice)
|
|
|
|
|
+ .orElse(null);
|
|
|
|
|
+
|
|
|
|
|
+ //商品属性信息
|
|
|
|
|
+ List<KwpGoodsAttribute> attributesList = kwpGoodsAttributeService.getByGoodsId(id);
|
|
|
|
|
+ List<GoodsAttributesDetail> attributes = BeanUtils.copyToList(attributesList, GoodsAttributesDetail.class);
|
|
|
|
|
+ //商品地址信息
|
|
|
|
|
+ KwpGoodsAddress goodsAddress = kwpGoodsAddressService.getByGoodsId(id);
|
|
|
|
|
+ AddressInfoDetail addressInfo = BeanUtils.copyProperties(goodsAddress, AddressInfoDetail.class);
|
|
|
|
|
+ if (Objects.nonNull(addressInfo)) {
|
|
|
|
|
+ addressInfo.setTypeName(CollectionUtils.isNotEmpty(addressMap) ? addressMap.get(addressInfo.getType()) : null);
|
|
|
|
|
+ }
|
|
|
|
|
+ detail.setImages(images).setPrice(price).setGoodsEntInfo(goodsEntInfo).setAttributes(attributes).setAddressInfo(addressInfo);
|
|
|
|
|
+
|
|
|
|
|
+ return detail;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @desc: 获取商品详情
|
|
* @desc: 获取商品详情
|
|
|
* @author: yzc
|
|
* @author: yzc
|
|
@@ -720,7 +816,7 @@ public class KwpGoodsService {
|
|
|
.map(priceRangeList -> priceRangeList.get(0))
|
|
.map(priceRangeList -> priceRangeList.get(0))
|
|
|
.map(KwpGoodsPriceRange::getPrice)
|
|
.map(KwpGoodsPriceRange::getPrice)
|
|
|
.orElse(null);
|
|
.orElse(null);
|
|
|
- goodsList.setPrice(price);
|
|
|
|
|
|
|
+ goodsList.setPrice(price);
|
|
|
|
|
|
|
|
result.add(goodsList);
|
|
result.add(goodsList);
|
|
|
});
|
|
});
|
|
@@ -858,6 +954,11 @@ public class KwpGoodsService {
|
|
|
public PageResult buildingMaterialsMarketList(BuildingMaterialsMarketListParam params, HttpServletRequest request) {
|
|
public PageResult buildingMaterialsMarketList(BuildingMaterialsMarketListParam params, HttpServletRequest request) {
|
|
|
Page<KwpGoods> page = new Page<>(params.getPage(), params.getPageSize());
|
|
Page<KwpGoods> page = new Page<>(params.getPage(), params.getPageSize());
|
|
|
LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ if (StrUtil.isNotBlank(params.getKeywords())) {
|
|
|
|
|
+ kwpSearchLogService.saveLog(params.getKeywords(), 1, request);
|
|
|
|
|
+ redisTemplate.opsForZSet().incrementScore(RedisConstant.HOT_KEY, params.getKeywords(), 1);
|
|
|
|
|
+ redisTemplate.expire(RedisConstant.HOT_KEY, DateTimeUtil.getTime(), TimeUnit.SECONDS);
|
|
|
|
|
+ }
|
|
|
wrapper.eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).eq(KwpGoods::getDelFlag, Global.NO);
|
|
wrapper.eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).eq(KwpGoods::getDelFlag, Global.NO);
|
|
|
if (StringUtils.isNotBlank(params.getGoodsType()) && StringUtils.isNotBlank(params.getGoodsTypeValue())) {
|
|
if (StringUtils.isNotBlank(params.getGoodsType()) && StringUtils.isNotBlank(params.getGoodsTypeValue())) {
|
|
|
List<SysDictResDto> goodsTypeList = remoteSystemService.queryDictBottom(params.getGoodsType(), params.getGoodsTypeValue());
|
|
List<SysDictResDto> goodsTypeList = remoteSystemService.queryDictBottom(params.getGoodsType(), params.getGoodsTypeValue());
|
|
@@ -878,22 +979,19 @@ public class KwpGoodsService {
|
|
|
if (StringUtils.isNotBlank(params.getKeywords())) {
|
|
if (StringUtils.isNotBlank(params.getKeywords())) {
|
|
|
List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByName(params.getKeywords());
|
|
List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByName(params.getKeywords());
|
|
|
List<Long> entIds = entList.stream().map(EntCacheResDto::getId).toList();
|
|
List<Long> entIds = entList.stream().map(EntCacheResDto::getId).toList();
|
|
|
- if (CollectionUtils.isNotEmpty(entIds)) {
|
|
|
|
|
- wrapper.and(e -> e.in(KwpGoods::getSupplyEntId, entIds).or().like(KwpGoods::getName, params.getKeywords()));
|
|
|
|
|
|
|
+ wrapper.and(kwpGoodsLambdaQueryWrapper -> kwpGoodsLambdaQueryWrapper.like(KwpGoods::getName, params.getKeywords())
|
|
|
|
|
+ .or().like(KwpGoods::getSpec, params.getKeywords())
|
|
|
|
|
+ .or(CollUtil.isNotEmpty(entIds)).in(CollUtil.isNotEmpty(entIds), KwpGoods::getSupplyEntId, entIds)
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
|
|
+ if (Objects.nonNull(params.getSign())) {//查询签约或未签约商品
|
|
|
|
|
+ List<Long> longs = tradeOrderInfoService.querySignGoods(LoginUserHolder.getEntId());
|
|
|
|
|
+ if (Objects.equals(params.getSign(), 1)) {
|
|
|
|
|
+ wrapper.in(CollUtil.isNotEmpty(longs), KwpGoods::getId, longs);
|
|
|
} else {
|
|
} else {
|
|
|
- wrapper.like(KwpGoods::getName, params.getKeywords());
|
|
|
|
|
|
|
+ wrapper.notIn(CollUtil.isNotEmpty(longs), KwpGoods::getId, longs);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
- //专场逻辑
|
|
|
|
|
- String accessSpecial = request.getHeader("Access-Special");
|
|
|
|
|
- //是否主平台
|
|
|
|
|
- boolean mainPlatform = remoteSystemService.queryMainPlatform(accessSpecial);
|
|
|
|
|
- if (!mainPlatform) {
|
|
|
|
|
- List<Long> entIds = remoteSystemService.queryEntIdsByCode(accessSpecial, String.valueOf(EntTypeEnum.SUPPLIER.getCode()));
|
|
|
|
|
- wrapper.in(KwpGoods::getEntId, entIds);
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
wrapper.last("order by RAND()");
|
|
wrapper.last("order by RAND()");
|
|
|
Page<KwpGoods> kwpGoodsPage = kwpGoodsMapper.selectPage(page, wrapper);
|
|
Page<KwpGoods> kwpGoodsPage = kwpGoodsMapper.selectPage(page, wrapper);
|
|
|
List<KwpGoods> list = kwpGoodsPage.getRecords();
|
|
List<KwpGoods> list = kwpGoodsPage.getRecords();
|
|
@@ -928,6 +1026,7 @@ public class KwpGoodsService {
|
|
|
productNameMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
productNameMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
unitMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
unitMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
}
|
|
}
|
|
|
|
|
+ Long entId = LoginUserHolder.getEntId();
|
|
|
list.forEach(e -> {
|
|
list.forEach(e -> {
|
|
|
BuildingMaterialsMarketList materials = BeanUtils.copyProperties(e, BuildingMaterialsMarketList.class);
|
|
BuildingMaterialsMarketList materials = BeanUtils.copyProperties(e, BuildingMaterialsMarketList.class);
|
|
|
KwpGoodsAddress address = addressMap.get(e.getId());
|
|
KwpGoodsAddress address = addressMap.get(e.getId());
|
|
@@ -939,6 +1038,14 @@ public class KwpGoodsService {
|
|
|
.setPrice(CollectionUtils.isEmpty(priceRanges) ? null : priceRanges.get(0).getPrice())
|
|
.setPrice(CollectionUtils.isEmpty(priceRanges) ? null : priceRanges.get(0).getPrice())
|
|
|
.setThumb(FileUtils.splice(e.getThumb()))
|
|
.setThumb(FileUtils.splice(e.getThumb()))
|
|
|
.setSupplyEnt(entMap.get(e.getSupplyEntId()));
|
|
.setSupplyEnt(entMap.get(e.getSupplyEntId()));
|
|
|
|
|
+ materials.setSignFlag(false);
|
|
|
|
|
+ if (Objects.nonNull(entId)) {
|
|
|
|
|
+ TradeContractGoodsDto tradeContractResDto = remoteContractService.queryTradeContractNew(entId, e.getId(),LocalDateTime.now());
|
|
|
|
|
+ if (Objects.nonNull(tradeContractResDto)) {
|
|
|
|
|
+ materials.setSignPrice(tradeContractResDto.getPrice());
|
|
|
|
|
+ materials.setSignFlag(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
result.add(materials);
|
|
result.add(materials);
|
|
|
});
|
|
});
|
|
|
return PageResult.build(params.getPage(), params.getPageSize(), kwpGoodsPage.getTotal(), result);
|
|
return PageResult.build(params.getPage(), params.getPageSize(), kwpGoodsPage.getTotal(), result);
|
|
@@ -1291,12 +1398,12 @@ public class KwpGoodsService {
|
|
|
return list.stream().map(KwpGoods::getId).toList();
|
|
return list.stream().map(KwpGoods::getId).toList();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public GoodsInfoResp getGoods( GoodsInfoReq req) {
|
|
|
|
|
|
|
+ public GoodsInfoResp getGoods(GoodsInfoReq req) {
|
|
|
log.info("查询商品信息,请求参数 :{}", JSON.toJSONString(req));
|
|
log.info("查询商品信息,请求参数 :{}", JSON.toJSONString(req));
|
|
|
//查询上商品信息
|
|
//查询上商品信息
|
|
|
Long entId =StringUtils.isNotBlank(req.getEntId()) ? Long.valueOf(req.getEntId()) : null;
|
|
Long entId =StringUtils.isNotBlank(req.getEntId()) ? Long.valueOf(req.getEntId()) : null;
|
|
|
List<KwpGoods> goods = kwpGoodsRepository.queryByEntIdAndGoodsName(entId, req.getGoodsName());
|
|
List<KwpGoods> goods = kwpGoodsRepository.queryByEntIdAndGoodsName(entId, req.getGoodsName());
|
|
|
- if (org.apache.commons.collections4.CollectionUtils.isEmpty( goods)){
|
|
|
|
|
|
|
+ if (org.apache.commons.collections4.CollectionUtils.isEmpty(goods)) {
|
|
|
return new GoodsInfoResp();
|
|
return new GoodsInfoResp();
|
|
|
}
|
|
}
|
|
|
//组装商品参数
|
|
//组装商品参数
|
|
@@ -1316,4 +1423,147 @@ public class KwpGoodsService {
|
|
|
goodsInfo.setPriceUnit(x.getPriceUnit());
|
|
goodsInfo.setPriceUnit(x.getPriceUnit());
|
|
|
return goodsInfo;
|
|
return goodsInfo;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ public Set<Object> hotKeys() {
|
|
|
|
|
+ return redisTemplate.opsForZSet().reverseRange(RedisConstant.HOT_KEY, 0, 9);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private List<BuildingMaterialsMarketList> tran(List<KwpGoods> list) {
|
|
|
|
|
+ List<BuildingMaterialsMarketList> result = new ArrayList<>(list.size());
|
|
|
|
|
+
|
|
|
|
|
+ List<Long> goodsIds = new ArrayList<>(list.size());
|
|
|
|
|
+ List<Long> supplyEntIds = new ArrayList<>(list.size());
|
|
|
|
|
+ list.forEach(e -> {
|
|
|
|
|
+ goodsIds.add(e.getId());
|
|
|
|
|
+ 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, 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));
|
|
|
|
|
+ Map<String, Map<String, String>> dict = remoteSystemService.queryDictByType(List.of(DictTypeEnum.PRODUCT_NAME_TYPE.getType(),
|
|
|
|
|
+ DictTypeEnum.UNIT_TYPE.getType()));
|
|
|
|
|
+ Map<String, String> productNameMap, unitMap;
|
|
|
|
|
+ if (CollectionUtils.isNotEmpty(dict)) {
|
|
|
|
|
+ productNameMap = dict.get(DictTypeEnum.PRODUCT_NAME_TYPE.getType());
|
|
|
|
|
+ unitMap = dict.get(DictTypeEnum.UNIT_TYPE.getType());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ productNameMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
|
|
+ unitMap = new HashMap<>(Global.NUMERICAL_SIXTEEN);
|
|
|
|
|
+ }
|
|
|
|
|
+ Long entId = LoginUserHolder.getEntId();
|
|
|
|
|
+
|
|
|
|
|
+ list.forEach(e -> {
|
|
|
|
|
+ BuildingMaterialsMarketList materials = BeanUtils.copyProperties(e, BuildingMaterialsMarketList.class);
|
|
|
|
|
+ KwpGoodsAddress address = addressMap.get(e.getId());
|
|
|
|
|
+ List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(e.getId());
|
|
|
|
|
+ materials.setGoodsTypeLabel(CollectionUtils.isNotEmpty(productNameMap) ? productNameMap.get(e.getGoodsType()) : null)
|
|
|
|
|
+ .setUnitLabel(CollectionUtils.isNotEmpty(unitMap) ? unitMap.get(e.getUnit()) : null)
|
|
|
|
|
+ .setAddressName(Objects.isNull(address) ? null : address.getCityName())
|
|
|
|
|
+ .setDetailAddress(Objects.isNull(address) ? null : address.getDetailAddress())
|
|
|
|
|
+ .setPrice(CollectionUtils.isEmpty(priceRanges) ? null : priceRanges.get(0).getPrice())
|
|
|
|
|
+ .setThumb(FileUtils.splice(e.getThumb()))
|
|
|
|
|
+ .setSupplyEnt(entMap.get(e.getSupplyEntId()))
|
|
|
|
|
+ ;
|
|
|
|
|
+ materials.setSignFlag(false);
|
|
|
|
|
+ if (Objects.nonNull(entId)) {
|
|
|
|
|
+ TradeContractGoodsDto tradeContractResDto = remoteContractService.queryTradeContractNew(entId, e.getId(),LocalDateTime.now());
|
|
|
|
|
+ if (Objects.nonNull(tradeContractResDto)) {
|
|
|
|
|
+ materials.setSignPrice(tradeContractResDto.getPrice());
|
|
|
|
|
+ materials.setSignFlag(true);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ result.add(materials);
|
|
|
|
|
+ });
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public List<BuildingMaterialsMarketList> hootGoods() {
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+ LocalDateTime start = now.minusDays(30);
|
|
|
|
|
+ Map<Long, BigDecimal> res = new HashMap<>();
|
|
|
|
|
+ Map<Long, OrderSaleVo> sale = new HashMap<>();
|
|
|
|
|
+ Map<Long, GoodsViewLogVo> view = new HashMap<>();
|
|
|
|
|
+ //30天销售量 60%
|
|
|
|
|
+ List<OrderSaleVo> orderSaleVos = tradeOrderInfoService.queryRecentSale(start, now);
|
|
|
|
|
+ //30天浏览量 40%
|
|
|
|
|
+ List<GoodsViewLogVo> goodsViewLogVos = kwpGoodsViewLogMapper.searchViewCount(start, now);
|
|
|
|
|
+ if (CollUtil.isNotEmpty(goodsViewLogVos)) {
|
|
|
|
|
+ view = goodsViewLogVos.stream().collect(Collectors.toMap(GoodsViewLogVo::getGoodsId, e -> e, (a, b) -> a));
|
|
|
|
|
+ }
|
|
|
|
|
+ if (CollUtil.isNotEmpty(orderSaleVos)) {
|
|
|
|
|
+ sale = orderSaleVos.stream().collect(Collectors.toMap(OrderSaleVo::getGoodsId, e -> e, (a, b) -> a));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ for (Map.Entry<Long, OrderSaleVo> one : sale.entrySet()) {
|
|
|
|
|
+ BigDecimal mul = NumberUtil.mul(one.getValue().getAmount(), new BigDecimal("0.6"));
|
|
|
|
|
+ GoodsViewLogVo goodsViewLogVo = view.get(one.getKey());
|
|
|
|
|
+ BigDecimal mul2 = new BigDecimal("0");
|
|
|
|
|
+ if (Objects.nonNull(goodsViewLogVo)) {
|
|
|
|
|
+ mul2 = NumberUtil.mul(goodsViewLogVo.getCount(), new BigDecimal("0.4"));
|
|
|
|
|
+ }
|
|
|
|
|
+ res.put(one.getKey(), NumberUtil.add(mul, mul2));
|
|
|
|
|
+ }
|
|
|
|
|
+ for (Map.Entry<Long, GoodsViewLogVo> two : view.entrySet()) {
|
|
|
|
|
+ BigDecimal bigDecimal = res.get(two.getKey());
|
|
|
|
|
+ //校验是否已经计算比重值
|
|
|
|
|
+ if (Objects.isNull(bigDecimal)) {
|
|
|
|
|
+ BigDecimal mul = NumberUtil.mul(two.getValue().getCount(), new BigDecimal("0.4"));
|
|
|
|
|
+ OrderSaleVo orderSaleVo = sale.get(two.getKey());
|
|
|
|
|
+ BigDecimal mul2 = new BigDecimal("0");
|
|
|
|
|
+ if (Objects.nonNull(orderSaleVo)) {
|
|
|
|
|
+ mul2 = NumberUtil.mul(orderSaleVo.getAmount(), new BigDecimal("0.6"));
|
|
|
|
|
+ }
|
|
|
|
|
+ res.put(two.getKey(), NumberUtil.add(mul, mul2));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ //所有的商品id
|
|
|
|
|
+ Set<Long> longs = res.keySet();
|
|
|
|
|
+ if (CollUtil.isEmpty(longs)) { //查询商品信息,按创建时间倒叙取数据
|
|
|
|
|
+ List<KwpGoods> kwpGoods = kwpGoodsMapper.selectList(new LambdaQueryWrapper<KwpGoods>()
|
|
|
|
|
+ .eq(KwpGoods::getDelFlag, 0)
|
|
|
|
|
+ .orderByDesc(KwpGoods::getCreateTime).last("limit 10")
|
|
|
|
|
+ );
|
|
|
|
|
+ if (CollectionUtils.isEmpty(kwpGoods)) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ return tran(kwpGoods);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (CollUtil.size(longs) < 10) {//不足10个,查询商品信息,补足10个
|
|
|
|
|
+ List<KwpGoods> add = kwpGoodsMapper.selectBatchIds(longs);
|
|
|
|
|
+
|
|
|
|
|
+ List<KwpGoods> kwpGoods = kwpGoodsMapper.selectList(new LambdaQueryWrapper<KwpGoods>()
|
|
|
|
|
+ .eq(KwpGoods::getDelFlag, 0).orderByDesc(KwpGoods::getCreateTime).last("limit " + (10 - CollUtil.size(longs)))
|
|
|
|
|
+ );
|
|
|
|
|
+ add.addAll(kwpGoods);
|
|
|
|
|
+ return tran(add);
|
|
|
|
|
+ }
|
|
|
|
|
+ List<KwpGoods> add = kwpGoodsMapper.selectBatchIds(CollUtil.sub(longs, 0, 10));
|
|
|
|
|
+
|
|
|
|
|
+ return tran(add);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public List<Long> selectByPara(String goodsName, List<String> goodsType, String goodsSpec) {
|
|
|
|
|
+ LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ wrapper.and(w -> w.like(StringUtils.isNotBlank(goodsName), KwpGoods::getName, goodsName)
|
|
|
|
|
+ .or()
|
|
|
|
|
+ .in(CollUtil.isNotEmpty(goodsType), KwpGoods::getGoodsType, goodsType)
|
|
|
|
|
+ .or()
|
|
|
|
|
+ .like(StringUtils.isNotBlank(goodsSpec), KwpGoods::getSpec, goodsSpec));
|
|
|
|
|
+ List<KwpGoods> list = kwpGoodsMapper.selectList(wrapper);
|
|
|
|
|
+ if (CollUtil.isEmpty(list)) {
|
|
|
|
|
+ return Collections.emptyList();
|
|
|
|
|
+ }
|
|
|
|
|
+ return list.stream().map(KwpGoods::getId).toList();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
}
|
|
}
|