From d112d90ed9d9aa4eee2caae247ebb1b27b335173 Mon Sep 17 00:00:00 2001 From: yueyang <2495544247@qq.com> Date: Thu, 26 Nov 2026 17:51:46 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AE=89=E8=A3=85=E8=B4=B9=E7=94=A8?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E6=9C=88=E5=BA=A6=E5=AE=89=E8=A3=85=E5=85=AC?= =?UTF-8?q?=E5=8F=B8=E5=AF=B9=E6=AF=94=20(#1483)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/InstallationFeeUsagePageData.php | 55 ++++- .../installation-fee-usage.blade.php | 219 +++++++----------- tests/Feature/Business/ManagementCrudTest.php | 15 +- 3 files changed, 148 insertions(+), 141 deletions(-) diff --git a/modules/EcommerceFinance/View/InstallationFeeUsagePageData.php b/modules/EcommerceFinance/View/InstallationFeeUsagePageData.php index 66c125a8..19e35d5d 100644 --- a/modules/EcommerceFinance/View/InstallationFeeUsagePageData.php +++ b/modules/EcommerceFinance/View/InstallationFeeUsagePageData.php @@ -59,6 +59,8 @@ class InstallationFeeUsagePageData } $periods = $this->buildPeriods($fromMonth, $toMonth, $result['rows']); + $summary = $this->buildSummary($periods); + $periods = $this->applyComparableCosts($periods, $summary['benchmark_rates']); return $this->payload( $range, @@ -66,7 +68,7 @@ class InstallationFeeUsagePageData $fromMonth, $toMonth, $periods, - $this->buildSummary($periods), + $summary, ); } @@ -334,6 +336,57 @@ class InstallationFeeUsagePageData ]; } + /** @param array{wan:?float,luban:?float} $rates */ + private function applyComparableCosts(array $periods, array $rates): array + { + $previousTotal = null; + $previousOrders = null; + foreach ($periods as &$period) { + $periodTotal = 0.0; + $hasEstimatedCost = false; + foreach ($period['vendors'] as &$vendor) { + $rate = $rates[$vendor['key']] ?? null; + if ($rate === null) { + $vendor['comparable_amount'] = null; + $vendor['comparable_unit_cost'] = null; + continue; + } + + $amount = round($vendor['orders'] * $rate, 2); + $vendor['comparable_amount'] = $amount; + $vendor['comparable_unit_cost'] = $this->unitCost($amount, $vendor['orders']); + $periodTotal += $amount; + $hasEstimatedCost = true; + } + unset($vendor); + + $period['comparable_amount'] = $hasEstimatedCost ? round($periodTotal, 2) : null; + $period['comparable_unit_cost'] = $period['comparable_amount'] === null + ? null + : $this->unitCost($period['comparable_amount'], $period['total_orders']); + $period['fee_change_rate'] = $period['comparable_amount'] !== null + && $previousTotal !== null + && $previousTotal > 0 + ? round((($period['comparable_amount'] - $previousTotal) / $previousTotal) * 100, 1) + : null; + $period['order_change_rate'] = $period['total_orders'] > 0 + && $previousOrders !== null + && $previousOrders > 0 + ? round((($period['total_orders'] - $previousOrders) / $previousOrders) * 100, 1) + : null; + + if ($period['comparable_amount'] !== null) { + $previousTotal = $period['comparable_amount']; + } + if ($period['total_orders'] > 0) { + $previousOrders = $period['total_orders']; + } + } + unset($period); + + return $periods; + } + private function isCompleteReviewPeriod(array $period): bool { if ($period['total_orders'] <= 0) { diff --git a/resources/views/business/pages/financial-operations/installation-fee-usage.blade.php b/resources/views/business/pages/financial-operations/installation-fee-usage.blade.php index 54fdf8dc..b6f8bac7 100644 --- a/resources/views/business/pages/financial-operations/installation-fee-usage.blade.php +++ b/resources/views/business/pages/financial-operations/installation-fee-usage.blade.php @@ -7,7 +7,6 @@ $error = $installationFeeUsageError ?? null; $currentPeriod = $summary['latest_period'] ?? null; $previousPeriod = $summary['previous_period'] ?? null; - $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); @@ -312,6 +311,30 @@ white-space: nowrap; } + .installation-company-table .is-muted, + .installation-company-value { + display: block; + margin-top: 0.15rem; + color: var(--ic-muted); + font-size: 0.6875rem; + line-height: 1.45; + white-space: nowrap; + } + + .installation-company-pill { + display: inline-flex; + align-items: center; + min-height: 1.35rem; + margin-left: 0.3rem; + padding: 0 0.38rem; + border: 1px solid rgba(133, 102, 50, 0.36); + border-radius: 999px; + color: var(--ic-accent-dark); + font-size: 0.625rem; + font-weight: 600; + vertical-align: middle; + } + .installation-company-share { display: flex; min-width: 8rem; @@ -451,170 +474,102 @@
{{ $currentPeriod ?? '当前月' }} 安装单量 {{ number_format((int) ($summary['current_orders'] ?? 0)) }} 单 - {{ $previousPeriod ?? '上月' }}:{{ number_format((int) ($summary['previous_orders'] ?? 0)) }} 单 + 万师傅 {{ number_format((int) ($summary['vendors'][0]['orders'] ?? 0)) }} 单 · 鲁班 {{ number_format((int) ($summary['vendors'][1]['orders'] ?? 0)) }} 单
- {{ $currentPeriod ?? '当前月' }} 已审核安装费 - ¥{{ $moneyWan($summary['current_confirmed_amount'] ?? 0) }} 万 - {{ $previousPeriod ?? '上月' }}:¥{{ $moneyWan($summary['previous_confirmed_amount'] ?? 0) }} 万 + {{ $currentPeriod ?? '当前月' }} 预估安装费 + ¥{{ $moneyWan($summary['estimated_mixed_amount'] ?? 0) }} 万 + 按安装公司基准单均折算全部发货单
- {{ $currentPeriod ?? '当前月' }} 审核覆盖 - {{ $percent($summary['current_review_rate'] ?? 0) }}% - {{ number_format((int) ($summary['current_reviewed_orders'] ?? 0)) }} / {{ number_format((int) ($summary['current_orders'] ?? 0)) }} 单已审核 + {{ $currentPeriod ?? '当前月' }} 预估单均 + ¥{{ $money($summary['estimated_mixed_unit_cost'] ?? 0) }} + 预估安装费 ÷ 可识别安装单量
- 供应商切换预估影响 + 切换安装公司影响 {{ $switchImpactDisplay['text'] }} @if ($hasBenchmark) - 预订单均 ¥{{ $money($summary['estimated_mixed_unit_cost'] ?? 0) }} - · 全万师傅 ¥{{ $money($summary['estimated_all_wan_unit_cost'] ?? 0) }} + 全万师傅预估 ¥{{ $moneyWan($summary['estimated_all_wan_amount'] ?? 0) }} 万 + · 基准 {{ $summary['benchmark_label'] }} @else - 暂无完整审核基准 + 暂无可用基准 @endif

- 单量按安装主单的发货月份统计,安装公司分为万师傅、鲁班系列和其他安装公司;金额只计入客服审核通过的明细结算金额。 - 切换影响按同单量预估:以最近两个“万师傅和鲁班审核覆盖率均不低于 70%”的月份为安装公司单均基准, - 比较当前实际供应商占比与全部使用万师傅的预估成本。正数为预计增加,负数为预计节省,最终以审核结算为准。 - @if ($hasBenchmark) 当前基准:{{ $summary['benchmark_label'] }}。@endif + 单量按发货月份汇总,安装公司分为万师傅、鲁班系列和其他安装公司。为了让每个月可以横向比较, + 安装费统一按最近两个完整月份的公司单均乘以当月各公司实际单量进行预估,不再区分审核和未审核。 + 切换影响是当前供应商占比与“全部使用万师傅”的预估差额,最终金额以结算为准。

-
-
- {{ $currentPeriod ?? '当前月' }} · 安装公司费用分析 - {{ $previousPeriod ?? '上月' }} 对比 · 金额单位:元 -
-
- - - - - - - - - - - - - - - - - - @forelse ($vendorRows as $vendor) - - - - - - - - - - - - - - @empty - - - - @endforelse - - @if ($vendorRows !== []) - - - - - - - - - - - - - - - - - - - - - @endif -
安装公司{{ $currentPeriod ?? '当前月' }}单量单量占比审核覆盖已审核金额已审核单均基准单均预估安装费{{ $previousPeriod ?? '上月' }}单量{{ $previousPeriod ?? '上月' }}已审核金额{{ $previousPeriod ?? '上月' }}单均
{{ $vendor['label'] }}{{ number_format((int) $vendor['orders']) }} -
- {{ $percent($vendor['order_share'] ?? 0) }}% - -
-
- {{ $percent($vendor['review_rate'] ?? 0) }}% - ({{ number_format((int) ($vendor['reviewed_orders'] ?? 0)) }}) - ¥{{ $money($vendor['settled_amount'] ?? 0) }}¥{{ $money($vendor['unit_cost'] ?? 0) }} - {{ $vendor['benchmark_rate'] === null ? '—' : '¥' . $money($vendor['benchmark_rate']) }} - - {{ $vendor['estimated_amount'] === null ? '—' : '¥' . $money($vendor['estimated_amount']) }} - {{ number_format((int) ($vendor['previous_orders'] ?? 0)) }}¥{{ $money($vendor['previous_settled_amount'] ?? 0) }}¥{{ $money($vendor['previous_unit_cost'] ?? 0) }}
所选期间暂无安装公司数据。
合计{{ number_format((int) ($summary['current_orders'] ?? 0)) }}100.0%{{ $percent($summary['current_review_rate'] ?? 0) }}%¥{{ $money($summary['current_confirmed_amount'] ?? 0) }}¥{{ $money($summary['current_confirmed_unit_cost'] ?? 0) }}—¥{{ $money($summary['estimated_mixed_amount'] ?? 0) }}{{ number_format((int) ($summary['previous_orders'] ?? 0)) }}¥{{ $money($summary['previous_confirmed_amount'] ?? 0) }}¥{{ $money($summary['previous_confirmed_unit_cost'] ?? 0) }}
同样单量全部使用万师傅的预估成本¥{{ $money($summary['estimated_all_wan_amount'] ?? 0) }} - 切换影响 - {{ $switchImpactDisplay['text'] }} -
-
-
-
- 逐月 · 各安装公司单量与已审核金额 - 按发货月份;最近月份优先 + 月度安装费对比 + 按安装公司区分 · 最近月份优先
- - - - - + + + + + + - @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) - - - - - - + + + @foreach (['wan', 'luban', 'other'] as $vendorKey) + @php($vendor = $period['vendors'][$vendorKey]) + - - - - @endif - @endforeach - @endforeach - @if (! $hasMonthlyRows) + @endforeach + + + + + @endif + @empty - + - @endif + @endforelse
月份安装公司 安装单量单量占比审核覆盖已审核金额已审核单均万师傅鲁班系列其他安装公司预估安装费单均安装费环比
{{ $period['period'] }}{{ $vendor['label'] }}{{ number_format((int) $vendor['orders']) }}{{ $percent($vendor['order_share']) }}% - {{ $percent($vendor['review_rate']) }}% - ({{ number_format((int) $vendor['reviewed_orders']) }}) + @forelse (array_reverse($periods) as $period) + @if ((int) $period['total_orders'] > 0) +
+ {{ $period['period'] }} + @if ($period['period'] === $currentPeriod) + 当前 + @endif + {{ number_format((int) $period['total_orders']) }} + @if ($vendor['comparable_amount'] === null) + {{ number_format((int) $vendor['orders']) }} 单 · {{ $percent($vendor['order_share']) }}% + 暂无预估 + @else + {{ number_format((int) $vendor['orders']) }} 单 · {{ $percent($vendor['order_share']) }}% + ¥{{ $money($vendor['comparable_amount']) }} · 单均 ¥{{ $money($vendor['comparable_unit_cost']) }} + @endif ¥{{ $money($vendor['settled_amount']) }}¥{{ $money($vendor['unit_cost']) }}
+ {{ $period['comparable_amount'] === null ? '—' : '¥' . $money($period['comparable_amount']) }} + + {{ $period['comparable_unit_cost'] === null ? '—' : '¥' . $money($period['comparable_unit_cost']) }} + + @if ($period['fee_change_rate'] === null) + — + @else + + {{ $period['fee_change_rate'] > 0 ? '+' : '' }}{{ $percent($period['fee_change_rate']) }}% + + @endif +
所选期间暂无安装公司数据。所选期间暂无安装公司数据。
diff --git a/tests/Feature/Business/ManagementCrudTest.php b/tests/Feature/Business/ManagementCrudTest.php index 970eef7c..03815fa2 100644 --- a/tests/Feature/Business/ManagementCrudTest.php +++ b/tests/Feature/Business/ManagementCrudTest.php @@ -569,17 +569,16 @@ class ManagementCrudTest extends FeatureTestCase 'range' => '6', ])) ->assertOk() - ->assertSeeText('安装公司费用分析') + ->assertSeeText('月度安装费对比') ->assertSeeText('万师傅') ->assertSeeText('鲁班系列') - ->assertSeeText('供应商切换预估影响') + ->assertSeeText('切换安装公司影响') ->assertSeeText('增加 ¥500.00') - ->assertSeeText('同样单量全部使用万师傅的预估成本') - ->assertSeeText('审核覆盖') - ->assertSeeText('50.0%') - ->assertSeeText('当前基准') - ->assertSeeText('最终以审核结算为准') - ->assertSeeText('逐月 · 各安装公司单量与已审核金额') + ->assertSeeText('预估安装费') + ->assertSeeText('安装费环比') + ->assertSeeText('不再区分审核和未审核') + ->assertSeeText('最终金额以结算为准') + ->assertDontSeeText('审核覆盖') ->assertDontSeeText('平台安装费分析'); }