From b1414a662212c522912700cb6b188fe0481f9ce7 Mon Sep 17 00:00:00 2001 From: limeng <1131177064@qq.com> Date: Thu, 15 Oct 2026 14:03:35 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BF=AB=E9=80=92=E5=BA=94=E4=BB=98=EF=BC=9A?= =?UTF-8?q?=E6=B8=85=E7=A9=BA=E8=BF=90=E8=B4=B9=E5=AF=B9=E8=B4=A6=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E5=B9=B6=E5=81=9C=E7=94=A8=E9=94=99=E8=AF=AF=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E6=BA=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Http/Controllers/Business/Pages.php | 85 +--------- .../freight-reconciliation.blade.php | 145 +++--------------- .../CourierFreightReconciliationPageTest.php | 102 ++++-------- tests/Feature/Business/PagesTest.php | 38 +---- 4 files changed, 67 insertions(+), 303 deletions(-) diff --git a/app/Http/Controllers/Business/Pages.php b/app/Http/Controllers/Business/Pages.php index 13a8e06b..36330db2 100644 --- a/app/Http/Controllers/Business/Pages.php +++ b/app/Http/Controllers/Business/Pages.php @@ -48,7 +48,6 @@ use Modules\EcommerceFinance\Repositories\AlibabaAccountBalanceRepository; use Modules\EcommerceFinance\Repositories\AlibabaBillRepository; use Modules\EcommerceFinance\View\BillOffsetPageData; use Modules\EcommerceFinance\Repositories\CourierInformationMirrorRepository; -use Modules\EcommerceFinance\Repositories\CourierFreightReconciliationMirrorRepository; use Modules\EcommerceFinance\Repositories\CourierSurchargeSettlementMirrorRepository; use Modules\EcommerceFinance\Repositories\ShippingOrderRepository; use Modules\EcommerceFinance\Repositories\ThirdPartyWarehouseStorageMirrorRepository; @@ -420,7 +419,6 @@ class Pages extends Controller private readonly ProductCatalogMirrorRepository $productCatalog, private readonly ProductPriceMirrorRepository $productPrices, private readonly CourierInformationMirrorRepository $courierInformation, - private readonly CourierFreightReconciliationMirrorRepository $courierFreightReconciliations, private readonly ThirdPartyWarehouseStorageMirrorRepository $thirdPartyWarehouseStorage, private readonly RawBoardPayablesRepository $rawBoardPayables, private readonly DingPayableWorkflowMirrorRepository $dingPayableWorkflows, @@ -574,18 +572,11 @@ class Pages extends Controller } if ($section === 'courier-payables' && $page === 'freight-reconciliation' && request()->boolean('courier_summary')) { - try { - $summary = $this->courierFreightReconciliations->requestSummary($this->freightReconciliationFilters()); - $response = response()->json(['data' => $summary], $summary === null ? 202 : 200, [ - 'Cache-Control' => 'private, no-store', 'X-Accel-Buffering' => 'no', - ]); - // Explicit framing lets clients finish reading before the - // application termination callback computes the aggregate. - return $response->header('Content-Length', strlen($response->getContent())); - } catch (Throwable $exception) { - report($exception); - return response()->json(['message' => '完整汇总暂时无法计算,明细仍可正常查看。'], 503, ['Cache-Control' => 'private, no-store']); - } + return response()->json([ + 'data' => ['count' => 0, 'freight' => 0], + 'status' => 'disabled', + 'message' => '原数据源已停用,本页面不再展示原运费对账数据。', + ], 200, ['Cache-Control' => 'private, no-store']); } return view('business.pages.show', $this->viewData( @@ -4660,75 +4651,11 @@ class Pages extends Controller return $text !== '' && is_numeric($text) ? (float) $text : null; } - private function freightReconciliationFilters(): array - { - $request = request(); - $date = static function (mixed $value): string { - $value = trim((string) $value); - return preg_match('/^\d{4}-\d{2}-\d{2}$/', $value) === 1 ? $value : ''; - }; - return [ - 'express_no' => mb_substr(trim((string) $request->query('express_no', '')), 0, 80), - 'express_name' => mb_substr(trim((string) $request->query('express_name', '')), 0, 80), - 'month' => mb_substr(trim((string) $request->query('month', '')), 0, 20), - 'status' => mb_substr(trim((string) $request->query('status', '')), 0, 40), - 'modified_from' => $date($request->query('modified_from', '')), - 'modified_to' => $date($request->query('modified_to', '')), - ]; - } - protected function contentForFreightReconciliation(): array { - $request = request(); - $filters = $this->freightReconciliationFilters(); - $page = max((int) $request->query('page', 1), 1); - $limit = min(max((int) setting('default.list_limit', 25), 1), 100); - $rows = new Paginator([], $limit, $page, [ - 'path' => $request->url(), - 'query' => $request->except('page'), - ]); - $state = null; - $sync = ['code' => 'unavailable', 'last_succeeded_at' => null, 'lag_minutes' => null]; - $summary = ['count' => null, 'freight' => null]; - $error = null; - $pending = false; - - try { - if (! $this->courierFreightReconciliations->available()) { - $error = '共享业务镜像尚未建立,运费对账暂时无法读取。'; - } elseif (! $this->courierFreightReconciliations->ready()) { - $state = $this->courierFreightReconciliations->state(); - $sync = $this->courierFreightReconciliations->syncStatus($state); - $pending = true; - $error = '运费对账镜像正在完成首次同步,完成前不会把未同步数据误判为无数据。'; - } else { - $result = $this->courierFreightReconciliations->paginate($filters, $page, $limit); - $rows = new Paginator( - Collection::make($result['data'] ?? []), - $limit, - $page, - ['path' => $request->url(), 'query' => $request->except('page')], - ); - $rows->hasMorePagesWhen((bool) ($result['has_more'] ?? false)); - $state = $result['state'] ?? null; - $sync = $result['sync'] ?? $sync; - $summary = $result['summary'] ?? $summary; - } - } catch (Throwable $exception) { - report($exception); - $error = '运费对账数据暂时无法读取,请稍后重试。'; - } - + // 原来源口径不适用;保留入口,但不读取明细、同步状态或汇总。 return [ 'view' => 'business.pages.courier-payables.freight-reconciliation', - 'freightReconciliations' => $rows, - 'freightReconciliationFilters' => $filters, - 'freightReconciliationSummary' => $summary, - 'freightReconciliationState' => $state, - 'freightReconciliationSync' => $sync, - 'freightReconciliationError' => $error, - 'freightReconciliationPending' => $pending, - 'freightReconciliationSummaryUrl' => $error === null ? $request->fullUrlWithQuery(['courier_summary' => 1, 'page' => null]) : null, ]; } diff --git a/resources/views/business/pages/courier-payables/freight-reconciliation.blade.php b/resources/views/business/pages/courier-payables/freight-reconciliation.blade.php index 37b01b31..63cfcf9b 100644 --- a/resources/views/business/pages/courier-payables/freight-reconciliation.blade.php +++ b/resources/views/business/pages/courier-payables/freight-reconciliation.blade.php @@ -1,131 +1,32 @@ -@php - $filters = $freightReconciliationFilters ?? []; - $summary = $freightReconciliationSummary ?? []; - $summaryReady = isset($summary['count'], $summary['freight']); - $sync = $freightReconciliationSync ?? ['code' => 'unavailable', 'last_succeeded_at' => null, 'lag_minutes' => null]; - $statusLabels = ['fresh' => '数据新鲜', 'stale' => '数据可能滞后', 'syncing' => '同步中', 'initializing' => '首次同步中', 'pending' => '等待同步', 'failed' => '同步失败', 'initial_failed' => '首次同步失败', 'unavailable' => '镜像不可用']; - $money = static fn (mixed $value): string => number_format((float) ($value ?? 0), 2); - $number = static fn (mixed $value): string => $value === null || $value === '' ? '-' : rtrim(rtrim(number_format((float) $value, 4, '.', ''), '0'), '.'); -@endphp -
原数据源已停用
+原数据来源不适用于运费对账,已清空本页面展示;接入正确数据源前,不再展示原明细或运费汇总。
+数据来源:JianSun · dbo.jst_order_express_details + dbo.Jst_SendData_View_extension + dbo.jst_salesOutboundInfo · 共享业务镜像
+| {{ $heading }} | + @endforeach +||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 本页面数据已清空,等待接入正确的运费对账数据源。 | ||||||||||||||||||||||
@if ($summaryReady) 完整筛选汇总{{ !empty($summary['computed_at']) ? ' · ' . $summary['computed_at'] : '' }} @elseif (!empty($freightReconciliationSummaryUrl)) 正在计算完整筛选汇总,明细可继续查看… @else 同步完成后提供汇总 @endif
-| {{ $heading }} | - @endforeach -||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| {{ $row['waybill'] ?? '-' }} | -{{ $row['product_id'] ?? '-' }} | -{{ $row['send_time'] ?? '-' }} | -{{ $row['transaction_order_no'] ?? '-' }} | -{{ $row['province'] ?? '-' }} | {{ $row['city'] ?? '-' }} | {{ $row['district'] ?? '-' }} | {{ $row['barcode'] ?? '-' }} | -{{ $row['express_name'] ?? '-' }} | {{ $row['express_name_2'] ?? '-' }} | {{ $row['quantity'] ?? '-' }} | -{{ $row['product_name'] ?? '-' }} | {{ $row['platform'] ?? '-' }} | {{ $row['shop_name'] ?? '-' }} | {{ $row['warehouse'] ?? '-' }} | -{{ $number($row['volume'] ?? null) }} | {{ $row['supplier'] ?? '-' }} | - @foreach (['length','width','height','freight','reconciliation_weight','reconciliation_volume'] as $numberField) -{{ $row[$numberField] === null ? '-' : ($numberField === 'freight' ? $money($row[$numberField]) : $number($row[$numberField])) }} | - @endforeach -|||||
| @if ($freightReconciliationPending ?? false) 正在等待物流明细镜像首次同步完成… @else 暂无符合条件的运费对账数据 @endif | ||||||||||||||||||||||