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,
{