fix: show vip marketing promotion flow
This commit is contained in:
parent
d66f0cf119
commit
a2b3db3afa
@ -93,7 +93,7 @@ class Pages extends Controller
|
||||
'jd-promotion', 'douyin-promotion', 'dewu-promotion', 'vip-promotion',
|
||||
];
|
||||
|
||||
/** @var list<string> 推广账户流水及唯品会税务数据已合并到营销账户账单页的页签 */
|
||||
/** @var list<string> 推广账户流水已合并到营销账户账单页的页签 */
|
||||
protected const PROMOTION_MARKETING_TABS = [
|
||||
'jd-promotion', 'douyin-promotion', 'dewu-promotion', 'vip-promotion',
|
||||
];
|
||||
@ -1166,6 +1166,9 @@ class Pages extends Controller
|
||||
'shop_name' => mb_substr(trim((string) $request->query('shop_name', '')), 0, 100),
|
||||
'account' => mb_substr(trim((string) $request->query('account', '')), 0, 100),
|
||||
];
|
||||
if ($platform === 'vip') {
|
||||
$filters['advertiser_id'] = mb_substr(trim((string) $request->query('advertiser_id', '')), 0, 100);
|
||||
}
|
||||
|
||||
try {
|
||||
$repository = app(\Modules\EcommerceFinance\Repositories\PlatformPromotionAccountRepository::class);
|
||||
@ -1188,24 +1191,20 @@ class Pages extends Controller
|
||||
|
||||
if ($platform === 'vip') {
|
||||
fputcsv($csv, [
|
||||
'平台', '店铺', '平台店铺', '申报金额(元)', '退货订单数',
|
||||
'退货服务金额(元)', '退货商品金额(元)', '销售订单数',
|
||||
'销售服务金额(元)', '销售商品金额(元)', '交易笔数', '交易时间',
|
||||
'平台', '营销账户', '账户名称', '广告主 ID', '广告主名称',
|
||||
'报表日期', '花费(元)', '曝光量', '更新时间',
|
||||
]);
|
||||
foreach ($data['vipTax'] ?? [] as $row) {
|
||||
foreach ($data['vipMarketingDaily'] ?? [] as $row) {
|
||||
fputcsv($csv, [
|
||||
'唯品会税务数据',
|
||||
$row['shopName'] ?? '',
|
||||
$row['storeName'] ?? '',
|
||||
$row['reportAmount'] ?? '',
|
||||
$row['returnOrderCount'] ?? '',
|
||||
$row['returnServiceAmount'] ?? '',
|
||||
$row['returnSkuAmount'] ?? '',
|
||||
$row['saleOrderCount'] ?? '',
|
||||
$row['salesServiceAmount'] ?? '',
|
||||
$row['salesSkuAmount'] ?? '',
|
||||
$row['transactionNum'] ?? '',
|
||||
$row['transactionTime'] ?? '',
|
||||
'唯品会推广流水',
|
||||
$row['account'] ?? '',
|
||||
$row['accountName'] ?? '',
|
||||
$row['advertiserId'] ?? '',
|
||||
$row['advertiserTitle'] ?? '',
|
||||
$row['reportDate'] ?? '',
|
||||
$row['costYuan'] ?? '',
|
||||
$row['impressionCount'] ?? '',
|
||||
$row['updatedAt'] ?? '',
|
||||
]);
|
||||
}
|
||||
fclose($csv);
|
||||
|
||||
@ -362,7 +362,7 @@ return [
|
||||
['slug' => 'jd-promotion', 'title' => '京东京准通'],
|
||||
['slug' => 'douyin-promotion', 'title' => '抖音千川'],
|
||||
['slug' => 'dewu-promotion', 'title' => '得物推广账户'],
|
||||
['slug' => 'vip-promotion', 'title' => '唯品会税务数据'],
|
||||
['slug' => 'vip-promotion', 'title' => '唯品会推广流水'],
|
||||
],
|
||||
],
|
||||
['slug' => 'deposit-account-balance', 'title' => '店铺保证金账户余额'],
|
||||
|
||||
@ -6,7 +6,7 @@ use InvalidArgumentException;
|
||||
use Modules\EcommerceFinance\Services\UpstreamReadOnlyQuery;
|
||||
use Modules\EcommerceFinance\Services\UpstreamReadOnlyQueryFactory;
|
||||
|
||||
/** 固定字段、固定表的推广账户及唯品会税务数据只读查询。 */
|
||||
/** 固定字段、固定表的推广账户及唯品会营销日报只读查询。 */
|
||||
class PlatformPromotionAccountRepository
|
||||
{
|
||||
private const SOURCE = 'js_data_middle_platform';
|
||||
@ -18,12 +18,13 @@ class PlatformPromotionAccountRepository
|
||||
public function dashboard(array $filters, int $limit = 200, ?string $platform = null): array
|
||||
{
|
||||
if ($platform !== null && ! in_array($platform, ['jd', 'douyin', 'dewu', 'vip'], true)) {
|
||||
throw new InvalidArgumentException('未知的推广账户或税务数据平台。');
|
||||
throw new InvalidArgumentException('未知的推广账户平台。');
|
||||
}
|
||||
|
||||
$month = $filters['month'];
|
||||
$shop = $filters['shop_name'] ?? null;
|
||||
$account = $filters['account'] ?? null;
|
||||
$advertiser = $filters['advertiser_id'] ?? null;
|
||||
$limit = min(max($limit, 1), 5000);
|
||||
$query = $this->queries->forSource(self::SOURCE);
|
||||
|
||||
@ -34,7 +35,8 @@ class PlatformPromotionAccountRepository
|
||||
$douyinStatus = [];
|
||||
$dewu = [];
|
||||
$dewuSummary = [];
|
||||
$vipTax = [];
|
||||
$vipMarketing = [];
|
||||
$vipMarketingDaily = [];
|
||||
$vipSummary = [];
|
||||
|
||||
if ($platform === null || $platform === 'jd') {
|
||||
@ -54,12 +56,14 @@ class PlatformPromotionAccountRepository
|
||||
}
|
||||
|
||||
if ($platform === null || $platform === 'vip') {
|
||||
$vipTax = $this->query($query, "SELECT TOP {$limit} shopName, storeName, reportAmount, returnOrderCount, returnServiceAmount, returnSkuAmount, saleOrderCount, salesServiceAmount, salesSkuAmount, transactionNum, transactionTime FROM JSDataMiddlePlatform.dbo.vip_taxDeclarationDetail WHERE dataMonth = ?", [$month], $shop, null, 'shopName');
|
||||
$vipMarketing = $this->query($query, "SELECT TOP {$limit} account, accountName, advertiserId, dataMonth, startDate, endDate, totalCostYuan, totalImpressionCount, recordCount, updatedAt FROM JSDataMiddlePlatform.dbo.vip_marketingMonthlySummary WHERE dataMonth = ?", [$month], null, $account, null, true, $advertiser);
|
||||
$vipMarketingDaily = $this->query($query, "SELECT TOP {$limit} account, accountName, advertiserId, advertiserTitle, dataMonth, reportDate, reportTimestamp, costYuan, impressionCount, updatedAt FROM JSDataMiddlePlatform.dbo.vip_marketingDailyReport WHERE dataMonth = ?", [$month], null, $account, null, false, $advertiser, 'reportDate, advertiserId, account');
|
||||
$vipSummary = [
|
||||
'report_amount' => $this->sum($vipTax, 'reportAmount'),
|
||||
'return_order_count' => $this->sum($vipTax, 'returnOrderCount'),
|
||||
'sale_order_count' => $this->sum($vipTax, 'saleOrderCount'),
|
||||
'transaction_num' => $this->sum($vipTax, 'transactionNum'),
|
||||
'cost' => $this->sum($vipMarketing, 'totalCostYuan'),
|
||||
'impressions' => $this->sum($vipMarketing, 'totalImpressionCount'),
|
||||
'record_count' => $this->sum($vipMarketing, 'recordCount'),
|
||||
'account_count' => $this->distinctCount($vipMarketing, 'account'),
|
||||
'daily_record_count' => count($vipMarketingDaily),
|
||||
];
|
||||
}
|
||||
|
||||
@ -71,10 +75,11 @@ class PlatformPromotionAccountRepository
|
||||
'dyStatus' => $douyinStatus,
|
||||
'dw' => $dewu,
|
||||
'dwSummary' => $dewuSummary,
|
||||
// 保留旧键为空数组,避免调用方因契约变更报错;唯品会页签只使用税务明细。
|
||||
// 保留旧键为空数组,避免调用方因契约变更报错;唯品会页签只使用营销日报。
|
||||
'vipSales' => [],
|
||||
'vipTax' => $vipTax,
|
||||
'vipMarketing' => [],
|
||||
'vipTax' => [],
|
||||
'vipMarketing' => $vipMarketing,
|
||||
'vipMarketingDaily' => $vipMarketingDaily,
|
||||
'vipSummary' => $vipSummary,
|
||||
];
|
||||
}
|
||||
@ -95,10 +100,12 @@ class PlatformPromotionAccountRepository
|
||||
array $bindings,
|
||||
?string $shop,
|
||||
?string $account,
|
||||
string $shopColumn,
|
||||
?string $shopColumn,
|
||||
bool $summary = false,
|
||||
?string $advertiser = null,
|
||||
?string $orderBy = null,
|
||||
): array {
|
||||
if ($shop !== null && $shop !== '') {
|
||||
if ($shop !== null && $shop !== '' && $shopColumn !== null) {
|
||||
$sql .= " AND {$shopColumn} LIKE ?";
|
||||
$bindings[] = '%' . $shop . '%';
|
||||
}
|
||||
@ -106,8 +113,12 @@ class PlatformPromotionAccountRepository
|
||||
$sql .= ' AND account LIKE ?';
|
||||
$bindings[] = '%' . $account . '%';
|
||||
}
|
||||
if ($advertiser !== null && $advertiser !== '') {
|
||||
$sql .= ' AND advertiserId LIKE ?';
|
||||
$bindings[] = '%' . $advertiser . '%';
|
||||
}
|
||||
if (! $summary) {
|
||||
$sql .= ' ORDER BY 1';
|
||||
$sql .= ' ORDER BY ' . ($orderBy ?: '1');
|
||||
}
|
||||
|
||||
return $query->select($sql, $bindings);
|
||||
@ -117,4 +128,17 @@ class PlatformPromotionAccountRepository
|
||||
{
|
||||
return round(array_sum(array_map(static fn (array $row): float => (float) ($row[$key] ?? 0), $rows)), 2);
|
||||
}
|
||||
|
||||
private function distinctCount(array $rows, string $key): int
|
||||
{
|
||||
$values = [];
|
||||
foreach ($rows as $row) {
|
||||
$value = $row[$key] ?? null;
|
||||
if ($value !== null && $value !== '') {
|
||||
$values[(string) $value] = true;
|
||||
}
|
||||
}
|
||||
|
||||
return count($values);
|
||||
}
|
||||
}
|
||||
|
||||
@ -33,6 +33,9 @@ class PlatformPromotionAccountPageData
|
||||
'shop_name' => $this->text(request('shop_name')),
|
||||
'account' => $this->text(request('account')),
|
||||
];
|
||||
if ($platform === 'vip') {
|
||||
$filters['advertiser_id'] = $this->text(request('advertiser_id'));
|
||||
}
|
||||
try {
|
||||
if ($requestedMonth === '') {
|
||||
$month = $this->repository->latestMonth() ?: $month;
|
||||
@ -69,7 +72,7 @@ class PlatformPromotionAccountPageData
|
||||
'platform' => $platform,
|
||||
'marketingTab' => $tab,
|
||||
'rows' => $this->emptyPaginator(),
|
||||
'error' => '推广账户数据暂时无法读取,请稍后重试。',
|
||||
'error' => '平台推广数据暂时无法读取,请稍后重试。',
|
||||
];
|
||||
}
|
||||
}
|
||||
@ -81,7 +84,7 @@ class PlatformPromotionAccountPageData
|
||||
|
||||
private function paginateRows(array $data, string $tab): LengthAwarePaginator
|
||||
{
|
||||
$key = ['jd' => 'jd', 'douyin' => 'dy', 'dewu' => 'dw', 'vip' => 'vipTax'][$tab];
|
||||
$key = ['jd' => 'jd', 'douyin' => 'dy', 'dewu' => 'dw', 'vip' => 'vipMarketingDaily'][$tab];
|
||||
$rows = $data[$key] ?? [];
|
||||
$page = max((int) request('page', 1), 1);
|
||||
$perPage = 50;
|
||||
|
||||
@ -8,28 +8,25 @@
|
||||
'dewu' => $data['dwSummary'] ?? [],
|
||||
default => $data['vipSummary'] ?? [],
|
||||
};
|
||||
$titles = ['jd' => '京东京准通', 'douyin' => '抖音千川', 'dewu' => '得物推广账户', 'vip' => '唯品会税务数据'];
|
||||
$titles = ['jd' => '京东京准通', 'douyin' => '抖音千川', 'dewu' => '得物推广账户', 'vip' => '唯品会推广流水'];
|
||||
$filterLabel = $platform === 'vip' ? $titles[$platform] . '筛选' : $titles[$platform] . '推广账户筛选';
|
||||
$columns = match ($platform) {
|
||||
'jd' => [['shop_name', '店铺'], ['account', '账户'], ['show_date', '日期'], ['trade_type_name', '交易类型'], ['amount', '金额'], ['balance_amount', '余额'], ['remark', '备注']],
|
||||
'douyin' => [['shopName', '店铺'], ['account', '账户'], ['qianchuanAavid', '广告账户'], ['statDate', '日期'], ['cost', '花费'], ['income', '收入'], ['transferIn', '转入'], ['transferOut', '转出'], ['balance', '余额'], ['status', '状态'], ['remark', '备注']],
|
||||
'dewu' => [['shop_name', '店铺'], ['account', '账户'], ['trade_date', '日期'], ['amount_type', '金额类型'], ['flow_type', '收支类型'], ['trade_amount_yuan', '金额'], ['balance_yuan', '余额'], ['remark', '备注']],
|
||||
default => [
|
||||
['shopName', '店铺'],
|
||||
['storeName', '平台店铺'],
|
||||
['reportAmount', '申报金额(元)'],
|
||||
['returnOrderCount', '退货订单数'],
|
||||
['returnServiceAmount', '退货服务金额(元)'],
|
||||
['returnSkuAmount', '退货商品金额(元)'],
|
||||
['saleOrderCount', '销售订单数'],
|
||||
['salesServiceAmount', '销售服务金额(元)'],
|
||||
['salesSkuAmount', '销售商品金额(元)'],
|
||||
['transactionNum', '交易笔数'],
|
||||
['transactionTime', '交易时间'],
|
||||
['account', '营销账户'],
|
||||
['accountName', '账户名称'],
|
||||
['advertiserId', '广告主 ID'],
|
||||
['advertiserTitle', '广告主名称'],
|
||||
['reportDate', '报表日期'],
|
||||
['costYuan', '花费(元)'],
|
||||
['impressionCount', '曝光量'],
|
||||
['updatedAt', '更新时间'],
|
||||
],
|
||||
};
|
||||
$moneyFields = ['amount', 'balance_amount', 'cost', 'income', 'transferIn', 'transferOut', 'balance', 'trade_amount_yuan', 'balance_yuan', 'reportAmount', 'returnServiceAmount', 'returnSkuAmount', 'salesServiceAmount', 'salesSkuAmount'];
|
||||
$integerFields = ['returnOrderCount', 'saleOrderCount', 'transactionNum'];
|
||||
$moneyFields = ['amount', 'balance_amount', 'cost', 'income', 'transferIn', 'transferOut', 'balance', 'trade_amount_yuan', 'balance_yuan', 'costYuan'];
|
||||
$integerFields = ['impressionCount'];
|
||||
@endphp
|
||||
<style>
|
||||
.marketing-platform-promotion-page { color: #171717; }
|
||||
@ -63,16 +60,19 @@
|
||||
<div class="marketing-platform-promotion-page">
|
||||
<form method="GET" class="promotion-toolbar" aria-label="{{ $filterLabel }}">
|
||||
<label>数据月份 <input type="month" name="month" value="{{ $filters['month'] ?? now()->format('Y-m') }}" required></label>
|
||||
<label>店铺 <input type="text" name="shop_name" value="{{ $filters['shop_name'] ?? '' }}" placeholder="店铺名称"></label>
|
||||
@if ($platform !== 'vip')
|
||||
<label>店铺 <input type="text" name="shop_name" value="{{ $filters['shop_name'] ?? '' }}" placeholder="店铺名称"></label>
|
||||
<label>账户 <input type="text" name="account" value="{{ $filters['account'] ?? '' }}" placeholder="账户名称"></label>
|
||||
@else
|
||||
<label>营销账户 <input type="text" name="account" value="{{ $filters['account'] ?? '' }}" placeholder="账户标识或名称"></label>
|
||||
<label>广告主 ID <input type="text" name="advertiser_id" value="{{ $filters['advertiser_id'] ?? '' }}" placeholder="广告主 ID"></label>
|
||||
@endif
|
||||
<button class="biz-btn biz-btn-primary" type="submit">查询</button>
|
||||
<a class="biz-btn biz-btn-ghost" href="{{ route('business.pages.export', [
|
||||
'section' => request()->route('section') ?? 'billing-transactions',
|
||||
'page' => request()->route('page') ?? 'marketing-account-bills',
|
||||
'tab' => $marketingTab,
|
||||
] + request()->only(['month', 'shop_name', 'account'])) }}">导出 CSV</a>
|
||||
] + request()->only(['month', 'shop_name', 'account', 'advertiser_id'])) }}">导出 CSV</a>
|
||||
</form>
|
||||
|
||||
@if (! empty($error))
|
||||
@ -96,10 +96,10 @@
|
||||
<div class="biz-card promotion-card"><div class="promotion-card-title">净额(元)</div><div class="promotion-kpi">{{ number_format((float) ($summary['net'] ?? 0), 2) }}</div></div>
|
||||
<div class="biz-card promotion-card"><div class="promotion-card-title">流水笔数</div><div class="promotion-kpi">{{ number_format((int) ($summary['record_count'] ?? 0)) }}</div></div>
|
||||
@else
|
||||
<div class="biz-card promotion-card"><div class="promotion-card-title">申报金额(元)</div><div class="promotion-kpi">{{ number_format((float) ($summary['report_amount'] ?? 0), 2) }}</div></div>
|
||||
<div class="biz-card promotion-card"><div class="promotion-card-title">销售订单数</div><div class="promotion-kpi">{{ number_format((int) ($summary['sale_order_count'] ?? 0)) }}</div></div>
|
||||
<div class="biz-card promotion-card"><div class="promotion-card-title">退货订单数</div><div class="promotion-kpi">{{ number_format((int) ($summary['return_order_count'] ?? 0)) }}</div></div>
|
||||
<div class="biz-card promotion-card"><div class="promotion-card-title">交易笔数</div><div class="promotion-kpi">{{ number_format((int) ($summary['transaction_num'] ?? 0)) }}</div></div>
|
||||
<div class="biz-card promotion-card"><div class="promotion-card-title">月度花费(元)</div><div class="promotion-kpi">{{ number_format((float) ($summary['cost'] ?? 0), 2) }}</div></div>
|
||||
<div class="biz-card promotion-card"><div class="promotion-card-title">月度曝光量</div><div class="promotion-kpi">{{ number_format((int) ($summary['impressions'] ?? 0)) }}</div></div>
|
||||
<div class="biz-card promotion-card"><div class="promotion-card-title">营销账户数</div><div class="promotion-kpi">{{ number_format((int) ($summary['account_count'] ?? 0)) }}</div></div>
|
||||
<div class="biz-card promotion-card"><div class="promotion-card-title">日报明细数</div><div class="promotion-kpi">{{ number_format((int) ($summary['daily_record_count'] ?? 0)) }}</div></div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@ -112,7 +112,7 @@
|
||||
<td>{{ in_array($column[0], $moneyFields, true) && is_numeric($value) ? number_format((float) $value, 2) : (in_array($column[0], $integerFields, true) && is_numeric($value) ? number_format((int) $value) : ($value ?? '—')) }}</td>
|
||||
@endforeach</tr>
|
||||
@empty
|
||||
<tr><td colspan="{{ count($columns) }}">该月份暂无数据</td></tr>
|
||||
<tr><td colspan="{{ count($columns) }}">{{ $platform === 'vip' && ($summary['record_count'] ?? 0) > 0 ? '该月份已有月度营销汇总,但日报明细尚未入库' : '该月份暂无数据' }}</td></tr>
|
||||
@endforelse
|
||||
</tbody></table></div>
|
||||
<div class="promotion-pagination"><span>每页最多 50 条 · 共 {{ number_format($rows->total()) }} 条</span><nav aria-label="{{ $titles[$platform] }}分页"><div class="promotion-pagination__buttons">
|
||||
|
||||
@ -75,7 +75,7 @@ class MarketingPlatformPromotionBillsTest extends FeatureTestCase
|
||||
$this->assertStringContainsString('测试店铺', $response->streamedContent());
|
||||
}
|
||||
|
||||
public function test_vip_tab_uses_tax_declaration_data_without_marketing_fields(): void
|
||||
public function test_vip_tab_uses_marketing_daily_data(): void
|
||||
{
|
||||
$this->allowMarketingAccountBillsPage();
|
||||
|
||||
@ -85,25 +85,23 @@ class MarketingPlatformPromotionBillsTest extends FeatureTestCase
|
||||
'month' => '2026-08',
|
||||
'shop_name' => '',
|
||||
'account' => '',
|
||||
'advertiser_id' => '',
|
||||
], 5000, 'vip')->andReturn([
|
||||
'vipTax' => [[
|
||||
'shopName' => '唯品测试店',
|
||||
'storeName' => '唯品平台店',
|
||||
'reportAmount' => 123.45,
|
||||
'returnOrderCount' => 2,
|
||||
'returnServiceAmount' => 3.2,
|
||||
'returnSkuAmount' => 4.3,
|
||||
'saleOrderCount' => 10,
|
||||
'salesServiceAmount' => 5.4,
|
||||
'salesSkuAmount' => 6.5,
|
||||
'transactionNum' => 12,
|
||||
'transactionTime' => '2026-08-31 23:59:59',
|
||||
'vipMarketingDaily' => [[
|
||||
'account' => 'vip-account-01',
|
||||
'accountName' => '唯品营销账户',
|
||||
'advertiserId' => 'adv-001',
|
||||
'advertiserTitle' => '唯品广告主',
|
||||
'reportDate' => '2026-08-31',
|
||||
'costYuan' => 123.45,
|
||||
'impressionCount' => 6789,
|
||||
'updatedAt' => '2026-08-31 23:59:59',
|
||||
]],
|
||||
'vipSummary' => [
|
||||
'report_amount' => 123.45,
|
||||
'return_order_count' => 2,
|
||||
'sale_order_count' => 10,
|
||||
'transaction_num' => 12,
|
||||
'cost' => 123.45,
|
||||
'impressions' => 6789,
|
||||
'account_count' => 1,
|
||||
'daily_record_count' => 1,
|
||||
],
|
||||
]);
|
||||
$this->app->instance(PlatformPromotionAccountRepository::class, $repository);
|
||||
@ -115,18 +113,18 @@ class MarketingPlatformPromotionBillsTest extends FeatureTestCase
|
||||
'tab' => 'vip-promotion',
|
||||
]))
|
||||
->assertOk()
|
||||
->assertSeeText('唯品会税务数据')
|
||||
->assertSee('aria-label="唯品会税务数据筛选"', false)
|
||||
->assertSeeText('申报金额(元)')
|
||||
->assertSeeText('退货订单数')
|
||||
->assertSeeText('唯品测试店')
|
||||
->assertSeeText('唯品会推广流水')
|
||||
->assertSee('aria-label="唯品会推广流水筛选"', false)
|
||||
->assertSeeText('营销账户')
|
||||
->assertSeeText('广告主 ID')
|
||||
->assertSeeText('唯品营销账户')
|
||||
->assertSeeText('123.45')
|
||||
->assertDontSeeText('营销花费')
|
||||
->assertDontSeeText('实际销售额')
|
||||
->assertDontSeeText('销售目标');
|
||||
->assertSeeText('6,789')
|
||||
->assertDontSeeText('申报金额(元)')
|
||||
->assertDontSeeText('退货订单数');
|
||||
}
|
||||
|
||||
public function test_vip_export_contains_tax_declaration_fields_only(): void
|
||||
public function test_vip_export_contains_marketing_daily_fields(): void
|
||||
{
|
||||
$this->allowMarketingAccountBillsPage();
|
||||
|
||||
@ -136,19 +134,17 @@ class MarketingPlatformPromotionBillsTest extends FeatureTestCase
|
||||
'month' => '2026-08',
|
||||
'shop_name' => '',
|
||||
'account' => '',
|
||||
'advertiser_id' => '',
|
||||
], 5000, 'vip')->andReturn([
|
||||
'vipTax' => [[
|
||||
'shopName' => '唯品测试店',
|
||||
'storeName' => '唯品平台店',
|
||||
'reportAmount' => 123.45,
|
||||
'returnOrderCount' => 2,
|
||||
'returnServiceAmount' => 3.2,
|
||||
'returnSkuAmount' => 4.3,
|
||||
'saleOrderCount' => 10,
|
||||
'salesServiceAmount' => 5.4,
|
||||
'salesSkuAmount' => 6.5,
|
||||
'transactionNum' => 12,
|
||||
'transactionTime' => '2026-08-31 23:59:59',
|
||||
'vipMarketingDaily' => [[
|
||||
'account' => 'vip-account-01',
|
||||
'accountName' => '唯品营销账户',
|
||||
'advertiserId' => 'adv-001',
|
||||
'advertiserTitle' => '唯品广告主',
|
||||
'reportDate' => '2026-08-31',
|
||||
'costYuan' => 123.45,
|
||||
'impressionCount' => 6789,
|
||||
'updatedAt' => '2026-08-31 23:59:59',
|
||||
]],
|
||||
]);
|
||||
$this->app->instance(PlatformPromotionAccountRepository::class, $repository);
|
||||
@ -158,15 +154,17 @@ class MarketingPlatformPromotionBillsTest extends FeatureTestCase
|
||||
'page' => 'marketing-account-bills',
|
||||
'tab' => 'vip-promotion',
|
||||
'month' => '2026-08',
|
||||
'advertiser_id' => '',
|
||||
]));
|
||||
|
||||
$response->assertOk()->assertDownload('_vip_2026-08.csv');
|
||||
$csv = $response->streamedContent();
|
||||
$this->assertStringContainsString('唯品会税务数据', $csv);
|
||||
$this->assertStringContainsString('申报金额(元)', $csv);
|
||||
$this->assertStringContainsString('唯品测试店', $csv);
|
||||
$this->assertStringNotContainsString('营销花费', $csv);
|
||||
$this->assertStringNotContainsString('VIP营销', $csv);
|
||||
$this->assertStringContainsString('唯品会推广流水', $csv);
|
||||
$this->assertStringContainsString('广告主 ID', $csv);
|
||||
$this->assertStringContainsString('唯品营销账户', $csv);
|
||||
$this->assertStringContainsString('123.45', $csv);
|
||||
$this->assertStringNotContainsString('申报金额(元)', $csv);
|
||||
$this->assertStringNotContainsString('唯品会税务数据', $csv);
|
||||
}
|
||||
|
||||
public function test_removed_platform_promotion_directory_returns_to_the_current_page_with_feedback(): void
|
||||
|
||||
@ -53,24 +53,36 @@ class PlatformPromotionAccountRepositoryTest extends TestCase
|
||||
], 200, 'unknown');
|
||||
}
|
||||
|
||||
public function test_vip_dashboard_only_queries_tax_declaration_details(): void
|
||||
public function test_vip_dashboard_queries_marketing_month_summary_and_daily_details(): void
|
||||
{
|
||||
$factory = Mockery::mock(UpstreamReadOnlyQueryFactory::class);
|
||||
$query = Mockery::mock(UpstreamReadOnlyQuery::class);
|
||||
$factory->shouldReceive('forSource')->once()->with('js_data_middle_platform')->andReturn($query);
|
||||
$query->shouldReceive('select')->once()->with(
|
||||
Mockery::on(static fn (string $sql): bool => str_contains($sql, 'vip_taxDeclarationDetail')
|
||||
Mockery::on(static fn (string $sql): bool => str_contains($sql, 'vip_marketingMonthlySummary')
|
||||
&& str_contains($sql, 'SELECT TOP 5000')
|
||||
&& ! str_contains($sql, 'vip_marketingMonthlySummary')
|
||||
&& ! str_contains($sql, 'vip_taxDeclarationDetail')
|
||||
&& ! str_contains($sql, 'vip_marketingDailyReport')),
|
||||
['2026-08'],
|
||||
)->andReturn([
|
||||
[
|
||||
'account' => 'vip-account-01',
|
||||
'totalCostYuan' => 123.45,
|
||||
'totalImpressionCount' => 6789,
|
||||
'recordCount' => 1,
|
||||
],
|
||||
]);
|
||||
$query->shouldReceive('select')->once()->with(
|
||||
Mockery::on(static fn (string $sql): bool => str_contains($sql, 'vip_marketingDailyReport')
|
||||
&& str_contains($sql, 'SELECT TOP 5000')
|
||||
&& ! str_contains($sql, 'vip_taxDeclarationDetail')
|
||||
&& ! str_contains($sql, 'vip_monthlySaleProgress')),
|
||||
['2026-08'],
|
||||
)->andReturn([
|
||||
[
|
||||
'shopName' => '唯品测试店',
|
||||
'reportAmount' => 123.45,
|
||||
'returnOrderCount' => 2,
|
||||
'saleOrderCount' => 10,
|
||||
'transactionNum' => 12,
|
||||
'account' => 'vip-account-01',
|
||||
'costYuan' => 123.45,
|
||||
'impressionCount' => 6789,
|
||||
],
|
||||
]);
|
||||
|
||||
@ -78,14 +90,16 @@ class PlatformPromotionAccountRepositoryTest extends TestCase
|
||||
'month' => '2026-08',
|
||||
'shop_name' => '',
|
||||
'account' => '',
|
||||
'advertiser_id' => '',
|
||||
], 5000, 'vip');
|
||||
|
||||
$this->assertCount(1, $result['vipTax']);
|
||||
$this->assertCount(1, $result['vipMarketingDaily']);
|
||||
$this->assertSame([], $result['vipSales']);
|
||||
$this->assertSame([], $result['vipMarketing']);
|
||||
$this->assertSame(123.45, $result['vipSummary']['report_amount']);
|
||||
$this->assertSame(2.0, $result['vipSummary']['return_order_count']);
|
||||
$this->assertSame(10.0, $result['vipSummary']['sale_order_count']);
|
||||
$this->assertSame(12.0, $result['vipSummary']['transaction_num']);
|
||||
$this->assertSame([], $result['vipTax']);
|
||||
$this->assertCount(1, $result['vipMarketing']);
|
||||
$this->assertSame(123.45, $result['vipSummary']['cost']);
|
||||
$this->assertSame(6789.0, $result['vipSummary']['impressions']);
|
||||
$this->assertSame(1, $result['vipSummary']['account_count']);
|
||||
$this->assertSame(1, $result['vipSummary']['daily_record_count']);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user