4b154430 刘嘉

菠萝派接口- 更改产品库存调用新数据源

1 个父辈 d0afcb9f
......@@ -10,6 +10,8 @@ import com.sibu.orderHelper.integral.pineapple.request.CallRequest;
import com.sibu.orderHelper.integral.reponse.PineappleSyncStockResponse;
import com.sibu.orderHelper.integral.reponse.SkuApiResponse;
import com.sibu.orderHelper.integral.request.PineappleSyncStockRequest;
import com.sibu.orderHelper.mall.member.read.MemberReadDao;
import com.sibu.orderHelper.mall.member.write.MemberWriteDao;
import com.sibu.orderHelper.service.redis.RedisProductSkuService;
import com.sibu.orderHelper.service.redis.RedisProductStockService;
import org.apache.log4j.Logger;
......@@ -24,10 +26,13 @@ import java.util.Map;
@Service
public class SyncStockBizServiceImpl extends AbstractBizService<PineappleSyncStockRequest> {
private static Logger log = Logger.getLogger(SyncStockBizServiceImpl.class);
@Resource
private MemberReadDao memberReadDao;
@Resource
private PineappleDao pineappleDao;
private MemberWriteDao memberWriteDao;
@Transactional(rollbackFor = Exception.class)
@Transactional(value ="transactionManagerForMall",rollbackFor = Exception.class)
@Override
public PineappleSyncStockResponse call(CallRequest<PineappleSyncStockRequest> callRequest) throws Exception {
PineappleSyncStockResponse pineappleSyncStockResponse = new PineappleSyncStockResponse();
......@@ -41,16 +46,16 @@ public class SyncStockBizServiceImpl extends AbstractBizService<PineappleSyncSto
params.put("skuId",callRequest.getBizModel().getSkuID());
params.put("stock",callRequest.getBizModel().getQuantity());
DownloadProductBean downloadProductBeans = pineappleDao.getDownloadProductBeanByMap(params);
DownloadProductBean downloadProductBeans = memberReadDao.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()));
}
if(pineappleDao.updateSkuStock(params) != 1){
if(memberWriteDao.updateSkuStock(params) != 1){
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());
List<DownloadProductSkuBean> skuBean = memberReadDao.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()));
......@@ -60,7 +65,7 @@ public class SyncStockBizServiceImpl extends AbstractBizService<PineappleSyncSto
return a+b;
});
params.put("productStock",sumStock);
if(pineappleDao.updateProductStock(params) != 1){
if(memberWriteDao.updateProductStock(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())));
}
......