fix: 服务公司总览展示结算比例并收紧首列 #1091

Merged
DoDo merged 2 commits from fix/dodo-service-company-rate-display into main 2026-11-11 17:25:43 +08:00
3 changed files with 98 additions and 3 deletions

View File

@ -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) {

View File

@ -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 @@
</div>
@else
<div class="svc-table-wrap">
<table class="svc-table">
<table class="svc-table svc-table--companies">
<thead>
<tr>
<th>公司名称</th>
@ -794,7 +859,7 @@
<th class="is-number">当前人数</th>
<th class="is-number">人员工资快照</th>
<th class="is-number">店铺公司</th>
<th class="is-number">结算基数</th>
<th class="is-number">结算比例</th>
<th class="is-number">服务收入</th>
<th>开票 / 到账</th>
<th>对账状态</th>
@ -820,7 +885,7 @@
<td class="is-number">{{ number_format($company['people_count']) }}</td>
<td class="is-number">¥{{ $wan($company['labor_cost']) }}</td>
<td class="is-number">{{ number_format($company['relation_count']) }}</td>
<td class="is-number">¥{{ $wan($company['base_amount']) }}</td>
<td class="is-number">{{ $company['settlement_rate_label'] }}</td>
<td class="is-number"><strong>¥{{ $wan($company['settlement_amount']) }}</strong></td>
<td>{{ $company['invoice_label'] }} / {{ $company['payment_label'] }}</td>
<td>

View File

@ -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);
'<th>税务类型</th>',
'<th>工商类型</th>',
], false)
->assertSee('<th class="is-number">结算比例</th>', false)
->assertDontSee('<th class="is-number">结算基数</th>', 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