优化快手电子凭证:客服核销页、店铺展示与筛选

- 客服角色仅展示「券码核销」Tab,本地列表直接核销
- 卖家列改为店铺名+ID 展示,并返回 shopName
- 新增轻量店铺列表接口,支持按店铺下拉筛选
- 修复 asRecord 空值导致的前端构建类型错误
This commit is contained in:
yml2213
2026-07-10 17:46:40 +08:00
parent 7aeaafbe75
commit 36fb994acd
6 changed files with 414 additions and 139 deletions
@@ -32,9 +32,12 @@ export async function listAdminKuaishouIndustryVouchers(
input: KuaishouIndustryVoucherAdminListQuery = {},
) {
const result = await listKuaishouIndustryVouchersForAdmin(input)
const shopNameBySellerId = buildKuaishouIndustryShopNameMap()
return {
items: result.items.map(mapAdminKuaishouIndustryVoucher),
items: result.items.map((voucher) =>
mapAdminKuaishouIndustryVoucher(voucher, shopNameBySellerId),
),
pagination: {
page: result.page,
pageSize: result.pageSize,
@@ -43,6 +46,27 @@ export async function listAdminKuaishouIndustryVouchers(
}
}
/** 轻量店铺选项:仅展示名与 ID,供筛选/下拉使用(不含 token 等敏感字段) */
export function listAdminKuaishouIndustryShops() {
const shops = listKuaishouIndustryShopConfigs(getKuaishouIndustrySourceConfig())
return {
shops: shops
.map((shop) => {
const sellerId = String(shop.sellerId || '').trim()
const shopId = String(shop.shopId || '').trim()
const shopName = String(shop.customShopName || shop.shopName || '').trim()
return {
sellerId,
shopId,
shopName,
enabled: shop.enabled !== false,
}
})
.filter((shop) => shop.sellerId || shop.shopId),
}
}
export async function listAdminKuaishouIndustryRefunds(input: JsonObject = {}) {
assertRequired(input.beginTime, '开始时间未填写')
assertRequired(input.endTime, '结束时间未填写')
@@ -370,7 +394,11 @@ function sanitizeOpenApiRequest(request: JsonObject | undefined): JsonObject | n
}
}
function mapAdminKuaishouIndustryVoucher(voucher: KuaishouIndustryVoucherRow) {
function mapAdminKuaishouIndustryVoucher(
voucher: KuaishouIndustryVoucherRow,
shopNameBySellerId: Map<string, string> = buildKuaishouIndustryShopNameMap(),
) {
const sellerId = String(voucher.seller_id || '').trim()
return {
id: voucher.id,
voucherCode: voucher.voucher_code,
@@ -378,7 +406,8 @@ function mapAdminKuaishouIndustryVoucher(voucher: KuaishouIndustryVoucherRow) {
orderId: voucher.order_id,
taskId: voucher.task_id,
unitIndex: voucher.unit_index,
sellerId: voucher.seller_id,
sellerId,
shopName: shopNameBySellerId.get(sellerId) || '',
tokenMasked: maskSecret(voucher.token),
status: voucher.status,
validStartTime: Number(voucher.valid_start_time || 0) || 0,
@@ -397,6 +426,29 @@ function mapAdminKuaishouIndustryVoucher(voucher: KuaishouIndustryVoucherRow) {
}
}
function buildKuaishouIndustryShopNameMap(): Map<string, string> {
const map = new Map<string, string>()
const shops = listKuaishouIndustryShopConfigs(getKuaishouIndustrySourceConfig())
for (const shop of shops) {
const name = String(shop.customShopName || shop.shopName || '').trim()
if (!name) {
continue
}
const sellerId = String(shop.sellerId || '').trim()
const shopId = String(shop.shopId || '').trim()
if (sellerId) {
map.set(sellerId, name)
}
if (shopId && shopId !== sellerId) {
map.set(shopId, name)
}
}
return map
}
function mapTaskReference(task: TaskRow) {
return {
taskId: task.id,