...
|
...
|
@@ -23,10 +23,12 @@ import org.apache.commons.lang3.tuple.Pair; |
|
|
import org.elasticsearch.common.collect.Maps;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.ui.ModelMap;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
...
|
...
|
@@ -62,7 +64,8 @@ import com.yohoufo.dal.product.SaleCategoryMapper; |
|
|
import com.yohoufo.dal.product.SecondhandFlawMapper;
|
|
|
import com.yohoufo.dal.product.SecondhandImagesMapper;
|
|
|
import com.yohoufo.dal.product.SecondhandInfoMapper;
|
|
|
import com.yohoufo.dal.product.SizeAddRecordMapper;
|
|
|
import com.yohoufo.dal.product.SelfSizeMapper;
|
|
|
import com.yohoufo.dal.product.SelfSizeUidMapper;
|
|
|
import com.yohoufo.dal.product.SizeMapper;
|
|
|
import com.yohoufo.dal.product.StorageMapper;
|
|
|
import com.yohoufo.dal.product.StoragePriceMapper;
|
...
|
...
|
@@ -79,8 +82,9 @@ import com.yohoufo.dal.product.model.SaleCategory; |
|
|
import com.yohoufo.dal.product.model.SecondhandFlaw;
|
|
|
import com.yohoufo.dal.product.model.SecondhandImages;
|
|
|
import com.yohoufo.dal.product.model.SecondhandInfo;
|
|
|
import com.yohoufo.dal.product.model.SelfSize;
|
|
|
import com.yohoufo.dal.product.model.SelfSizeUid;
|
|
|
import com.yohoufo.dal.product.model.Size;
|
|
|
import com.yohoufo.dal.product.model.SizeAddRecord;
|
|
|
import com.yohoufo.dal.product.model.Storage;
|
|
|
import com.yohoufo.dal.product.model.StoragePrice;
|
|
|
import com.yohoufo.product.model.PriceTrendBO;
|
...
|
...
|
@@ -98,7 +102,6 @@ import com.yohoufo.product.response.SkupDetailForScreenResp; |
|
|
import com.yohoufo.product.response.StorageLeastPriceResp;
|
|
|
import com.yohoufo.product.service.ProductSearchService;
|
|
|
import com.yohoufo.product.service.ProductService;
|
|
|
import org.springframework.web.servlet.ModelAndView;
|
|
|
|
|
|
|
|
|
@Service
|
...
|
...
|
@@ -170,7 +173,10 @@ public class ProductServiceImpl implements ProductService { |
|
|
private ConfigReader configReader;
|
|
|
|
|
|
@Autowired
|
|
|
private SizeAddRecordMapper sizeAddRecordMapper;
|
|
|
private SelfSizeMapper selfSizeMapper;
|
|
|
|
|
|
@Autowired
|
|
|
private SelfSizeUidMapper selfSizeUidMapper;
|
|
|
|
|
|
@Override
|
|
|
public ProductDetailResp queryProductDetailById(Integer productId) {
|
...
|
...
|
@@ -214,7 +220,7 @@ public class ProductServiceImpl implements ProductService { |
|
|
productInfo.setSecondHandLeastPrice(secondHandLeastPrice);
|
|
|
}
|
|
|
goodsSizes.sort(Comparator.comparing(GoodsSize::getOrderBy));
|
|
|
List<JSONObject> otherAddSizeList = getOtherSizeList(product.getMaxSortId(), product.getMidSortId(), goodsBOList);
|
|
|
List<JSONObject> otherAddSizeList = getOtherSizeList(product.getMaxSortId(), product.getMidSortId(), goodsSizes);
|
|
|
if(!CollectionUtils.isEmpty(otherAddSizeList)) {
|
|
|
goodsBO.setCanAddSize(true);
|
|
|
goodsBO.setOtherSizeList(otherAddSizeList);
|
...
|
...
|
@@ -264,7 +270,7 @@ public class ProductServiceImpl implements ProductService { |
|
|
|
|
|
}
|
|
|
|
|
|
private List<JSONObject> getOtherSizeList(Integer maxSortId, Integer midSortId, List<GoodsBO> goodsBOList) {
|
|
|
private List<JSONObject> getOtherSizeList(Integer maxSortId, Integer midSortId, List<GoodsSize> goodsSizes) {
|
|
|
List<JSONObject> result = Lists.newArrayList();
|
|
|
if(!canAddSize(maxSortId)) {
|
|
|
return result;
|
...
|
...
|
@@ -276,12 +282,9 @@ public class ProductServiceImpl implements ProductService { |
|
|
}
|
|
|
|
|
|
List<Integer> sizeIdList = sizeList.stream().map(Size::getId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
if(!CollectionUtils.isEmpty(goodsBOList)) {
|
|
|
List<GoodsSize> goodsSizes = goodsBOList.get(0).getSizeList();
|
|
|
if(!CollectionUtils.isEmpty(goodsSizes)) {
|
|
|
List<Integer> goodsSizeIdList = goodsSizes.stream().map(GoodsSize::getSizeId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
sizeIdList.removeAll(goodsSizeIdList);
|
|
|
}
|
|
|
if(!CollectionUtils.isEmpty(goodsSizes)) {
|
|
|
List<Integer> goodsSizeIdList = goodsSizes.stream().map(GoodsSize::getSizeId).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
sizeIdList.removeAll(goodsSizeIdList);
|
|
|
}
|
|
|
|
|
|
if(CollectionUtils.isEmpty(sizeIdList)) {
|
...
|
...
|
@@ -1696,50 +1699,75 @@ public class ProductServiceImpl implements ProductService { |
|
|
throw new ServiceException(400, "goodsId不存在");
|
|
|
}
|
|
|
|
|
|
//校验sizetId
|
|
|
//校验sizeId
|
|
|
String[] sizeIdArr = sizeIds.split(",");
|
|
|
List<SizeAddRecord> needAddRecordList = Lists.newArrayList();
|
|
|
List<SizeAddRecord> needUpdateRecordList = Lists.newArrayList();
|
|
|
List<SelfSize> needAddRecordList = Lists.newArrayList();
|
|
|
List<SelfSizeUid> needRelateUidList = Lists.newArrayList();
|
|
|
|
|
|
//goodsId现对应的尺码
|
|
|
List<Storage> storageList = storageMapper.selectByGoodsId(goodsId);
|
|
|
List<Integer> existSizeIdList = storageList.stream().map(Storage::getSizeId).collect(Collectors.toList());
|
|
|
List<Size> sizeList = sizeMapper.selectByIds(existSizeIdList);
|
|
|
Map<Integer, String> sizeIdNameMap = sizeList.stream().collect(Collectors.toMap(Size::getId, Size::getSizeName));
|
|
|
List<SizeAddRecord> existRecordList = sizeAddRecordMapper.selectByProductIdAndSizeId(productId, sizeIds);
|
|
|
Map<Integer, String> dbSizeIdApplyUidMap = existRecordList.stream().collect(Collectors.toMap(SizeAddRecord::getSizeId, SizeAddRecord::getApplyUid));
|
|
|
if(MapUtils.isEmpty(dbSizeIdApplyUidMap)) {
|
|
|
dbSizeIdApplyUidMap = Maps.newHashMap();
|
|
|
List<SelfSize> existRecordList = selfSizeMapper.selectByProductIdAndSizeId(productId, sizeIds);
|
|
|
Map<Integer, SelfSize> selfSizeMap = existRecordList.stream().collect(Collectors.toMap(SelfSize::getSizeId, s->s));
|
|
|
if(MapUtils.isEmpty(selfSizeMap)) {
|
|
|
selfSizeMap = Maps.newHashMap();
|
|
|
}
|
|
|
|
|
|
//自助尺码uid关联表
|
|
|
List<SelfSizeUid> selfSizeUidList = selfSizeUidMapper.selectByProductIdAndSizeId(productId, sizeIds);
|
|
|
Map<Integer, List<SelfSizeUid>> sizeIdUidMap = selfSizeUidList.stream().collect(Collectors.groupingBy(SelfSizeUid::getSizeId));
|
|
|
|
|
|
List<String> warnSizeNameList = Lists.newArrayList();
|
|
|
for(int i=0; i<sizeIdArr.length; i++) {
|
|
|
Integer sizeId = Integer.parseInt(sizeIdArr[i]);
|
|
|
if(existSizeIdList.contains(sizeId)) {
|
|
|
throw new ServiceException(506, "尺码" + sizeIdNameMap.get(sizeId) + "已存在,不需要添加,请重新选择");
|
|
|
warnSizeNameList.add(sizeIdNameMap.get(sizeId));
|
|
|
}
|
|
|
|
|
|
SizeAddRecord record = new SizeAddRecord();
|
|
|
record.setProductId(productId);
|
|
|
record.setGoodsId(goodsId);
|
|
|
record.setSizeId(sizeId);
|
|
|
record.setCreateTime(DateUtil.getCurrentTimeSecond());
|
|
|
if(dbSizeIdApplyUidMap.keySet().contains(sizeId)) {
|
|
|
record.setApplyUid(dbSizeIdApplyUidMap.get(sizeId) + "," + applyUid);
|
|
|
record.setUpdateTime(DateUtil.getCurrentTimeSecond());
|
|
|
needUpdateRecordList.add(record);
|
|
|
if(selfSizeMap.keySet().contains(sizeId)) {
|
|
|
List<SelfSizeUid> selfSizeUids = sizeIdUidMap.get(sizeId);
|
|
|
List<Integer> uidList = Lists.newArrayList();
|
|
|
if(!CollectionUtils.isEmpty(selfSizeUids)) {
|
|
|
uidList = selfSizeUids.stream().map(SelfSizeUid::getUid).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
if(!uidList.contains(applyUid)) {
|
|
|
SelfSize selfSize = selfSizeMap.get(sizeId);
|
|
|
SelfSizeUid selfSizeUid = new SelfSizeUid();
|
|
|
BeanUtils.copyProperties(selfSize, selfSizeUid);
|
|
|
selfSizeUid.setUid(applyUid);
|
|
|
needRelateUidList.add(selfSizeUid);
|
|
|
}
|
|
|
}else {
|
|
|
record.setApplyUid(applyUid.toString());
|
|
|
SelfSize record = new SelfSize();
|
|
|
record.setProductId(productId);
|
|
|
record.setGoodsId(goodsId);
|
|
|
record.setSizeId(sizeId);
|
|
|
needAddRecordList.add(record);
|
|
|
|
|
|
SelfSizeUid selfSizeUid = new SelfSizeUid();
|
|
|
selfSizeUid.setProductId(productId);
|
|
|
selfSizeUid.setGoodsId(goodsId);
|
|
|
selfSizeUid.setSizeId(sizeId);
|
|
|
selfSizeUid.setUid(applyUid);
|
|
|
needRelateUidList.add(selfSizeUid);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
if(!CollectionUtils.isEmpty(warnSizeNameList)) {
|
|
|
throw new ServiceException(506, "你的提交的添加尺码申请中,尺码:" + String.join(",", warnSizeNameList) + "信息已存在,请刷页面重新选择");
|
|
|
}
|
|
|
|
|
|
if(!CollectionUtils.isEmpty(needAddRecordList)) {
|
|
|
//添加尺码审核记录
|
|
|
sizeAddRecordMapper.insertBatch(needAddRecordList);
|
|
|
selfSizeMapper.insertBatch(needAddRecordList);
|
|
|
}
|
|
|
|
|
|
if(!CollectionUtils.isEmpty(needUpdateRecordList)) {
|
|
|
//更新尺码审核记录
|
|
|
sizeAddRecordMapper.updateBatchApplyUid(needUpdateRecordList);
|
|
|
if(!CollectionUtils.isEmpty(needRelateUidList)) {
|
|
|
//增加尺码uid关联记录
|
|
|
selfSizeUidMapper.insertBatch(needRelateUidList);
|
|
|
}
|
|
|
|
|
|
}
|
...
|
...
|
|