From f8dcad69e81281d00950f837c8e65201a5fa26d5 Mon Sep 17 00:00:00 2001 From: limeng <1131177064@qq.com> Date: Tue, 22 Sep 2026 12:15:26 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=B8=AA=E4=BA=BA=E5=AF=B9?= =?UTF-8?q?=E6=96=B9=E7=AD=BE=E7=BD=B2=E4=B8=BB=E4=BD=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Business/CourierAgreementSignatures.php | 24 +++++++- .../CourierAgreementSignatureService.php | 8 ++- .../agreement-signing.blade.php | 59 +++++++++++++++++-- .../Business/AgreementSigningPageTest.php | 3 + .../CourierAgreementSignatureWorkflowTest.php | 27 +++++++++ 5 files changed, 113 insertions(+), 8 deletions(-) diff --git a/app/Http/Controllers/Business/CourierAgreementSignatures.php b/app/Http/Controllers/Business/CourierAgreementSignatures.php index 1547be58..60e336cf 100644 --- a/app/Http/Controllers/Business/CourierAgreementSignatures.php +++ b/app/Http/Controllers/Business/CourierAgreementSignatures.php @@ -56,6 +56,13 @@ class CourierAgreementSignatures extends Controller ]); } + if (in_array($requestedType, ['account-proof', 'account-change'], true) + && ! $request->filled('counterparty_signer_type')) { + // Existing integrations omit this field and historically meant an + // enterprise signer, so keep that behavior as the compatibility default. + $request->merge(['counterparty_signer_type' => 'organization']); + } + $data = $request->validate($this->rules()); $type = $data['document_type']; if ($type === 'authorization' && count($data['authorization_items'] ?? []) === 0) { @@ -79,6 +86,20 @@ class CourierAgreementSignatures extends Controller $data['shared_courier_name'] = $sharedCouriers[0]; $data['shared_note'] = trim((string) ($data['shared_note'] ?? '')) ?: null; } + if (in_array($type, ['account-proof', 'account-change'], true)) { + $data['counterparty_signer_type'] = $data['counterparty_signer_type'] ?? 'organization'; + $data['operator_name'] = trim((string) ($data['operator_name'] ?? '')) ?: null; + + if ($data['counterparty_signer_type'] === 'organization' && blank($data['operator_name'])) { + throw ValidationException::withMessages(['operator_name' => '企业签署主体必须填写 E 签宝实名认证姓名。']); + } + + if ($data['counterparty_signer_type'] === 'person') { + // A personal signer uses the same real name for the signer and + // the E-sign identity; the UI should not require it twice. + $data['operator_name'] = trim((string) $data['counterparty_organization_name']); + } + } $this->validateEsignAccount($data['esign_account'], 'esign_account'); if (! empty($data['secondary_esign_account'])) { $this->validateEsignAccount($data['secondary_esign_account'], 'secondary_esign_account'); @@ -282,8 +303,9 @@ class CourierAgreementSignatures extends Controller 'signing_deadline' => $date, 'esign_account' => ['required', 'string', 'max:255'], 'secondary_esign_account' => ['required_if:document_type,entity-change,cooperation-contract,authorization', 'nullable', 'string', 'max:255'], - 'operator_name' => ['required_if:document_type,account-proof,account-change', 'nullable', 'string', 'min:2', 'max:100'], + 'operator_name' => ['nullable', 'string', 'min:2', 'max:100'], 'counterparty_organization_name' => ['required_if:document_type,account-proof,account-change', 'nullable', 'string', 'min:2', 'max:255'], + 'counterparty_signer_type' => ['required_if:document_type,account-proof,account-change', 'nullable', 'in:organization,person'], 'archive_mode' => ['required', 'in:auto,manual'], 'account_proof_effective_date' => ['required_if:document_type,account-proof', 'date'], 'account_proof_account_name' => ['required_if:document_type,account-proof', 'string', 'max:255'], diff --git a/app/Support/CourierAgreementSignatureService.php b/app/Support/CourierAgreementSignatureService.php index f17fe566..f10dfa51 100644 --- a/app/Support/CourierAgreementSignatureService.php +++ b/app/Support/CourierAgreementSignatureService.php @@ -285,10 +285,12 @@ final class CourierAgreementSignatureService $payload = $signature->payload ?? []; if (in_array($signature->document_type, ['account-proof', 'account-change'], true)) { + $isPerson = ($payload['counterparty_signer_type'] ?? 'organization') === 'person'; + return [[ - 'signer_type' => 1, - 'organization_name' => $signature->organization_name, - 'operator_name' => $signature->operator_name, + 'signer_type' => $isPerson ? 0 : 1, + 'organization_name' => $isPerson ? null : $signature->organization_name, + 'operator_name' => $isPerson ? ($signature->operator_name ?: $signature->organization_name) : $signature->operator_name, 'operator_account' => $signature->operator_account, ]]; } diff --git a/resources/views/business/pages/courier-payables/agreement-signing.blade.php b/resources/views/business/pages/courier-payables/agreement-signing.blade.php index 1602d7f7..1bd3aabe 100644 --- a/resources/views/business/pages/courier-payables/agreement-signing.blade.php +++ b/resources/views/business/pages/courier-payables/agreement-signing.blade.php @@ -205,6 +205,7 @@ } .agreement-field label, + .agreement-field-label, .agreement-table th { color: var(--agreement-muted); font-size: 0.75rem; @@ -1427,10 +1428,17 @@

选择快递公司后自动带出工作平台的“电子签章经办人”(dzqzjbr);如资料未维护,可手工填写对方在 E 签宝实名绑定的手机号或邮箱。

+
+ 对方签署主体类型 +
+ + +
+
- + -

必须与对方 E 签宝企业认证名称一致;这是签署主体,不要求与银行卡持卡人姓名一致。

+

必须与对方 E 签宝企业认证名称一致;这是签署主体,不要求与银行卡持卡人姓名一致。

@@ -1910,8 +1918,12 @@ var subjectCodeInput = root.querySelector('[data-subject-code]'); var courierSelect = root.querySelector('[data-courier-select]'); var esignAccountInput = root.querySelector('input[name="esign_account"]'); + var accountSignerTypeField = root.querySelector('[data-account-signer-type-field]'); + var accountSignerTypeInputs = Array.prototype.slice.call(root.querySelectorAll('[data-account-signer-type]')); var accountOrganizationField = root.querySelector('[data-account-organization-field]'); var accountOrganizationInput = root.querySelector('[data-account-organization-name]'); + var accountSignerLabel = root.querySelector('[data-account-signer-label]'); + var accountSignerHelp = root.querySelector('[data-account-signer-help]'); var operatorNameInput = root.querySelector('[data-account-operator-name]'); var operatorRequiredMark = root.querySelector('[data-account-operator-required]'); var sharedCourierList = root.querySelector('[data-shared-courier-list]'); @@ -2423,18 +2435,42 @@ var courier = fieldValue('[name="courier_name"]', '快递公司'); var companyName = fieldValue('[name="company_full_name"]', '待填写公司全称'); var accountAgreement = templateType === 'account-proof' || templateType === 'account-change'; + var accountSignerTypeInput = accountSignerTypeInputs.find(function (input) { + return input.checked; + }); + var accountSignerType = accountSignerTypeInput ? accountSignerTypeInput.value : 'organization'; + var accountSignerIsPerson = accountSignerType === 'person'; + if (accountSignerTypeField) { + accountSignerTypeField.hidden = !accountAgreement; + } if (accountOrganizationField) { accountOrganizationField.hidden = !accountAgreement; } if (accountOrganizationInput) { accountOrganizationInput.disabled = !accountAgreement; accountOrganizationInput.required = accountAgreement; + accountOrganizationInput.autocomplete = accountSignerIsPerson ? 'name' : 'organization'; + accountOrganizationInput.placeholder = accountSignerIsPerson + ? '填写对方在 E 签宝实名认证的姓名' + : '填写对方在 E 签宝认证的企业全称'; } if (operatorNameInput) { - operatorNameInput.required = accountAgreement; + operatorNameInput.disabled = !accountAgreement || accountSignerIsPerson; + operatorNameInput.required = accountAgreement && !accountSignerIsPerson; + if (accountSignerIsPerson) { + operatorNameInput.value = accountOrganizationInput ? accountOrganizationInput.value : ''; + } } if (operatorRequiredMark) { - operatorRequiredMark.hidden = !accountAgreement; + operatorRequiredMark.hidden = !accountAgreement || accountSignerIsPerson; + } + if (accountSignerLabel) { + accountSignerLabel.textContent = accountSignerIsPerson ? '对方签署个人姓名' : '对方签署企业全称'; + } + if (accountSignerHelp) { + accountSignerHelp.textContent = accountSignerIsPerson + ? '填写与 E 签宝账号实名一致的个人姓名;该姓名会作为个人签署人发送,不需要填写企业全称。' + : '必须与对方 E 签宝企业认证名称一致;这是签署主体,不要求与银行卡持卡人姓名一致。'; } activateTemplate(templateType); refreshSignerAccountLabels(templateType); @@ -2544,6 +2580,21 @@ } } + accountSignerTypeInputs.forEach(function (input) { + input.addEventListener('change', refreshPreview); + }); + + if (accountOrganizationInput) { + accountOrganizationInput.addEventListener('input', function () { + var selectedType = accountSignerTypeInputs.find(function (input) { + return input.checked; + }); + if (selectedType && selectedType.value === 'person' && operatorNameInput) { + operatorNameInput.value = accountOrganizationInput.value; + } + }); + } + tabs.forEach(function (tab, index) { tab.addEventListener('click', function () { showTab(tab.dataset.agreementTab); diff --git a/tests/Feature/Business/AgreementSigningPageTest.php b/tests/Feature/Business/AgreementSigningPageTest.php index 70265663..9926c3bd 100644 --- a/tests/Feature/Business/AgreementSigningPageTest.php +++ b/tests/Feature/Business/AgreementSigningPageTest.php @@ -71,6 +71,9 @@ class AgreementSigningPageTest extends FeatureTestCase ->assertSee('data-subject-linked-name', false) ->assertSeeText('签署截止日期') ->assertSeeText('对方 E 签宝账号') + ->assertSeeText('对方签署主体类型') + ->assertSee('对方签署个人姓名', false) + ->assertSee('name="counterparty_signer_type"', false) ->assertSee('data-primary-esign-label', false) ->assertSee('data-secondary-esign-label', false) ->assertSee("labels.primary = '快递方 E 签宝账号'", false) diff --git a/tests/Feature/Business/CourierAgreementSignatureWorkflowTest.php b/tests/Feature/Business/CourierAgreementSignatureWorkflowTest.php index 76e5d939..3bcd66e3 100644 --- a/tests/Feature/Business/CourierAgreementSignatureWorkflowTest.php +++ b/tests/Feature/Business/CourierAgreementSignatureWorkflowTest.php @@ -151,6 +151,33 @@ class CourierAgreementSignatureWorkflowTest extends FeatureTestCase Http::assertNothingSent(); } + public function test_account_proof_can_be_signed_by_a_personal_counterparty(): void + { + $this->fakeEsign(); + $payload = $this->accountProofPayload('request-person-counterparty'); + $payload['counterparty_signer_type'] = 'person'; + $payload['counterparty_organization_name'] = '李斯'; + unset($payload['operator_name']); + + $this->loginAs() + ->post(route('business.courier-agreement-signatures.store'), $payload) + ->assertRedirect(); + + $signature = CourierAgreementSignature::query()->firstOrFail(); + $this->assertSame('person', $signature->payload['counterparty_signer_type']); + $this->assertSame('李斯', $signature->operator_name); + + Http::assertSent(function (ClientRequest $request): bool { + if ($request->url() !== 'https://smlopenapi.esign.test/v3/sign-flow/create-by-file') { + return false; + } + + return data_get($request->data(), 'signers.0.signerType') === 0 + && data_get($request->data(), 'signers.0.psnSignerInfo.psnInfo.psnName') === '李斯' + && data_get($request->data(), 'signers.0.orgSignerInfo') === null; + }); + } + public function test_cooperation_contract_maps_party_variables_and_creates_two_signers(): void { $this->fakeEsign();