mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 19:49:19 +08:00
feat: 不收几推广费为0的推广记录
This commit is contained in:
@@ -29,9 +29,9 @@ async function main() {
|
||||
{
|
||||
id: 'pdd-ad-fee',
|
||||
name: '拼多多商品推广费同步',
|
||||
version: '0.3.9',
|
||||
version: '0.3.10',
|
||||
description:
|
||||
'从推广总览读取推广费并同步到 BI(浮窗滚动条统一 thin)',
|
||||
'从推广总览读取推广费并同步到 BI(总花费为 0 不记录)',
|
||||
matchUrlPatterns: [
|
||||
'*://yingxiao.pinduoduo.com/*',
|
||||
'https://yingxiao.pinduoduo.com/',
|
||||
|
||||
@@ -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({
|
||||
|
||||
Reference in New Issue
Block a user