diff --git a/app/Http/Controllers/Business/Pages.php b/app/Http/Controllers/Business/Pages.php index 2cf4de99..6e9da723 100644 --- a/app/Http/Controllers/Business/Pages.php +++ b/app/Http/Controllers/Business/Pages.php @@ -5245,6 +5245,16 @@ class Pages extends Controller $query->where('document_type', $type); } + $partnerType = $this->agreementFilterPartnerType(); + if ($partnerType !== null) { + // Partner type is encrypted in the signing snapshot. Filter all + // candidates before pagination, reading only the fields needed. + $matchingIds = (clone $query)->select(['id', 'payload'])->lazyById(200) + ->filter(static fn (CourierAgreementSignature $task): bool => $task->partnerType() === $partnerType) + ->pluck('id')->all(); + $query->whereIn('id', $matchingIds); + } + return $query ->latest('id') ->paginate(50, ['*'], 'agreement_task_page')->withQueryString(); @@ -5295,6 +5305,17 @@ class Pages extends Controller return in_array($scope, ['active', 'archived', 'all'], true) ? $scope : 'active'; } + protected function agreementFilterPartnerType(): ?string + { + if ($this->agreementFilterScope() !== 'archived') { + return null; + } + + $partnerType = trim((string) request('agreement_partner_type', '')); + + return in_array($partnerType, ['courier', 'supplier'], true) ? $partnerType : null; + } + protected function agreementSubjects(?string $page): Collection { if ($page !== 'agreement-signing') { @@ -5321,7 +5342,7 @@ class Pages extends Controller try { $type = $this->agreementFilterType(); - if ($type !== null && $type !== 'quote-confirmation') { + if (($type !== null && $type !== 'quote-confirmation') || $this->agreementFilterPartnerType() === 'supplier') { return collect(); } diff --git a/app/Models/Business/CourierAgreementSignature.php b/app/Models/Business/CourierAgreementSignature.php index 8395f0e8..204fc4a5 100644 --- a/app/Models/Business/CourierAgreementSignature.php +++ b/app/Models/Business/CourierAgreementSignature.php @@ -87,7 +87,7 @@ class CourierAgreementSignature extends Model 'operator_account' => 'encrypted', ]; - public function partnerTypeLabel(): string + public function partnerType(): string { // Records created before partner types were introduced are courier tasks. try { @@ -97,7 +97,12 @@ class CourierAgreementSignature extends Model $partnerType = 'courier'; } - return $partnerType === 'supplier' ? '供应商' : '快递公司'; + return $partnerType === 'supplier' ? 'supplier' : 'courier'; + } + + public function partnerTypeLabel(): string + { + return $this->partnerType() === 'supplier' ? '供应商' : '快递公司'; } /** Only completed archives with a readable courier snapshot belong to contract management. */ 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 b507f47f..edb49d13 100644 --- a/resources/views/business/pages/courier-payables/agreement-signing.blade.php +++ b/resources/views/business/pages/courier-payables/agreement-signing.blade.php @@ -19,8 +19,10 @@ @php($agreementType = trim((string) request('agreement_type', ''))) @php($agreementScope = trim((string) request('agreement_scope', $agreementStatus === 'archived' ? 'archived' : 'active'))) @php($agreementScope = in_array($agreementScope, ['active', 'archived', 'all'], true) ? $agreementScope : 'active') +@php($agreementPartnerType = trim((string) request('agreement_partner_type', ''))) +@php($agreementPartnerType = $agreementScope === 'archived' && in_array($agreementPartnerType, ['courier', 'supplier'], true) ? $agreementPartnerType : '') @php($agreementPaymentPrefill = \App\Business\CourierProfileData::agreementPrefill(request('payment_account'))) -@php($agreementFiltersActive = $agreementSearch !== '' || $agreementStatus !== '' || $agreementType !== '') +@php($agreementFiltersActive = $agreementSearch !== '' || $agreementStatus !== '' || $agreementType !== '' || $agreementPartnerType !== '')