|
|
|
@ -84,6 +84,9 @@ import org.springframework.context.annotation.Configuration;
|
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
import org.springframework.transaction.PlatformTransactionManager;
|
|
|
|
|
import org.springframework.transaction.TransactionStatus;
|
|
|
|
|
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
@ -93,6 +96,9 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class ProcessMovePublishToPicTaskService extends TaskBaseService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private PlatformTransactionManager transactionManager;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
MoveProductPublishQueueService moveProductPublishQueueService;
|
|
|
|
|
|
|
|
|
@ -144,6 +150,7 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
|
|
|
|
|
@Autowired
|
|
|
|
|
private ProductService productService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Map<String, Boolean> isProcessed = new HashMap<>();
|
|
|
|
|
private static Map<String, Integer> tryTimes = new HashMap<>();
|
|
|
|
|
|
|
|
|
@ -179,7 +186,7 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
|
|
|
|
|
@Scheduled(fixedRate = 10000)
|
|
|
|
|
@Override
|
|
|
|
|
public void runTask() {
|
|
|
|
|
super.runTaskWithTransaction();
|
|
|
|
|
super.runTask();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -397,42 +404,42 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
|
|
|
|
|
// TODO
|
|
|
|
|
private Ret rebuildAddRetReason(Ret addRet, JSONArray brandList, MoveShopSettingBO condition, String cid, AccessToken accessToken) {
|
|
|
|
|
|
|
|
|
|
if (addRet.getReason().contains("请重新选择品牌") || addRet.getReason().contains("该类目下无品牌") || addRet.getReason().contains("品牌不属于该类目")) {
|
|
|
|
|
if (StringUtils.isNumeric(condition.getBrandId())) {
|
|
|
|
|
Map<String, JSONObject> brandMap = brandList.stream().filter(x -> ((JSONObject) x).containsKey("id")).collect(Collectors.toMap(x -> ((JSONObject) x).getString("id"), x -> (JSONObject) x, (v1, v2) -> v1));
|
|
|
|
|
JSONObject brand = brandMap.get(condition.getBrandId());
|
|
|
|
|
String brandName = brand.getString("brand_chinese_name") != null ? brand.getString("brand_chinese_name") : brand.getString("brand_english_name");
|
|
|
|
|
addRet.setReason("当前类目无 " + brandName + " 品牌权限,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>");
|
|
|
|
|
return addRet;
|
|
|
|
|
} else if (Objects.equals(condition.getBrandId(), MoveConst.brandEmpty)) {
|
|
|
|
|
addRet.setReason("当前类目品牌必填,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a><br>您在搬家配置设置“品牌留空”。若您已经申请品牌,请修改搬家配置,若没有申请品牌,请前往店铺后台申请品牌");
|
|
|
|
|
return addRet;
|
|
|
|
|
} else if (brandList.isEmpty()) {
|
|
|
|
|
addRet.setReason("当前类目品牌必填,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>");
|
|
|
|
|
return addRet;
|
|
|
|
|
} else if (brandList.size() != 0) {
|
|
|
|
|
List<String> brandNames = brandList.stream().map(x -> {
|
|
|
|
|
JSONObject temp = (JSONObject) x;
|
|
|
|
|
return temp.containsKey("brand_chinese_name") ? temp.getString("brand_chinese_name") : temp.getString("brand_english_name");
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
addRet.setReason("当前类目无\"" + String.join(",", brandNames) + "\"品牌权限,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>");
|
|
|
|
|
return addRet;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (addRet.getReason().contains("没有品牌资质,非普通店商品请使用有资质的品牌")) {
|
|
|
|
|
return rebuildAddRetBrandQualificationReason(addRet, brandList, cid, accessToken);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (addRet.getReason().contains("颜色对应的规格值不能重复,请核对")) {
|
|
|
|
|
addRet.setReason(addRet.getReason() + ",请检查是否包含特殊符号或违禁词(" + String.join(",", MoveConst.getSpecialBanWordList()) + ")");
|
|
|
|
|
}
|
|
|
|
|
// if (addRet.getReason().contains("请重新选择品牌") || addRet.getReason().contains("该类目下无品牌") || addRet.getReason().contains("品牌不属于该类目")) {
|
|
|
|
|
// if (StringUtils.isNumeric(condition.getBrandId())) {
|
|
|
|
|
// Map<String, JSONObject> brandMap = brandList.stream().filter(x -> ((JSONObject) x).containsKey("id")).collect(Collectors.toMap(x -> ((JSONObject) x).getString("id"), x -> (JSONObject) x, (v1, v2) -> v1));
|
|
|
|
|
// JSONObject brand = brandMap.get(condition.getBrandId());
|
|
|
|
|
// String brandName = brand.getString("brand_chinese_name") != null ? brand.getString("brand_chinese_name") : brand.getString("brand_english_name");
|
|
|
|
|
// addRet.setReason("当前类目无 " + brandName + " 品牌权限,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>");
|
|
|
|
|
// return addRet;
|
|
|
|
|
// } else if (Objects.equals(condition.getBrandId(), MoveConst.brandEmpty)) {
|
|
|
|
|
// addRet.setReason("当前类目品牌必填,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a><br>您在搬家配置设置“品牌留空”。若您已经申请品牌,请修改搬家配置,若没有申请品牌,请前往店铺后台申请品牌");
|
|
|
|
|
// return addRet;
|
|
|
|
|
// } else if (brandList.isEmpty()) {
|
|
|
|
|
// addRet.setReason("当前类目品牌必填,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>");
|
|
|
|
|
// return addRet;
|
|
|
|
|
// } else if (brandList.size() != 0) {
|
|
|
|
|
// List<String> brandNames = brandList.stream().map(x -> {
|
|
|
|
|
// JSONObject temp = (JSONObject) x;
|
|
|
|
|
// return temp.containsKey("brand_chinese_name") ? temp.getString("brand_chinese_name") : temp.getString("brand_english_name");
|
|
|
|
|
// }).collect(Collectors.toList());
|
|
|
|
|
// addRet.setReason("当前类目无\"" + String.join(",", brandNames) + "\"品牌权限,请前往店铺后台申请品牌,<a href=\"https://fxg.jinritemai.com/ffa/grs/qualification/list?type=2\" target=\"_blank\">立即申请</a>");
|
|
|
|
|
// return addRet;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
Matcher matcherBanWord = Pattern.compile("规格值含有敏感词(?::|:)\\[([^\\]]+)\\]").matcher(addRet.getReason());
|
|
|
|
|
Matcher matcherBanWordDescription = Pattern.compile("商品规格值描述“(.*)”不符合平台要求").matcher(addRet.getReason());
|
|
|
|
|
if (matcherBanWord.matches() || matcherBanWordDescription.matches()) {
|
|
|
|
|
addRet.setReason(addRet.getReason() + ",并且过滤后会导致sku规格值重复,请检查并手动修改");
|
|
|
|
|
}
|
|
|
|
|
// if (addRet.getReason().contains("没有品牌资质,非普通店商品请使用有资质的品牌")) {
|
|
|
|
|
// return rebuildAddRetBrandQualificationReason(addRet, brandList, cid, accessToken);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// if (addRet.getReason().contains("颜色对应的规格值不能重复,请核对")) {
|
|
|
|
|
// addRet.setReason(addRet.getReason() + ",请检查是否包含特殊符号或违禁词(" + String.join(",", MoveConst.getSpecialBanWordList()) + ")");
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// Matcher matcherBanWord = Pattern.compile("规格值含有敏感词(?::|:)\\[([^\\]]+)\\]").matcher(addRet.getReason());
|
|
|
|
|
// Matcher matcherBanWordDescription = Pattern.compile("商品规格值描述“(.*)”不符合平台要求").matcher(addRet.getReason());
|
|
|
|
|
// if (matcherBanWord.matches() || matcherBanWordDescription.matches()) {
|
|
|
|
|
// addRet.setReason(addRet.getReason() + ",并且过滤后会导致sku规格值重复,请检查并手动修改");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
return addRet;
|
|
|
|
|
}
|
|
|
|
@ -1592,10 +1599,20 @@ public class ProcessMovePublishToPicTaskService extends TaskBaseService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int queueId = createMoveProductPublishToPicQueue(queueMsg);
|
|
|
|
|
List<String> materialIds = Arrays.asList(urlAndMaterialIdMap.values().toArray(new String[0]));
|
|
|
|
|
saveMaterialBiz(queueMsg.getShopId(), CommonConst.BIZ_MOVE, queueId, materialIds, urlAndMaterialIdMap);
|
|
|
|
|
deleteQueueMsg(queueMsg);
|
|
|
|
|
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
|
|
|
|
|
TransactionStatus status = transactionManager.getTransaction(def);
|
|
|
|
|
try{
|
|
|
|
|
int queueId = createMoveProductPublishToPicQueue(queueMsg);
|
|
|
|
|
List<String> materialIds = Arrays.asList(urlAndMaterialIdMap.values().toArray(new String[0]));
|
|
|
|
|
saveMaterialBiz(queueMsg.getShopId(), CommonConst.BIZ_MOVE, queueId, materialIds, urlAndMaterialIdMap);
|
|
|
|
|
deleteQueueMsg(queueMsg);
|
|
|
|
|
transactionManager.commit(status);
|
|
|
|
|
}catch (Throwable e){
|
|
|
|
|
e.printStackTrace();
|
|
|
|
|
transactionManager.rollback(status);
|
|
|
|
|
log.info("任务执行失败 数据回滚: ", e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|