fix: 安装费用趋势改按安装公司区分 (#1479)

This commit is contained in:
yueyang 2026-11-26 17:40:28 +08:00
parent 4539031eb1
commit 832fe6399a
5 changed files with 300 additions and 438 deletions

View File

@ -225,15 +225,12 @@ class InstallationDetailMirrorRepository
}
/**
* 按发货月份、平台和安装公司汇总安装单量,并返回已审核结算金额。
*
* 平台与安装公司用于分析供应商切换;审核状态用于区分已确认金额和待审核单量。
* 按发货月份和安装公司汇总安装单量,并返回已审核结算金额。
*
* @return array{
* ready:bool,
* rows:list<array{
* period:string,
* platform:string,
* installation_company:string,
* orders:int,
* reviewed_orders:int,
@ -241,7 +238,7 @@ class InstallationDetailMirrorRepository
* }>
* }
*/
public function platformFeeUsageTrend(string $fromMonth, string $toMonth): array
public function installationCompanyFeeUsageTrend(string $fromMonth, string $toMonth): array
{
$dataset = $this->datasets->get(self::DATASET);
$items = $this->datasets->get(self::ITEM_DATASET);
@ -285,25 +282,21 @@ class InstallationDetailMirrorRepository
$periodSql = $connection->getDriverName() === 'sqlite'
? "strftime('%Y-%m', install_main.ShipTIme)"
: "DATE_FORMAT(install_main.ShipTIme, '%Y-%m')";
$platformSql = $this->platformSql('install_main');
$companySql = "COALESCE(NULLIF(TRIM(install_main.installCompanyName), ''), '未填写安装公司')";
$rows = (clone $main)
->leftJoinSub($itemReview, 'item_review', static fn ($join) =>
$join->on('item_review.guid', '=', 'install_main.SourceGuid'))
->selectRaw($periodSql . ' AS period')
->selectRaw($platformSql . ' AS platform')
->selectRaw($companySql . ' AS installation_company')
->selectRaw('COUNT(*) AS orders')
->selectRaw('SUM(CASE WHEN item_review.reviewed = 1 THEN 1 ELSE 0 END) AS reviewed_orders')
->selectRaw('ROUND(COALESCE(SUM(item_review.settled_amount), 0), 2) AS settled_amount')
->groupByRaw($periodSql . ', ' . $platformSql . ', ' . $companySql)
->groupByRaw($periodSql . ', ' . $companySql)
->orderByRaw($periodSql)
->orderByRaw($platformSql)
->orderByRaw($companySql)
->get()
->map(static fn (object $row): array => [
'period' => trim((string) ($row->period ?? '')),
'platform' => trim((string) ($row->platform ?? '其他')),
'installation_company' => trim((string) ($row->installation_company ?? '未填写安装公司')),
'orders' => (int) ($row->orders ?? 0),
'reviewed_orders' => (int) ($row->reviewed_orders ?? 0),

View File

@ -6,7 +6,7 @@ use Illuminate\Support\Carbon;
use Modules\EcommerceFinance\Repositories\InstallationDetailMirrorRepository;
use Throwable;
/** 安装费汇总:按平台分析安装单量、已审核金额和供应商切换影响。 */
/** 安装费汇总:按安装公司分析单量、金额、单均和供应商切换影响。 */
class InstallationFeeUsagePageData
{
public const RANGE_OPTIONS = [
@ -15,17 +15,6 @@ class InstallationFeeUsagePageData
'ytd' => '本年至今',
];
private const PLATFORM_ORDER = [
'淘系' => 10,
'京东' => 20,
'拼多多' => 30,
'抖音' => 40,
'唯品会' => 50,
'得物' => 60,
'京喜' => 70,
'其他' => 80,
];
public function __construct(
private readonly InstallationDetailMirrorRepository $repository,
) {
@ -42,7 +31,7 @@ class InstallationFeeUsagePageData
$rangeLabel = $fromMonth . ' 至 ' . $toMonth;
try {
$result = $this->repository->platformFeeUsageTrend($fromMonth, $toMonth);
$result = $this->repository->installationCompanyFeeUsageTrend($fromMonth, $toMonth);
} catch (Throwable $exception) {
report($exception);
@ -53,7 +42,7 @@ class InstallationFeeUsagePageData
$toMonth,
$this->emptyPeriods($fromMonth, $toMonth),
[],
'安装费平台分析暂时无法读取,请稍后重试。',
'安装费安装公司分析暂时无法读取,请稍后重试。',
);
}
@ -97,7 +86,6 @@ class InstallationFeeUsagePageData
/**
* @param list<array{
* period:string,
* platform:string,
* installation_company:string,
* orders:int,
* reviewed_orders:int,
@ -119,8 +107,7 @@ class InstallationFeeUsagePageData
}
$index = $indexes[$period];
$platform = $row['platform'] !== '' ? $row['platform'] : '其他';
$vendor = $this->vendorKey($row['installation_company']);
$vendorKey = $this->vendorKey($row['installation_company']);
$orders = (int) $row['orders'];
$reviewedOrders = (int) $row['reviewed_orders'];
$settledAmount = (float) $row['settled_amount'];
@ -128,30 +115,9 @@ class InstallationFeeUsagePageData
$periods[$index]['total_orders'] += $orders;
$periods[$index]['reviewed_orders'] += $reviewedOrders;
$periods[$index]['settled_amount'] += $settledAmount;
$periods[$index]['vendors'][$vendor]['orders'] += $orders;
$periods[$index]['vendors'][$vendor]['reviewed_orders'] += $reviewedOrders;
$periods[$index]['vendors'][$vendor]['settled_amount'] += $settledAmount;
if (! isset($periods[$index]['platforms'][$platform])) {
$periods[$index]['platforms'][$platform] = [
'platform' => $platform,
'orders' => 0,
'reviewed_orders' => 0,
'settled_amount' => 0.0,
'review_rate' => 0.0,
'unit_cost' => 0.0,
'vendors' => $this->emptyVendors(),
];
}
$platformData = &$periods[$index]['platforms'][$platform];
$platformData['orders'] += $orders;
$platformData['reviewed_orders'] += $reviewedOrders;
$platformData['settled_amount'] += $settledAmount;
$platformData['vendors'][$vendor]['orders'] += $orders;
$platformData['vendors'][$vendor]['reviewed_orders'] += $reviewedOrders;
$platformData['vendors'][$vendor]['settled_amount'] += $settledAmount;
unset($platformData);
$periods[$index]['vendors'][$vendorKey]['orders'] += $orders;
$periods[$index]['vendors'][$vendorKey]['reviewed_orders'] += $reviewedOrders;
$periods[$index]['vendors'][$vendorKey]['settled_amount'] += $settledAmount;
}
foreach ($periods as &$period) {
@ -167,26 +133,6 @@ class InstallationFeeUsagePageData
}
unset($vendor);
foreach ($period['platforms'] as &$platform) {
$platform['settled_amount'] = round((float) $platform['settled_amount'], 2);
$platform['review_rate'] = $this->ratio($platform['reviewed_orders'], $platform['orders']);
$platform['unit_cost'] = $this->unitCost($platform['settled_amount'], $platform['reviewed_orders']);
foreach ($platform['vendors'] as &$vendor) {
$vendor['settled_amount'] = round((float) $vendor['settled_amount'], 2);
$vendor['review_rate'] = $this->ratio($vendor['reviewed_orders'], $vendor['orders']);
$vendor['unit_cost'] = $this->unitCost($vendor['settled_amount'], $vendor['reviewed_orders']);
$vendor['order_share'] = $this->ratio($vendor['orders'], $platform['orders']);
}
unset($vendor);
}
unset($platform);
uasort($period['platforms'], static function (array $left, array $right): int {
return ($right['orders'] <=> $left['orders'])
?: ((self::PLATFORM_ORDER[$left['platform']] ?? 99) <=> (self::PLATFORM_ORDER[$right['platform']] ?? 99));
});
$period['platforms'] = array_values($period['platforms']);
}
unset($period);
@ -208,7 +154,6 @@ class InstallationFeeUsagePageData
'settled_amount' => 0.0,
'unit_cost' => 0.0,
'vendors' => $this->emptyVendors(),
'platforms' => [],
];
$cursor->addMonthNoOverflow();
}
@ -290,62 +235,42 @@ class InstallationFeeUsagePageData
$benchmarkIndexes,
);
sort($benchmarkPeriods, SORT_STRING);
$rates = $this->benchmarkRates($periods, $benchmarkIndexes);
$previousPlatforms = collect($previous['platforms'] ?? [])->keyBy('platform');
$benchmarkRates = $this->benchmarkRates($periods, $benchmarkIndexes);
$previousVendors = collect($previous['vendors'] ?? [])->keyBy('key');
$platformRows = [];
$estimatedOrders = 0;
$wanOrders = (int) $current['vendors']['wan']['orders'];
$lubanOrders = (int) $current['vendors']['luban']['orders'];
$switchOrders = $wanOrders + $lubanOrders;
$wanRate = $benchmarkRates['wan'] ?? null;
$lubanRate = $benchmarkRates['luban'] ?? null;
$vendorRows = [];
$estimatedMixedAmount = 0.0;
$estimatedAllWanAmount = 0.0;
foreach ($current['platforms'] as $platform) {
$wanOrders = (int) ($platform['vendors']['wan']['orders'] ?? 0);
$lubanOrders = (int) ($platform['vendors']['luban']['orders'] ?? 0);
$wanRate = $this->benchmarkRate($rates, $platform['platform'], 'wan');
$lubanRate = $this->benchmarkRate($rates, $platform['platform'], 'luban');
$mixedAmount = null;
$allWanAmount = null;
$switchImpact = null;
if ($wanOrders + $lubanOrders > 0 && $wanRate !== null && $lubanRate !== null) {
$mixedAmount = $wanOrders * $wanRate + $lubanOrders * $lubanRate;
$allWanAmount = ($wanOrders + $lubanOrders) * $wanRate;
$switchImpact = $mixedAmount - $allWanAmount;
$estimatedOrders += $wanOrders + $lubanOrders;
$estimatedMixedAmount += $mixedAmount;
$estimatedAllWanAmount += $allWanAmount;
foreach ($current['vendors'] as $vendor) {
$rate = $benchmarkRates[$vendor['key']] ?? null;
$estimatedAmount = $rate === null ? null : $vendor['orders'] * $rate;
if ($vendor['key'] !== 'other' && $estimatedAmount !== null) {
$estimatedMixedAmount += $estimatedAmount;
}
if ($vendor['key'] === 'wan' && $rate !== null) {
$estimatedAllWanAmount = $switchOrders * $rate;
}
$prior = $previousPlatforms->get($platform['platform']);
$platformRows[] = [
'platform' => $platform['platform'],
'orders' => (int) $platform['orders'],
'wan_orders' => $wanOrders,
'luban_orders' => $lubanOrders,
'other_orders' => (int) ($platform['vendors']['other']['orders'] ?? 0),
'luban_share' => $this->ratio(
$lubanOrders,
$wanOrders + $lubanOrders + (int) ($platform['vendors']['other']['orders'] ?? 0),
),
'reviewed_orders' => (int) $platform['reviewed_orders'],
'review_rate' => (float) $platform['review_rate'],
'settled_amount' => (float) $platform['settled_amount'],
'confirmed_unit_cost' => (float) $platform['unit_cost'],
'wan_benchmark_rate' => $wanRate,
'luban_benchmark_rate' => $lubanRate,
'estimated_amount' => $mixedAmount === null ? null : round($mixedAmount, 2),
'all_wan_amount' => $allWanAmount === null ? null : round($allWanAmount, 2),
'switch_impact' => $switchImpact === null ? null : round($switchImpact, 2),
$prior = $previousVendors->get($vendor['key']);
$vendorRows[] = [
...$vendor,
'benchmark_rate' => $rate,
'estimated_amount' => $estimatedAmount === null ? null : round($estimatedAmount, 2),
'previous_orders' => (int) ($prior['orders'] ?? 0),
'previous_settled_amount' => round((float) ($prior['settled_amount'] ?? 0), 2),
'previous_unit_cost' => round((float) ($prior['unit_cost'] ?? 0), 2),
'previous_reviewed_orders' => (int) ($prior['reviewed_orders'] ?? 0),
'previous_review_rate' => (float) ($prior['review_rate'] ?? 0),
'previous_settled_amount' => (float) ($prior['settled_amount'] ?? 0),
'previous_unit_cost' => (float) ($prior['unit_cost'] ?? 0),
];
}
usort($platformRows, static fn (array $left, array $right): int =>
($right['orders'] <=> $left['orders'])
?: ((self::PLATFORM_ORDER[$left['platform']] ?? 99) <=> (self::PLATFORM_ORDER[$right['platform']] ?? 99)));
$switchImpact = $estimatedOrders > 0
$switchImpact = $switchOrders > 0 && $wanRate !== null && $lubanRate !== null
? round($estimatedMixedAmount - $estimatedAllWanAmount, 2)
: null;
@ -366,16 +291,17 @@ class InstallationFeeUsagePageData
'benchmark_label' => $benchmarkPeriods === []
? null
: $benchmarkPeriods[0] . ' 至 ' . $benchmarkPeriods[count($benchmarkPeriods) - 1],
'estimated_orders' => $estimatedOrders,
'benchmark_rates' => $benchmarkRates,
'estimated_orders' => $switchOrders,
'estimated_mixed_amount' => round($estimatedMixedAmount, 2),
'estimated_all_wan_amount' => round($estimatedAllWanAmount, 2),
'estimated_mixed_unit_cost' => $this->unitCost($estimatedMixedAmount, $estimatedOrders),
'estimated_all_wan_unit_cost' => $this->unitCost($estimatedAllWanAmount, $estimatedOrders),
'estimated_mixed_unit_cost' => $this->unitCost($estimatedMixedAmount, $switchOrders),
'estimated_all_wan_unit_cost' => $this->unitCost($estimatedAllWanAmount, $switchOrders),
'switch_impact' => $switchImpact,
'switch_impact_rate' => $estimatedAllWanAmount > 0.004 && $switchImpact !== null
? round(($switchImpact / $estimatedAllWanAmount) * 100, 1)
: null,
'platforms' => $platformRows,
'vendors' => $vendorRows,
];
}
@ -396,6 +322,7 @@ class InstallationFeeUsagePageData
'previous_confirmed_unit_cost' => 0.0,
'benchmark_periods' => [],
'benchmark_label' => null,
'benchmark_rates' => [],
'estimated_orders' => 0,
'estimated_mixed_amount' => 0.0,
'estimated_all_wan_amount' => 0.0,
@ -403,7 +330,7 @@ class InstallationFeeUsagePageData
'estimated_all_wan_unit_cost' => 0.0,
'switch_impact' => null,
'switch_impact_rate' => null,
'platforms' => [],
'vendors' => [],
];
}
@ -426,52 +353,27 @@ class InstallationFeeUsagePageData
/** @param list<int> $periodIndexes */
private function benchmarkRates(array $periods, array $periodIndexes): array
{
$platforms = [];
$rates = [
'wan' => ['reviewed_orders' => 0, 'settled_amount' => 0.0],
'luban' => ['reviewed_orders' => 0, 'settled_amount' => 0.0],
];
foreach ($periodIndexes as $periodIndex) {
foreach ($periods[$periodIndex]['platforms'] as $platform) {
foreach (['wan', 'luban'] as $vendorKey) {
$vendor = $platform['vendors'][$vendorKey];
$platforms[$platform['platform']][$vendorKey] ??= [
'reviewed_orders' => 0,
'settled_amount' => 0.0,
];
$platforms[$platform['platform']][$vendorKey]['reviewed_orders'] += (int) $vendor['reviewed_orders'];
$platforms[$platform['platform']][$vendorKey]['settled_amount'] += (float) $vendor['settled_amount'];
}
}
}
$companies = [];
foreach ($platforms as &$vendors) {
foreach ($vendors as $vendorKey => &$rate) {
$rate['rate'] = $this->unitCost($rate['settled_amount'], $rate['reviewed_orders']);
$companies[$vendorKey]['reviewed_orders'] = ($companies[$vendorKey]['reviewed_orders'] ?? 0)
+ $rate['reviewed_orders'];
$companies[$vendorKey]['settled_amount'] = ($companies[$vendorKey]['settled_amount'] ?? 0.0)
+ $rate['settled_amount'];
foreach ($rates as $vendorKey => &$rate) {
$vendor = $periods[$periodIndex]['vendors'][$vendorKey];
$rate['reviewed_orders'] += (int) $vendor['reviewed_orders'];
$rate['settled_amount'] += (float) $vendor['settled_amount'];
}
unset($rate);
}
unset($vendors);
foreach ($companies as &$company) {
$company['rate'] = $this->unitCost($company['settled_amount'], $company['reviewed_orders']);
}
unset($company);
return ['platforms' => $platforms, 'companies' => $companies];
}
private function benchmarkRate(array $rates, string $platform, string $vendorKey): ?float
{
$platformRate = $rates['platforms'][$platform][$vendorKey] ?? null;
if ($platformRate !== null && $platformRate['reviewed_orders'] >= 10) {
return $platformRate['rate'] > 0 ? (float) $platformRate['rate'] : null;
}
$companyRate = $rates['companies'][$vendorKey]['rate'] ?? null;
return $companyRate !== null && $companyRate > 0 ? (float) $companyRate : null;
return [
'wan' => $rates['wan']['reviewed_orders'] > 0
? $this->unitCost($rates['wan']['settled_amount'], $rates['wan']['reviewed_orders'])
: null,
'luban' => $rates['luban']['reviewed_orders'] > 0
? $this->unitCost($rates['luban']['settled_amount'], $rates['luban']['reviewed_orders'])
: null,
];
}
private function vendorKey(string $company): string

View File

@ -7,7 +7,7 @@
$error = $installationFeeUsageError ?? null;
$currentPeriod = $summary['latest_period'] ?? null;
$previousPeriod = $summary['previous_period'] ?? null;
$platformRows = $summary['platforms'] ?? [];
$vendorRows = $summary['vendors'] ?? [];
$moneyWan = static fn (mixed $value): string => number_format((float) $value / 10000, 2);
$money = static fn (mixed $value): string => number_format((float) $value, 2);
$percent = static fn (mixed $value): string => number_format((float) $value, 1);
@ -28,105 +28,97 @@
};
$switchImpact = $summary['switch_impact'] ?? null;
$switchImpactDisplay = $impact($switchImpact);
$currentPlatformOrders = (int) collect($platformRows)->sum('orders');
$currentWanOrders = (int) collect($platformRows)->sum('wan_orders');
$currentLubanOrders = (int) collect($platformRows)->sum('luban_orders');
$currentSettledAmount = (float) collect($platformRows)->sum('settled_amount');
$currentEstimatedAmount = (float) collect($platformRows)->sum(fn (array $row): float => (float) ($row['estimated_amount'] ?? 0));
$currentAllWanAmount = (float) collect($platformRows)->sum(fn (array $row): float => (float) ($row['all_wan_amount'] ?? 0));
$previousOrders = (int) collect($platformRows)->sum('previous_orders');
$previousSettledAmount = (float) collect($platformRows)->sum('previous_settled_amount');
$hasBenchmark = ! empty($summary['benchmark_periods']);
@endphp
<div class="installation-platform-page">
<div class="installation-company-page">
<style>
.installation-platform-page {
--ip-ink: var(--vip-content-ink, #171717);
--ip-muted: var(--vip-content-muted, #595959);
--ip-border: var(--vip-border, #d8d2c7);
--ip-surface: var(--vip-surface, #ffffff);
--ip-soft: var(--vip-content-accent-soft, #f7f0de);
--ip-accent: var(--vip-content-accent, #b9954f);
--ip-accent-dark: var(--vip-content-accent-dark, #856632);
--ip-success: var(--vip-success, #53793e);
--ip-warning: var(--vip-warning, #935f07);
color: var(--ip-ink);
.installation-company-page {
--ic-ink: var(--vip-content-ink, #171717);
--ic-muted: var(--vip-content-muted, #595959);
--ic-border: var(--vip-border, #d8d2c7);
--ic-surface: var(--vip-surface, #ffffff);
--ic-soft: var(--vip-content-accent-soft, #f7f0de);
--ic-accent: var(--vip-content-accent, #b9954f);
--ic-accent-dark: var(--vip-content-accent-dark, #856632);
--ic-success: var(--vip-success, #53793e);
--ic-warning: var(--vip-warning, #935f07);
color: var(--ic-ink);
font-family: "JetBrains Mono", "Microsoft YaHei", "PingFang SC", monospace;
font-size: 0.8125rem;
}
.installation-platform-toolbar {
.installation-company-toolbar {
display: flex;
align-items: flex-end;
justify-content: space-between;
gap: 1rem;
flex-wrap: wrap;
padding: 1rem;
border: 1px solid var(--ip-border);
border: 1px solid var(--ic-border);
border-radius: 0.5rem;
background: var(--ip-surface);
background: var(--ic-surface);
}
.installation-platform-toolbar__filters,
.installation-platform-toolbar__actions {
.installation-company-toolbar__filters,
.installation-company-toolbar__actions {
display: flex;
align-items: flex-end;
gap: 0.75rem;
flex-wrap: wrap;
}
.installation-platform-field,
.installation-platform-static {
.installation-company-field,
.installation-company-static {
display: flex;
min-width: 10rem;
flex-direction: column;
gap: 0.3rem;
}
.installation-platform-field span,
.installation-platform-static span {
color: var(--ip-muted);
.installation-company-field span,
.installation-company-static span {
color: var(--ic-muted);
font-size: 0.6875rem;
font-weight: 600;
}
.installation-platform-field select {
.installation-company-field select {
height: 2.125rem;
padding: 0 0.65rem;
border: 1px solid var(--ip-border);
border: 1px solid var(--ic-border);
border-radius: 0.5rem;
outline: none;
background: var(--ip-surface);
color: var(--ip-ink);
background: var(--ic-surface);
color: var(--ic-ink);
font: inherit;
}
.installation-platform-field select:focus {
border-color: var(--ip-accent-dark);
.installation-company-field select:focus {
border-color: var(--ic-accent-dark);
box-shadow: 0 0 0 3px rgba(133, 102, 50, 0.2);
}
.installation-platform-static strong {
.installation-company-static strong {
display: flex;
height: 2.125rem;
align-items: center;
color: var(--ip-ink);
color: var(--ic-ink);
font-size: 0.75rem;
font-weight: 500;
}
.installation-platform-button {
.installation-company-button {
display: inline-flex;
height: 2.125rem;
align-items: center;
justify-content: center;
gap: 0.35rem;
padding: 0 0.85rem;
border: 1px solid var(--ip-border);
border: 1px solid var(--ic-border);
border-radius: 0.5rem;
background: var(--ip-surface);
color: var(--ip-ink);
background: var(--ic-surface);
color: var(--ic-ink);
cursor: pointer;
font: inherit;
font-size: 0.75rem;
@ -134,18 +126,18 @@
text-decoration: none;
}
.installation-platform-button.is-primary {
border-color: var(--ip-accent-dark);
background: var(--ip-accent-dark);
.installation-company-button.is-primary {
border-color: var(--ic-accent-dark);
background: var(--ic-accent-dark);
color: #ffffff;
}
.installation-platform-button:focus-visible {
.installation-company-button:focus-visible {
outline: 3px solid rgba(133, 102, 50, 0.2);
outline-offset: 1px;
}
.installation-platform-alert {
.installation-company-alert {
margin-top: 0.75rem;
padding: 0.75rem 1rem;
border: 1px solid #b80000;
@ -155,36 +147,36 @@
font-size: 0.75rem;
}
.installation-platform-kpis {
.installation-company-kpis {
display: grid;
grid-template-columns: repeat(4, minmax(0, 1fr));
margin-top: 0.75rem;
border: 1px solid var(--ip-border);
border: 1px solid var(--ic-border);
border-radius: 0.5rem;
background: var(--ip-surface);
background: var(--ic-surface);
}
.installation-platform-kpi {
.installation-company-kpi {
min-width: 0;
padding: 0.9rem 1rem;
border-right: 1px solid var(--ip-border);
border-right: 1px solid var(--ic-border);
}
.installation-platform-kpi:last-child {
.installation-company-kpi:last-child {
border-right: 0;
}
.installation-platform-kpi > span {
.installation-company-kpi > span {
display: block;
color: var(--ip-muted);
color: var(--ic-muted);
font-size: 0.6875rem;
}
.installation-platform-kpi > strong {
.installation-company-kpi > strong {
display: block;
margin-top: 0.35rem;
overflow: hidden;
color: var(--ip-ink);
color: var(--ic-ink);
font-size: 1.25rem;
font-weight: 700;
font-variant-numeric: tabular-nums;
@ -193,88 +185,88 @@
white-space: nowrap;
}
.installation-platform-kpi > small {
.installation-company-kpi > small {
display: block;
margin-top: 0.25rem;
color: var(--ip-muted);
color: var(--ic-muted);
font-size: 0.6875rem;
line-height: 1.45;
}
.installation-platform-kpi .is-increase {
color: var(--ip-warning);
.installation-company-kpi .is-increase {
color: var(--ic-warning);
}
.installation-platform-kpi .is-saving {
color: var(--ip-success);
.installation-company-kpi .is-saving {
color: var(--ic-success);
}
.installation-platform-rules {
.installation-company-rules {
margin: 0.75rem 0 0;
padding: 0.7rem 0.9rem;
border: 1px solid var(--ip-border);
border-left: 3px solid var(--ip-accent);
border: 1px solid var(--ic-border);
border-left: 3px solid var(--ic-accent);
border-radius: 0.5rem;
background: var(--ip-soft);
color: var(--ip-muted);
background: var(--ic-soft);
color: var(--ic-muted);
font-size: 0.6875rem;
line-height: 1.65;
}
.installation-platform-card {
.installation-company-card {
margin-top: 0.75rem;
border: 1px solid var(--ip-border);
border: 1px solid var(--ic-border);
border-radius: 0.5rem;
background: var(--ip-surface);
background: var(--ic-surface);
}
.installation-platform-card__head {
.installation-company-card__head {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 0.75rem;
flex-wrap: wrap;
padding: 0.9rem 1rem;
border-bottom: 1px solid var(--ip-border);
border-bottom: 1px solid var(--ic-border);
}
.installation-platform-card__head strong {
.installation-company-card__head strong {
font-size: 0.8125rem;
}
.installation-platform-card__head span {
color: var(--ip-muted);
.installation-company-card__head span {
color: var(--ic-muted);
font-size: 0.6875rem;
}
.installation-platform-table-wrap {
max-height: 34rem;
.installation-company-table-wrap {
max-height: 32rem;
overflow: auto;
scrollbar-color: var(--ip-accent) #f1ece3;
scrollbar-color: var(--ic-accent) #f1ece3;
scrollbar-width: thin;
}
.installation-platform-table-wrap.is-monthly {
max-height: 28rem;
.installation-company-table-wrap.is-monthly {
max-height: 27rem;
}
.installation-platform-table {
.installation-company-table {
width: 100%;
border-collapse: collapse;
font-size: 0.75rem;
font-variant-numeric: tabular-nums;
}
.installation-platform-table.is-comparison {
min-width: 106rem;
.installation-company-table.is-current {
min-width: 68rem;
}
.installation-platform-table.is-monthly {
min-width: 62rem;
.installation-company-table.is-monthly {
min-width: 58rem;
}
.installation-platform-table th,
.installation-platform-table td {
.installation-company-table th,
.installation-company-table td {
padding: 0.65rem 0.7rem;
border-right: 1px solid #eee8dd;
border-bottom: 1px solid #eee8dd;
@ -282,72 +274,67 @@
vertical-align: middle;
}
.installation-platform-table th:last-child,
.installation-platform-table td:last-child {
.installation-company-table th:last-child,
.installation-company-table td:last-child {
border-right: 0;
}
.installation-platform-table thead th {
.installation-company-table thead th {
position: sticky;
top: 0;
z-index: 2;
background: var(--ip-soft);
color: var(--ip-muted);
background: var(--ic-soft);
color: var(--ic-muted);
font-size: 0.6875rem;
font-weight: 700;
white-space: nowrap;
}
.installation-platform-table tbody tr:hover td,
.installation-platform-table tfoot tr:hover td {
.installation-company-table tbody tr:hover td,
.installation-company-table tfoot tr:hover td {
background: #fcfaf4;
}
.installation-platform-table tfoot td {
.installation-company-table tfoot td {
background: #f8f4eb;
font-weight: 700;
}
.installation-platform-table .is-number {
.installation-company-table .is-number {
text-align: right;
white-space: nowrap;
}
.installation-platform-table .is-platform {
min-width: 5.25rem;
color: var(--ip-ink);
.installation-company-table .is-company {
min-width: 6rem;
color: var(--ic-ink);
font-weight: 700;
white-space: nowrap;
}
.installation-platform-table .is-muted {
color: var(--ip-muted);
white-space: nowrap;
}
.installation-platform-share {
.installation-company-share {
display: flex;
min-width: 7rem;
min-width: 8rem;
align-items: center;
gap: 0.45rem;
}
.installation-platform-share__track {
width: 3.75rem;
.installation-company-share__track {
width: 4rem;
height: 0.38rem;
overflow: hidden;
border-radius: 999px;
background: #e9e2d5;
}
.installation-platform-share__fill {
.installation-company-share__fill {
display: block;
height: 100%;
border-radius: inherit;
background: var(--ip-accent);
background: var(--ic-accent);
}
.installation-platform-impact {
.installation-company-impact {
display: inline-flex;
min-height: 1.45rem;
align-items: center;
@ -359,71 +346,71 @@
white-space: nowrap;
}
.installation-platform-impact.is-increase {
.installation-company-impact.is-increase {
background: #fff7e8;
color: var(--ip-warning);
color: var(--ic-warning);
}
.installation-platform-impact.is-saving {
.installation-company-impact.is-saving {
background: #f2f8ec;
color: var(--ip-success);
color: var(--ic-success);
}
.installation-platform-impact.is-neutral,
.installation-platform-impact.is-empty {
.installation-company-impact.is-neutral,
.installation-company-impact.is-empty {
background: #f5f3ee;
color: var(--ip-muted);
border-color: var(--ip-border);
color: var(--ic-muted);
border-color: var(--ic-border);
}
.installation-platform-empty {
.installation-company-empty {
padding: 2.5rem 1rem;
color: var(--ip-muted);
color: var(--ic-muted);
text-align: center;
}
@media (max-width: 900px) {
.installation-platform-kpis {
.installation-company-kpis {
grid-template-columns: repeat(2, minmax(0, 1fr));
}
.installation-platform-kpi:nth-child(2) {
.installation-company-kpi:nth-child(2) {
border-right: 0;
}
.installation-platform-kpi:nth-child(-n + 2) {
border-bottom: 1px solid var(--ip-border);
.installation-company-kpi:nth-child(-n + 2) {
border-bottom: 1px solid var(--ic-border);
}
}
@media (max-width: 600px) {
.installation-platform-toolbar,
.installation-platform-toolbar__filters,
.installation-platform-toolbar__actions,
.installation-platform-field,
.installation-platform-static {
.installation-company-toolbar,
.installation-company-toolbar__filters,
.installation-company-toolbar__actions,
.installation-company-field,
.installation-company-static {
width: 100%;
align-items: stretch;
}
.installation-platform-kpis {
.installation-company-kpis {
grid-template-columns: 1fr;
}
.installation-platform-kpi {
.installation-company-kpi {
border-right: 0;
border-bottom: 1px solid var(--ip-border);
border-bottom: 1px solid var(--ic-border);
}
.installation-platform-kpi:last-child {
.installation-company-kpi:last-child {
border-bottom: 0;
}
}
</style>
<form method="GET" class="installation-platform-toolbar" aria-label="安装费平台分析筛选">
<div class="installation-platform-toolbar__filters">
<label class="installation-platform-field">
<form method="GET" class="installation-company-toolbar" aria-label="安装费安装公司筛选">
<div class="installation-company-toolbar__filters">
<label class="installation-company-field">
<span>统计区间</span>
<select name="range">
@foreach ($rangeOptions as $value => $label)
@ -431,22 +418,22 @@
@endforeach
</select>
</label>
<div class="installation-platform-static">
<div class="installation-company-static">
<span>单量口径</span>
<strong>发货月份 · 安装主单去重</strong>
</div>
<div class="installation-platform-static">
<div class="installation-company-static">
<span>当前范围</span>
<strong>{{ $rangeLabel }}</strong>
</div>
</div>
<div class="installation-platform-toolbar__actions">
<button type="submit" class="installation-platform-button is-primary">
<div class="installation-company-toolbar__actions">
<button type="submit" class="installation-company-button is-primary">
<span class="material-icons-outlined" aria-hidden="true">search</span>
<span>查询</span>
</button>
<a
class="installation-platform-button"
class="installation-company-button"
href="{{ route('business.pages.show', ['section' => $section['slug'], 'page' => 'installation-details']) }}"
>
<span class="material-icons-outlined" aria-hidden="true">table_rows</span>
@ -456,32 +443,32 @@
</form>
@if ($error)
<div class="installation-platform-alert" role="alert">{{ $error }}</div>
<div class="installation-company-alert" role="alert">{{ $error }}</div>
@endif
@if (! $error)
<section class="installation-platform-kpis" aria-label="安装费平台分析指标">
<div class="installation-platform-kpi">
<section class="installation-company-kpis" aria-label="安装费安装公司分析指标">
<div class="installation-company-kpi">
<span>{{ $currentPeriod ?? '当前月' }} 安装单量</span>
<strong>{{ number_format((int) ($summary['current_orders'] ?? 0)) }} 单</strong>
<small>{{ $previousPeriod ?? '上月' }}:{{ number_format((int) ($summary['previous_orders'] ?? 0)) }} 单</small>
</div>
<div class="installation-platform-kpi">
<div class="installation-company-kpi">
<span>{{ $currentPeriod ?? '当前月' }} 已审核安装费</span>
<strong>¥{{ $moneyWan($summary['current_confirmed_amount'] ?? 0) }} 万</strong>
<small>仅已审核结算;{{ $previousPeriod ?? '上月' }}:¥{{ $moneyWan($summary['previous_confirmed_amount'] ?? 0) }} 万</small>
<small>{{ $previousPeriod ?? '上月' }}:¥{{ $moneyWan($summary['previous_confirmed_amount'] ?? 0) }} 万</small>
</div>
<div class="installation-platform-kpi">
<div class="installation-company-kpi">
<span>{{ $currentPeriod ?? '当前月' }} 审核覆盖</span>
<strong>{{ $percent($summary['current_review_rate'] ?? 0) }}%</strong>
<small>{{ number_format((int) ($summary['current_reviewed_orders'] ?? 0)) }} / {{ number_format((int) ($summary['current_orders'] ?? 0)) }} 单已审核</small>
</div>
<div class="installation-platform-kpi">
<div class="installation-company-kpi">
<span>供应商切换预估影响</span>
<strong class="{{ $switchImpactDisplay['class'] }}">{{ $switchImpactDisplay['text'] }}</strong>
<small>
@if ($hasBenchmark)
预估单均 ¥{{ $money($summary['estimated_mixed_unit_cost'] ?? 0) }}
预订单均 ¥{{ $money($summary['estimated_mixed_unit_cost'] ?? 0) }}
· 全万师傅 ¥{{ $money($summary['estimated_all_wan_unit_cost'] ?? 0) }}
@else
暂无完整审核基准
@ -490,105 +477,92 @@
</div>
</section>
<p class="installation-platform-rules">
单量按安装主单的发货月份统计;金额只计入客服审核通过的明细结算金额,未审核部分显示为待确认。
切换影响只做同平台、同单量预估:以最近两个“万师傅和鲁班审核覆盖率均不低于 70%”的月份为单均基准,
将当前平台单量分别按实际万师傅/鲁班占比和“全部万师傅”两种情况估算。正数为预计增加,负数为预计节省,
不是最终已结算结果。@if ($hasBenchmark) 当前基准:{{ $summary['benchmark_label'] }}。@endif
<p class="installation-company-rules">
单量按安装主单的发货月份统计,安装公司分为万师傅、鲁班系列和其他安装公司;金额只计入客服审核通过的明细结算金额。
切换影响按同单量预估:以最近两个“万师傅和鲁班审核覆盖率均不低于 70%”的月份为安装公司单均基准,
比较当前实际供应商占比与全部使用万师傅的预估成本。正数为预计增加,负数为预计节省,最终以审核结算为准。
@if ($hasBenchmark) 当前基准:{{ $summary['benchmark_label'] }}。@endif
</p>
<section class="installation-platform-card" aria-labelledby="installation-platform-comparison-title">
<div class="installation-platform-card__head">
<strong id="installation-platform-comparison-title">
{{ $currentPeriod ?? '当前月' }} · 平台安装费分析
</strong>
<section class="installation-company-card" aria-labelledby="installation-company-current-title">
<div class="installation-company-card__head">
<strong id="installation-company-current-title">{{ $currentPeriod ?? '当前月' }} · 安装公司费用分析</strong>
<span>{{ $previousPeriod ?? '上月' }} 对比 · 金额单位:元</span>
</div>
<div class="installation-platform-table-wrap">
<table class="installation-platform-table is-comparison">
<div class="installation-company-table-wrap">
<table class="installation-company-table is-current">
<thead>
<tr>
<th scope="col">平台</th>
<th scope="col">安装公司</th>
<th scope="col" class="is-number">{{ $currentPeriod ?? '当前月' }}单量</th>
<th scope="col" class="is-number">万师傅</th>
<th scope="col" class="is-number">鲁班系列</th>
<th scope="col">鲁班占比</th>
<th scope="col">单量占比</th>
<th scope="col" class="is-number">审核覆盖</th>
<th scope="col" class="is-number">已审核金额</th>
<th scope="col" class="is-number">已审核单均</th>
<th scope="col" class="is-number">基准万师傅单均</th>
<th scope="col" class="is-number">基准鲁班单均</th>
<th scope="col" class="is-number">实际占比预估金额</th>
<th scope="col" class="is-number">全万师傅预估金额</th>
<th scope="col">切换影响</th>
<th scope="col" class="is-number">基准单均</th>
<th scope="col" class="is-number">预估安装费</th>
<th scope="col" class="is-number">{{ $previousPeriod ?? '上月' }}单量</th>
<th scope="col" class="is-number">{{ $previousPeriod ?? '上月' }}已审核金额</th>
<th scope="col" class="is-number">{{ $previousPeriod ?? '上月' }}单均</th>
</tr>
</thead>
<tbody>
@forelse ($platformRows as $row)
@php($rowImpact = $impact($row['switch_impact'] ?? null))
@forelse ($vendorRows as $vendor)
<tr>
<td class="is-platform">{{ $row['platform'] }}</td>
<td class="is-number">{{ number_format((int) $row['orders']) }}</td>
<td class="is-number">{{ number_format((int) $row['wan_orders']) }}</td>
<td class="is-number">{{ number_format((int) $row['luban_orders']) }}</td>
<td class="is-company">{{ $vendor['label'] }}</td>
<td class="is-number">{{ number_format((int) $vendor['orders']) }}</td>
<td>
<div class="installation-platform-share">
<span>{{ $percent($row['luban_share'] ?? 0) }}%</span>
<span class="installation-platform-share__track" aria-hidden="true">
<span class="installation-platform-share__fill" style="width: {{ min(100, max(0, (float) ($row['luban_share'] ?? 0))) }}%"></span>
<div class="installation-company-share">
<span>{{ $percent($vendor['order_share'] ?? 0) }}%</span>
<span class="installation-company-share__track" aria-hidden="true">
<span class="installation-company-share__fill" style="width: {{ min(100, max(0, (float) ($vendor['order_share'] ?? 0))) }}%"></span>
</span>
</div>
</td>
<td class="is-number">
{{ $percent($row['review_rate'] ?? 0) }}%
<span class="is-muted">({{ number_format((int) ($row['reviewed_orders'] ?? 0)) }})</span>
{{ $percent($vendor['review_rate'] ?? 0) }}%
<span>({{ number_format((int) ($vendor['reviewed_orders'] ?? 0)) }})</span>
</td>
<td class="is-number">¥{{ $money($row['settled_amount'] ?? 0) }}</td>
<td class="is-number">¥{{ $money($row['confirmed_unit_cost'] ?? 0) }}</td>
<td class="is-number">¥{{ $money($vendor['settled_amount'] ?? 0) }}</td>
<td class="is-number">¥{{ $money($vendor['unit_cost'] ?? 0) }}</td>
<td class="is-number">
{{ $row['wan_benchmark_rate'] === null ? '—' : '¥' . $money($row['wan_benchmark_rate']) }}
{{ $vendor['benchmark_rate'] === null ? '—' : '¥' . $money($vendor['benchmark_rate']) }}
</td>
<td class="is-number">
{{ $row['luban_benchmark_rate'] === null ? '—' : '¥' . $money($row['luban_benchmark_rate']) }}
{{ $vendor['estimated_amount'] === null ? '—' : '¥' . $money($vendor['estimated_amount']) }}
</td>
<td class="is-number">
{{ $row['estimated_amount'] === null ? '—' : '¥' . $money($row['estimated_amount']) }}
</td>
<td class="is-number">
{{ $row['all_wan_amount'] === null ? '—' : '¥' . $money($row['all_wan_amount']) }}
</td>
<td>
<span class="installation-platform-impact {{ $rowImpact['class'] }}">{{ $rowImpact['text'] }}</span>
</td>
<td class="is-number">{{ number_format((int) ($row['previous_orders'] ?? 0)) }}</td>
<td class="is-number">¥{{ $money($row['previous_settled_amount'] ?? 0) }}</td>
<td class="is-number">{{ number_format((int) ($vendor['previous_orders'] ?? 0)) }}</td>
<td class="is-number">¥{{ $money($vendor['previous_settled_amount'] ?? 0) }}</td>
<td class="is-number">¥{{ $money($vendor['previous_unit_cost'] ?? 0) }}</td>
</tr>
@empty
<tr>
<td colspan="15" class="installation-platform-empty">所选期间暂无安装费平台数据。</td>
<td colspan="11" class="installation-company-empty">所选期间暂无安装公司数据。</td>
</tr>
@endforelse
</tbody>
@if ($platformRows !== [])
@if ($vendorRows !== [])
<tfoot>
<tr>
<td>合计</td>
<td class="is-number">{{ number_format($currentPlatformOrders) }}</td>
<td class="is-number">{{ number_format($currentWanOrders) }}</td>
<td class="is-number">{{ number_format($currentLubanOrders) }}</td>
<td>{{ $currentWanOrders + $currentLubanOrders > 0 ? $percent($currentLubanOrders / ($currentWanOrders + $currentLubanOrders) * 100) : '0.0' }}%</td>
<td class="is-number">{{ number_format((int) ($summary['current_orders'] ?? 0)) }}</td>
<td>100.0%</td>
<td class="is-number">{{ $percent($summary['current_review_rate'] ?? 0) }}%</td>
<td class="is-number">¥{{ $money($currentSettledAmount) }}</td>
<td class="is-number">¥{{ $money($summary['current_confirmed_amount'] ?? 0) }}</td>
<td class="is-number">¥{{ $money($summary['current_confirmed_unit_cost'] ?? 0) }}</td>
<td class="is-number">—</td>
<td class="is-number">—</td>
<td class="is-number">¥{{ $money($currentEstimatedAmount) }}</td>
<td class="is-number">¥{{ $money($currentAllWanAmount) }}</td>
<td><span class="installation-platform-impact {{ $switchImpactDisplay['class'] }}">{{ $switchImpactDisplay['text'] }}</span></td>
<td class="is-number">{{ number_format($previousOrders) }}</td>
<td class="is-number">¥{{ $money($previousSettledAmount) }}</td>
<td class="is-number">¥{{ $money($summary['estimated_mixed_amount'] ?? 0) }}</td>
<td class="is-number">{{ number_format((int) ($summary['previous_orders'] ?? 0)) }}</td>
<td class="is-number">¥{{ $money($summary['previous_confirmed_amount'] ?? 0) }}</td>
<td class="is-number">¥{{ $money($summary['previous_confirmed_unit_cost'] ?? 0) }}</td>
</tr>
<tr>
<td colspan="7">同样单量全部使用万师傅的预估成本</td>
<td class="is-number">¥{{ $money($summary['estimated_all_wan_amount'] ?? 0) }}</td>
<td colspan="3">
切换影响
<span class="installation-company-impact {{ $switchImpactDisplay['class'] }}">{{ $switchImpactDisplay['text'] }}</span>
</td>
</tr>
</tfoot>
@endif
@ -596,48 +570,51 @@
</div>
</section>
<section class="installation-platform-card" aria-labelledby="installation-platform-monthly-title">
<div class="installation-platform-card__head">
<strong id="installation-platform-monthly-title">逐月 · 逐平台安装单量与已审核金额</strong>
<section class="installation-company-card" aria-labelledby="installation-company-monthly-title">
<div class="installation-company-card__head">
<strong id="installation-company-monthly-title">逐月 · 各安装公司单量与已审核金额</strong>
<span>按发货月份;最近月份优先</span>
</div>
<div class="installation-platform-table-wrap is-monthly">
<table class="installation-platform-table is-monthly">
<div class="installation-company-table-wrap is-monthly">
<table class="installation-company-table is-monthly">
<thead>
<tr>
<th scope="col">月份</th>
<th scope="col">平台</th>
<th scope="col">安装公司</th>
<th scope="col" class="is-number">安装单量</th>
<th scope="col" class="is-number">万师傅</th>
<th scope="col" class="is-number">鲁班系列</th>
<th scope="col">单量占比</th>
<th scope="col" class="is-number">审核覆盖</th>
<th scope="col" class="is-number">已审核金额</th>
<th scope="col" class="is-number">已审核单均</th>
</tr>
</thead>
<tbody>
@forelse (array_reverse($periods) as $period)
@forelse ($period['platforms'] as $platform)
<tr>
<td class="is-platform">{{ $period['period'] }}</td>
<td>{{ $platform['platform'] }}</td>
<td class="is-number">{{ number_format((int) $platform['orders']) }}</td>
<td class="is-number">{{ number_format((int) ($platform['vendors']['wan']['orders'] ?? 0)) }}</td>
<td class="is-number">{{ number_format((int) ($platform['vendors']['luban']['orders'] ?? 0)) }}</td>
<td class="is-number">
{{ $percent($platform['review_rate']) }}%
<span class="is-muted">({{ number_format((int) $platform['reviewed_orders']) }})</span>
</td>
<td class="is-number">¥{{ $money($platform['settled_amount']) }}</td>
<td class="is-number">¥{{ $money($platform['unit_cost']) }}</td>
</tr>
@empty
@endforelse
@empty
@php($hasMonthlyRows = false)
@foreach (array_reverse($periods) as $period)
@foreach (['wan', 'luban', 'other'] as $vendorKey)
@php($vendor = $period['vendors'][$vendorKey])
@if ((int) $vendor['orders'] > 0)
@php($hasMonthlyRows = true)
<tr>
<td class="is-company">{{ $period['period'] }}</td>
<td>{{ $vendor['label'] }}</td>
<td class="is-number">{{ number_format((int) $vendor['orders']) }}</td>
<td>{{ $percent($vendor['order_share']) }}%</td>
<td class="is-number">
{{ $percent($vendor['review_rate']) }}%
<span>({{ number_format((int) $vendor['reviewed_orders']) }})</span>
</td>
<td class="is-number">¥{{ $money($vendor['settled_amount']) }}</td>
<td class="is-number">¥{{ $money($vendor['unit_cost']) }}</td>
</tr>
@endif
@endforeach
@endforeach
@if (! $hasMonthlyRows)
<tr>
<td colspan="8" class="installation-platform-empty">所选期间暂无平台安装数据。</td>
<td colspan="7" class="installation-company-empty">所选期间暂无安装公司数据。</td>
</tr>
@endforelse
@endif
</tbody>
</table>
</div>

View File

@ -491,19 +491,18 @@ class ManagementCrudTest extends FeatureTestCase
->assertJsonPath('change_rate', 25.0);
}
public function testInstallationFeeUsagePageShowsPlatformCostAndSwitchImpact(): void
public function testInstallationFeeUsagePageShowsCompanyCostAndSwitchImpact(): void
{
$previousMonth = now()->subMonthNoOverflow()->format('Y-m');
$currentMonth = now()->format('Y-m');
$benchmarkB = now()->subMonthsNoOverflow(3)->format('Y-m');
$benchmarkA = now()->subMonthsNoOverflow(2)->format('Y-m');
$mirror = Mockery::mock(InstallationDetailMirrorRepository::class);
$mirror->shouldReceive('platformFeeUsageTrend')->once()->andReturn([
$mirror->shouldReceive('installationCompanyFeeUsageTrend')->once()->andReturn([
'ready' => true,
'rows' => [
[
'period' => $benchmarkB,
'platform' => '淘系',
'installation_company' => '万师傅',
'orders' => 80,
'reviewed_orders' => 80,
@ -511,7 +510,6 @@ class ManagementCrudTest extends FeatureTestCase
],
[
'period' => $benchmarkB,
'platform' => '淘系',
'installation_company' => '鲁班到家',
'orders' => 20,
'reviewed_orders' => 20,
@ -519,7 +517,6 @@ class ManagementCrudTest extends FeatureTestCase
],
[
'period' => $benchmarkA,
'platform' => '淘系',
'installation_company' => '万师傅',
'orders' => 80,
'reviewed_orders' => 80,
@ -527,7 +524,6 @@ class ManagementCrudTest extends FeatureTestCase
],
[
'period' => $benchmarkA,
'platform' => '淘系',
'installation_company' => '鲁班到家',
'orders' => 20,
'reviewed_orders' => 20,
@ -535,7 +531,6 @@ class ManagementCrudTest extends FeatureTestCase
],
[
'period' => $previousMonth,
'platform' => '淘系',
'installation_company' => '万师傅',
'orders' => 80,
'reviewed_orders' => 80,
@ -543,7 +538,6 @@ class ManagementCrudTest extends FeatureTestCase
],
[
'period' => $previousMonth,
'platform' => '淘系',
'installation_company' => '鲁班到家',
'orders' => 20,
'reviewed_orders' => 0,
@ -551,7 +545,6 @@ class ManagementCrudTest extends FeatureTestCase
],
[
'period' => $currentMonth,
'platform' => '淘系',
'installation_company' => '万师傅',
'orders' => 50,
'reviewed_orders' => 50,
@ -559,7 +552,6 @@ class ManagementCrudTest extends FeatureTestCase
],
[
'period' => $currentMonth,
'platform' => '淘系',
'installation_company' => '鲁班到家',
'orders' => 50,
'reviewed_orders' => 0,
@ -577,16 +569,18 @@ class ManagementCrudTest extends FeatureTestCase
'range' => '6',
]))
->assertOk()
->assertSeeText('平台安装费分析')
->assertSeeText('安装公司费用分析')
->assertSeeText('万师傅')
->assertSeeText('鲁班系列')
->assertSeeText('供应商切换预估影响')
->assertSeeText('增加 ¥500.00')
->assertSeeText('实际占比预估金额')
->assertSeeText('全万师傅预估金额')
->assertSeeText('同样单量全部使用万师傅的预估成本')
->assertSeeText('审核覆盖')
->assertSeeText('50.0%')
->assertSeeText('当前基准')
->assertSeeText('不是最终已结算结果')
->assertSeeText('逐月 · 逐平台安装单量与已审核金额');
->assertSeeText('最终以审核结算为准')
->assertSeeText('逐月 · 各安装公司单量与已审核金额')
->assertDontSeeText('平台安装费分析');
}
public function testLegacyStandaloneInstallationFeeSummaryRedirectsToSubpage(): void

View File

@ -166,7 +166,7 @@ class InstallationDetailMirrorRepositoryTest extends TestCase
$this->assertSame(100.0,$result['change_rate']);
}
public function test_platform_fee_usage_trend_counts_orders_and_reviewed_amounts(): void
public function test_installation_company_fee_usage_trend_counts_orders_and_reviewed_amounts(): void
{
DB::connection('business_mirror')->table('fixture_install')->insert([
['Id'=>210,'SourceGuid'=>'trend-wan-1','OrderNum'=>'WAN-1','shop_name'=>'天猫-测试店','SubmitTime'=>'2026-06-01','ShipTIme'=>'2026-06-02','installCompanyName'=>'万师傅'],
@ -187,26 +187,22 @@ class InstallationDetailMirrorRepositoryTest extends TestCase
['Id'=>316,'guid'=>'trend-luban-3','shopproid'=>'P7','kfshTime'=>'2026-07-12 10:00:00','settleItemAmount'=>30.00],
]);
$result = $this->repository->platformFeeUsageTrend('2026-06', '2026-07');
$result = $this->repository->installationCompanyFeeUsageTrend('2026-06', '2026-07');
$rows = collect($result['rows'])->keyBy(
static fn (array $row): string => $row['period'] . '|' . $row['platform'] . '|' . $row['installation_company'],
static fn (array $row): string => $row['period'] . '|' . $row['installation_company'],
);
$this->assertTrue($result['ready']);
$this->assertSame(1, $rows['2026-06|淘系|万师傅']['orders']);
$this->assertSame(1, $rows['2026-06|淘系|万师傅']['reviewed_orders']);
$this->assertSame(30.0, $rows['2026-06|淘系|万师傅']['settled_amount']);
$this->assertSame(1, $rows['2026-06|京东|万师傅']['orders']);
$this->assertSame(40.0, $rows['2026-06|京东|万师傅']['settled_amount']);
$this->assertSame(1, $rows['2026-06|拼多多|鲁班到家']['orders']);
$this->assertSame(25.0, $rows['2026-06|拼多多|鲁班到家']['settled_amount']);
$this->assertSame(1, $rows['2026-07|淘系|鲁班到家']['orders']);
$this->assertSame(0, $rows['2026-07|淘系|鲁班到家']['reviewed_orders']);
$this->assertSame(0.0, $rows['2026-07|淘系|鲁班到家']['settled_amount']);
$this->assertSame(1, $rows['2026-07|抖音|鲁班到家']['reviewed_orders']);
$this->assertSame(20.0, $rows['2026-07|抖音|鲁班到家']['settled_amount']);
$this->assertSame(1, $rows['2026-07|淘系|鲁班大师']['reviewed_orders']);
$this->assertSame(30.0, $rows['2026-07|淘系|鲁班大师']['settled_amount']);
$this->assertSame(2, $rows['2026-06|万师傅']['orders']);
$this->assertSame(2, $rows['2026-06|万师傅']['reviewed_orders']);
$this->assertSame(70.0, $rows['2026-06|万师傅']['settled_amount']);
$this->assertSame(1, $rows['2026-06|鲁班到家']['orders']);
$this->assertSame(25.0, $rows['2026-06|鲁班到家']['settled_amount']);
$this->assertSame(2, $rows['2026-07|鲁班到家']['orders']);
$this->assertSame(1, $rows['2026-07|鲁班到家']['reviewed_orders']);
$this->assertSame(20.0, $rows['2026-07|鲁班到家']['settled_amount']);
$this->assertSame(1, $rows['2026-07|鲁班大师']['reviewed_orders']);
$this->assertSame(30.0, $rows['2026-07|鲁班大师']['settled_amount']);
}
public function test_monthly_settlement_buckets_only_include_approved_customer_reviews(): void