支持个人对方签署主体
This commit is contained in:
parent
0a0b899991
commit
f8dcad69e8
@ -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'],
|
||||
|
||||
@ -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,
|
||||
]];
|
||||
}
|
||||
|
||||
@ -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 @@
|
||||
<input class="agreement-control" id="agreement-esign-account" name="esign_account" type="text" value="" data-esign-account placeholder="手机号或邮箱" autocomplete="email" required>
|
||||
<p class="agreement-help">选择快递公司后自动带出工作平台的“电子签章经办人”(dzqzjbr);如资料未维护,可手工填写对方在 E 签宝实名绑定的手机号或邮箱。</p>
|
||||
</div>
|
||||
<div class="agreement-field agreement-field--full" data-account-signer-type-field>
|
||||
<span class="agreement-field-label">对方签署主体类型 <span class="agreement-required" aria-hidden="true">*</span></span>
|
||||
<div class="agreement-archive-options">
|
||||
<label class="agreement-archive-choice"><input type="radio" name="counterparty_signer_type" value="organization" checked data-account-signer-type><span><strong>企业</strong><span>填写 E 签宝认证的企业全称和经办人姓名</span></span></label>
|
||||
<label class="agreement-archive-choice"><input type="radio" name="counterparty_signer_type" value="person" data-account-signer-type><span><strong>个人</strong><span>填写 E 签宝实名认证的个人姓名,不需要企业全称</span></span></label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="agreement-field" data-account-organization-field>
|
||||
<label for="agreement-counterparty-organization">对方签署企业全称 <span class="agreement-required" aria-hidden="true">*</span></label>
|
||||
<label for="agreement-counterparty-organization"><span data-account-signer-label>对方签署企业全称</span> <span class="agreement-required" aria-hidden="true">*</span></label>
|
||||
<input class="agreement-control" id="agreement-counterparty-organization" name="counterparty_organization_name" type="text" placeholder="填写对方在 E 签宝认证的企业全称" autocomplete="organization" data-account-organization-name required>
|
||||
<p class="agreement-help">必须与对方 E 签宝企业认证名称一致;这是签署主体,不要求与银行卡持卡人姓名一致。</p>
|
||||
<p class="agreement-help" data-account-signer-help>必须与对方 E 签宝企业认证名称一致;这是签署主体,不要求与银行卡持卡人姓名一致。</p>
|
||||
</div>
|
||||
<div class="agreement-field">
|
||||
<label for="agreement-operator-name">对方 E 签宝实名认证姓名 <span class="agreement-required" data-account-operator-required aria-hidden="true">*</span></label>
|
||||
@ -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);
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user