diff --git a/app/Business/ServiceCompanyReconciliation/ServiceCompanyReconciliationRepository.php b/app/Business/ServiceCompanyReconciliation/ServiceCompanyReconciliationRepository.php index dad43ede..0ca25cde 100644 --- a/app/Business/ServiceCompanyReconciliation/ServiceCompanyReconciliationRepository.php +++ b/app/Business/ServiceCompanyReconciliation/ServiceCompanyReconciliationRepository.php @@ -96,6 +96,22 @@ class ServiceCompanyReconciliationRepository ->sum('service_fee'); $invoiceAmount = (float) $companySettlements->sum('invoice_amount'); $paidAmount = (float) $companySettlements->sum('paid_amount'); + $fixedFeeRatePercent = self::fixedFeeRatePercent((string) $company->service_type_code); + $relationFeeRates = $companyRelations + ->pluck('fee_rate') + ->map(static fn ($rate): float => round((float) $rate * 100, 4)) + ->unique() + ->sort() + ->values(); + $settlementRateLabel = $fixedFeeRatePercent !== null + ? self::feeRatePercentLabel($fixedFeeRatePercent) + : ($relationFeeRates->isEmpty() + ? '—' + : ($relationFeeRates->count() === 1 + ? self::feeRatePercentLabel((float) $relationFeeRates->first()) + : self::feeRatePercentLabel((float) $relationFeeRates->first()) + . '–' + . self::feeRatePercentLabel((float) $relationFeeRates->last()))); $hasOpenInvoice = $companySettlements->contains( static fn ($row): bool => ! in_array((string) $row->invoice_status, ['invoiced', 'waived'], true), ); @@ -124,6 +140,7 @@ class ServiceCompanyReconciliationRepository 'labor_cost' => $laborCost, 'relation_count' => $companyRelations->count(), 'base_amount' => (float) $companySettlements->sum('base_amount'), + 'settlement_rate_label' => $settlementRateLabel, 'settlement_amount' => $settlementAmount, 'confirmed_amount' => $confirmedAmount, 'invoice_amount' => $invoiceAmount, @@ -1059,6 +1076,11 @@ class ServiceCompanyReconciliationRepository return self::FIXED_FEE_RATES_PERCENT[$serviceTypeCode] ?? null; } + private static function feeRatePercentLabel(float $percent): string + { + return rtrim(rtrim(number_format($percent, 4, '.', ''), '0'), '.') . '%'; + } + private function serviceTypeCodeFromLabel(string $label): string { if (mb_stripos($label, '客服') !== false) { diff --git a/resources/views/business/pages/financial-operations/service-company-reconciliation.blade.php b/resources/views/business/pages/financial-operations/service-company-reconciliation.blade.php index 54a71442..b8ef7220 100644 --- a/resources/views/business/pages/financial-operations/service-company-reconciliation.blade.php +++ b/resources/views/business/pages/financial-operations/service-company-reconciliation.blade.php @@ -280,6 +280,71 @@ font-size: 12px; } + .svc-table--companies { + min-width: 1280px; + table-layout: fixed; + } + + .svc-table--companies th:nth-child(1), + .svc-table--companies td:nth-child(1) { + width: 250px; + } + + .svc-table--companies th:nth-child(2), + .svc-table--companies td:nth-child(2) { + width: 100px; + } + + .svc-table--companies th:nth-child(3), + .svc-table--companies td:nth-child(3) { + width: 110px; + } + + .svc-table--companies th:nth-child(4), + .svc-table--companies td:nth-child(4) { + width: 100px; + } + + .svc-table--companies th:nth-child(5), + .svc-table--companies td:nth-child(5) { + width: 75px; + } + + .svc-table--companies th:nth-child(6), + .svc-table--companies td:nth-child(6) { + width: 70px; + } + + .svc-table--companies th:nth-child(7), + .svc-table--companies td:nth-child(7) { + width: 110px; + } + + .svc-table--companies th:nth-child(8), + .svc-table--companies td:nth-child(8) { + width: 70px; + } + + .svc-table--companies th:nth-child(9), + .svc-table--companies td:nth-child(9) { + width: 90px; + } + + .svc-table--companies th:nth-child(10), + .svc-table--companies td:nth-child(10) { + width: 105px; + } + + .svc-table--companies th:nth-child(11), + .svc-table--companies td:nth-child(11) { + width: 140px; + } + + .svc-table--companies th:nth-child(12), + .svc-table--companies td:nth-child(12) { + width: 90px; + } + .svc-table th { padding: 10px 12px; border-bottom: 1px solid var(--svc-border); @@ -783,7 +848,7 @@ @else
| 公司名称 | @@ -794,7 +859,7 @@当前人数 | 人员工资快照 | 店铺公司 | -结算基数 | +结算比例 | 服务收入 | 开票 / 到账 | 对账状态 | @@ -820,7 +885,7 @@{{ number_format($company['people_count']) }} | ¥{{ $wan($company['labor_cost']) }} | {{ number_format($company['relation_count']) }} | -¥{{ $wan($company['base_amount']) }} | +{{ $company['settlement_rate_label'] }} | ¥{{ $wan($company['settlement_amount']) }} | {{ $company['invoice_label'] }} / {{ $company['payment_label'] }} | diff --git a/tests/Feature/Business/ServiceCompanyReconciliationTest.php b/tests/Feature/Business/ServiceCompanyReconciliationTest.php index 52de0c99..9968ff47 100644 --- a/tests/Feature/Business/ServiceCompanyReconciliationTest.php +++ b/tests/Feature/Business/ServiceCompanyReconciliationTest.php @@ -69,6 +69,7 @@ SQL); $this->loginAs() ->get(route('business.service-company-reconciliation.index')) ->assertOk() + ->assertSee('class="svc-table svc-table--companies"', false) ->assertSeeText('常州测试仓储服务有限公司') ->assertSeeText('常州测试客服服务有限公司') ->assertSeeText('常州测试运营服务有限公司') @@ -80,6 +81,9 @@ SQL); ' | 税务类型 | ', '工商类型 | ', ], false) + ->assertSee('结算比例 | ', false) + ->assertDontSee('结算基数 | ', false) + ->assertSeeText('1.5%') ->assertDontSeeText('上海测试科技有限公司'); $types = DB::connection('business_mirror') @@ -259,6 +263,10 @@ SQL); ->where('service_company_id', $serviceCompanyId) ->value('fee_rate'), ); + $this->get(route('business.service-company-reconciliation.index')) + ->assertOk() + ->assertSeeText('2%') + ->assertDontSeeText('结算基数'); } public function test_same_store_company_and_service_type_cannot_have_overlapping_service_companies(): void
|---|