feat(浏览器扩展): 改用新店铺名称精确匹配店铺接口

This commit is contained in:
2026-08-27 14:14:19 +08:00
parent bf602ed4b2
commit b3c77c08b1
18 changed files with 61 additions and 133 deletions
+12
View File
@@ -25,6 +25,18 @@ export interface PddShopFilters {
mallName?: string;
}
export async function matchPddChannelShopByMallName(
mallName: string,
): Promise<PddChannelShop | null> {
const name = mallName.trim();
if (!name) return null;
const qs = new URLSearchParams({ mallName: name });
return openApiRequest<PddChannelShop | null>(
`${OPEN_API_PATHS.pddShopMatchByName}?${qs.toString()}`,
{ method: 'GET' },
);
}
export async function listPddChannelShops(
query: PageQueryDTO<PddShopFilters> = { page: 1, pageSize: 50 },
): Promise<PageResultVO<PddChannelShop>> {
@@ -1,24 +1,16 @@
import type { PddChannelShop } from '@/api/open/pddShop';
import { listPddChannelShops } from '@/api/open/pddShop';
import { matchPddChannelShopByMallName } from '@/api/open/pddShop';
/**
* 用页面店铺名匹配 BI channelShop:仅接受 mallName 完全一致。
* 接口 filters 可能是模糊搜,结果里再做精确过滤。
* 用页面店铺名匹配 BI channelShop:后端按 mallName trim 后精确匹配。
*/
export async function matchChannelShopByMallName(
mallName: string,
): Promise<PddChannelShop | null> {
const name = mallName.trim();
if (!name) return null;
const result = await listPddChannelShops({
page: 1,
pageSize: 50,
filters: { mallName: name },
});
const records = result.records ?? [];
const exact = records.find((shop) => (shop.mallName ?? '').trim() === name);
return exact ?? null;
const shop = await matchPddChannelShopByMallName(name);
return shop ?? null;
}
export function shopAuthorizeHint(mallName: string): string {
@@ -2,6 +2,7 @@ export const EXTENSION_NAME = 'ECBI 数据同步';
export const OPEN_API_PATHS = {
pddShopList: '/open/v1/channel/pdd/shop/list',
pddShopMatchByName: '/open/v1/channel/pdd/shop/match-by-name',
pddGoodsAdFeeBatchImport: '/open/v1/channel/pdd/goods/adfee/batch-import',
pddGoodsAdFeeImportTask: '/open/v1/channel/pdd/goods/adfee/import-task',
extensionFeatureList: '/open/v1/extension/features',