From 7e64d2445843a7b9a96d47c41dfc8fbb7ec3f0a8 Mon Sep 17 00:00:00 2001 From: limeng <1131177064@qq.com> Date: Thu, 3 Sep 2026 13:48:18 +0800 Subject: [PATCH] feat: complete courier e-sign workflow and PDF rendering --- .../Business/CourierAgreementSignatures.php | 135 +++++- app/Http/Controllers/Business/Pages.php | 45 ++ .../Business/CourierAgreementSignature.php | 20 + .../CourierAgreementSignatureService.php | 20 + app/Support/CourierQuoteConfirmation.php | 91 ++++ app/Support/CourierQuotePdf.php | 27 +- app/Support/QuoteManagementSnapshot.php | 11 +- .../agreement-signing.blade.php | 394 ++++++++++++++++-- .../partials/cooperation-contract.blade.php | 10 +- .../business/pdf/courier-agreement.blade.php | 87 ++-- .../business/pdf/courier-quote.blade.php | 34 +- routes/admin.php | 3 + .../Business/AgreementSigningPageTest.php | 58 ++- .../CourierAgreementSignatureWorkflowTest.php | 145 +++++++ 14 files changed, 985 insertions(+), 95 deletions(-) create mode 100644 app/Support/CourierQuoteConfirmation.php diff --git a/app/Http/Controllers/Business/CourierAgreementSignatures.php b/app/Http/Controllers/Business/CourierAgreementSignatures.php index b9a7744b..6d65dbbe 100644 --- a/app/Http/Controllers/Business/CourierAgreementSignatures.php +++ b/app/Http/Controllers/Business/CourierAgreementSignatures.php @@ -3,9 +3,13 @@ namespace App\Http\Controllers\Business; use App\Models\Business\CourierAgreementSignature; +use App\Models\Business\CourierQuoteSignature; +use App\Models\Business\CourierQuoteVersion; use App\Models\Business\CourierSigningSubject; use App\Services\Esign\EsignClient; use App\Support\CourierAgreementSignatureService; +use App\Support\CourierQuoteConfirmation; +use App\Support\CourierQuoteSignatureService; use App\Utilities\SystemAccess; use Illuminate\Http\RedirectResponse; use Illuminate\Http\JsonResponse; @@ -20,15 +24,27 @@ class CourierAgreementSignatures extends Controller { private const COOPERATION_SECONDARY_ESIGN_ACCOUNT = '18052733960'; - public function __construct(private readonly CourierAgreementSignatureService $service) - { + public function __construct( + private readonly CourierAgreementSignatureService $service, + private readonly CourierQuoteSignatureService $quoteSignatureService, + private readonly CourierQuoteConfirmation $quoteConfirmation, + ) { } public function store(Request $request): RedirectResponse { $this->ensureCanManage(); abort_unless(EsignClient::configured(), 422, 'E 签宝沙箱尚未配置 App ID 或 AppSecret。'); - abort_unless(Schema::hasTable('business_courier_agreement_signatures'), 503, '协议签署数据表尚未完成迁移,请先执行数据库迁移。'); + $requestedType = (string) $request->input('document_type'); + if ($requestedType === 'quote-confirmation') { + abort_unless( + Schema::hasTable('business_courier_quote_versions') && Schema::hasTable('business_courier_quote_signatures'), + 503, + '报价签署数据表尚未完成迁移,请先执行数据库迁移。', + ); + } else { + abort_unless(Schema::hasTable('business_courier_agreement_signatures'), 503, '协议签署数据表尚未完成迁移,请先执行数据库迁移。'); + } if ($request->input('document_type') === 'cooperation-contract') { // 合作合同统一由我方固定 E 签宝账号完成第二签署方签署。 @@ -42,14 +58,39 @@ class CourierAgreementSignatures extends Controller if ($type === 'authorization' && count($data['authorization_items'] ?? []) === 0) { throw ValidationException::withMessages(['authorization_items' => '授权委托书至少选择一项授权事项。']); } + if ($type === 'shared-contract') { + $sharedCouriers = collect($data['shared_courier_names'] ?? []) + ->map(static fn ($name): string => trim((string) $name)) + ->filter() + ->unique() + ->values() + ->all(); + if ($sharedCouriers === [] && filled($data['shared_courier_name'] ?? null)) { + $sharedCouriers = [trim((string) $data['shared_courier_name'])]; + } + if ($sharedCouriers === []) { + throw ValidationException::withMessages(['shared_courier_names' => '请至少填写一家共用合同的快递公司。']); + } + $data['shared_courier_names'] = $sharedCouriers; + // Keep the first name for old records and integrations that still read the scalar field. + $data['shared_courier_name'] = $sharedCouriers[0]; + $data['shared_note'] = trim((string) ($data['shared_note'] ?? '')) ?: null; + } $this->validateEsignAccount($data['esign_account'], 'esign_account'); if (! empty($data['secondary_esign_account'])) { $this->validateEsignAccount($data['secondary_esign_account'], 'secondary_esign_account'); } - $data['organization_name'] = $data['signing_subject']; + if ($type === 'quote-confirmation') { + return $this->sendQuoteConfirmation($data); + } + + // signing_subject identifies our initiating company. The E-sign + // organization must be the counterparty that receives this request. + $data['organization_name'] = $this->counterpartyOrganizationName($data); $data['operator_name'] = $data['operator_name'] ?? $data['courier_name']; $data['operator_account'] = $data['esign_account']; + $data['payload'] = $this->payload($data); $signature = $this->service->send($data, user_id()); @@ -179,6 +220,40 @@ class CourierAgreementSignatures extends Controller return \Storage::disk('uploads')->download($path, $agreementSignature->business_no . '-' . $suffix . '.pdf', ['Content-Type' => 'application/pdf']); } + public function synchronizeQuote(CourierQuoteSignature $quoteSignature): RedirectResponse + { + $this->ensureCanManage(); + $signature = $this->quoteSignatureService->synchronize($quoteSignature, user_id()); + + return redirect() + ->route('business.pages.show', ['section' => 'courier-payables', 'page' => 'agreement-signing', 'agreement_view' => 'tasks']) + ->with('success', "报价确认单状态已同步:{$signature->statusLabel()}。"); + } + + public function downloadQuote(CourierQuoteSignature $quoteSignature, string $kind): StreamedResponse + { + $this->ensureCanManage(); + [$path, $suffix] = match ($kind) { + 'source' => [$quoteSignature->source_pdf_path, '报价确认单原文'], + 'signed' => [$quoteSignature->signed_pdf_path, '已签署报价确认单'], + 'certificate' => [$quoteSignature->certificate_path, '签署完成证书'], + default => abort(404), + }; + + abort_if(blank($path) || ! \Storage::disk('uploads')->exists($path), 404, '归档文件不存在。'); + $versionCode = $quoteSignature->version?->version_code ?: (string) $quoteSignature->quote_version_id; + + return \Storage::disk('uploads')->download($path, $versionCode . '-' . $suffix . '.pdf', ['Content-Type' => 'application/pdf']); + } + + public function previewQuote(CourierQuoteVersion $quoteVersion): JsonResponse + { + $this->ensureCanManage(); + abort_unless($quoteVersion->status === 'approved', 422, '只有已审核报价版本可以生成报价确认单。'); + + return response()->json($this->quoteConfirmation->data($quoteVersion)); + } + private function rules(): array { $date = ['required', 'date', 'after_or_equal:today', 'before_or_equal:' . now()->addDays(90)->toDateString()]; @@ -187,6 +262,7 @@ class CourierAgreementSignatures extends Controller 'idempotency_key' => ['required', 'string', 'max:80', 'regex:/^[A-Za-z0-9_-]+$/'], 'courier_name' => ['required', 'string', 'max:255'], 'document_type' => ['required', 'in:' . implode(',', array_keys(CourierAgreementSignature::DOCUMENTS))], + 'quote_version_id' => ['required_if:document_type,quote-confirmation', 'nullable', 'integer', 'min:1'], 'signing_subject' => ['required', 'string', 'min:2', 'max:255'], 'company_full_name' => ['required', 'string', 'min:2', 'max:255'], 'signing_deadline' => $date, @@ -212,8 +288,11 @@ class CourierAgreementSignatures extends Controller 'changed_company_start_date' => ['required_if:document_type,entity-change', 'date'], 'entity_proof_date' => ['required_if:document_type,entity-change', 'date'], 'contract_partner_name' => ['required_if:document_type,shared-contract', 'string', 'max:255'], - 'shared_courier_name' => ['required_if:document_type,shared-contract', 'string', 'max:255'], - 'shared_proof_date' => ['required_if:document_type,shared-contract', 'date'], + 'shared_courier_names' => ['nullable', 'array', 'min:1'], + 'shared_courier_names.*' => ['required', 'string', 'max:255'], + 'shared_courier_name' => ['nullable', 'string', 'max:255'], + 'shared_proof_date' => ['nullable', 'date'], + 'shared_note' => ['nullable', 'string', 'max:2000'], 'cooperation_party_a_name' => ['required_if:document_type,cooperation-contract', 'string', 'max:255'], 'cooperation_party_a_phone' => ['required_if:document_type,cooperation-contract', 'string', 'max:64'], 'cooperation_party_b_name' => ['required_if:document_type,cooperation-contract', 'string', 'max:255'], @@ -243,6 +322,50 @@ class CourierAgreementSignatures extends Controller return $payload; } + private function sendQuoteConfirmation(array $data): RedirectResponse + { + $version = CourierQuoteVersion::query() + ->where('status', 'approved') + ->findOrFail((int) $data['quote_version_id']); + $this->ensureQuoteVersionMatchesCourier($version, $data['courier_name']); + + $signature = $this->quoteSignatureService->prepareVersion($version, user_id()); + $account = trim((string) $data['esign_account']); + $signature = $this->quoteSignatureService->send($signature, [ + 'organization_name' => $version->carrier_name, + 'operator_name' => trim((string) ($data['operator_name'] ?? '')) ?: $version->carrier_name, + 'operator_account' => $account, + 'notice_type' => filter_var($account, FILTER_VALIDATE_EMAIL) !== false ? '2' : '1', + 'expires_at' => \Illuminate\Support\Carbon::parse($data['signing_deadline'])->endOfDay(), + ], user_id()); + + return redirect() + ->route('business.pages.show', ['section' => 'courier-payables', 'page' => 'agreement-signing', 'agreement_view' => 'tasks']) + ->with('success', "报价确认单 {$version->version_code} 已推送到 E 签宝,等待快递方签署并自动回传归档。") + ->with('quote_signature_id', $signature->id); + } + + private function ensureQuoteVersionMatchesCourier(CourierQuoteVersion $version, string $courier): void + { + abort_unless( + trim($version->carrier_name) === trim($courier), + 422, + '所选报价版本与快递公司不一致,请重新选择。', + ); + } + + private function counterpartyOrganizationName(array $data): string + { + return match ($data['document_type']) { + 'account-proof' => trim((string) $data['account_proof_account_name']), + 'account-change' => trim((string) $data['new_account_name']), + 'shared-contract' => trim((string) (($data['shared_courier_names'][0] ?? null) ?: ($data['shared_courier_name'] ?? $data['courier_name']))), + 'entity-change' => trim((string) ($data['former_company_name'] ?? $data['courier_name'])), + 'authorization' => trim((string) ($data['principal_name'] ?? $data['courier_name'])), + default => trim((string) $data['courier_name']), + }; + } + private function ensureCanManage(): void { abort_unless( diff --git a/app/Http/Controllers/Business/Pages.php b/app/Http/Controllers/Business/Pages.php index f0f775aa..367645cb 100644 --- a/app/Http/Controllers/Business/Pages.php +++ b/app/Http/Controllers/Business/Pages.php @@ -9,6 +9,8 @@ use App\Business\StoreReceivingAccountTemplate; use App\Business\StoreReceivingAccountWorkbookImporter; use App\Models\Banking\MarketingAccountBill; use App\Models\Business\CourierAgreementSignature; +use App\Models\Business\CourierQuoteSignature; +use App\Models\Business\CourierQuoteVersion; use App\Models\Business\CourierSigningSubject; use App\Models\Business\InstallationDetail; use App\Business\CourierSurchargeQuoteRepository; @@ -285,8 +287,10 @@ class Pages extends Controller 'inventoryData' => $this->inventoryContent($page['slug']), 'rawBoardData' => $this->rawBoardContent($page['slug']), 'agreementTasks' => $this->agreementTasks($page['slug']), + 'agreementQuoteSignatures' => $this->agreementQuoteSignatures($page['slug']), 'agreementSubjects' => $this->agreementSubjects($page['slug']), 'agreementCourierAccounts' => $this->agreementCourierAccounts($page['slug']), + 'agreementQuoteVersions' => $this->agreementQuoteVersions($page['slug']), ]; } @@ -336,8 +340,10 @@ class Pages extends Controller 'inventoryData' => $page ? $this->inventoryContent($page['slug']) : null, 'rawBoardData' => $page ? $this->rawBoardContent($page['slug']) : null, 'agreementTasks' => $this->agreementTasks($page['slug'] ?? null), + 'agreementQuoteSignatures' => $this->agreementQuoteSignatures($page['slug'] ?? null), 'agreementSubjects' => $this->agreementSubjects($page['slug'] ?? null), 'agreementCourierAccounts' => $this->agreementCourierAccounts($page['slug'] ?? null), + 'agreementQuoteVersions' => $this->agreementQuoteVersions($page['slug'] ?? null), ]; } @@ -438,6 +444,45 @@ class Pages extends Controller } } + protected function agreementQuoteSignatures(?string $page): Collection + { + if ($page !== 'agreement-signing') { + return collect(); + } + + try { + return CourierQuoteSignature::query() + ->with('version') + ->latest('id') + ->limit(50) + ->get(); + } catch (QueryException $exception) { + // 报价签署迁移尚未执行时仍允许打开协议签署页。 + report($exception); + return collect(); + } + } + + protected function agreementQuoteVersions(?string $page): Collection + { + if ($page !== 'agreement-signing') { + return collect(); + } + + try { + return CourierQuoteVersion::query() + ->where('status', 'approved') + ->orderByDesc('effective_date') + ->orderByDesc('id') + ->limit(100) + ->get(); + } catch (QueryException $exception) { + // 报价版本迁移尚未执行时仍允许打开协议签署页,报价确认单会提示暂无可选版本。 + report($exception); + return collect(); + } + } + protected function resolveContent(string $page, ?string $tab): ?array { return match ($page) { diff --git a/app/Models/Business/CourierAgreementSignature.php b/app/Models/Business/CourierAgreementSignature.php index 285c760e..72f612c8 100644 --- a/app/Models/Business/CourierAgreementSignature.php +++ b/app/Models/Business/CourierAgreementSignature.php @@ -54,6 +54,12 @@ class CourierAgreementSignature extends Model 'name' => '授权委托书', 'file' => '授权委托书(快递).docx', ], + 'quote-confirmation' => [ + 'code' => 'TPL-QUOTE-CONFIRMATION-V1', + 'version' => '1', + 'name' => '报价确认单', + 'file' => '报价确认单(报价版本快照).pdf', + ], ]; protected $table = 'business_courier_agreement_signatures'; @@ -106,4 +112,18 @@ class CourierAgreementSignature extends Model { return self::DOCUMENTS[$this->document_type]['name'] ?? $this->document_type; } + + /** + * The company that initiated the request is kept in the encrypted request + * snapshot. It is separate from organization_name, which is the E-sign + * signing organization for the counterparty. + */ + public function initiatorName(): string + { + $payloadName = trim((string) data_get($this->payload, 'signing_subject', '')); + + return $payloadName !== '' + ? $payloadName + : (trim((string) $this->company_full_name) ?: '—'); + } } diff --git a/app/Support/CourierAgreementSignatureService.php b/app/Support/CourierAgreementSignatureService.php index db154e4c..37987323 100644 --- a/app/Support/CourierAgreementSignatureService.php +++ b/app/Support/CourierAgreementSignatureService.php @@ -276,6 +276,21 @@ final class CourierAgreementSignatureService private function signersFor(CourierAgreementSignature $signature): array { $payload = $signature->payload ?? []; + + if (in_array($signature->document_type, ['account-proof', 'account-change'], true)) { + $name = $signature->organization_name; + $isOrganization = $this->looksLikeOrganization($name); + + return [[ + 'signer_type' => $isOrganization ? 1 : 0, + 'organization_name' => $isOrganization ? $name : null, + 'operator_name' => $isOrganization + ? ($signature->operator_name ?: $signature->courier_name) + : $name, + 'operator_account' => $signature->operator_account, + ]]; + } + $primary = [ 'signer_type' => 1, 'organization_name' => $signature->organization_name, @@ -330,6 +345,11 @@ final class CourierAgreementSignatureService return [$primary]; } + private function looksLikeOrganization(string $name): bool + { + return preg_match('/公司|有限公司|有限责任|企业|集团|合作社|事务所|中心|厂/u', $name) === 1; + } + private function safeTitle(string $title): string { $title = preg_replace('/[^\p{Han}\p{L}\p{N}_ -]/u', '-', $title) ?: '协议签署'; diff --git a/app/Support/CourierQuoteConfirmation.php b/app/Support/CourierQuoteConfirmation.php new file mode 100644 index 00000000..5633dd0f --- /dev/null +++ b/app/Support/CourierQuoteConfirmation.php @@ -0,0 +1,91 @@ +loadMissing(['change.items']); + $values = $this->decodeMatrix($version->values_json); + $nextVersion = CourierQuoteVersion::query() + ->where('carrier_name', $version->carrier_name) + ->where('quote_type', $version->quote_type) + ->where('effective_date', '>', $version->effective_date) + ->orderBy('effective_date') + ->first(); + + return [ + 'version_id' => $version->id, + 'version_code' => $version->version_code, + 'party_a' => company((int) $version->company_id)?->name ?: '当前公司', + 'party_b' => $version->carrier_name, + 'carrier_name' => $version->carrier_name, + 'quote_type' => $version->quote_type, + 'effective_date' => $version->effective_date?->toDateString(), + 'expiry_date' => $nextVersion?->effective_date?->copy()->subDay()->toDateString() ?: '长期', + 'face_fee' => $this->matrixMetric($values, ['面单费', '面单费用', '面单']), + 'bubble_coefficient' => $this->matrixMetric($values, ['计泡系数', '泡系数', '计泡']), + 'values' => $values, + 'formulas' => $this->decodeMatrix($version->formulas_json), + ]; + } + + private function decodeMatrix(?string $json): array + { + if (blank($json)) { + return []; + } + + $decoded = json_decode($json, true); + + return is_array($decoded) ? $decoded : []; + } + + private function matrixMetric(array $values, array $labels): string + { + foreach ($values as $rowIndex => $row) { + if (! is_array($row)) { + continue; + } + + foreach (array_values($row) as $columnIndex => $cell) { + $text = trim((string) $cell); + foreach ($labels as $label) { + if ($text !== $label && ! str_contains($text, $label)) { + continue; + } + + $inline = trim((string) preg_replace('/^.*?' . preg_quote($label, '/') . '\\s*[::=]?\\s*/u', '', $text)); + if ($inline !== '' && $inline !== $text && $inline !== $label) { + return $inline; + } + + $columnValues = []; + foreach (array_slice($values, $rowIndex + 1) as $nextRow) { + $value = is_array($nextRow) ? ($nextRow[$columnIndex] ?? null) : null; + if ($value !== null && trim((string) $value) !== '') { + $columnValues[] = trim((string) $value); + } + } + $columnValues = array_values(array_unique($columnValues)); + if (count($columnValues) === 1) { + return $columnValues[0]; + } + if (count($columnValues) > 1) { + return '详见报价明细'; + } + + $adjacent = $row[$columnIndex + 1] ?? null; + if ($adjacent !== null && trim((string) $adjacent) !== '') { + return trim((string) $adjacent); + } + } + } + } + + return '按报价明细'; + } +} diff --git a/app/Support/CourierQuotePdf.php b/app/Support/CourierQuotePdf.php index 2b5ced85..b85b85dc 100644 --- a/app/Support/CourierQuotePdf.php +++ b/app/Support/CourierQuotePdf.php @@ -7,16 +7,22 @@ use RuntimeException; final class CourierQuotePdf { + public function __construct(private readonly CourierQuoteConfirmation $confirmation) + { + } + public function render(CourierQuoteVersion $version): string { - $version->loadMissing(['change.items']); - $values = $this->decodeMatrix($version->values_json); - $formulas = $this->decodeMatrix($version->formulas_json); + $data = $this->confirmation->data($version); $html = view('business.pdf.courier-quote', [ 'version' => $version, 'change' => $version->change, - 'values' => $values, - 'formulas' => $formulas, + 'values' => $data['values'], + 'formulas' => $data['formulas'], + 'partyA' => $data['party_a'], + 'expiryDate' => $data['expiry_date'], + 'faceFee' => $data['face_fee'], + 'bubbleCoefficient' => $data['bubble_coefficient'], 'generatedAt' => now(), 'fontPath' => str_replace('\\', '/', resource_path('fonts/DroidSansFallback.ttf')), ])->render(); @@ -32,15 +38,4 @@ final class CourierQuotePdf return $bytes; } - - private function decodeMatrix(?string $json): array - { - if (blank($json)) { - return []; - } - - $decoded = json_decode($json, true); - - return is_array($decoded) ? $decoded : []; - } } diff --git a/app/Support/QuoteManagementSnapshot.php b/app/Support/QuoteManagementSnapshot.php index f57b1c36..36e7b73b 100644 --- a/app/Support/QuoteManagementSnapshot.php +++ b/app/Support/QuoteManagementSnapshot.php @@ -114,7 +114,7 @@ final class QuoteManagementSnapshot 'row_count' => count($values), 'column_count' => $columnCount, 'formula_count' => $this->formulaCount($formulas), - 'status' => '已审核待签署', + 'status' => $this->versionLifecycleStatus($version), 'signature_status' => $version->signature_status, 'values' => $values, 'formulas' => $formulas, @@ -135,6 +135,15 @@ final class QuoteManagementSnapshot } } + private function versionLifecycleStatus(CourierQuoteVersion $version): string + { + if ($version->signature_status !== '已签署并归档') { + return '待生效(待签章)'; + } + + return $version->effective_date?->isFuture() ? '待生效' : '生效中'; + } + private function normalizeMatrix(mixed $matrix): array { if (! is_array($matrix)) { 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 35750367..219a59f2 100644 --- a/resources/views/business/pages/courier-payables/agreement-signing.blade.php +++ b/resources/views/business/pages/courier-payables/agreement-signing.blade.php @@ -1,6 +1,9 @@ @php($agreementTasks = $agreementTasks ?? collect()) +@php($agreementQuoteSignatures = $agreementQuoteSignatures ?? collect()) @php($agreementSubjects = $agreementSubjects ?? collect()) @php($agreementCourierAccounts = $agreementCourierAccounts ?? []) +@php($agreementQuoteVersions = $agreementQuoteVersions ?? collect()) +@php($agreementCourierNames = collect(['新北中通', '新北中通其他', '新德邦快递', '睢宁中通', '武进极兔', '沭阳德邦', '常州圆通其他'])->merge($agreementQuoteVersions->pluck('carrier_name'))->filter()->unique()->values()) @php($agreementCooperationSecondaryEsignAccount = '18052733960') @php($agreementDefaultSubject = $agreementSubjects->firstWhere('is_default', true) ?: $agreementSubjects->first()) @php($agreementCompanyName = $agreementDefaultSubject?->name ?: company()?->name ?: '当前公司') @@ -504,6 +507,27 @@ font-size: 15px; } + .agreement-shared-courier-list { + display: grid; + gap: 0.5rem; + } + + .agreement-shared-courier-row { + display: grid; + grid-template-columns: minmax(0, 1fr) auto; + gap: 0.5rem; + align-items: center; + } + + .agreement-shared-courier-row .agreement-icon-button { + flex: 0 0 auto; + } + + .agreement-shared-courier-add { + justify-self: start; + margin-top: 0.15rem; + } + .agreement-modal { position: fixed; z-index: 1000; @@ -926,6 +950,32 @@ gap: 0.5rem; } + .agreement-preview-quote-matrix { + max-width: 100%; + margin: 1rem 0; + overflow-x: auto; + } + + .agreement-preview-quote-matrix table { + width: 100%; + border-collapse: collapse; + font-size: 0.72rem; + } + + .agreement-preview-quote-matrix th, + .agreement-preview-quote-matrix td { + min-width: 4.5rem; + border: 1px solid #E3DED4; + padding: 0.35rem 0.45rem; + text-align: left; + vertical-align: top; + } + + .agreement-preview-quote-matrix th { + background: #F3EEE4; + font-weight: 600; + } + .agreement-preview-parties { display: grid; gap: 0.45rem; @@ -1133,6 +1183,7 @@ + + + @endif + @if ($quoteSignature->source_pdf_path) + + @endif + @if ($quoteSignature->signed_pdf_path) + + @endif + @if ($quoteSignature->certificate_path) + + @endif + + + @endforeach + @foreach ($agreementTasks as $task) {{ $task->business_no }} {{ $task->courier_name }} {{ $task->documentLabel() }} {{ $task->statusLabel() }} - {{ $task->operator_name ?: '—' }} + {{ $task->initiatorName() }} {{ optional($task->updated_at)->format('Y-m-d H:i') }} @if ($task->esign_sign_flow_id && ! in_array($task->status, ['archived', 'rejected', 'expired', 'revoked'], true)) @@ -1184,7 +1263,8 @@ @endif - @empty + @endforeach + @if ($agreementTasks->isEmpty() && $agreementQuoteSignatures->isEmpty())
@@ -1200,7 +1280,7 @@
- @endforelse + @endif @@ -1229,7 +1309,7 @@ @@ -1240,9 +1320,10 @@ - + + @@ -1283,7 +1364,19 @@
- + +
+ @else -

甲 方:{{ $payload['cooperation_party_a_name'] ?? '' }}

乙 方:{{ $payload['cooperation_party_b_name'] ?? '' }}

代表人:

代表人:

日 期:签署后生成

日 期:签署后生成

签约地:常州市

+

甲 方:{!! $mixedText($payload['cooperation_party_a_name'] ?? '') !!}

乙 方:{!! $mixedText($payload['cooperation_party_b_name'] ?? '') !!}

代表人:

代表人:

日 期:签署后生成

日 期:签署后生成

签约地:常州市

@endif diff --git a/resources/views/business/pdf/courier-agreement.blade.php b/resources/views/business/pdf/courier-agreement.blade.php index a7be743d..dd0f2bfb 100644 --- a/resources/views/business/pdf/courier-agreement.blade.php +++ b/resources/views/business/pdf/courier-agreement.blade.php @@ -3,8 +3,10 @@ -
业务单号:{{ $signature->business_no }} 模板:{{ $signature->template_code }}
-

{{ $title }}

+@php + $mixedText = static function ($value): string { + $parts = preg_split('/([\x20-\x7E]+)/', (string) $value, -1, PREG_SPLIT_DELIM_CAPTURE) ?: []; + + return implode('', array_map(static function (string $part): string { + $escaped = e($part); + + return preg_match('/^[\x20-\x7E]+$/', $part) === 1 + ? '' . $escaped . '' + : $escaped; + }, $parts)); + }; +@endphp +@php + $sharedCourierNames = array_values(array_filter(array_map( + static fn ($name): string => trim((string) $name), + $payload['shared_courier_names'] ?? [$payload['shared_courier_name'] ?? ''], + ))); + $sharedCourierText = implode('、', $sharedCourierNames ?: ['待填写']); +@endphp +
业务单号:{!! $mixedText($signature->business_no) !!} 模板:{!! $mixedText($signature->template_code) !!}
+

{!! $mixedText($title) !!}

@if ($type === 'account-proof') -

TO {{ $payload['company_full_name'] }}:

-

基于我公司正规化管理的需要,同时保证广大客户的汇款安全,我司同意自 {{ $payload['account_proof_effective_date'] }} 起我司货款(运费),请汇款至以下账户:

+

TO {!! $mixedText($payload['company_full_name']) !!}:

+

基于我公司正规化管理的需要,同时保证广大客户的汇款安全,我司同意自 {!! $mixedText($payload['account_proof_effective_date']) !!} 起我司货款(运费),请汇款至以下账户:

-
开户名称:{{ $payload['account_proof_account_name'] }}
-
开户银行:{{ $payload['account_proof_bank_name'] }}
-
银行帐户:{{ $payload['account_proof_bank_account'] }}
+
开户名称:{!! $mixedText($payload['account_proof_account_name']) !!}
+
开户银行:{!! $mixedText($payload['account_proof_bank_name']) !!}
+
银行帐户:{!! $mixedText($payload['account_proof_bank_account']) !!}

请贵公司按照上述汇款资料付款,如因我司提供收款银行帐户资料错误,导致相关款项支付不到位,则由此产生的一切经济纠纷和责任由我司承担。我司承诺若上述收款银行帐户资料发生变化及时书面通知贵公司。

以上收款账户的变更,以我司的盖章为有效。

-

{{ $payload['courier_name'] }} 公司盖章:

日期:签署后生成

+

公司盖章:

日期:签署后生成

@elseif ($type === 'account-change') -

TO {{ $payload['company_full_name'] }}:

-

基于我公司正规化管理的需要,同时保证广大客户的汇款安全,我司收款账户将于 {{ $payload['account_change_date'] }} 变更账户,之前相应的账户(收款账户为:{{ $payload['old_account_name'] }},账号:{{ $payload['old_account_number'] }})于 {{ $payload['old_account_stop_date'] }} 停止使用,即日起我司收款的银行帐户进行变更,自 {{ $payload['new_account_effective_date'] }} 起我司与贵司往来款项请汇款至以下新账户,新汇款资料如下:

+

TO {!! $mixedText($payload['company_full_name']) !!}:

+

基于我公司正规化管理的需要,同时保证广大客户的汇款安全,我司收款账户将于 {!! $mixedText($payload['account_change_date']) !!} 变更账户,之前相应的账户(收款账户为:{!! $mixedText($payload['old_account_name']) !!},账号:{!! $mixedText($payload['old_account_number']) !!})于 {!! $mixedText($payload['old_account_stop_date']) !!} 停止使用,即日起我司收款的银行帐户进行变更,自 {!! $mixedText($payload['new_account_effective_date']) !!} 起我司与贵司往来款项请汇款至以下新账户,新汇款资料如下:

-
开户名称:{{ $payload['new_account_name'] }}
-
开户银行:{{ $payload['new_bank_name'] }}
-
银行账户:{{ $payload['new_bank_account'] }}
+
开户名称:{!! $mixedText($payload['new_account_name']) !!}
+
开户银行:{!! $mixedText($payload['new_bank_name']) !!}
+
银行账户:{!! $mixedText($payload['new_bank_account']) !!}

如因我司提供收款银行帐户资料错误导致相关款项支付不到位,由此产生的一切经济纠纷和责任由我司承担。以上收款账户的变更,以我司的盖章为有效。

-

{{ $payload['courier_name'] }} 公司盖章:

日期:签署后生成

+

公司盖章:

日期:签署后生成

@elseif ($type === 'entity-change') -

致 {{ $payload['company_full_name'] }}:

-

我司由于企业名称变更,原公司名称 {{ $payload['former_company_name'] }} 于 {{ $payload['entity_change_date'] }} 变更为 {{ $payload['changed_company_name'] }},自 {{ $payload['changed_company_start_date'] }} 开始,我司将启用变更后的公司与贵公司开展工作,原公司名称停止使用。

+

致 {!! $mixedText($payload['company_full_name']) !!}:

+

我司由于企业名称变更,原公司名称 {!! $mixedText($payload['former_company_name']) !!} 于 {!! $mixedText($payload['entity_change_date']) !!} 变更为 {!! $mixedText($payload['changed_company_name']) !!},自 {!! $mixedText($payload['changed_company_start_date']) !!} 开始,我司将启用变更后的公司与贵公司开展工作,原公司名称停止使用。

变更后,原公司的各项事宜由变更后的公司继续执行。原公司的结算未付款项,由变更之后的公司提供的收款账户收款。原公司的业务和款项若出现法律上的纠纷,由变更后的公司承担责任。

特此证明!

-

变更前公司法人签字盖公章:{{ $payload['former_company_name'] }}

变更后公司法人签字盖公章:{{ $payload['changed_company_name'] }}

日期:{{ $payload['entity_proof_date'] }}

+

变更前公司法人签字盖公章:{!! $mixedText($payload['former_company_name']) !!}

变更后公司法人签字盖公章:{!! $mixedText($payload['changed_company_name']) !!}

日期:{!! $mixedText($payload['entity_proof_date']) !!}

@elseif ($type === 'shared-contract') -

与 {{ $payload['contract_partner_name'] }} 合作的 {{ $payload['shared_courier_name'] }} 快递共用同一份合同,打款资料为同一份资料,同一个签字人以及同一个法人!

+

与 {!! $mixedText($payload['contract_partner_name'] ?? '') !!} 合作的 {!! $mixedText($sharedCourierText) !!} 共同用一份合同,打款资料为同一份资料,同一个签字人以及同一个法人!

特此证明!

-

法人签字并公司盖章:

日期:{{ $payload['shared_proof_date'] }}

+ @if (filled($payload['shared_note'] ?? null)) +

备注:{!! $mixedText($payload['shared_note']) !!}

+ @endif +

法人签字并公司盖章:

日期:{!! $mixedText($payload['shared_proof_date'] ?? '签署后生成') !!}

@elseif ($type === 'cooperation-contract') @include('business.partials.cooperation-contract', ['mode' => 'pdf', 'payload' => $payload]) @else
-
委托方:{{ $payload['principal_name'] }}
-
身份证号/营业执照号:{{ $payload['principal_id_number'] }}
-
受托方:{{ $payload['trustee_name'] }}
-
身份证号/营业执照号:{{ $payload['trustee_id_number'] }}
+
委托方:{!! $mixedText($payload['principal_name']) !!}
+
身份证号/营业执照号:{!! $mixedText($payload['principal_id_number']) !!}
+
受托方:{!! $mixedText($payload['trustee_name']) !!}
+
身份证号/营业执照号:{!! $mixedText($payload['trustee_id_number']) !!}
-

兹委托 {{ $payload['trustee_name'] }} 为我或我司的代理人,全权代表我或我司办理下列第 {{ implode('、', $payload['authorization_items'] ?? []) }} 条事项:

+

兹委托 {!! $mixedText($payload['trustee_name']) !!} 为我或我司的代理人,全权代表我或我司办理下列第 {!! $mixedText(implode('、', $payload['authorization_items'] ?? [])) !!} 条事项:

    -
  1. 代表委托方代签与 {{ $payload['bill_counterparty'] }} 的往来业务每月账单。
  2. -
  3. 代表委托方代签与 {{ $payload['loan_counterparty'] }} 借支协议的事项。
  4. +
  5. 代表委托方代签与 {!! $mixedText($payload['bill_counterparty']) !!} 的往来业务每月账单。
  6. +
  7. 代表委托方代签与 {!! $mixedText($payload['loan_counterparty']) !!} 借支协议的事项。
  8. 代表委托方代签汇款账号变更的事项。
  9. -
  10. 代表委托方代收 {{ $payload['payment_counterparty'] }} 的往来货款。
  11. +
  12. 代表委托方代收 {!! $mixedText($payload['payment_counterparty']) !!} 的往来货款。
-

委托有效期:从 {{ $payload['authorization_start_date'] }} 至 {{ $payload['authorization_end_date'] }} 止。

-

委托方:{{ $payload['principal_name'] }}

受托方:{{ $payload['trustee_name'] }}

日期:签署后生成

+

委托有效期:从 {!! $mixedText($payload['authorization_start_date']) !!} 至 {!! $mixedText($payload['authorization_end_date']) !!} 止。

+

委托方:{!! $mixedText($payload['principal_name']) !!}

受托方:{!! $mixedText($payload['trustee_name']) !!}

日期:签署后生成

@endif diff --git a/resources/views/business/pdf/courier-quote.blade.php b/resources/views/business/pdf/courier-quote.blade.php index 6bfa324a..6e6cb29a 100644 --- a/resources/views/business/pdf/courier-quote.blade.php +++ b/resources/views/business/pdf/courier-quote.blade.php @@ -2,7 +2,7 @@ - Quote {{ $version->version_code }} + 报价确认单 {{ $version->version_code }}