feat: 不收几推广费为0的推广记录

This commit is contained in:
2026-08-16 23:13:41 +08:00
parent 50ce131d60
commit b4455a4788
13 changed files with 43 additions and 25 deletions
@@ -27,17 +27,19 @@ export interface BatchImportPddGoodsAdFeeResult {
}>;
}
/** 插件统一模型 → 后端 batch-import 入参(日期取自每条 item) */
/** 插件统一模型 → 后端 batch-import 入参(日期取自每条 item;金额须大于 0) */
export function toBatchImportRequest(
batch: AdvertisingCostBatch,
): BatchImportPddGoodsAdFeeRequest {
return {
items: batch.items.map((item) => ({
channelShopId: batch.channelShopId,
feeDate: item.feeDate,
goodsId: item.goodsId,
feeAmount: item.feeAmount,
})),
items: batch.items
.filter((item) => Number(item.feeAmount) > 0)
.map((item) => ({
channelShopId: batch.channelShopId,
feeDate: item.feeDate,
goodsId: item.goodsId,
feeAmount: item.feeAmount,
})),
};
}
@@ -45,6 +47,9 @@ export async function batchImportPddGoodsAdFee(
batch: AdvertisingCostBatch,
): Promise<BatchImportPddGoodsAdFeeResult> {
const body = toBatchImportRequest(batch);
if (!body.items.length) {
throw new Error('没有可传入的记录(推广费须大于 0)');
}
return openApiRequest<BatchImportPddGoodsAdFeeResult>(
OPEN_API_PATHS.pddGoodsAdFeeBatchImport,
{
@@ -6,7 +6,7 @@ import { installMainWorldAdapters } from '@/features/runtime/mainWorldAdapters';
import { setFloatingVisible } from '@/content/floating/mount';
const FEATURE_ID = 'pdd-ad-fee';
const FEATURE_VERSION = '0.3.9';
const FEATURE_VERSION = '0.3.10';
export interface RemoteFeatureExport {
id: string;
@@ -134,7 +134,8 @@ export function parsePromotionItems(
const cells = Array.from(row.querySelectorAll(':scope > td'));
const feeCell = cells[feeCol];
const feeAmount = parseAmount(feeCell?.textContent);
if (feeAmount == null) continue;
// 总花费为 0 / 空 不记录
if (feeAmount == null || feeAmount <= 0) continue;
seen.add(goodsId);
items.push({