diff --git a/app/Business/ServiceCompanyReconciliation/ServiceCompanyReconciliationRepository.php b/app/Business/ServiceCompanyReconciliation/ServiceCompanyReconciliationRepository.php index 1f82df39..dad43ede 100644 --- a/app/Business/ServiceCompanyReconciliation/ServiceCompanyReconciliationRepository.php +++ b/app/Business/ServiceCompanyReconciliation/ServiceCompanyReconciliationRepository.php @@ -24,6 +24,10 @@ class ServiceCompanyReconciliationRepository 'settlement_income' => '业绩明细收入(不减退款)', ]; + public const FIXED_FEE_RATES_PERCENT = [ + 'customer_service' => 1.5, + ]; + private readonly ConnectionInterface $connection; public function __construct(DatabaseManager $database) @@ -523,6 +527,17 @@ class ServiceCompanyReconciliationRepository if ($feeRatePercent < 0 || $feeRatePercent > 100) { throw ValidationException::withMessages(['fee_rate_percent' => '结算比例必须在 0% 到 100% 之间。']); } + $fixedFeeRatePercent = self::fixedFeeRatePercent((string) $company['service_type_code']); + if ($fixedFeeRatePercent !== null + && abs($feeRatePercent - $fixedFeeRatePercent) > 0.000001) { + throw ValidationException::withMessages([ + 'fee_rate_percent' => sprintf( + '%s的结算比例固定为 %s%%。', + self::SERVICE_TYPES[(string) $company['service_type_code']], + rtrim(rtrim(number_format($fixedFeeRatePercent, 4, '.', ''), '0'), '.'), + ), + ]); + } $payload = [ 'service_company_key' => (string) $company['company_key'], @@ -1039,6 +1054,11 @@ class ServiceCompanyReconciliationRepository return $text === '' ? null : mb_substr($text, 0, $length); } + public static function fixedFeeRatePercent(string $serviceTypeCode): ?float + { + return self::FIXED_FEE_RATES_PERCENT[$serviceTypeCode] ?? null; + } + private function serviceTypeCodeFromLabel(string $label): string { if (mb_stripos($label, '客服') !== false) { diff --git a/app/Http/Controllers/Business/ServiceCompanyReconciliation.php b/app/Http/Controllers/Business/ServiceCompanyReconciliation.php index eed32d67..ad55f26f 100644 --- a/app/Http/Controllers/Business/ServiceCompanyReconciliation.php +++ b/app/Http/Controllers/Business/ServiceCompanyReconciliation.php @@ -41,6 +41,7 @@ class ServiceCompanyReconciliation extends Controller 'storeCompanies' => [], 'serviceTypes' => ServiceCompanyReconciliationRepository::SERVICE_TYPES, 'baseMetrics' => ServiceCompanyReconciliationRepository::BASE_METRICS, + 'fixedFeeRatePercent' => null, 'companyDirectory' => $this->repository->companyDirectory(), 'companyPlanSyncError' => $companyPlanSyncError, 'canEdit' => FinanceLedgerAccess::canEditMapping(user()), @@ -94,6 +95,9 @@ class ServiceCompanyReconciliation extends Controller 'storeCompanies' => $this->repository->storeCompanies($tenantId), 'serviceTypes' => ServiceCompanyReconciliationRepository::SERVICE_TYPES, 'baseMetrics' => ServiceCompanyReconciliationRepository::BASE_METRICS, + 'fixedFeeRatePercent' => ServiceCompanyReconciliationRepository::fixedFeeRatePercent( + (string) $company['service_type_code'], + ), 'companyDirectory' => $this->repository->companyDirectory(), 'companyPlanSyncError' => $companyPlanSyncError, 'canEdit' => FinanceLedgerAccess::canEditMapping(user()), 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 c981f4d7..54a71442 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 @@ -995,7 +995,13 @@

店铺公司结算关系

-

一行只对应一家店铺公司;修改比例会生成新版本。

+

+ @if ($fixedFeeRatePercent !== null) + 客服服务公司结算比例固定为 {{ $fixedFeeRatePercent }}%;其他信息修改会生成新版本。 + @else + 一行只对应一家店铺公司;修改比例会生成新版本。 + @endif +

@if ($canEdit)