Authored by caoyan

Merge branch 'dev_suggestPrice_20181119' into test6.8.2

... ... @@ -53,5 +53,8 @@ public class ChannelSkuCompareRspBo {
private String statusStr;
private Integer status;
private String channelUrl;
private String imageUrl;
}
... ...
... ... @@ -44,7 +44,7 @@
from storage
</select>
<select id="selectByGoodsId" resultMap="BaseResultMap">
select id, product_id, goods_id, size_id, storage_num, update_time, create_time
select id, product_id, goods_id, size_id, storage_num, update_time, create_time, suggest_low_price, suggest_high_price
from storage where goods_id = #{goodsId,jdbcType=INTEGER}
</select>
<select id="selectByGoodsIdList" resultMap="BaseResultMap">
... ...
... ... @@ -18,10 +18,12 @@ import com.alibaba.fastjson.JSONObject;
import com.yoho.core.common.utils.DateUtil;
import com.yoho.error.exception.ServiceException;
import com.yoho.ufo.dal.ChannelSkuCompareMapper;
import com.yoho.ufo.dal.GoodsMapper;
import com.yoho.ufo.dal.ProductMapper;
import com.yoho.ufo.dal.StorageMapper;
import com.yoho.ufo.dal.StoragePriceMapper;
import com.yoho.ufo.dal.UfoSizeMapper;
import com.yoho.ufo.dal.model.Goods;
import com.yoho.ufo.dal.model.Product;
import com.yoho.ufo.dal.model.Storage;
import com.yoho.ufo.dal.model.StoragePrice;
... ... @@ -32,6 +34,9 @@ import com.yoho.ufo.model.commoditybasicrole.size.Size;
import com.yoho.ufo.service.IBusinessExportService;
import com.yoho.ufo.service.IChannelSkuCompareService;
import com.yoho.ufo.service.model.PageResponseBO;
import com.yoho.ufo.util.CollectionUtil;
import com.yoho.ufo.util.ImagesConstant;
import com.yoho.ufo.util.ImagesHelper;
/**
* @author caoyan
... ... @@ -55,6 +60,9 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService,
@Autowired
private StoragePriceMapper storagePriceMapper;
@Autowired
private GoodsMapper goodsMapper;
@Override
public PageResponseBO<ChannelSkuCompareRspBo> queryList(ChannelSkuCompareReq req) {
... ... @@ -90,11 +98,16 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService,
List<Storage> storageList = storageMapper.selectByIds(skuList);
Map<Integer, Storage> storageMap = storageList.stream().collect(Collectors.toMap(Storage::getId, s->s));
//查询商品图片
List<Integer> goodsIdList = CollectionUtil.map(storageList, Storage::getGoodsId);
List<Goods> goodsList = goodsMapper.selectByIds(goodsIdList);
Map<Integer, String> goodsIdImageMap = goodsList.stream().collect(Collectors.toMap(Goods::getId, Goods::getColorImage));
//计算UFO当前价,可售sku最低价
List<StoragePrice> storagePriceList = storagePriceMapper.selectMinPriceByStorageIdList(skuList);
Map<Integer, BigDecimal> storageMinPriceMap = storagePriceList.stream().collect(Collectors.toMap(StoragePrice::getStorageId, StoragePrice::getPrice));
List<ChannelSkuCompareRspBo> respList = convertToResp(cscList, productMap, sizeIdNameMap, storageMap, storageMinPriceMap);
List<ChannelSkuCompareRspBo> respList = convertToResp(cscList, productMap, sizeIdNameMap, storageMap, storageMinPriceMap, goodsIdImageMap);
PageResponseBO<ChannelSkuCompareRspBo> result=new PageResponseBO<>();
result.setList(respList);
... ... @@ -183,7 +196,8 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService,
private List<ChannelSkuCompareRspBo> convertToResp(List<ChannelSkuCompare> cscList, Map<Integer, Product> productMap,
Map<Integer, String> sizeIdNameMap, Map<Integer, Storage> storageMap, Map<Integer, BigDecimal> storageMinPriceMap){
Map<Integer, String> sizeIdNameMap, Map<Integer, Storage> storageMap, Map<Integer, BigDecimal> storageMinPriceMap,
Map<Integer, String> goodsIdImageMap){
List<ChannelSkuCompareRspBo> boList = Lists.newArrayList();
for(ChannelSkuCompare csc : cscList) {
ChannelSkuCompareRspBo bo = new ChannelSkuCompareRspBo();
... ... @@ -210,6 +224,8 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService,
}
bo.setStatus(csc.getStatus());
bo.setStatusStr(bo.getStatus().intValue()==0 ? "正常" : "异常");
String imageUrl = goodsIdImageMap.get(storageMap.get(csc.getSku()).getGoodsId());
bo.setImageUrl(ImagesHelper.getImageAbsoluteUrl(imageUrl, ImagesConstant.BUCKET_GOODS_IMG));
boList.add(bo);
}
... ...
... ... @@ -18,6 +18,7 @@ import com.yohobuy.ufo.model.enums.InboxBusinessTypeEnum;
import com.yohobuy.ufo.model.request.product.ProductRequestBatchBo;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.elasticsearch.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.BeanUtils;
... ... @@ -289,6 +290,17 @@ public class ProductServiceImpl implements IProductService, ApplicationContextAw
if (CollectionUtils.isNotEmpty(storages)) {
bo.setStorageIdList(CollectionUtil.map(storages, Storage::getId));
bo.setSizeIdList(CollectionUtil.map(storages, Storage::getSizeId));
List<BigDecimal> suggestLowPriceList = CollectionUtil.map(storages, Storage::getSuggestLowPrice);
List<BigDecimal> suggestHighPriceList = CollectionUtil.map(storages, Storage::getSuggestHighPrice);
List<String> suggestPriceList = Lists.newArrayList();
for(int i=0; i<bo.getStorageIdList().size(); i++) {
String suggestPrice = "-";
if(null != suggestLowPriceList.get(i) && null != suggestHighPriceList.get(i)) {
suggestPrice = String.format("%d", suggestLowPriceList.get(i).intValue()) + " ~ " + String.format("%d", suggestHighPriceList.get(i).intValue());
}
suggestPriceList.add(suggestPrice);
}
bo.setSuggestPriceList(suggestPriceList);
}
return new ApiResponse<ProductEditResponceBo>(bo);
}
... ...
... ... @@ -369,6 +369,11 @@
field: "sku",
width: 80,
align: "center"
},{
title: "平台建议售价",
field: "suggestPrice",
width: 80,
align: "center"
}]],
cache: false,
pagination: false,
... ... @@ -489,7 +494,8 @@
colorName: colorName,
goodsName: colorName,
size: '',
sku: '-'
sku: '-',
suggestPrice: '-'
});
}
... ... @@ -526,7 +532,8 @@
colorName: colorName,
goodsName: goodsName,
size: $(item).parent().text(),
sku: '-'
sku: '-',
suggestPrice: '-'
});
});
... ... @@ -535,7 +542,8 @@
colorName: colorName,
goodsName: goodsName,
size: '',
sku: '-'
sku: '-',
suggestPrice:'-'
});
}
that.mergeCells();
... ... @@ -761,7 +769,8 @@
colorName: $('.group-color li[data-id='+that.detailData.colorId+']').text(),
goodsName: that.detailData.goodsName,
size: $('.group-size label[data-id=' + item + ']').text(),
sku: that.detailData.storageIdList[i]
sku: that.detailData.storageIdList[i],
suggestPrice: that.detailData.suggestPriceList[i]
});
}
}
... ...