From ea0680913e051816bf5dc7da4645ee642206fa6a Mon Sep 17 00:00:00 2001 From: limeng <1131177064@qq.com> Date: Thu, 26 Nov 2026 16:48:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BF=AB=E9=80=92=E5=85=AC=E5=8F=B8?= =?UTF-8?q?=E4=B8=BB=E4=BD=93=E5=8F=98=E6=9B=B4=E5=8F=96=E6=B6=88=E9=93=B6?= =?UTF-8?q?=E8=A1=8C=E5=8D=A1=E4=B8=8A=E4=BC=A0=20(#1470)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Business/CourierAgreementSignatures.php | 6 ++- app/Support/CourierAgreementCredentials.php | 12 ++++-- .../credential-upload.blade.php | 43 ++++++++++++------- .../CourierAgreementCredentialsTest.php | 23 +++++++--- 4 files changed, 59 insertions(+), 25 deletions(-) diff --git a/app/Http/Controllers/Business/CourierAgreementSignatures.php b/app/Http/Controllers/Business/CourierAgreementSignatures.php index d171649e..bf0ab05f 100644 --- a/app/Http/Controllers/Business/CourierAgreementSignatures.php +++ b/app/Http/Controllers/Business/CourierAgreementSignatures.php @@ -525,7 +525,11 @@ class CourierAgreementSignatures extends Controller 'payment_counterparty' => ['required_if:document_type,authorization', 'string', 'max:255'], 'authorization_start_date' => ['required_if:document_type,authorization', 'date'], 'authorization_end_date' => ['required_if:document_type,authorization', 'date', 'after_or_equal:authorization_start_date'], - ] + $supplierFields + CourierAgreementCredentials::rules((string) request('document_type'), request()->boolean('credential_required')); + ] + $supplierFields + CourierAgreementCredentials::rules( + (string) request('document_type'), + request()->boolean('credential_required'), + (string) request('partner_type', 'courier'), + ); } private function payload(array $data): array diff --git a/app/Support/CourierAgreementCredentials.php b/app/Support/CourierAgreementCredentials.php index 69937030..8d7be7e5 100644 --- a/app/Support/CourierAgreementCredentials.php +++ b/app/Support/CourierAgreementCredentials.php @@ -16,12 +16,16 @@ final class CourierAgreementCredentials 'bank_front' => '银行卡正面', 'bank_back' => '银行卡背面', ]; - public static function definitions(string $type): array + public static function definitions(string $type, string $partnerType = 'courier'): array { $sheets = [ 'identity' => ['name' => '身份证推送单', 'images' => ['id_front', 'id_back']], 'bank' => ['name' => '银行卡推送单', 'images' => ['bank_front', 'bank_back']], ]; + if ($type === 'entity-change' && $partnerType === 'courier') { + unset($sheets['bank']); + } + return match ($type) { 'authorization' => $sheets, 'entity-change' => ['license' => ['name' => '营业执照盖章推送单', 'images' => ['license']]] + $sheets, @@ -29,9 +33,9 @@ final class CourierAgreementCredentials }; } - public static function rules(string $type, bool $requested): array + public static function rules(string $type, bool $requested, string $partnerType = 'courier'): array { - $allowed = self::definitions($type); + $allowed = self::definitions($type, $partnerType); $required = $requested ? array_merge(...array_column($allowed ?: [['images' => []]], 'images')) : []; $rules = [ 'credential_required' => ['nullable', 'boolean', Rule::prohibitedIf($allowed === [] && $requested)], @@ -48,7 +52,7 @@ final class CourierAgreementCredentials public function prepare(CourierAgreementSignature $signature, array $uploads): array { - $definitions = self::definitions($signature->document_type); + $definitions = self::definitions($signature->document_type, $signature->partnerType()); if (! ($signature->payload['credential_required'] ?? false)) { return []; } diff --git a/resources/views/business/pages/courier-payables/credential-upload.blade.php b/resources/views/business/pages/courier-payables/credential-upload.blade.php index a6a15d4e..e6493607 100644 --- a/resources/views/business/pages/courier-payables/credential-upload.blade.php +++ b/resources/views/business/pages/courier-payables/credential-upload.blade.php @@ -1,3 +1,13 @@ +@php + use App\Support\CourierAgreementCredentials; + + $credentialDefinitions = []; + foreach (['courier', 'supplier'] as $credentialPartnerType) { + foreach (['authorization', 'entity-change'] as $credentialDocumentType) { + $credentialDefinitions[$credentialPartnerType][$credentialDocumentType] = CourierAgreementCredentials::definitions($credentialDocumentType, $credentialPartnerType); + } + } +@endphp