diff --git a/app/Http/Controllers/Business/CourierAgreementSignatures.php b/app/Http/Controllers/Business/CourierAgreementSignatures.php index d2ec95ec..4302616d 100644 --- a/app/Http/Controllers/Business/CourierAgreementSignatures.php +++ b/app/Http/Controllers/Business/CourierAgreementSignatures.php @@ -531,7 +531,7 @@ class CourierAgreementSignatures extends Controller unset($payload['esign_account'], $payload['idempotency_key'], $payload['operator_name'], $payload['credential_images']); $payload['authorization_items'] = array_values(array_map('strval', $data['authorization_items'] ?? [])); if (($data['document_type'] ?? '') === 'cooperation-contract') { - $payload['cooperation_party_a_esign_account'] = CourierAgreementSignature::COOPERATION_PARTY_A_PHONE; + $payload['cooperation_bilateral_signing'] = true; } if (($data['document_type'] ?? '') === 'cooperation-contract' && ($data['partner_type'] ?? 'courier') === 'courier') { $payload['cooperation_party_b_signing_place'] = trim((string) ($data['cooperation_party_b_signing_place'] ?? '')) ?: '常州市'; diff --git a/app/Models/Business/CourierAgreementSignature.php b/app/Models/Business/CourierAgreementSignature.php index d7ad5eb3..358dc33e 100644 --- a/app/Models/Business/CourierAgreementSignature.php +++ b/app/Models/Business/CourierAgreementSignature.php @@ -19,7 +19,7 @@ class CourierAgreementSignature extends Model public const STATUS_FAILED = 'failed'; public const STATUS_UNKNOWN = 'unknown'; - public const COOPERATION_PARTY_A_PHONE = '18112896651'; + public const COOPERATION_PARTY_A_PHONE = '18052733960'; public const DOCUMENTS = [ 'account-proof' => [ diff --git a/app/Services/Esign/EsignClient.php b/app/Services/Esign/EsignClient.php index 23492bd3..8b292053 100644 --- a/app/Services/Esign/EsignClient.php +++ b/app/Services/Esign/EsignClient.php @@ -103,6 +103,13 @@ final class EsignClient $this->configuration->signFlowInitiator($organizationName); } + public function initiatorSignerIdentity(string $organizationName): array + { + $initiator = $this->configuration->signFlowInitiator($organizationName)['orgInitiator']; + + return ['organization_id' => $initiator['orgId'], 'operator_id' => $initiator['transactor']['psnId']]; + } + /** 已实名企业和个人通过账号 ID 签署,无需人工填写经办人姓名。 */ public function organizationSignerIdentity(string $organizationName, string $account): array { diff --git a/app/Support/CourierAgreementSignatureService.php b/app/Support/CourierAgreementSignatureService.php index 97530c0d..f1c9632e 100644 --- a/app/Support/CourierAgreementSignatureService.php +++ b/app/Support/CourierAgreementSignatureService.php @@ -417,8 +417,7 @@ final class CourierAgreementSignatureService 'signing_positions' => $positions, ]; // Requests already saved retain their original signer list on retry. - $partyAAccount = $payload['cooperation_party_a_esign_account'] ?? null; - if (blank($partyAAccount)) { + if (empty($payload['cooperation_bilateral_signing']) && blank($payload['cooperation_party_a_esign_account'] ?? null)) { return [$counterparty]; } @@ -431,7 +430,7 @@ final class CourierAgreementSignatureService throw new RuntimeException('乙方:' . $exception->getMessage(), previous: $exception); } try { - $partyAIdentity = $client->organizationSignerIdentity($payload['cooperation_party_a_name'], $partyAAccount); + $partyAIdentity = $client->initiatorSignerIdentity($payload['cooperation_party_a_name']); } catch (RuntimeException $exception) { throw new RuntimeException('甲方:' . $exception->getMessage(), previous: $exception); } diff --git a/tests/Feature/Business/AgreementSigningPageTest.php b/tests/Feature/Business/AgreementSigningPageTest.php index 9e41fea0..bef2a105 100644 --- a/tests/Feature/Business/AgreementSigningPageTest.php +++ b/tests/Feature/Business/AgreementSigningPageTest.php @@ -141,7 +141,7 @@ class AgreementSigningPageTest extends FeatureTestCase ->assertSee("setPreviewValue('proofSigner', '公司盖章')", false) ->assertSee("setPreviewValue('changeSigner', '公司盖章')", false) ->assertSeeText('先乙方后甲方') - ->assertSee('value="18112896651" readonly', false) + ->assertSee('value="18052733960" readonly', false) ->assertSee('name="secondary_operator_name"', false) ->assertSeeText('填写变量') ->assertSeeText('签署完成后自动归档') diff --git a/tests/Feature/Business/CourierAgreementSignatureWorkflowTest.php b/tests/Feature/Business/CourierAgreementSignatureWorkflowTest.php index f60e83dd..d220abab 100644 --- a/tests/Feature/Business/CourierAgreementSignatureWorkflowTest.php +++ b/tests/Feature/Business/CourierAgreementSignatureWorkflowTest.php @@ -230,7 +230,7 @@ class CourierAgreementSignatureWorkflowTest extends FeatureTestCase $this->assertSame($template, $signature->payload['supplier_contract_template']); $this->assertSame('SUP-TEST-001', $signature->payload['supplier_contract_fields']['number']); $this->assertNull($signature->payload['supplier_contract_signer_name']); - $this->assertSame('18112896651', $signature->payload['cooperation_party_a_phone']); + $this->assertSame('18052733960', $signature->payload['cooperation_party_a_phone']); $this->assertSame('13800138000', $signature->payload['cooperation_party_b_phone']); $source = Storage::disk('uploads')->get($signature->source_pdf_path); $this->assertStringStartsWith('%PDF-', $source); @@ -256,8 +256,8 @@ class CourierAgreementSignatureWorkflowTest extends FeatureTestCase && data_get($signers, '0.orgSignerInfo.transactorInfo.psnId') === 'person-courier' && data_get($signers, '0.orgSignerInfo.transactorInfo.psnInfo') === null && data_get($signers, '1.signConfig.signOrder') === 2 - && data_get($signers, '1.orgSignerInfo.orgId') === 'org-party-a' - && data_get($signers, '1.orgSignerInfo.transactorInfo.psnId') === 'person-party-a' + && data_get($signers, '1.orgSignerInfo.orgId') === 'org-selected' + && data_get($signers, '1.orgSignerInfo.transactorInfo.psnId') === 'person-selected' && data_get($signers, '1.signFields.0.mustSign') === true; }); $again = app(\App\Support\CourierAgreementSignatureService::class)->send([ @@ -643,7 +643,7 @@ class CourierAgreementSignatureWorkflowTest extends FeatureTestCase $this->assertSame('TPL-COOPERATION-CONTRACT-V1', $signature->template_code); $this->assertArrayNotHasKey('secondary_esign_account', $signature->payload); $this->assertArrayNotHasKey('secondary_operator_name', $signature->payload); - $this->assertSame('18112896651', $signature->payload['cooperation_party_a_phone']); + $this->assertSame('18052733960', $signature->payload['cooperation_party_a_phone']); $this->assertSame('13800138000', $signature->payload['cooperation_party_b_phone']); $this->assertNull($signature->operator_name); $this->assertSame('2026-12-31', $signature->payload['cooperation_end_date']); @@ -665,8 +665,8 @@ class CourierAgreementSignatureWorkflowTest extends FeatureTestCase && data_get($signers, '0.orgSignerInfo.transactorInfo.psnId') === 'person-courier' && data_get($signers, '0.orgSignerInfo.transactorInfo.psnInfo') === null && data_get($signers, '1.signConfig.signOrder') === 2 - && data_get($signers, '1.orgSignerInfo.orgId') === 'org-party-a' - && data_get($signers, '1.orgSignerInfo.transactorInfo.psnId') === 'person-party-a' + && data_get($signers, '1.orgSignerInfo.orgId') === 'org-selected' + && data_get($signers, '1.orgSignerInfo.transactorInfo.psnId') === 'person-selected' && data_get($signers, '1.signFields.0.mustSign') === true; }); } @@ -1712,10 +1712,10 @@ 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' => str_ends_with($request->url(), 'orgName=' . rawurlencode($this->company->name)) ? 'org-party-a' : 'org-courier', 'authorizeUserInfo' => false], + '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' => str_ends_with($request->url(), 'psnAccount=18112896651') ? 'person-party-a' : 'person-courier', 'authorizeUserInfo' => false, 'psnInfo' => null], + '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,