|
|
@@ -25,6 +25,7 @@ import com.sckw.product.model.vo.req.*;
|
|
|
import com.sckw.product.model.vo.res.*;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
import com.sckw.system.api.model.dto.res.EntCacheResDto;
|
|
|
+import com.sckw.system.api.model.dto.res.SysAreaCacheResDto;
|
|
|
import com.sckw.system.api.model.dto.res.UserCacheResDto;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
@@ -68,6 +69,11 @@ public class KwpGoodsService {
|
|
|
Long entId = LoginUserHolder.getEntId();
|
|
|
//添加商品信息
|
|
|
KwpGoods goods = BeanUtils.copyProperties(addGoodsParam, KwpGoods.class);
|
|
|
+ if (Objects.nonNull(addGoodsParam.getAddressInfo())){
|
|
|
+ Integer cityCode = addGoodsParam.getAddressInfo().getCityCode();
|
|
|
+ SysAreaCacheResDto area = remoteSystemService.queryAreaCacheById(cityCode);
|
|
|
+ goods.setProvinceCode(area.getProvinceCode());
|
|
|
+ }
|
|
|
goods.setEntId(entId).setStatus(GoodsStatusEnum.SAVED.getCode());
|
|
|
kwpGoodsMapper.insert(goods);
|
|
|
addGoodsOtherInfo(goods.getId(), addGoodsParam);
|
|
|
@@ -88,7 +94,10 @@ public class KwpGoodsService {
|
|
|
Long entId = LoginUserHolder.getEntId();
|
|
|
//添加商品信息
|
|
|
KwpGoods goods = BeanUtils.copyProperties(addGoodsParam, KwpGoods.class);
|
|
|
- goods.setEntId(entId).setAddedTime(new Date()).setStatus(GoodsStatusEnum.PUT_ON_SHELVES.getCode());
|
|
|
+ Integer cityCode = addGoodsParam.getAddressInfo().getCityCode();
|
|
|
+ SysAreaCacheResDto area = remoteSystemService.queryAreaCacheById(cityCode);
|
|
|
+ goods.setProvinceCode(area.getProvinceCode()).setEntId(entId)
|
|
|
+ .setAddedTime(new Date()).setStatus(GoodsStatusEnum.PUT_ON_SHELVES.getCode());
|
|
|
kwpGoodsMapper.insert(goods);
|
|
|
addGoodsOtherInfo(goods.getId(), addGoodsParam);
|
|
|
}
|
|
|
@@ -104,8 +113,10 @@ public class KwpGoodsService {
|
|
|
private void addGoodsOtherInfo(Long goodsId, AddGoodsParam addGoodsParam) {
|
|
|
//添加商品地址信息
|
|
|
KwpGoodsAddress address = BeanUtils.copyProperties(addGoodsParam.getAddressInfo(), KwpGoodsAddress.class);
|
|
|
- address.setGoodsId(goodsId);
|
|
|
- kwpGoodsAddressService.insert(address);
|
|
|
+ if (Objects.nonNull(address)){
|
|
|
+ address.setGoodsId(goodsId);
|
|
|
+ kwpGoodsAddressService.insert(address);
|
|
|
+ }
|
|
|
//添加商品属性信息
|
|
|
List<GoodsAttributes> attributes = addGoodsParam.getAttributes();
|
|
|
if (CollectionUtils.isNotEmpty(attributes)) {
|
|
|
@@ -206,6 +217,11 @@ public class KwpGoodsService {
|
|
|
if (Objects.equals(param.getStatus(), GoodsStatusEnum.PUT_ON_SHELVES.getCode())) {
|
|
|
goods.setAddedTime(new Date());
|
|
|
}
|
|
|
+ if (Objects.nonNull(param.getAddressInfo())){
|
|
|
+ Integer cityCode = param.getAddressInfo().getCityCode();
|
|
|
+ SysAreaCacheResDto area = remoteSystemService.queryAreaCacheById(cityCode);
|
|
|
+ goods.setProvinceCode(area.getProvinceCode());
|
|
|
+ }
|
|
|
kwpGoodsMapper.updateById(goods);
|
|
|
updateGoodsOtherInfo(param);
|
|
|
}
|
|
|
@@ -221,9 +237,11 @@ public class KwpGoodsService {
|
|
|
Long goodsId = param.getId();
|
|
|
//更新商品地址信息
|
|
|
kwpGoodsAddressService.delByGoodsIds(Collections.singletonList(goodsId));
|
|
|
- KwpGoodsAddress address = BeanUtils.copyProperties(param.getAddressInfo(), KwpGoodsAddress.class);
|
|
|
- address.setGoodsId(goodsId);
|
|
|
- kwpGoodsAddressService.insert(address);
|
|
|
+ if (Objects.nonNull(param.getAddressInfo())) {
|
|
|
+ KwpGoodsAddress address = BeanUtils.copyProperties(param.getAddressInfo(), KwpGoodsAddress.class);
|
|
|
+ address.setGoodsId(goodsId);
|
|
|
+ kwpGoodsAddressService.insert(address);
|
|
|
+ }
|
|
|
|
|
|
//更新商品属性信息
|
|
|
kwpGoodsAttributeService.delByGoodsIds(Collections.singletonList(goodsId));
|
|
|
@@ -358,7 +376,7 @@ public class KwpGoodsService {
|
|
|
.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).getCityName() + addressMap.get(id).getDetailAddress())
|
|
|
+ .setAddress(Objects.isNull(addressMap.get(id)) ? null : addressMap.get(id).getName() + addressMap.get(id).getDetailAddress())
|
|
|
.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())
|
|
|
@@ -536,12 +554,22 @@ public class KwpGoodsService {
|
|
|
* @return: com.sckw.core.model.page.PageResult
|
|
|
*/
|
|
|
public PageResult buildingMaterialsMarketList(BuildingMaterialsMarketListParam params) {
|
|
|
+ List<Long> entIds = new ArrayList<>();
|
|
|
+ if (StringUtils.isNotBlank(params.getKeywords())) {
|
|
|
+ List<EntCacheResDto> entList = remoteSystemService.queryEntCacheByName(params.getKeywords());
|
|
|
+ if (CollectionUtils.isNotEmpty(entList)) {
|
|
|
+ entIds = entList.stream().map(EntCacheResDto::getId).toList();
|
|
|
+ }
|
|
|
+ }
|
|
|
Page<KwpGoods> page = new Page<>(params.getPage(), params.getPageSize());
|
|
|
LambdaQueryWrapper<KwpGoods> wrapper = new LambdaQueryWrapper<>();
|
|
|
- wrapper.like(StringUtils.isNotBlank(params.getKeywords()), KwpGoods::getName, params.getKeywords())
|
|
|
- .in(CollectionUtils.isNotEmpty(params.getGoodsTypes()), KwpGoods::getGoodsType, params.getGoodsTypes())
|
|
|
+ List<Long> finalEntIds = entIds;
|
|
|
+ wrapper.in(CollectionUtils.isNotEmpty(params.getGoodsTypes()), KwpGoods::getGoodsType, params.getGoodsTypes())
|
|
|
.in(CollectionUtils.isNotEmpty(params.getTradings()), KwpGoods::getTrading, params.getTradings())
|
|
|
- .eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).eq(KwpGoods::getDelFlag, Global.NO);
|
|
|
+ .in(CollectionUtils.isNotEmpty(params.getProvinceCodes()), KwpGoods::getProvinceCode, params.getProvinceCodes())
|
|
|
+ .eq(KwpGoods::getStatus, GoodsStatusEnum.PUT_ON_SHELVES.getCode()).eq(KwpGoods::getDelFlag, Global.NO)
|
|
|
+ .and(e -> e.in(CollectionUtils.isNotEmpty(finalEntIds), KwpGoods::getSupplyEntId, finalEntIds)
|
|
|
+ .or().like(StringUtils.isNotBlank(params.getKeywords()), KwpGoods::getName, params.getKeywords()));
|
|
|
Page<KwpGoods> kwpGoodsPage = kwpGoodsMapper.selectPage(page, wrapper);
|
|
|
List<KwpGoods> list = kwpGoodsPage.getRecords();
|
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
|
@@ -568,7 +596,7 @@ public class KwpGoodsService {
|
|
|
BuildingMaterialsMarketList materials = BeanUtils.copyProperties(e, BuildingMaterialsMarketList.class);
|
|
|
KwpGoodsAddress address = addressMap.get(e.getId());
|
|
|
List<KwpGoodsPriceRange> priceRanges = priceRangeMap.get(e.getId());
|
|
|
- materials.setCityName(Objects.isNull(address) ? null : address.getCityName())
|
|
|
+ materials.setAddressName(Objects.isNull(address) ? null : address.getName())
|
|
|
.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()))
|