fix(shops): 视频号授权允许回调地址为空,透传 appId/toUserName,超时调至 15s

This commit is contained in:
liufumingren 2026-08-15 20:12:26 +08:00
parent 2e95fb19d4
commit f127853592
2 changed files with 13 additions and 6 deletions

View File

@ -149,6 +149,10 @@ class ShopsMethodService extends MainService {
callbackurl,
callback_url: callbackUrlSnake,
callbackUrl,
appId,
app_id: appIdSnake,
toUserName,
to_user_name: toUserNameSnake,
} = data || {};
return await this.callShopsSystem('getAuthorizeSessionKey', {
@ -156,6 +160,8 @@ class ShopsMethodService extends MainService {
callbackurl: callbackurl !== undefined
? callbackurl
: (callbackUrlSnake !== undefined ? callbackUrlSnake : callbackUrl),
appId: appId !== undefined ? appId : appIdSnake,
toUserName: toUserName !== undefined ? toUserName : toUserNameSnake,
}, '获取授权会话失败');
}
}

View File

@ -691,11 +691,6 @@ class ShopsService extends Service {
const authUrl = 'http://61.160.223.183:3012/api';
const shopId = data.id !== undefined ? data.id : (data.shop_id !== undefined ? data.shop_id : data.shopId);
const callbackUrl = this.normalizeText(
data.callbackurl !== undefined ? data.callbackurl : data.callback_url,
'callbackurl',
{ required: true, maxLength: 500 }
);
const appId = data.appId || '';
const toUserName = data.toUserName || '';
const shop = await this.findShopById(shopId, { allowDeleted: false });
@ -712,6 +707,12 @@ class ShopsService extends Service {
});
const platName = printPlatform ? printPlatform.get_auth_platform_name : platformCode;
// 视频号授权不依赖回调地址,允许 callbackurl 为空;其他平台仍必填
const callbackUrl = this.normalizeText(
data.callbackurl !== undefined ? data.callbackurl : data.callback_url,
'callbackurl',
{ required: platName !== '视频号', maxLength: 500 }
);
const requestData = {
RedirectCodeUrl: callbackUrl,
command: 'saveShop',
@ -735,7 +736,7 @@ class ShopsService extends Service {
const respone = await ctx.curl(authUrl, {
method: 'POST',
dataType: 'json',
timeout: 5000,
timeout: 15000,
data: requestData,
});
await this.app.setCacheAsync('last_respone_auth_polo', JSON.stringify(respone), 3600);