From 821cba385f7fc20527565aa6904fa6ccb6b0fab6 Mon Sep 17 00:00:00 2001 From: qiuxiang Date: Mon, 9 Nov 2026 23:03:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B4=A6=E6=88=B7=E4=BD=99=E9=A2=9D?= =?UTF-8?q?=E6=80=BB=E8=A7=88=E5=A2=9E=E5=8A=A0=E6=9C=9F=E6=9C=AB=E4=BD=99?= =?UTF-8?q?=E9=A2=9D=E6=98=8E=E7=BB=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StoreReceivingBalanceOverview.php | 20 ++++++++ .../StoreReceivingBalanceOverviewService.php | 40 +++++++++++++++ .../StoreReceivingBalanceOverview.vue | 50 +++++++++++++------ routes/admin.php | 2 + ...reReceivingBalanceOverviewEndpointTest.php | 37 ++++++++++++++ ...oreReceivingBalanceOverviewServiceTest.php | 31 ++++++++++++ .../StoreReceivingBalanceOverviewTest.php | 3 ++ 7 files changed, 169 insertions(+), 14 deletions(-) diff --git a/modules/EcommerceFinance/Http/Controllers/StoreReceivingBalanceOverview.php b/modules/EcommerceFinance/Http/Controllers/StoreReceivingBalanceOverview.php index e239bee7..d2cc0f74 100644 --- a/modules/EcommerceFinance/Http/Controllers/StoreReceivingBalanceOverview.php +++ b/modules/EcommerceFinance/Http/Controllers/StoreReceivingBalanceOverview.php @@ -70,6 +70,26 @@ class StoreReceivingBalanceOverview extends Controller } } + public function balanceDetail(Request $request, StoreReceivingBalanceOverviewService $service) + { + $this->authorizeStoreReceivingBills(); + $validated = $request->validate([ + 'month' => ['nullable', 'date_format:Y-m'], + ]); + + try { + return response()->json($service->balanceDetail( + (string) ($validated['month'] ?? now('Asia/Shanghai')->format('Y-m')), + )); + } catch (Throwable $exception) { + report($exception); + + return response()->json([ + 'message' => '期末余额明细暂时无法读取,请稍后重试。', + ], 503); + } + } + private function authorizeStoreReceivingBills(): void { $section = collect(SidebarPermissions::navigationFor(user())) diff --git a/modules/EcommerceFinance/Services/StoreReceivingBalanceOverviewService.php b/modules/EcommerceFinance/Services/StoreReceivingBalanceOverviewService.php index 0d3b7bd5..acf433f2 100644 --- a/modules/EcommerceFinance/Services/StoreReceivingBalanceOverviewService.php +++ b/modules/EcommerceFinance/Services/StoreReceivingBalanceOverviewService.php @@ -151,6 +151,46 @@ class StoreReceivingBalanceOverviewService return $this->flowDetail($month, 'expense'); } + /** + * 期末余额合计的平台明细。 + * + * 直接复用总览的平台余额,确保明细合计与期末余额卡片口径一致。 + * 明细金额统一返回元,页面再按万元展示。 + * + * @return array + */ + public function balanceDetail(string $month): array + { + $overview = $this->overview($month); + $details = []; + + foreach ($overview['platforms'] as $platform) { + if (! $platform['available'] || ! is_numeric($platform['balance'] ?? null)) { + continue; + } + + $details[] = [ + 'platform_slug' => $platform['slug'], + 'platform' => $platform['name'], + 'store_name' => '', + 'bill_item' => '', + 'amount' => round((float) $platform['balance'], 2), + ]; + } + + return [ + 'month' => $month, + 'period' => $overview['period'], + 'summary' => [ + 'balance' => $overview['summary']['balance'], + 'platform_count' => $overview['summary']['platform_count'], + 'available_platform_count' => $overview['summary']['available_platform_count'], + 'complete' => $overview['summary']['complete'], + ], + 'details' => $details, + ]; + } + /** @return array */ private function flowDetail(string $month, string $flow): array { diff --git a/resources/assets/js/components/business/StoreReceivingBalanceOverview.vue b/resources/assets/js/components/business/StoreReceivingBalanceOverview.vue index fc4cd7b5..bc15b224 100644 --- a/resources/assets/js/components/business/StoreReceivingBalanceOverview.vue +++ b/resources/assets/js/components/business/StoreReceivingBalanceOverview.vue @@ -28,11 +28,11 @@ @@ -73,7 +73,7 @@
{{ detailTitle }} -

{{ monthLabel }} · 按平台、店铺和账单项目汇总

+

{{ monthLabel }} · {{ detailDescription }}

当前筛选合计(万元) @@ -83,7 +83,7 @@
-
+
-