fix(brand-check): 补测耗尽通知按失败类别说话,代理套餐问题不再算成上游的锅
16890 改烧任务归属用户自己的代理提取链接后,失败主因从上游不可用变成用户侧套餐: 现网 12 分钟内 18 条「全部 N 把代理 key 处于冷却」、4 条「余额不足」。而耗尽通知仍一律写 「上游商标库持续不可用,建议稍后重新提交采集任务重跑这些 ASIN」——既把账算到别人头上, 又把人推向"重跑必然还是同样失败"的那条路。 - 新增 BrandCheckFailureNotice:原始原因 → Kind(未配置/套餐耗尽/冷却/出口被拒/技术性/上游), 每类给一句"发生了什么 + 该做什么",代理侧全部指向「密钥设置」的「代理设置」。 - 拒付判定排在冷却之前:key 因余额不足被拒后整批写冷却,只报冷却等于让用户白等。 - pushRecheckOutcome 多收一个 Kind,耗尽分支改用它给的句子;last_error 照库存原文供后台取证。 - 30 支用例(分类器 9 / 通知 7 / 调度 10,含冷却原话透传到通知那支),判据串取自现网读到的原文。
This commit is contained in:
+27
-4
@@ -3,6 +3,7 @@ package com.nanri.aiimage.modules.collectdata.service;
|
||||
import com.nanri.aiimage.common.service.DistributedJobLockService;
|
||||
import com.nanri.aiimage.config.CollectDataBrandRecheckProperties;
|
||||
import com.nanri.aiimage.modules.brand.client.BrandCheckClient;
|
||||
import com.nanri.aiimage.modules.brand.support.BrandCheckFailureNotice;
|
||||
import com.nanri.aiimage.modules.collectdata.model.entity.CollectDataBrandRecheckEntity;
|
||||
import com.nanri.aiimage.modules.collectdata.service.CollectDataBrandRecheckInjector.GroupOutcome;
|
||||
import com.nanri.aiimage.modules.notification.service.NotificationDispatchService;
|
||||
@@ -119,7 +120,7 @@ class CollectDataBrandRecheckSchedulerTest {
|
||||
verify(recheckService).postponeWithoutAttempt(List.of(e1), 30);
|
||||
verify(brandCheckClient, never()).checkAll(anyList(), anyString(), any());
|
||||
verify(notificationDispatchService, never()).pushRecheckOutcome(
|
||||
any(), any(), anyString(), anyString(), anyInt(), anyInt(), anyInt(), anyInt());
|
||||
any(), any(), anyString(), anyString(), anyInt(), anyInt(), anyInt(), anyInt(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -167,7 +168,28 @@ class CollectDataBrandRecheckSchedulerTest {
|
||||
verify(recheckService, never()).markAttempted(any(), anyString());
|
||||
verify(taskFileJobService).enqueueAssembleResult(100L, "COLLECT_DATA", 9L, "task:100");
|
||||
verify(notificationDispatchService).pushRecheckOutcome(
|
||||
961L, 100L, "COLLECT_DATA", "COLLECT_DATA-100", 3, 1, 0, 0);
|
||||
961L, 100L, "COLLECT_DATA", "COLLECT_DATA-100", 3, 1, 0, 0,
|
||||
BrandCheckFailureNotice.Kind.UPSTREAM);
|
||||
}
|
||||
|
||||
@Test
|
||||
void runRoundPassesProxyCooldownKindThroughToNotification() {
|
||||
// 上游回来的原因就是"全部 key 处于冷却"时,通知必须拿到冷却这一类,
|
||||
// 而不是继续按"上游商标库不可用"对用户说话。
|
||||
CollectDataBrandRecheckEntity e1 = entry(1, 100L, "zara");
|
||||
when(recheckService.listDue(any(), anyInt())).thenReturn(List.of(e1));
|
||||
when(fileTaskMapper.selectById(100L)).thenReturn(task(100L, "SUCCESS"));
|
||||
when(taskDistributedLockService.acquire("COLLECT_DATA", 100L, 2000L)).thenReturn(taskLock);
|
||||
when(brandCheckClient.checkAll(anyList(), eq("Terms"), any())).thenReturn(
|
||||
new BrandCheckClient.BrandCheckBatchResult(List.of(), List.of(), List.of("zara"),
|
||||
"全部 1 把代理 key 处于冷却,最早还要等 299 秒"));
|
||||
|
||||
scheduler.runRound();
|
||||
|
||||
verify(recheckService).markAttempted(e1, "全部 1 把代理 key 处于冷却,最早还要等 299 秒");
|
||||
verify(notificationDispatchService).pushRecheckOutcome(
|
||||
961L, 100L, "COLLECT_DATA", "COLLECT_DATA-100", 0, 0, 1, 0,
|
||||
BrandCheckFailureNotice.Kind.PROXY_COOLDOWN);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -185,7 +207,8 @@ class CollectDataBrandRecheckSchedulerTest {
|
||||
verify(injector, never()).apply(any(), any());
|
||||
verify(taskFileJobService, never()).enqueueAssembleResult(anyLong(), anyString(), anyLong(), anyString());
|
||||
verify(notificationDispatchService).pushRecheckOutcome(
|
||||
961L, 100L, "COLLECT_DATA", "COLLECT_DATA-100", 0, 0, 1, 0);
|
||||
961L, 100L, "COLLECT_DATA", "COLLECT_DATA-100", 0, 0, 1, 0,
|
||||
BrandCheckFailureNotice.Kind.UPSTREAM);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -220,7 +243,7 @@ class CollectDataBrandRecheckSchedulerTest {
|
||||
verify(taskFileJobService, never()).enqueueAssembleResult(anyLong(), anyString(), anyLong(), anyString());
|
||||
// 注入失败:无修复、无收口,不打扰用户
|
||||
verify(notificationDispatchService, never()).pushRecheckOutcome(
|
||||
any(), any(), anyString(), anyString(), anyInt(), anyInt(), anyInt(), anyInt());
|
||||
any(), any(), anyString(), anyString(), anyInt(), anyInt(), anyInt(), anyInt(), any());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user