|
|
|
@ -124,6 +124,9 @@ public class MoveService {
|
|
|
|
|
@Autowired
|
|
|
|
|
RedisService redisService;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
ProductToDsItemFailService productToDsItemFailService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据搬家配置,修改数据
|
|
|
|
|
*
|
|
|
|
@ -632,6 +635,8 @@ public class MoveService {
|
|
|
|
|
}
|
|
|
|
|
ProductAddV2Data productAddV2Data = (ProductAddV2Data) addProductRet.getData().get("data");
|
|
|
|
|
String productId = String.valueOf(productAddV2Data.getProductId());
|
|
|
|
|
String sourceSellerId = (String) addProductRet.getData().getOrDefault("sourceSellerId", "");
|
|
|
|
|
log.info("sourceSellerId: " + sourceSellerId + " productId: " + productId + " sourceItemId: " + sourceItemId );
|
|
|
|
|
|
|
|
|
|
// 请求上报分销关系,重试3次, 可以失败,失败异步任务进行同步
|
|
|
|
|
JSONObject dsResult = null;
|
|
|
|
@ -640,14 +645,18 @@ public class MoveService {
|
|
|
|
|
if (ObjectUtil.isNotEmpty(dsResult)) {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
log.info("分销关系推送失败,重试" + i + "次");
|
|
|
|
|
CommonTool.randomSleep();
|
|
|
|
|
}
|
|
|
|
|
if (ObjectUtil.isNotEmpty(dsResult)) {
|
|
|
|
|
log.info("分销关系推送成功");
|
|
|
|
|
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
|
|
|
|
|
TransactionStatus dsTransStatus = transactionManager.getTransaction(def);
|
|
|
|
|
try {
|
|
|
|
|
// 保存分销关系
|
|
|
|
|
ProductToDsItem productToDsItem = new ProductToDsItem();
|
|
|
|
|
productToDsItem.setProductId(productId);
|
|
|
|
|
productToDsItem.setSourceSellerId((String) addProductRet.getData().getOrDefault("sourceSellerId", ""));
|
|
|
|
|
productToDsItem.setSourceSellerId(sourceSellerId);
|
|
|
|
|
productToDsItem.setShopId(shopId);
|
|
|
|
|
productToDsItem.setSourceItemId(sourceItemId);
|
|
|
|
|
productToDsItem.setGmtCreate(new Date());
|
|
|
|
@ -659,12 +668,24 @@ public class MoveService {
|
|
|
|
|
dsQueue.setShopId(shopId);
|
|
|
|
|
dsQueue.setProductId(Long.valueOf(productId));
|
|
|
|
|
dsRelateProductAnalysisOpOrderQueueService.insertSelective(dsQueue);
|
|
|
|
|
transactionManager.commit(dsTransStatus);
|
|
|
|
|
log.info("分销关系入库成功");
|
|
|
|
|
} catch (Throwable e) {
|
|
|
|
|
E.throwMSException("分销关系推送失败");
|
|
|
|
|
log.error("分销关系推送异常", e);
|
|
|
|
|
transactionManager.rollback(dsTransStatus);
|
|
|
|
|
E.throwMSException("分销关系推送异常");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
log.info("分销关系推送失败");
|
|
|
|
|
// 存入失败的分销关系中,异步任务进行同步
|
|
|
|
|
|
|
|
|
|
ProductToDsItemFail productToDsItemFail = new ProductToDsItemFail();
|
|
|
|
|
productToDsItemFail.setProductId(productId);
|
|
|
|
|
productToDsItemFail.setSourceSellerId(sourceSellerId);
|
|
|
|
|
productToDsItemFail.setShopId(shopId);
|
|
|
|
|
productToDsItemFail.setSourceItemId(sourceItemId);
|
|
|
|
|
productToDsItemFail.setGmtCreate(new Date());
|
|
|
|
|
productToDsItemFail.setGmtModified(new Date());
|
|
|
|
|
productToDsItemFailService.insertSelective(productToDsItemFail);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|