...
|
...
|
@@ -100,11 +100,37 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService { |
|
|
return result;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public int updateSuggestPrice(ChannelSkuCompareReq req) {
|
|
|
if(null == req.getStatus() || req.getStatus().intValue() != 0 || null == req.getId()) {
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
ChannelSkuCompare csc = channelSkuCompareMapper.selectById(req.getId());
|
|
|
if(null == csc) {
|
|
|
LOGGER.error("id not exist! id is {}", req.getId());
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
Storage storage = storageMapper.selectByPrimaryKey(csc.getSku());
|
|
|
if(null == storage) {
|
|
|
LOGGER.error("storageId not exist! storageId is {}", csc.getSku());
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
//更新
|
|
|
BigDecimal suggestLowPrice = csc.getChannelPrice().multiply(BigDecimal.valueOf(1).subtract(csc.getLowRate()));
|
|
|
BigDecimal suggestHighPrice = csc.getChannelPrice().multiply(BigDecimal.valueOf(1).add(csc.getHighRate()));
|
|
|
return storageMapper.updateSuggestPriceById(csc.getSku(), suggestLowPrice, suggestHighPrice);
|
|
|
|
|
|
}
|
|
|
|
|
|
private List<ChannelSkuCompareRspBo> convertToResp(List<ChannelSkuCompare> cscList, Map<Integer, Product> productMap,
|
|
|
Map<Integer, String> sizeIdNameMap, Map<Integer, Storage> storageMap, Map<Integer, BigDecimal> storageMinPriceMap){
|
|
|
List<ChannelSkuCompareRspBo> boList = Lists.newArrayList();
|
|
|
for(ChannelSkuCompare csc : cscList) {
|
|
|
ChannelSkuCompareRspBo bo = new ChannelSkuCompareRspBo();
|
|
|
bo.setId(csc.getId());
|
|
|
bo.setProductId(csc.getProductId());
|
|
|
bo.setSku(csc.getSku());
|
|
|
bo.setProductName(productMap.get(csc.getProductId()).getProductName());
|
...
|
...
|
@@ -137,7 +163,7 @@ public class ChannelSkuCompareServiceImpl implements IChannelSkuCompareService { |
|
|
}
|
|
|
|
|
|
private static String getFormatPrice(BigDecimal price) {
|
|
|
return String.format("%d", price.intValue());
|
|
|
return String.format("%.2f", price.doubleValue());
|
|
|
}
|
|
|
|
|
|
private boolean checkAndBuildParam(ChannelSkuCompareReq req) {
|
...
|
...
|
|