fix(pdd-extension): 拼多多官方接口频控(40002)容错与轻量探测,避免有效 Cookie 被拒

This commit is contained in:
yml2213
2026-09-14 13:09:16 +08:00
parent a47661e67e
commit 4f97275c80
2 changed files with 43 additions and 3 deletions
+35
View File
@@ -124,6 +124,41 @@ router.post('/sync-cookie', async (req, res, next) => {
})
if (!testResult.valid) {
// 容错机制:若 Cookie 包含 PASS_ID 且拼多多官方接口触发频控 (40002),说明会话身份有效已通达官方网关
// (若未登录或已失效,PDD 会优先返回 43001 会话过期,而非 40002 频控)。
// 此时采纳并保存 Cookie,避免客服陷入重复点击导致的频控死循环。
if (testResult.rateLimited && hasPassId) {
logWarn(
'[pdd-extension]',
`插件上报店铺 [${store.shopName}(${store.shopId})] Cookie 探测触发频控 (40002),但包含有效 PASS_ID,视为有效并采纳更新`,
{
shopId: store.shopId,
hasPassId,
hasRckk,
},
)
const updatedStore = await updatePddStoreCookieFromExtension(store.shopId, {
cookie: decrypted.cookie,
userAgent: decrypted.userAgent,
etag: decrypted.etag,
})
res.json({
code: 0,
message:
'Cookie 同步成功!(网关提示操作过于频繁 40002,凭证已保存生效,后台将在静默后自动拉单)',
data: {
shopId: updatedStore.shopId,
shopName: updatedStore.shopName,
valid: true,
rateLimited: true,
lastExtensionSyncAt: updatedStore.lastExtensionSyncAt,
},
})
return
}
logWarn('[pdd-extension]', `插件上报的 Cookie 实测未通过: ${testResult.message}`, {
shopId: store.shopId,
hasPassId,