From 9ce558148855a25d5db6600d41366195f43f9a3a Mon Sep 17 00:00:00 2001 From: limeng <1131177064@qq.com> Date: Thu, 17 Sep 2026 15:43:12 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BB=93=E5=82=A8=E6=A0=B8?= =?UTF-8?q?=E7=AE=97=E6=98=8E=E7=BB=86=E6=9F=A5=E7=9C=8B=E5=B9=B6=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=AF=BC=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ThirdPartyWarehouseStorageDetailExport.php | 49 ++++++++++++++++ ...dPartyWarehouseStorageSettlementExport.php | 42 +------------- .../Business/ThirdPartyWarehouseQuotes.php | 39 ++++++++++++- .../third-party-warehouse-quotes.blade.php | 16 +++++- .../ThirdPartyWarehouseQuotePageTest.php | 57 ++++++++++++++++++- 5 files changed, 157 insertions(+), 46 deletions(-) create mode 100644 app/Exports/ThirdPartyWarehouseStorageDetailExport.php diff --git a/app/Exports/ThirdPartyWarehouseStorageDetailExport.php b/app/Exports/ThirdPartyWarehouseStorageDetailExport.php new file mode 100644 index 00000000..c01806d8 --- /dev/null +++ b/app/Exports/ThirdPartyWarehouseStorageDetailExport.php @@ -0,0 +1,49 @@ +> $rows */ + public function __construct(private readonly array $rows) + { + } + + public function title(): string + { + return '每日商品仓储费'; + } + + /** @return array */ + public function headings(): array + { + return [ + '日期', '货主', '商品编码', '商品名称', '供应商', '分类', '单位', + '上日结余', '当日进出净额', '当日库存结余', '当天仓储费', + ]; + } + + /** @return array> */ + public function array(): array + { + return array_map(static fn (array $row): array => [ + $row['date'], + $row['owner'], + $row['sku_code'], + $row['product_name'], + $row['supplier'], + $row['category'], + $row['unit'], + (float) $row['opening'], + (float) $row['net_movement'], + (float) $row['closing'], + (float) $row['storage_fee'], + ], $this->rows); + } +} diff --git a/app/Exports/ThirdPartyWarehouseStorageSettlementExport.php b/app/Exports/ThirdPartyWarehouseStorageSettlementExport.php index f158198c..b4a2a359 100644 --- a/app/Exports/ThirdPartyWarehouseStorageSettlementExport.php +++ b/app/Exports/ThirdPartyWarehouseStorageSettlementExport.php @@ -31,7 +31,7 @@ class ThirdPartyWarehouseStorageSettlementExport implements WithMultipleSheets new StorageSettlementSummarySheet($this->result['summary']), new StorageSettlementDailySheet($this->result['summary'], $this->result['daily']), new StorageSettlementSkuSheet($this->result['per_sku']), - new StorageSettlementDailySkuSheet($this->result['daily_sku'] ?? []), + new ThirdPartyWarehouseStorageDetailExport($this->result['daily_sku'] ?? []), ]; } } @@ -186,43 +186,3 @@ class StorageSettlementSkuSheet implements FromArray, WithHeadings, WithTitle ], $this->perSku); } } - -class StorageSettlementDailySkuSheet implements FromArray, WithHeadings, WithTitle -{ - /** @param list> $dailySku */ - public function __construct(private readonly array $dailySku) - { - } - - public function title(): string - { - return '每日商品仓储费'; - } - - /** @return array */ - public function headings(): array - { - return [ - '日期', '货主', '商品编码', '商品名称', '供应商', '分类', '单位', - '上日结余', '当日进出净额', '当日库存结余', '当天仓储费', - ]; - } - - /** @return array> */ - public function array(): array - { - return array_map(static fn (array $row): array => [ - $row['date'], - $row['owner'], - $row['sku_code'], - $row['product_name'], - $row['supplier'], - $row['category'], - $row['unit'], - (float) $row['opening'], - (float) $row['net_movement'], - (float) $row['closing'], - (float) $row['storage_fee'], - ], $this->dailySku); - } -} diff --git a/app/Http/Livewire/Business/ThirdPartyWarehouseQuotes.php b/app/Http/Livewire/Business/ThirdPartyWarehouseQuotes.php index 6e7a992c..3427a468 100644 --- a/app/Http/Livewire/Business/ThirdPartyWarehouseQuotes.php +++ b/app/Http/Livewire/Business/ThirdPartyWarehouseQuotes.php @@ -4,6 +4,7 @@ namespace App\Http\Livewire\Business; use App\Business\ThirdPartyWarehouseQuoteRepository; use App\Business\ThirdPartyWarehouseStorageFeeCalculator; +use App\Exports\ThirdPartyWarehouseStorageDetailExport; use App\Exports\ThirdPartyWarehouseStorageSettlementExport; use App\Models\Business\ThirdPartyWarehouseQuote; use App\Models\Business\ThirdPartyWarehouseStorageSettlement; @@ -181,6 +182,30 @@ class ThirdPartyWarehouseQuotes extends Component return Excel::download(new ThirdPartyWarehouseStorageSettlementExport($result), $fileName); } + public function exportSettlementDetails(string $period): ?BinaryFileResponse + { + $this->ensureAuthenticated(); + abort_unless(preg_match('/^\d{4}-(0[1-9]|1[0-2])$/', $period) === 1, 422); + + $settlement = $this->settlementForPeriod($period); + if ($settlement === null) { + $this->settlementError = '未找到 ' . $period . ' 的核算存档,请先核算。'; + + return null; + } + + $dailySku = ($settlement->detail_json ?: [])['daily_sku'] ?? []; + if ($dailySku === []) { + $this->showMissingSettlementDetails($period); + + return null; + } + + $fileName = $settlement->warehouse_name . '每日商品仓储费明细_' . $period . '.xlsx'; + + return Excel::download(new ThirdPartyWarehouseStorageDetailExport($dailySku), $fileName); + } + public function viewSettlementDetails(string $period): void { $this->ensureAuthenticated(); @@ -194,6 +219,7 @@ class ThirdPartyWarehouseQuotes extends Component $settlement = $this->settlementForPeriod($period); if ($settlement === null) { $this->settlementDetailMessage = '未找到 ' . $period . ' 的核算存档。'; + $this->dispatch('warehouse-settlement-details-opened'); return; } @@ -201,7 +227,7 @@ class ThirdPartyWarehouseQuotes extends Component $detail = $settlement->detail_json ?: []; $dailySku = $detail['daily_sku'] ?? []; if ($dailySku === []) { - $this->settlementDetailMessage = $period . ' 的原存档没有每日商品明细,请重新核算该月份后查看。'; + $this->showMissingSettlementDetails($period); return; } @@ -210,6 +236,7 @@ class ThirdPartyWarehouseQuotes extends Component sort($dates); $this->settlementDetailDates = $dates; $this->settlementDetailDate = $dates[0] ?? ''; + $this->dispatch('warehouse-settlement-details-opened'); } public function closeSettlementDetails(): void @@ -327,6 +354,16 @@ class ThirdPartyWarehouseQuotes extends Component ->first(); } + private function showMissingSettlementDetails(string $period): void + { + $this->settlementPeriod = $period; + $this->settlementDetailPeriod = $period; + $this->settlementDetailDate = ''; + $this->settlementDetailDates = []; + $this->settlementDetailMessage = $period . ' 的原存档没有每日商品明细,请重新核算该月份后查看和导出。'; + $this->dispatch('warehouse-settlement-details-opened'); + } + /** @return array> */ protected function rules(): array { diff --git a/resources/views/business/pages/courier-payables/partials/third-party-warehouse-quotes.blade.php b/resources/views/business/pages/courier-payables/partials/third-party-warehouse-quotes.blade.php index ed7f631c..750cbd30 100644 --- a/resources/views/business/pages/courier-payables/partials/third-party-warehouse-quotes.blade.php +++ b/resources/views/business/pages/courier-payables/partials/third-party-warehouse-quotes.blade.php @@ -4,7 +4,12 @@ }; @endphp -
+