diff --git a/app/Business/CourierContractPageData.php b/app/Business/CourierContractPageData.php index 5d041c16..3293fe7e 100644 --- a/app/Business/CourierContractPageData.php +++ b/app/Business/CourierContractPageData.php @@ -22,7 +22,7 @@ class CourierContractPageData 'unknown' => '期限待核对', ]; - public function page(bool $includeRows = true): array + public function page(bool $includeRows = true, string $partnerType = 'courier'): array { $search = mb_substr(trim((string) request()->query('contract_search', '')), 0, 255); $status = (string) request()->query('contract_status', ''); @@ -61,7 +61,7 @@ class CourierContractPageData 'signed_pdf_path', 'certificate_path', 'archived_at', 'created_by', 'created_at']) ->lazyById(250); foreach ($signatures as $signature) { - $payload = $signature->archivedCourierContractPayload(); + $payload = $signature->archivedContractPayload($partnerType); if ($payload === null) { try { $signature->payload; diff --git a/app/Http/Controllers/Business/CourierContracts.php b/app/Http/Controllers/Business/CourierContracts.php index ba75d580..53c0045a 100644 --- a/app/Http/Controllers/Business/CourierContracts.php +++ b/app/Http/Controllers/Business/CourierContracts.php @@ -11,9 +11,19 @@ class CourierContracts extends Controller { /** A read-only archive entry point with courier-information page access, not signing-management access. */ public function download(CourierAgreementSignature $agreementSignature, string $kind): StreamedResponse + { + return $this->serveFile($agreementSignature, $kind, 'courier'); + } + + public function downloadSupplier(CourierAgreementSignature $agreementSignature, string $kind): StreamedResponse + { + return $this->serveFile($agreementSignature, $kind, 'supplier'); + } + + private function serveFile(CourierAgreementSignature $agreementSignature, string $kind, string $partnerType): StreamedResponse { abort_unless($agreementSignature->company_id === (int) company_id() - && $agreementSignature->archivedCourierContractPayload() !== null, 404); + && $agreementSignature->archivedContractPayload($partnerType) !== null, 404); $path = match ($kind) { 'signed' => $agreementSignature->signed_pdf_path, 'certificate' => $agreementSignature->certificate_path, diff --git a/app/Http/Controllers/Business/Pages.php b/app/Http/Controllers/Business/Pages.php index 9ff94471..2b968d7c 100644 --- a/app/Http/Controllers/Business/Pages.php +++ b/app/Http/Controllers/Business/Pages.php @@ -5439,6 +5439,17 @@ class Pages extends Controller return $this->resolveContent($page, $tab); } + protected function contentForSupplierManagement(): array + { + $showContracts = request()->query('supplier_view') === 'contracts'; + $data = $showContracts + ? ['view' => 'business.pages.supplier-payables.supplier-management'] + : app(\Modules\EcommerceFinance\View\SupplierManagementPageData::class)->page(); + + return $data + ['supplierShowContracts' => $showContracts] + + app(\App\Business\CourierContractPageData::class)->page($showContracts, 'supplier'); + } + protected function resolveContent(string $page, ?string $tab): ?array { return match ($page) { @@ -5460,7 +5471,7 @@ class Pages extends Controller 'warehouse-freight' => ['view' => 'business.pages.courier-payables.warehouse-freight'], 'board-deductions' => $this->contentForBoardDeductions(), 'supplier-payables-report' => $this->contentForSupplierPayablesReport(), - 'supplier-management' => app(\Modules\EcommerceFinance\View\SupplierManagementPageData::class)->page(), + 'supplier-management' => $this->contentForSupplierManagement(), 'accessory-freight-deductions' => app(\Modules\EcommerceFinance\View\SupplierAccessoryFreightPageData::class)->page(), 'manufacturer-bookkeeping' => app(\Modules\EcommerceFinance\View\SupplierBookkeepingPageData::class)->page(), 'payable-cloud-warehouse-vehicle-fee' => $this->contentForDingPayableWorkflows(), diff --git a/app/Models/Business/CourierAgreementSignature.php b/app/Models/Business/CourierAgreementSignature.php index 204fc4a5..f29c960a 100644 --- a/app/Models/Business/CourierAgreementSignature.php +++ b/app/Models/Business/CourierAgreementSignature.php @@ -105,8 +105,12 @@ class CourierAgreementSignature extends Model return $this->partnerType() === 'supplier' ? '供应商' : '快递公司'; } - /** Only completed archives with a readable courier snapshot belong to contract management. */ public function archivedCourierContractPayload(): ?array + { + return $this->archivedContractPayload('courier'); + } + + public function archivedContractPayload(string $partnerType): ?array { if ($this->status !== self::STATUS_ARCHIVED || $this->document_type !== 'cooperation-contract') { return null; @@ -119,7 +123,7 @@ class CourierAgreementSignature extends Model } // Before partner_type was introduced all signing tasks were courier tasks. - return is_array($payload) && ($payload['partner_type'] ?? 'courier') === 'courier' ? $payload : null; + return is_array($payload) && ($payload['partner_type'] ?? 'courier') === $partnerType ? $payload : null; } public function credentialDocuments(): array diff --git a/resources/views/business/pages/supplier-payables/partials/supplier-contracts.blade.php b/resources/views/business/pages/supplier-payables/partials/supplier-contracts.blade.php new file mode 100644 index 00000000..d7fcc751 --- /dev/null +++ b/resources/views/business/pages/supplier-payables/partials/supplier-contracts.blade.php @@ -0,0 +1,80 @@ +@php + $contractLabels = \App\Business\CourierContractPageData::STATUSES; + $fileUrl = static fn (int $id, bool $preview = false): string => route('business.supplier-contracts.download', [ + 'agreementSignature' => $id, 'kind' => 'signed', + ] + ($preview ? ['preview' => 1] : [])); +@endphp + +
+ +按归档合同的约定日期提前 {{ \App\Business\CourierContractPageData::REMINDER_DAYS }} 天提醒。约定期限届满后,请核对续签及自动续期条款。
+ +@if ($courierContractError) +| 供应商 | 期限状态 | 合同编号 | +开始日期 | 结束日期 | 距到期天数 | +甲方签署主体 | 乙方签署主体 | 签署单号 | 签署原件 | +
|---|---|---|---|---|---|---|---|---|---|
| {{ $contract['courier_name'] }} | +{{ $contractLabels[$contract['status']] }} | +{{ $contract['number'] ?: '未填写' }} | +{{ $contract['start_date'] ?: '待核对' }} | +{{ $contract['end_date'] ?: '待核对' }} | +@if ($contract['days'] === null)无法计算 @elseif ($contract['days'] < 0)已届满 {{ abs($contract['days']) }} 天 @elseif ($contract['days'] === 0)今天到期 @else{{ $contract['days'] }} 天@endif | +{{ $contract['party_a'] ?: '未填写' }} | +{{ $contract['party_b'] ?: '未填写' }} | +{{ $contract['business_no'] }} | ++ @if ($contract['has_signed_file']) + 查看签署原件 · + 下载 + @else + 归档附件缺失 + @endif + | +
| 当前条件下没有已归档的供应商合作合同。 | |||||||||