5ae8e917 刘嘉

菠萝派接口- 更新库存修改

1 个父辈 fd096c00
......@@ -32,28 +32,28 @@ public class SyncStockBizServiceImpl extends AbstractBizService<PineappleSyncSto
public PineappleSyncStockResponse call(CallRequest<PineappleSyncStockRequest> callRequest) throws Exception {
PineappleSyncStockResponse pineappleSyncStockResponse = new PineappleSyncStockResponse();
if(callRequest.getBizModel().getQuantity() < 0){
log.error(String.format("菠萝派商城appkey[%s]更新库存失败,库存必须大于或等于0,商品ID是:%s",callRequest.getRequest().getAppkey(),callRequest.getBizModel().getPlatProductID()));
throw new BizException(String.format("菠萝派商城appkey[%s]更新库存失败,库存必须大于或等于0,商品ID是:%s",callRequest.getRequest().getAppkey(),callRequest.getBizModel().getPlatProductID()));
log.error(String.format("菠萝派商城appkey[%s]更新库存失败,库存必须大于或等于0,商品ID是:[%s]",callRequest.getRequest().getAppkey(),callRequest.getBizModel().getPlatProductID()));
throw new BizException(String.format("菠萝派商城appkey[%s]更新库存失败,库存必须大于或等于0,商品ID是:[%s]",callRequest.getRequest().getAppkey(),callRequest.getBizModel().getPlatProductID()));
}
Map<String,Object> params = new HashMap<>();
params.put("supplierId",callRequest.getSupplier().getId());
params.put("sellerId",callRequest.getSupplier().getId());
params.put("productId",callRequest.getBizModel().getPlatProductID());
params.put("skuId",callRequest.getBizModel().getSkuID());
params.put("stock",callRequest.getBizModel().getQuantity());
List<DownloadProductBean> downloadProductBeans = pineappleDao.downloadProductListByMap(params);
DownloadProductBean downloadProductBeans = pineappleDao.getDownloadProductBeanByMap(params);
if(StringUtil.isNull(downloadProductBeans)){
log.error(String.format("菠萝派商城appkey[%s],没有该商品[%s]",callRequest.getRequest().getAppkey(),callRequest.getBizModel().getPlatProductID()));
throw new BizException(String.format("菠萝派商城appkey[%s,没有该商品[%s]",callRequest.getRequest().getAppkey(),callRequest.getBizModel().getPlatProductID()));
throw new BizException(String.format("菠萝派商城appkey[%s],没有该商品[%s]",callRequest.getRequest().getAppkey(),callRequest.getBizModel().getPlatProductID()));
}
if(pineappleDao.updateSkuStock(params) != 1){
log.error(String.format("菠萝派商城appkey[%s]更新库存失败,没有该商品[%s]",callRequest.getRequest().getAppkey(),callRequest.getBizModel().getPlatProductID()));
throw new BizException(String.format("菠萝派商城appkey[%s]更新库存失败,没有该商品[%s]",callRequest.getRequest().getAppkey(),callRequest.getBizModel().getPlatProductID()));
log.error(String.format("菠萝派商城appkey[%s]更新sku库存失败,没有该sku[%s]",callRequest.getRequest().getAppkey(),callRequest.getBizModel().getPlatProductID()));
throw new BizException(String.format("菠萝派商城appkey[%s]更新sku库存失败,没有该sku[%s]",callRequest.getRequest().getAppkey(),callRequest.getBizModel().getPlatProductID()));
}
List<DownloadProductSkuBean> skuBean = pineappleDao.downloadSkuByProductId(callRequest.getBizModel().getPlatProductID());
if(StringUtil.isNull(skuBean)){
log.error(String.format("菠萝派商城appkey[%s]更新库存失败,查询不到该SKU[%s]",callRequest.getRequest().getAppkey(),callRequest.getBizModel().getPlatProductID()));
throw new BizException(String.format("菠萝派商城appkey[%s]更新库存失败,查询不到该SKU[%s]",callRequest.getRequest().getAppkey(),callRequest.getBizModel().getPlatProductID()));
log.error(String.format("菠萝派商城appkey[%s]更新库存失败,查询不到该商品所有的sku[%s]",callRequest.getRequest().getAppkey(),callRequest.getBizModel().getPlatProductID()));
throw new BizException(String.format("菠萝派商城appkey[%s]更新库存失败,查询不到该商品所有的sku[%s]",callRequest.getRequest().getAppkey(),callRequest.getBizModel().getPlatProductID()));
}
//获取sku总库存
Integer sumStock = skuBean.stream().map(s -> s.getSkuQuantity()).reduce(0,(a,b) ->{
......