feat: 报价确认单自动带入企业并按账号核验实名 (#1324)
This commit is contained in:
parent
6518018b9f
commit
082c7f7f38
@ -115,7 +115,7 @@ class CourierAgreementSignatures extends Controller
|
||||
$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'])) {
|
||||
if ($type !== 'quote-confirmation' && $data['counterparty_signer_type'] === 'organization' && blank($data['operator_name'])) {
|
||||
throw ValidationException::withMessages(['operator_name' => '企业签署主体必须填写 E 签宝实名认证姓名。']);
|
||||
}
|
||||
|
||||
|
||||
@ -2375,6 +2375,7 @@
|
||||
var courierContractParties = @json($agreementCourierContractParties);
|
||||
var courierContractPartiesHelp = root.querySelector('[data-courier-contract-parties]');
|
||||
var selectedContractCourier = '';
|
||||
var selectedQuoteSigner = '';
|
||||
var selectedSupplierId = '';
|
||||
var visibleCourierIndexes = [];
|
||||
var activeCourierIndex = -1;
|
||||
@ -3043,6 +3044,22 @@
|
||||
}
|
||||
}
|
||||
|
||||
function syncQuoteSignerProfile(signerType) {
|
||||
if (currentPartnerType !== 'courier' || selectedDocument().value !== 'quote-confirmation') {
|
||||
selectedQuoteSigner = '';
|
||||
return;
|
||||
}
|
||||
|
||||
var name = courierSelect.value;
|
||||
var selection = JSON.stringify([name, signerType]);
|
||||
if (selectedQuoteSigner === selection) return;
|
||||
selectedQuoteSigner = selection;
|
||||
|
||||
var parties = Object.prototype.hasOwnProperty.call(courierContractParties, name) ? courierContractParties[name] : null;
|
||||
accountOrganizationInput.value = signerType === 'organization' && parties && !parties.ambiguous ? parties.party_b : '';
|
||||
operatorNameInput.value = '';
|
||||
}
|
||||
|
||||
function closeCourierOptions() {
|
||||
if (!courierSearch || !courierOptionsList) {
|
||||
return;
|
||||
@ -3442,6 +3459,7 @@
|
||||
return input.checked;
|
||||
});
|
||||
var accountSignerType = accountSignerTypeInput ? accountSignerTypeInput.value : 'organization';
|
||||
syncQuoteSignerProfile(accountSignerType);
|
||||
var accountSignerIsPerson = counterpartyIdentity && accountSignerType === 'person';
|
||||
var otherSignerIsPerson = (cooperationContract || authorization) && accountSignerType === 'person';
|
||||
var sharedSignerIsPerson = sharedContract && accountSignerType === 'person';
|
||||
@ -3455,7 +3473,7 @@
|
||||
if (accountSignerTypeField) {
|
||||
accountSignerTypeField.hidden = !signerTypeFieldVisible;
|
||||
setText('[data-signer-type-organization-title]', '企业签署');
|
||||
setText('[data-signer-type-organization-help]', '企业名称和经办人姓名分别填写');
|
||||
setText('[data-signer-type-organization-help]', quoteConfirmation ? '企业全称自动带入,经办人按账号核验' : '企业名称和经办人姓名分别填写');
|
||||
setText('[data-signer-type-person-title]', '个人签署');
|
||||
setText('[data-signer-type-person-help]', '签署人姓名须与 E 签宝账号实名认证一致');
|
||||
}
|
||||
@ -3471,17 +3489,18 @@
|
||||
: '填写对方在 E 签宝认证的企业全称';
|
||||
}
|
||||
if (operatorNameInput) {
|
||||
var needsPrimaryOperator = (sharedContract && !sharedSignerIsPerson) || (counterpartyIdentity && !accountSignerIsPerson) || entityChange || ((cooperationContract || authorization) && !otherSignerIsPerson);
|
||||
var quoteAccountIdentity = quoteConfirmation && !accountSignerIsPerson;
|
||||
var needsPrimaryOperator = (sharedContract && !sharedSignerIsPerson) || (accountAgreement && !accountSignerIsPerson) || entityChange || ((cooperationContract || authorization) && !otherSignerIsPerson);
|
||||
operatorNameInput.disabled = !needsPrimaryOperator;
|
||||
operatorNameInput.required = needsPrimaryOperator;
|
||||
operatorNameInput.placeholder = formerCompanyDeregistered
|
||||
? '填写原公司法人 E 签宝实名认证姓名'
|
||||
: '填写与 E 签宝账号匹配的实名姓名';
|
||||
: quoteAccountIdentity ? '推送时按上方账号自动核验,无需填写姓名' : '填写与 E 签宝账号匹配的实名姓名';
|
||||
if (accountSignerIsPerson) {
|
||||
operatorNameInput.value = accountOrganizationInput ? accountOrganizationInput.value : '';
|
||||
}
|
||||
root.querySelector('[data-primary-operator-field]').hidden = !needsPrimaryOperator;
|
||||
setText('[data-primary-operator-label]', formerCompanyDeregistered ? '原公司法人 E 签宝实名认证姓名' : entityChange ? '变更前主体 E 签宝实名认证姓名' : '对方 E 签宝实名认证姓名');
|
||||
root.querySelector('[data-primary-operator-field]').hidden = !needsPrimaryOperator && !quoteAccountIdentity;
|
||||
setText('[data-primary-operator-label]', quoteAccountIdentity ? '对方 E 签宝实名身份' : formerCompanyDeregistered ? '原公司法人 E 签宝实名认证姓名' : entityChange ? '变更前主体 E 签宝实名认证姓名' : '对方 E 签宝实名认证姓名');
|
||||
}
|
||||
if (operatorRequiredMark) {
|
||||
operatorRequiredMark.hidden = !operatorNameInput.required;
|
||||
@ -3491,7 +3510,7 @@
|
||||
operatorHelp.textContent = sharedContract
|
||||
? '填写物流商归属企业经办人的真实姓名,须与上方 E 签宝账号实名认证一致;快递名称填写在下方物流商名单。'
|
||||
: quoteConfirmation
|
||||
? '填写签署账号绑定的个人实名姓名,不能填写快递名称或企业名称;报价确认单由所选企业或个人签署。'
|
||||
? '推送时向 E 签宝查询并核验该账号的实名身份;接口可能不返回姓名,无需手工填写。未实名或查询失败时会提示原因。'
|
||||
: '仅用于 E 签宝身份核验,不是收款人姓名;收款人姓名请填写在下方账户资料中。';
|
||||
}
|
||||
if (accountSignerLabel) {
|
||||
@ -3500,7 +3519,9 @@
|
||||
if (accountSignerHelp) {
|
||||
accountSignerHelp.textContent = accountSignerIsPerson
|
||||
? '填写与 E 签宝账号实名一致的个人姓名;该姓名会作为个人签署人发送,不需要填写企业全称。'
|
||||
: '必须与对方 E 签宝企业认证名称一致;这是签署主体,不要求与银行卡持卡人姓名一致。';
|
||||
: quoteConfirmation
|
||||
? '按快递名称从快递资料的“合同主体”预填,可修改;资料缺失或同名资料不唯一时请手工填写并核对。'
|
||||
: '必须与对方 E 签宝企业认证名称一致;这是签署主体,不要求与银行卡持卡人姓名一致。';
|
||||
}
|
||||
activateTemplate(supplierContract ? 'supplier-cooperation' : templateType);
|
||||
root.querySelectorAll('[data-courier-contract-metadata]').forEach(function (field) {
|
||||
|
||||
@ -1010,7 +1010,7 @@ class CourierAgreementSignatureWorkflowTest extends FeatureTestCase
|
||||
}
|
||||
|
||||
/** @dataProvider quoteConfirmationSigners */
|
||||
public function test_quote_confirmation_binds_an_approved_version_and_uses_only_the_courier_signer(string $signerType, bool $retry): void
|
||||
public function test_quote_confirmation_binds_an_approved_version_and_uses_only_the_courier_signer(string $signerType, bool $retry, bool $accountIdentity = false): void
|
||||
{
|
||||
$this->fakeEsign();
|
||||
$selectedSubject = '示例签署甲方有限公司';
|
||||
@ -1108,7 +1108,7 @@ class CourierAgreementSignatureWorkflowTest extends FeatureTestCase
|
||||
'esign_account' => '13800138000',
|
||||
'counterparty_signer_type' => $signerType,
|
||||
'counterparty_organization_name' => $counterpartyName,
|
||||
...($signerType === 'organization' ? ['operator_name' => '李经理'] : []),
|
||||
...($signerType === 'organization' && ! $accountIdentity ? ['operator_name' => '李经理'] : []),
|
||||
'archive_mode' => 'auto',
|
||||
])
|
||||
->assertRedirect();
|
||||
@ -1118,7 +1118,7 @@ class CourierAgreementSignatureWorkflowTest extends FeatureTestCase
|
||||
$this->assertDatabaseCount('business_courier_quote_signatures', 1);
|
||||
$this->assertSame($version->id, $signature->quote_version_id);
|
||||
$this->assertSame($counterpartyName, $signature->organization_name);
|
||||
$this->assertSame('李经理', $signature->operator_name);
|
||||
$this->assertSame($accountIdentity ? null : '李经理', $signature->operator_name);
|
||||
$this->assertNull($signature->last_error);
|
||||
if ($failedSignature) {
|
||||
$this->assertSame($failedSignature->id, $signature->id);
|
||||
@ -1134,7 +1134,15 @@ class CourierAgreementSignatureWorkflowTest extends FeatureTestCase
|
||||
$this->assertStringNotContainsString($this->company->name, implode('', $pdfText));
|
||||
$this->assertStringNotContainsString('默认企业', implode('', $pdfText));
|
||||
|
||||
Http::assertSent(function (ClientRequest $request) use ($signerType, $counterpartyName): bool {
|
||||
if ($accountIdentity) {
|
||||
$requests = Http::recorded()->map(static fn (array $record) => $record[0]);
|
||||
$this->assertSame([
|
||||
'https://smlopenapi.esign.test/v3/organizations/identity-info?orgName=' . rawurlencode($counterpartyName),
|
||||
'https://smlopenapi.esign.test/v3/persons/identity-info?psnAccount=13800138000',
|
||||
], $requests->take(2)->map->url()->all());
|
||||
}
|
||||
|
||||
Http::assertSent(function (ClientRequest $request) use ($signerType, $counterpartyName, $accountIdentity): bool {
|
||||
if ($request->url() !== 'https://smlopenapi.esign.test/v3/sign-flow/create-by-file') {
|
||||
return false;
|
||||
}
|
||||
@ -1149,9 +1157,11 @@ class CourierAgreementSignatureWorkflowTest extends FeatureTestCase
|
||||
? data_get($signers[0], 'psnSignerInfo.psnAccount') === '13800138000'
|
||||
&& data_get($signers[0], 'psnSignerInfo.psnInfo.psnName') === $counterpartyName
|
||||
&& ! isset($signers[0]['orgSignerInfo'])
|
||||
: data_get($signers[0], 'orgSignerInfo.orgName') === $counterpartyName
|
||||
: ($accountIdentity
|
||||
? data_get($signers[0], 'orgSignerInfo') === ['orgId' => 'org-courier', 'transactorInfo' => ['psnId' => 'person-courier']]
|
||||
: data_get($signers[0], 'orgSignerInfo.orgName') === $counterpartyName
|
||||
&& data_get($signers[0], 'orgSignerInfo.transactorInfo.psnAccount') === '13800138000'
|
||||
&& data_get($signers[0], 'orgSignerInfo.transactorInfo.psnInfo.psnName') === '李经理');
|
||||
&& data_get($signers[0], 'orgSignerInfo.transactorInfo.psnInfo.psnName') === '李经理'));
|
||||
});
|
||||
}
|
||||
|
||||
@ -1161,6 +1171,8 @@ class CourierAgreementSignatureWorkflowTest extends FeatureTestCase
|
||||
'enterprise' => ['organization', false],
|
||||
'personal' => ['person', false],
|
||||
'retry failed enterprise task' => ['organization', true],
|
||||
'verified account without a disclosed name' => ['organization', false, true],
|
||||
'retry failed task with verified account' => ['organization', true, true],
|
||||
];
|
||||
}
|
||||
|
||||
@ -1196,7 +1208,6 @@ class CourierAgreementSignatureWorkflowTest extends FeatureTestCase
|
||||
public static function invalidQuoteConfirmationIdentities(): array
|
||||
{
|
||||
return [
|
||||
'missing operator' => [['operator_name' => null], 'operator_name'],
|
||||
'courier alias used as operator' => [['operator_name' => '新北中通'], 'operator_name'],
|
||||
'enterprise used as operator' => [['operator_name' => '新北中通快递有限公司'], 'operator_name'],
|
||||
'missing counterparty' => [['counterparty_organization_name' => null], 'counterparty_organization_name'],
|
||||
@ -1659,6 +1670,12 @@ class CourierAgreementSignatureWorkflowTest extends FeatureTestCase
|
||||
{
|
||||
Http::fake(function (ClientRequest $request) {
|
||||
return match (true) {
|
||||
str_starts_with($request->url(), 'https://smlopenapi.esign.test/v3/organizations/identity-info?') => Http::response([
|
||||
'code' => 0, 'data' => ['realnameStatus' => 1, 'orgId' => 'org-courier', 'authorizeUserInfo' => false],
|
||||
]),
|
||||
str_starts_with($request->url(), 'https://smlopenapi.esign.test/v3/persons/identity-info?') => Http::response([
|
||||
'code' => 0, 'data' => ['realnameStatus' => 1, 'psnId' => 'person-courier', 'authorizeUserInfo' => false, 'psnInfo' => null],
|
||||
]),
|
||||
$request->url() === 'https://smlopenapi.esign.test/v3/files/file-upload-url' => Http::response([
|
||||
'code' => 0,
|
||||
'data' => ['fileId' => 'file-agreement-001', 'fileUploadUrl' => 'https://upload.esign.test/agreement-001'],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user