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 @@
- 单量按安装主单的发货月份统计,安装公司分为万师傅、鲁班系列和其他安装公司;金额只计入客服审核通过的明细结算金额。 - 切换影响按同单量预估:以最近两个“万师傅和鲁班审核覆盖率均不低于 70%”的月份为安装公司单均基准, - 比较当前实际供应商占比与全部使用万师傅的预估成本。正数为预计增加,负数为预计节省,最终以审核结算为准。 - @if ($hasBenchmark) 当前基准:{{ $summary['benchmark_label'] }}。@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'] }} - | -||||||||
| 月份 | -安装公司 | 安装单量 | -单量占比 | -审核覆盖 | -已审核金额 | -已审核单均 | +万师傅 | +鲁班系列 | +其他安装公司 | +预估安装费 | +单均 | +安装费环比 | ||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {{ $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']) }} | + @foreach (['wan', 'luban', 'other'] as $vendorKey) + @php($vendor = $period['vendors'][$vendorKey]) ++ @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 + | + + @endif + @empty|||||||
| 所选期间暂无安装公司数据。 | +所选期间暂无安装公司数据。 | |||||||||||||