Authored by caoyan

UFO比价

@@ -53,5 +53,8 @@ public class ChannelSkuCompareRspBo { @@ -53,5 +53,8 @@ public class ChannelSkuCompareRspBo {
53 private String statusStr; 53 private String statusStr;
54 54
55 private Integer status; 55 private Integer status;
  56 +
56 private String channelUrl; 57 private String channelUrl;
  58 +
  59 + private String imageUrl;
57 } 60 }
@@ -18,7 +18,7 @@ @@ -18,7 +18,7 @@
18 <properties> 18 <properties>
19 <project-name>ufo-platform</project-name> 19 <project-name>ufo-platform</project-name>
20 <spring.version>4.3.8.RELEASE</spring.version> 20 <spring.version>4.3.8.RELEASE</spring.version>
21 - <ufo.model.version>1.0-SNAPSHOT</ufo.model.version> 21 + <ufo.model.version>2.0-SNAPSHOT</ufo.model.version>
22 <inboxclient.version>1.0.0-SNAPSHOT</inboxclient.version> 22 <inboxclient.version>1.0.0-SNAPSHOT</inboxclient.version>
23 </properties> 23 </properties>
24 24
@@ -18,10 +18,12 @@ import com.alibaba.fastjson.JSONObject; @@ -18,10 +18,12 @@ import com.alibaba.fastjson.JSONObject;
18 import com.yoho.core.common.utils.DateUtil; 18 import com.yoho.core.common.utils.DateUtil;
19 import com.yoho.error.exception.ServiceException; 19 import com.yoho.error.exception.ServiceException;
20 import com.yoho.ufo.dal.ChannelSkuCompareMapper; 20 import com.yoho.ufo.dal.ChannelSkuCompareMapper;
  21 +import com.yoho.ufo.dal.GoodsMapper;
21 import com.yoho.ufo.dal.ProductMapper; 22 import com.yoho.ufo.dal.ProductMapper;
22 import com.yoho.ufo.dal.StorageMapper; 23 import com.yoho.ufo.dal.StorageMapper;
23 import com.yoho.ufo.dal.StoragePriceMapper; 24 import com.yoho.ufo.dal.StoragePriceMapper;
24 import com.yoho.ufo.dal.UfoSizeMapper; 25 import com.yoho.ufo.dal.UfoSizeMapper;
  26 +import com.yoho.ufo.dal.model.Goods;
25 import com.yoho.ufo.dal.model.Product; 27 import com.yoho.ufo.dal.model.Product;
26 import com.yoho.ufo.dal.model.Storage; 28 import com.yoho.ufo.dal.model.Storage;
27 import com.yoho.ufo.dal.model.StoragePrice; 29 import com.yoho.ufo.dal.model.StoragePrice;
@@ -32,6 +34,9 @@ import com.yoho.ufo.model.commoditybasicrole.size.Size; @@ -32,6 +34,9 @@ import com.yoho.ufo.model.commoditybasicrole.size.Size;
32 import com.yoho.ufo.service.IBusinessExportService; 34 import com.yoho.ufo.service.IBusinessExportService;
33 import com.yoho.ufo.service.IChannelSkuCompareService; 35 import com.yoho.ufo.service.IChannelSkuCompareService;
34 import com.yoho.ufo.service.model.PageResponseBO; 36 import com.yoho.ufo.service.model.PageResponseBO;
  37 +import com.yoho.ufo.util.CollectionUtil;
  38 +import com.yoho.ufo.util.ImagesConstant;
  39 +import com.yoho.ufo.util.ImagesHelper;
35 40
36 /** 41 /**
37 * @author caoyan 42 * @author caoyan
@@ -55,6 +60,9 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService, @@ -55,6 +60,9 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService,
55 60
56 @Autowired 61 @Autowired
57 private StoragePriceMapper storagePriceMapper; 62 private StoragePriceMapper storagePriceMapper;
  63 +
  64 + @Autowired
  65 + private GoodsMapper goodsMapper;
58 66
59 @Override 67 @Override
60 public PageResponseBO<ChannelSkuCompareRspBo> queryList(ChannelSkuCompareReq req) { 68 public PageResponseBO<ChannelSkuCompareRspBo> queryList(ChannelSkuCompareReq req) {
@@ -90,11 +98,16 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService, @@ -90,11 +98,16 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService,
90 List<Storage> storageList = storageMapper.selectByIds(skuList); 98 List<Storage> storageList = storageMapper.selectByIds(skuList);
91 Map<Integer, Storage> storageMap = storageList.stream().collect(Collectors.toMap(Storage::getId, s->s)); 99 Map<Integer, Storage> storageMap = storageList.stream().collect(Collectors.toMap(Storage::getId, s->s));
92 100
  101 + //查询商品图片
  102 + List<Integer> goodsIdList = CollectionUtil.map(storageList, Storage::getGoodsId);
  103 + List<Goods> goodsList = goodsMapper.selectByIds(goodsIdList);
  104 + Map<Integer, String> goodsIdImageMap = goodsList.stream().collect(Collectors.toMap(Goods::getId, Goods::getColorImage));
  105 +
93 //计算UFO当前价,可售sku最低价 106 //计算UFO当前价,可售sku最低价
94 List<StoragePrice> storagePriceList = storagePriceMapper.selectMinPriceByStorageIdList(skuList); 107 List<StoragePrice> storagePriceList = storagePriceMapper.selectMinPriceByStorageIdList(skuList);
95 Map<Integer, BigDecimal> storageMinPriceMap = storagePriceList.stream().collect(Collectors.toMap(StoragePrice::getStorageId, StoragePrice::getPrice)); 108 Map<Integer, BigDecimal> storageMinPriceMap = storagePriceList.stream().collect(Collectors.toMap(StoragePrice::getStorageId, StoragePrice::getPrice));
96 109
97 - List<ChannelSkuCompareRspBo> respList = convertToResp(cscList, productMap, sizeIdNameMap, storageMap, storageMinPriceMap); 110 + List<ChannelSkuCompareRspBo> respList = convertToResp(cscList, productMap, sizeIdNameMap, storageMap, storageMinPriceMap, goodsIdImageMap);
98 111
99 PageResponseBO<ChannelSkuCompareRspBo> result=new PageResponseBO<>(); 112 PageResponseBO<ChannelSkuCompareRspBo> result=new PageResponseBO<>();
100 result.setList(respList); 113 result.setList(respList);
@@ -183,7 +196,8 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService, @@ -183,7 +196,8 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService,
183 196
184 197
185 private List<ChannelSkuCompareRspBo> convertToResp(List<ChannelSkuCompare> cscList, Map<Integer, Product> productMap, 198 private List<ChannelSkuCompareRspBo> convertToResp(List<ChannelSkuCompare> cscList, Map<Integer, Product> productMap,
186 - Map<Integer, String> sizeIdNameMap, Map<Integer, Storage> storageMap, Map<Integer, BigDecimal> storageMinPriceMap){ 199 + Map<Integer, String> sizeIdNameMap, Map<Integer, Storage> storageMap, Map<Integer, BigDecimal> storageMinPriceMap,
  200 + Map<Integer, String> goodsIdImageMap){
187 List<ChannelSkuCompareRspBo> boList = Lists.newArrayList(); 201 List<ChannelSkuCompareRspBo> boList = Lists.newArrayList();
188 for(ChannelSkuCompare csc : cscList) { 202 for(ChannelSkuCompare csc : cscList) {
189 ChannelSkuCompareRspBo bo = new ChannelSkuCompareRspBo(); 203 ChannelSkuCompareRspBo bo = new ChannelSkuCompareRspBo();
@@ -210,6 +224,8 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService, @@ -210,6 +224,8 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService,
210 } 224 }
211 bo.setStatus(csc.getStatus()); 225 bo.setStatus(csc.getStatus());
212 bo.setStatusStr(bo.getStatus().intValue()==0 ? "正常" : "异常"); 226 bo.setStatusStr(bo.getStatus().intValue()==0 ? "正常" : "异常");
  227 + String imageUrl = goodsIdImageMap.get(storageMap.get(csc.getSku()).getGoodsId());
  228 + bo.setImageUrl(ImagesHelper.getImageAbsoluteUrl(imageUrl, ImagesConstant.BUCKET_GOODS_IMG));
213 boList.add(bo); 229 boList.add(bo);
214 } 230 }
215 231