From 119f52c442d56524935f292b00624fdb7fca77e2 Mon Sep 17 00:00:00 2001 From: qiuxiang <394405259@qq.com> Date: Thu, 19 Nov 2026 15:40:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=B4=A6=E6=88=B7=E4=BD=99=E9=A2=9D):=20?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B9=B3=E5=8F=B0=E4=B8=8E=E5=BA=97=E9=93=BA?= =?UTF-8?q?=E6=AF=8F=E6=97=A5=E4=BD=99=E9=A2=9D=E8=A7=86=E5=9B=BE=20(#1273?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 每日余额明细支持汇总、平台和店铺维度,增加真实每日余额接口、店铺筛选分页及点击日期查看当日四项明细。 --- .../StoreReceivingBalanceOverview.php | 29 + .../StoreReceivingBalanceOverviewService.php | 296 +++++- .../StoreReceivingBalanceOverview.vue | 889 +++++++++++++++--- routes/admin.php | 2 + ...reReceivingBalanceOverviewEndpointTest.php | 77 ++ ...oreReceivingBalanceOverviewServiceTest.php | 102 ++ .../StoreReceivingBalanceOverviewTest.php | 53 +- 7 files changed, 1282 insertions(+), 166 deletions(-) diff --git a/modules/EcommerceFinance/Http/Controllers/StoreReceivingBalanceOverview.php b/modules/EcommerceFinance/Http/Controllers/StoreReceivingBalanceOverview.php index c11bdb09..cf79ebb0 100644 --- a/modules/EcommerceFinance/Http/Controllers/StoreReceivingBalanceOverview.php +++ b/modules/EcommerceFinance/Http/Controllers/StoreReceivingBalanceOverview.php @@ -131,6 +131,35 @@ class StoreReceivingBalanceOverview extends Controller } } + public function dailyBalances(Request $request, StoreReceivingBalanceOverviewService $service) + { + $this->authorizeStoreReceivingBills(); + + try { + $period = $this->requestedPeriod($request); + $cacheKey = implode(':', [ + 'ecommerce-finance', + 'account-balance-daily', + 'v1', + (string) company_id(), + $period[0], + $period[1] ?? '', + ]); + + return response()->json(Cache::remember( + $cacheKey, + now()->addMinutes(30), + static fn (): array => $service->dailyBalances(...$period), + )); + } catch (Throwable $exception) { + report($exception); + + return response()->json([ + 'message' => '每日余额明细暂时无法读取,请稍后重试。', + ], 503); + } + } + /** @return array{0:string,1?:string} */ private function requestedPeriod(Request $request): array { diff --git a/modules/EcommerceFinance/Services/StoreReceivingBalanceOverviewService.php b/modules/EcommerceFinance/Services/StoreReceivingBalanceOverviewService.php index 7bba0037..ae95273a 100644 --- a/modules/EcommerceFinance/Services/StoreReceivingBalanceOverviewService.php +++ b/modules/EcommerceFinance/Services/StoreReceivingBalanceOverviewService.php @@ -343,6 +343,138 @@ class StoreReceivingBalanceOverviewService ]; } + /** + * 汇总、平台和店铺三个层级的每日余额。 + * + * 平台每日余额以平台期初为起点,按真实账单发生日期滚动; + * 店铺每日余额以店铺期初为起点。任何一层缺少可靠期初时, + * 对应日期的余额返回 null,并在 available 中明确标记。 + * + * @return array + */ + public function dailyBalances(string $periodStart, ?string $periodEnd = null): array + { + [$periodStart, $periodEnd, $periodMonth] = $this->periodForRange($periodStart, $periodEnd); + $dates = $this->dateRange($periodStart, $periodEnd); + $overview = $this->overview($periodStart, $periodEnd); + $platforms = $overview['platforms']; + $stores = []; + $errors = []; + $platformOrder = []; + + foreach ($platforms as $index => &$platform) { + $slug = (string) $platform['slug']; + $platformOrder[$slug] = $index; + $activityAvailable = true; + try { + $activity = $this->dailyActivity($slug, $periodStart, $periodEnd, $dates); + } catch (Throwable $exception) { + report($exception); + $activity = ['by_date' => [], 'by_store' => []]; + $activityAvailable = false; + $errors[$slug] = $this->safeErrorMessage($exception); + } + + $daily = $this->rollDailyBalances( + $dates, + $activityAvailable + && $platform['available'] + && is_numeric($platform['opening_balance'] ?? null) + ? (float) $platform['opening_balance'] + : null, + $activity['by_date'], + ); + $platform['daily'] = $daily; + $platform['daily_error'] = $activityAvailable ? null : $errors[$slug]; + $platform['daily_reconciled'] = $this->dailyReconciled( + $daily, + is_numeric($platform['income'] ?? null) ? (float) $platform['income'] : null, + is_numeric($platform['expense'] ?? null) ? (float) $platform['expense'] : null, + ); + + try { + $storeBalances = $this->fetchPlatformStoreBalances($slug, $periodStart, $periodEnd); + } catch (Throwable $exception) { + report($exception); + $errors[$slug . ':stores'] = $this->safeErrorMessage($exception); + continue; + } + + foreach ($storeBalances as $storeBalance) { + $storeName = $this->storeName($storeBalance['store_name'] ?? ''); + $storeKey = $this->dailyStoreKey($slug, $storeName); + $storeDaily = $this->rollDailyBalances( + $dates, + $activityAvailable && is_numeric($storeBalance['opening_balance'] ?? null) + ? (float) $storeBalance['opening_balance'] + : null, + $activity['by_store'][$storeKey] ?? [], + ); + $totals = $this->dailyTotals($dates, $storeDaily); + $stores[] = [ + 'platform_slug' => $slug, + 'platform' => $platform['name'], + 'store_name' => $storeName, + 'opening_balance' => is_numeric($storeBalance['opening_balance'] ?? null) + ? round((float) $storeBalance['opening_balance'], 2) + : null, + 'income' => $totals['income'], + 'expense' => $totals['expense'], + 'amount' => $totals['closing'], + 'available' => $totals['available'], + 'daily' => $storeDaily, + ]; + } + } + unset($platform); + + usort($stores, static function (array $left, array $right) use ($platformOrder): int { + return [ + $platformOrder[$left['platform_slug']] ?? 99, + $left['store_name'], + ] <=> [ + $platformOrder[$right['platform_slug']] ?? 99, + $right['store_name'], + ]; + }); + + $summaryDaily = []; + foreach ($dates as $date) { + $dayRows = array_map( + static fn (array $platform): ?array => $platform['daily'][$date] ?? null, + $platforms, + ); + $available = $dayRows !== [] + && ! in_array(null, $dayRows, true) + && ! in_array(false, array_column($dayRows, 'available'), true); + $summaryDaily[$date] = [ + 'date' => $date, + 'opening' => $available ? round(array_sum(array_column($dayRows, 'opening')), 2) : null, + 'income' => $available ? round(array_sum(array_column($dayRows, 'income')), 2) : null, + 'expense' => $available ? round(array_sum(array_column($dayRows, 'expense')), 2) : null, + 'closing' => $available ? round(array_sum(array_column($dayRows, 'closing')), 2) : null, + 'available' => $available, + ]; + } + + return [ + ...$overview, + 'platforms' => $platforms, + 'dates' => $dates, + 'daily_summary' => $summaryDaily, + 'stores' => $stores, + 'daily_errors' => $errors, + 'store_summary' => [ + 'store_count' => count($stores), + 'available_store_count' => count(array_filter( + $stores, + static fn (array $store): bool => (bool) $store['available'], + )), + ], + 'daily_note' => '按账单实际发生日期滚动计算;缺少可靠期初或当天没有可计算余额时显示“—”。', + ]; + } + /** * 指定平台在账期内的店铺期末余额,供双源核对和趋势复用。 * @@ -449,6 +581,153 @@ class StoreReceivingBalanceOverviewService ]; } + /** + * @return iterable> + */ + protected function fetchPlatformDailyRows(string $platform, string $start, string $end): iterable + { + return $this->fetchPlatformRows($platform, $start, $end, null); + } + + /** @return list */ + private function dateRange(string $start, string $end): array + { + $first = CarbonImmutable::parse($start, 'Asia/Shanghai')->startOfDay(); + $last = CarbonImmutable::parse($end, 'Asia/Shanghai')->startOfDay(); + if ($last->lt($first)) { + throw new RuntimeException('invalid_balance_overview_period'); + } + if ($first->diffInDays($last) > 62) { + throw new RuntimeException('余额明细一次最多查询 62 天'); + } + + $dates = []; + for ($date = $first; $date->lte($last); $date = $date->addDay()) { + $dates[] = $date->format('Y-m-d'); + } + + return $dates; + } + + /** + * @param list $dates + * @return array{by_date:array,by_store:array>} + */ + private function dailyActivity(string $platform, string $start, string $end, array $dates): array + { + $dateSet = array_fill_keys($dates, true); + $byDate = []; + $byStore = []; + + foreach ($this->fetchPlatformDailyRows($platform, $start, $end) as $row) { + $date = substr(trim((string) ($row['occurred_at'] ?? '')), 0, 10); + if (! isset($dateSet[$date])) { + continue; + } + + $storeKey = $this->dailyStoreKey($platform, (string) ($row['store_name'] ?? '')); + $incomeCents = (int) round((float) ($row['income'] ?? 0) * 100); + $expenseCents = (int) round((float) ($row['expense'] ?? 0) * 100); + $byDate[$date]['income_cents'] = ($byDate[$date]['income_cents'] ?? 0) + $incomeCents; + $byDate[$date]['expense_cents'] = ($byDate[$date]['expense_cents'] ?? 0) + $expenseCents; + $byStore[$storeKey][$date]['income_cents'] = ( + $byStore[$storeKey][$date]['income_cents'] ?? 0 + ) + $incomeCents; + $byStore[$storeKey][$date]['expense_cents'] = ( + $byStore[$storeKey][$date]['expense_cents'] ?? 0 + ) + $expenseCents; + } + + foreach ($byDate as $date => $value) { + $byDate[$date] = [ + 'income' => round(($value['income_cents'] ?? 0) / 100, 2), + 'expense' => round(($value['expense_cents'] ?? 0) / 100, 2), + ]; + } + foreach ($byStore as $storeKey => $storeDates) { + foreach ($storeDates as $date => $value) { + $byStore[$storeKey][$date] = [ + 'income' => round(($value['income_cents'] ?? 0) / 100, 2), + 'expense' => round(($value['expense_cents'] ?? 0) / 100, 2), + ]; + } + } + + return ['by_date' => $byDate, 'by_store' => $byStore]; + } + + /** + * @param list $dates + * @param array $activity + * @return array + */ + private function rollDailyBalances(array $dates, ?float $opening, array $activity): array + { + $currentClosing = $opening === null ? null : round($opening, 2); + $daily = []; + foreach ($dates as $date) { + $dayIncome = round((float) ($activity[$date]['income'] ?? 0), 2); + $dayExpense = round((float) ($activity[$date]['expense'] ?? 0), 2); + $dayOpening = $currentClosing; + if ($currentClosing !== null) { + $currentClosing = round($currentClosing + $dayIncome - $dayExpense, 2); + } + $daily[$date] = [ + 'date' => $date, + 'opening' => $dayOpening, + 'income' => $dayIncome, + 'expense' => $dayExpense, + 'closing' => $currentClosing, + 'available' => $currentClosing !== null, + ]; + } + + return $daily; + } + + /** + * @param array $daily + */ + private function dailyReconciled(array $daily, ?float $income, ?float $expense): bool + { + if ($income === null || $expense === null || $daily === []) { + return false; + } + $dailyIncome = round(array_sum(array_column($daily, 'income')), 2); + $dailyExpense = round(array_sum(array_column($daily, 'expense')), 2); + + return abs($dailyIncome - $income) <= 0.02 && abs($dailyExpense - $expense) <= 0.02; + } + + /** + * @param list $dates + * @param array $daily + * @return array{income:float,expense:float,closing:float|null,available:bool} + */ + private function dailyTotals(array $dates, array $daily): array + { + $rows = array_values(array_intersect_key($daily, array_fill_keys($dates, true))); + $available = $rows !== [] && ! in_array(false, array_column($rows, 'available'), true); + + return [ + 'income' => round(array_sum(array_column($rows, 'income')), 2), + 'expense' => round(array_sum(array_column($rows, 'expense')), 2), + 'closing' => $available + ? round((float) ($rows[array_key_last($rows)]['closing'] ?? 0), 2) + : null, + 'available' => $available, + ]; + } + + private function dailyStoreKey(string $platform, string $storeName): string + { + $storeName = $this->storeName($storeName); + + return in_array($platform, ['pinduoduo', 'douyin'], true) + ? JushuitanShopBalanceRepository::normalizeStoreName($storeName) + : $storeName; + } + /** @return array */ private function flowDetail(string $periodStart, ?string $periodEnd, string $flow): array { @@ -1126,14 +1405,16 @@ class StoreReceivingBalanceOverviewService string $platform, string $start, string $end, - string $flow, + ?string $flow, ): iterable { $filters = [ 'start' => $start, 'end' => $end, - 'business_type' => $flow === 'income' ? '收入' : '支出', ]; + if ($flow !== null) { + $filters['business_type'] = $flow === 'income' ? '收入' : '支出'; + } if ($platform === 'taobao-alipay') { $filters['exclude_store_name_prefix'] = self::OVERVIEW_EXCLUDED_TAOBAO_ALIPAY_STORE_PREFIX; } @@ -1169,8 +1450,14 @@ class StoreReceivingBalanceOverviewService { $query = AccountBill::query() ->where('company_id', company_id()) - ->where('bill_type', $platform) - ->where($flow, '>', 0); + ->where('bill_type', $platform); + if ($flow === null) { + $query->where(function (Builder $query): void { + $query->where('income', '>', 0)->orWhere('expense', '>', 0); + }); + } else { + $query->where($flow, '>', 0); + } if (in_array($platform, ['vipshop', 'vipshop-jx'], true)) { $settlePeriod = "JSON_UNQUOTE(JSON_EXTRACT(payload, '$.settle_period'))"; @@ -1187,6 +1474,7 @@ class StoreReceivingBalanceOverviewService 'bill_item' => $platform === 'vipshop-jx' ? (string) data_get($bill->payload ?? [], 'second_remark', '') : (string) ($bill->bill_item ?? ''), + 'occurred_at' => (string) ($bill->occurred_at ?? ''), 'income' => (float) $bill->income, 'expense' => (float) $bill->expense, ]; diff --git a/resources/assets/js/components/business/StoreReceivingBalanceOverview.vue b/resources/assets/js/components/business/StoreReceivingBalanceOverview.vue index d9417bbe..ef5dc70d 100644 --- a/resources/assets/js/components/business/StoreReceivingBalanceOverview.vue +++ b/resources/assets/js/components/business/StoreReceivingBalanceOverview.vue @@ -1,5 +1,5 @@ @@ -277,13 +437,7 @@ import { Mandarin } from 'flatpickr/dist/l10n/zh'; import 'flatpickr/dist/flatpickr.css'; const pad = value => String(value).padStart(2, '0'); -const formatIsoDate = date => `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}`; -const parseIsoDate = (value) => { - const parts = String(value || '').split('-').map(Number); - if (parts.length !== 3 || parts.some(part => !Number.isFinite(part))) return null; - - return new Date(parts[0], parts[1] - 1, parts[2]); -}; +const roundMoney = value => Math.round((Number(value) || 0) * 100) / 100; const lastCompleteMonthRange = () => { const now = new Date(); const year = now.getMonth() === 0 ? now.getFullYear() - 1 : now.getFullYear(); @@ -295,80 +449,6 @@ const lastCompleteMonthRange = () => { end: `${year}-${pad(month)}-${pad(lastDay)}`, }; }; -const enumerateDates = (start, end) => { - const first = parseIsoDate(start); - const last = parseIsoDate(end); - if (!first || !last || first > last) return []; - - const dates = []; - const cursor = new Date(first.getFullYear(), first.getMonth(), first.getDate()); - while (cursor <= last) { - dates.push(formatIsoDate(cursor)); - cursor.setDate(cursor.getDate() + 1); - } - - return dates; -}; -const mulberry32 = (seed) => { - let state = seed >>> 0; - - return () => { - state = (state + 0x6D2B79F5) >>> 0; - let value = Math.imul(state ^ (state >>> 15), 1 | state); - value = (value + Math.imul(value ^ (value >>> 7), 61 | value)) ^ value; - - return ((value ^ (value >>> 14)) >>> 0) / 4294967296; - }; -}; -const allocateCents = (targetCents, weights) => { - const totalCents = Math.max(0, Math.round(Number(targetCents) || 0)); - const weightTotal = weights.reduce((sum, weight) => sum + weight, 0) || 1; - const allocated = weights.map(weight => Math.floor((totalCents * weight) / weightTotal)); - const remainder = totalCents - allocated.reduce((sum, value) => sum + value, 0); - if (allocated.length) allocated[allocated.length - 1] += remainder; - - return allocated; -}; -const buildSeededTrend = ({ start, end, opening, income, expense }) => { - const dates = enumerateDates(start, end); - if (!dates.length) return []; - - const random = mulberry32(20261001); - const incomeWeights = []; - const expenseWeights = []; - - dates.forEach((date) => { - const parsed = parseIsoDate(date); - const dayOfWeek = parsed.getDay(); - const dayOfMonth = parsed.getDate(); - const isWeekend = dayOfWeek === 0 || dayOfWeek === 6; - incomeWeights.push((0.8 + random() * 0.55) * (isWeekend ? 0.78 : 1)); - - let expenseWeight = (0.82 + random() * 0.48) * (isWeekend ? 0.72 : 1); - if ([10, 20, 31].includes(dayOfMonth)) expenseWeight *= 1.55; - expenseWeights.push(expenseWeight); - }); - - const incomeByDay = allocateCents(Math.round(Number(income || 0) * 100), incomeWeights); - const expenseByDay = allocateCents(Math.round(Number(expense || 0) * 100), expenseWeights); - let runningOpening = Math.round(Number(opening || 0) * 100); - - return dates.map((date, index) => { - const dayIncome = incomeByDay[index]; - const dayExpense = expenseByDay[index]; - const closing = runningOpening + dayIncome - dayExpense; - const row = { - date, - opening: runningOpening, - income: dayIncome, - expense: dayExpense, - closing, - }; - runningOpening = closing; - - return row; - }); -}; const emptySummary = () => ({ opening_balance: null, @@ -403,6 +483,25 @@ export default { error: '', summary: emptySummary(), platforms: [], + dailyLoading: true, + dailyError: '', + dailyDates: [], + dailySummary: {}, + dailyPlatforms: [], + stores: [], + dailyNote: '每日余额按账单实际发生日期滚动计算,单位为万元。', + detailView: 'summary', + detailTabs: [ + { key: 'summary', label: '汇总' }, + { key: 'platform', label: '平台' }, + { key: 'store', label: '店铺' }, + ], + storePlatformFilter: '', + storeKeyword: '', + storePage: 1, + storePageSize: 30, + expandedStorePlatforms: {}, + selectedDailyDetail: null, requestSerial: 0, horizon: 30, horizonOptions: [ @@ -414,6 +513,9 @@ export default { }; }, computed: { + busy() { + return this.loading || this.dailyLoading; + }, invalidDateRange() { return Boolean( this.dateRange.start @@ -437,6 +539,66 @@ export default { horizonLabel() { return `近 ${this.horizon} 天`; }, + visibleDates() { + if (this.horizon === 7) return this.dailyDates.slice(-7); + + return this.dailyDates.length > 31 ? this.dailyDates.slice(-31) : this.dailyDates; + }, + filteredStoreRows() { + const keyword = this.storeKeyword.toLocaleLowerCase('zh-CN'); + + return this.stores.filter((store) => { + if (this.storePlatformFilter && store.platform_slug !== this.storePlatformFilter) return false; + if (!keyword) return true; + + return String(store.store_name || '').toLocaleLowerCase('zh-CN').includes(keyword); + }); + }, + storePageCount() { + return Math.max(1, Math.ceil(this.filteredStoreRows.length / this.storePageSize)); + }, + pagedStoreRows() { + const page = Math.min(Math.max(this.storePage, 1), this.storePageCount); + const start = (page - 1) * this.storePageSize; + + return this.filteredStoreRows.slice(start, start + this.storePageSize); + }, + pagedStoreGroups() { + const groups = new Map(); + this.pagedStoreRows.forEach((store) => { + if (!groups.has(store.platform_slug)) { + groups.set(store.platform_slug, { + slug: store.platform_slug, + platform: store.platform, + stores: [], + totals: {}, + }); + } + const group = groups.get(store.platform_slug); + group.stores.push(store); + }); + + return Array.from(groups.values()).map((group) => { + const totals = {}; + this.visibleDates.forEach((date) => { + const daily = group.stores.map(store => store.daily?.[date] || null); + const available = daily.length > 0 + && daily.every(day => day && day.available && Number.isFinite(Number(day.closing))); + totals[date] = available + ? { + date, + opening: roundMoney(daily.reduce((sum, day) => sum + Number(day.opening || 0), 0)), + income: roundMoney(daily.reduce((sum, day) => sum + Number(day.income || 0), 0)), + expense: roundMoney(daily.reduce((sum, day) => sum + Number(day.expense || 0), 0)), + closing: roundMoney(daily.reduce((sum, day) => sum + Number(day.closing || 0), 0)), + available: true, + } + : null; + }); + + return { ...group, totals }; + }); + }, statusClass() { return { 'is-loading': this.loading, @@ -450,6 +612,15 @@ export default { .filter(platform => !platform.available) .map(platform => platform.name); }, + platformRows() { + const dailyBySlug = new Map(this.dailyPlatforms.map(platform => [platform.slug, platform])); + const basePlatforms = this.platforms.length ? this.platforms : this.dailyPlatforms; + + return basePlatforms.map(platform => ({ + ...platform, + ...(dailyBySlug.get(platform.slug) || {}), + })); + }, cards() { return [ { @@ -487,26 +658,21 @@ export default { ]; }, fullTrendRows() { - if (!this.summary.complete) return []; - const values = [ - this.summary.opening_balance, - this.summary.income, - this.summary.expense, - ].map(Number); - if (values.some(value => !Number.isFinite(value))) return []; + return this.visibleDates.map((date) => { + const row = this.dailySummary[date] || {}; - return buildSeededTrend({ - start: this.queryRange.start, - end: this.queryRange.end, - opening: values[0], - income: values[1], - expense: values[2], + return { + date, + opening: this.valueToCents(row.opening), + income: this.valueToCents(row.income), + expense: this.valueToCents(row.expense), + closing: this.valueToCents(row.closing), + available: Boolean(row.available), + }; }); }, visibleRows() { - if (this.horizon === 7) return this.fullTrendRows.slice(-7); - - return this.fullTrendRows.length > 31 ? this.fullTrendRows.slice(-31) : this.fullTrendRows; + return this.fullTrendRows; }, chart() { const width = 1000; @@ -532,7 +698,23 @@ export default { }; } - const values = rows.map(row => row.closing / 1000000); + const values = rows + .filter(row => row.available && Number.isFinite(row.closing)) + .map(row => row.closing / 1000000); + if (!values.length) { + return { + width, + height, + plotLeft, + plotRight, + plotBottom, + points: [], + xTicks: [], + yTicks: [], + linePath: '', + areaPath: '', + }; + } const rawMin = Math.min(...values); const rawMax = Math.max(...values); const spread = Math.max(rawMax - rawMin, Math.abs(rawMax) * 0.08, 1); @@ -548,12 +730,18 @@ export default { const yForValue = value => ( plotTop + ((domainMax - value) / (domainMax - domainMin || 1)) * plotHeight ); - const points = rows.map((row, index) => ({ - row, - index, - x: xForIndex(index), - y: yForValue(row.closing / 1000000), - })); + const points = rows + .map((row, index) => { + if (!row.available || !Number.isFinite(row.closing)) return null; + + return { + row, + index, + x: xForIndex(index), + y: yForValue(row.closing / 1000000), + }; + }) + .filter(Boolean); const linePath = points .map((point, index) => `${index === 0 ? 'M' : 'L'} ${point.x.toFixed(2)} ${point.y.toFixed(2)}`) .join(' '); @@ -607,13 +795,26 @@ export default { watch: { horizon() { this.hideTooltip(); + this.closeDailyDetail(); }, queryRange: { deep: true, handler() { this.hideTooltip(); + this.closeDailyDetail(); }, }, + storePlatformFilter() { + this.storePage = 1; + this.closeDailyDetail(); + }, + storeKeyword() { + this.storePage = 1; + this.closeDailyDetail(); + }, + storePageCount(value) { + if (this.storePage > value) this.storePage = value; + }, }, mounted() { this.fetchOverview(); @@ -622,10 +823,14 @@ export default { async fetchOverview() { const requestId = ++this.requestSerial; this.loading = true; + this.dailyLoading = true; this.error = ''; + this.dailyError = ''; + this.hideTooltip(); + this.closeDailyDetail(); try { - const response = await window.axios.get(this.apiBase, { + const response = await window.axios.get(`${this.apiBase}/daily-balance`, { params: { start: this.queryRange.start, end: this.queryRange.end, @@ -636,15 +841,30 @@ export default { const body = response.data || {}; this.summary = { ...emptySummary(), ...(body.summary || {}) }; this.platforms = Array.isArray(body.platforms) ? body.platforms : []; + this.dailyDates = Array.isArray(body.dates) ? body.dates : []; + this.dailySummary = body.daily_summary || {}; + this.dailyPlatforms = this.platforms; + this.stores = Array.isArray(body.stores) ? body.stores : []; + this.dailyNote = body.daily_note + || '每日余额按账单实际发生日期滚动计算,单位为万元。'; + this.storePage = 1; } catch (error) { if (requestId !== this.requestSerial) return; this.summary = emptySummary(); this.platforms = []; + this.dailyDates = []; + this.dailySummary = {}; + this.dailyPlatforms = []; + this.stores = []; this.error = (error.response && error.response.data && error.response.data.message) - || '店铺余额趋势看板暂时无法读取,请稍后重试。'; + || '账户余额总览暂时无法读取,请稍后重试。'; + this.dailyError = this.error; } finally { - if (requestId === this.requestSerial) this.loading = false; + if (requestId === this.requestSerial) { + this.loading = false; + this.dailyLoading = false; + } } }, applyTimeRange() { @@ -665,6 +885,96 @@ export default { if (this.horizon === value) return; this.horizon = value; }, + selectDetailView(view) { + if (this.detailView === view) return; + this.detailView = view; + this.storePage = 1; + this.closeDailyDetail(); + }, + isStoreGroupExpanded(slug) { + return this.expandedStorePlatforms[slug] !== false; + }, + toggleStoreGroup(slug) { + this.expandedStorePlatforms = { + ...this.expandedStorePlatforms, + [slug]: !this.isStoreGroupExpanded(slug), + }; + }, + valueToCents(value) { + if (value === null || value === undefined || value === '') return null; + const number = Number(value); + + return Number.isFinite(number) ? Math.round(number * 100) : null; + }, + dailyValue(item, date) { + const row = item && item.daily ? item.daily[date] : null; + + return row && row.available && Number.isFinite(Number(row.closing)) ? row : null; + }, + dailyCell(item, date) { + const row = this.dailyValue(item, date); + + return row ? this.plainMoney(this.valueToCents(row.closing)) : '—'; + }, + dailySummaryValue(date) { + const row = this.dailySummary[date]; + + return row && row.available && Number.isFinite(Number(row.closing)) ? row : null; + }, + dailySummaryCell(date) { + const row = this.dailySummaryValue(date); + + return row ? this.plainMoney(this.valueToCents(row.closing)) : '—'; + }, + storeDailyValue(store, date) { + return this.dailyValue(store, date); + }, + storeDailyCell(store, date) { + return this.dailyCell(store, date); + }, + groupCell(group, date) { + const row = group.totals[date]; + + return row ? this.plainMoney(this.valueToCents(row.closing)) : '—'; + }, + openDailyDetail(kind, item, date) { + const values = kind === 'summary' + ? this.dailySummaryValue(date) + : kind === 'group' + ? item.totals[date] + : this.dailyValue(item, date); + if (!values) return; + + this.selectedDailyDetail = { + date, + title: kind === 'store' + ? `${item.platform} · ${item.store_name}` + : kind === 'platform' || kind === 'group' + ? item.name || item.platform + : '全部平台', + values, + }; + }, + closeDailyDetail() { + this.selectedDailyDetail = null; + }, + dailyDetailMoney(key) { + const value = this.selectedDailyDetail?.values?.[key]; + + return value !== null + && value !== undefined + && value !== '' + && Number.isFinite(Number(value)) + ? this.plainMoney(this.valueToCents(value)) + : '—'; + }, + dailyDetailSigned(key) { + const value = this.selectedDailyDetail?.values?.[key]; + if (value === null || value === undefined || value === '' || !Number.isFinite(Number(value))) return '—'; + const sign = key === 'expense' ? '−' : '+'; + + return `${sign}${this.plainMoney(this.valueToCents(value))}`; + }, showTooltip(event, index) { const host = this.$refs.chartWrap; if (!host) return; @@ -1218,6 +1528,294 @@ export default { color: var(--trend-muted); text-align: center !important; } +.trend-table-caption { + margin-top: .25rem !important; +} +.trend-detail-tabs { + display: inline-flex; + flex: 0 0 auto; + gap: .2rem; + padding: .2rem; + border-radius: .5rem; + background: #f1f5f9; +} +.trend-detail-tabs button { + min-width: 3.75rem; + height: 1.9rem; + padding: 0 .65rem; + border: 0; + border-radius: .38rem; + background: transparent; + color: var(--trend-muted); + font: 600 .6875rem/1 inherit; + cursor: pointer; +} +.trend-detail-tabs button.is-active { + background: #fff; + color: #765722; + box-shadow: 0 1px 4px rgba(23, 23, 23, .12); +} +.trend-detail-tabs button:focus-visible, +.trend-matrix-cell:focus-visible, +.trend-group-toggle:focus-visible, +.trend-store-filters select:focus-visible, +.trend-store-filters input:focus-visible, +.trend-store-pagination button:focus-visible, +.trend-day-detail-close:focus-visible { + outline: 2px solid rgba(185, 149, 79, .42); + outline-offset: 2px; +} +.trend-matrix-scroll { + max-height: 26rem; + overflow: auto; + border-top: 1px solid var(--trend-line); +} +.trend-matrix-table { + width: max-content; + min-width: 100%; + border-collapse: separate; + border-spacing: 0; + color: #334155; + font-size: .6875rem; +} +.trend-matrix-table th, +.trend-matrix-table td { + min-width: 4.65rem; + height: 2.55rem; + padding: .45rem .7rem; + border-right: 1px solid #f1f5f9; + border-bottom: 1px solid #f1f5f9; + background: #fff; + text-align: right; + white-space: nowrap; + font-variant-numeric: tabular-nums; +} +.trend-matrix-table thead th { + position: sticky; + z-index: 2; + top: 0; + background: #faf8f3; + color: #6f6556; + font-weight: 600; +} +.trend-matrix-table tbody tr:hover > * { + background: #fcfaf5; +} +.trend-matrix-table .trend-sticky-platform, +.trend-matrix-table .trend-sticky-store { + position: sticky; + left: 0; + z-index: 3; + text-align: left; + background: #fff; +} +.trend-matrix-table .trend-sticky-platform { + width: 8rem; + min-width: 8rem; +} +.trend-matrix-table .trend-sticky-store { + left: 8rem; + width: 14rem; + min-width: 14rem; +} +.trend-matrix-table thead .trend-sticky-platform, +.trend-matrix-table thead .trend-sticky-store { + z-index: 4; + background: #faf8f3; +} +.trend-matrix-table .trend-matrix-total > * { + background: #fbfaf7; + font-weight: 700; +} +.trend-matrix-table .trend-store-group > * { + background: #f8f5ee; + font-weight: 700; +} +.trend-matrix-cell { + width: 100%; + min-height: 1.5rem; + padding: .2rem 0; + border: 0; + background: transparent; + color: inherit; + font: inherit; + font-variant-numeric: tabular-nums; + text-align: right; + cursor: pointer; +} +.trend-matrix-cell:hover { + color: #765722; +} +.trend-matrix-cell:disabled { + color: #a8a29a; + cursor: default; +} +.trend-matrix-cell.is-closing { + color: #171717; + font-weight: 700; +} +.trend-store-filters { + display: flex; + align-items: flex-end; + flex-wrap: wrap; + gap: .65rem; + padding: .75rem 1.2rem; + border-top: 1px solid #eee9df; + background: #fcfbf8; +} +.trend-store-filters label { + display: flex; + min-width: 10rem; + flex-direction: column; + gap: .25rem; + color: var(--trend-muted); + font-size: .6875rem; +} +.trend-store-filters .trend-store-search { + min-width: 14rem; + flex: 1; +} +.trend-store-filters select, +.trend-store-filters input { + width: 100%; + height: 2rem; + padding: 0 .65rem; + border: 1px solid #d8d2c7; + border-radius: .42rem; + background: #fff; + color: var(--trend-ink); + font: 400 .75rem/1 "JetBrains Mono", "Microsoft YaHei", "PingFang SC", monospace; +} +.trend-store-count { + margin-left: auto; + padding-bottom: .55rem; + color: #8a8173; + font-size: .6875rem; + white-space: nowrap; +} +.trend-group-toggle { + display: inline-flex; + align-items: center; + gap: .35rem; + padding: 0; + border: 0; + background: transparent; + color: #61513a; + font: 700 .6875rem/1 inherit; + cursor: pointer; +} +.trend-store-name { + padding-left: 1.35rem !important; + font-weight: 500; +} +.trend-store-pagination { + display: flex; + align-items: center; + justify-content: flex-end; + gap: .7rem; + padding: .65rem 1.2rem; + border-top: 1px solid #eee9df; + color: var(--trend-muted); + font-size: .6875rem; +} +.trend-store-pagination button, +.trend-daily-error button { + height: 1.9rem; + padding: 0 .7rem; + border: 1px solid #d8d2c7; + border-radius: .38rem; + background: #fff; + color: #55462e; + font: 600 .6875rem/1 inherit; + cursor: pointer; +} +.trend-store-pagination button:disabled { + color: #aaa297; + cursor: default; +} +.trend-daily-error { + display: flex; + align-items: center; + gap: .7rem; + padding: .8rem 1.2rem; + border-top: 1px solid #f0d8c7; + background: #fff8f2; + color: #8a4b16; + font-size: .75rem; +} +.trend-daily-error button { + margin-left: auto; +} +.trend-day-detail { + position: relative; + display: flex; + align-items: center; + gap: 1.2rem; + margin: .75rem 1.2rem 1rem; + padding: .75rem 2rem .75rem .85rem; + border: 1px solid #d9c9a9; + border-radius: .55rem; + background: #fffaf0; + color: #4d4437; +} +.trend-day-detail > div:first-child { + display: flex; + min-width: 12rem; + flex-direction: column; + gap: .2rem; +} +.trend-day-detail strong { + color: #2d2923; + font-size: .75rem; +} +.trend-day-detail span { + color: var(--trend-muted); + font-size: .6875rem; +} +.trend-day-detail dl { + display: grid; + grid-template-columns: repeat(4, minmax(5.5rem, auto)); + gap: .9rem; + margin: 0; +} +.trend-day-detail dl div { + display: flex; + flex-direction: column; + gap: .15rem; +} +.trend-day-detail dt { + color: var(--trend-muted); + font-size: .625rem; +} +.trend-day-detail dd { + margin: 0; + color: #241f19; + font-size: .75rem; + font-weight: 700; + font-variant-numeric: tabular-nums; +} +.trend-day-detail dd.is-income { + color: var(--trend-green); +} +.trend-day-detail dd.is-expense { + color: var(--trend-red); +} +.trend-day-detail dd.is-closing { + color: #765722; +} +.trend-day-detail-close { + position: absolute; + top: .45rem; + right: .5rem; + width: 1.5rem; + height: 1.5rem; + padding: 0; + border: 0; + background: transparent; + color: #8b7c63; + font-size: 1rem; + cursor: pointer; +} .trend-footnote { margin: 1rem .2rem 0; color: #9ca3af; @@ -1232,6 +1830,14 @@ export default { width: 100%; align-items: flex-start; } + .trend-day-detail { + align-items: flex-start; + flex-direction: column; + gap: .65rem; + } + .trend-day-detail dl { + grid-template-columns: repeat(2, minmax(5.5rem, 1fr)); + } } @media (max-width: 760px) { .balance-trend { @@ -1260,6 +1866,11 @@ export default { flex-direction: column; gap: .3rem; } + .trend-store-count { + width: 100%; + margin-left: 0; + padding-bottom: 0; + } } @media (max-width: 520px) { .trend-cards { diff --git a/routes/admin.php b/routes/admin.php index 3bf25369..828502b9 100644 --- a/routes/admin.php +++ b/routes/admin.php @@ -53,6 +53,8 @@ Route::get('ecommerce-finance/account-bills/overview/balance-detail', [StoreRece ->name('ecommerce-finance.account-bills.overview.balance-detail'); Route::get('ecommerce-finance/account-bills/overview/balance-store-detail', [StoreReceivingBalanceOverview::class, 'balanceStoreDetail']) ->name('ecommerce-finance.account-bills.overview.balance-store-detail'); +Route::get('ecommerce-finance/account-bills/overview/daily-balance', [StoreReceivingBalanceOverview::class, 'dailyBalances']) + ->name('ecommerce-finance.account-bills.overview.daily-balance'); Route::get('ecommerce-finance/alipay-bills', [AlipayBills::class, 'index']) ->name('ecommerce-finance.alipay-bills.index'); Route::get('ecommerce-finance/alipay-bills/export', [AlipayBills::class, 'export']) diff --git a/tests/Feature/Business/StoreReceivingBalanceOverviewEndpointTest.php b/tests/Feature/Business/StoreReceivingBalanceOverviewEndpointTest.php index 7c64f208..c58bcad8 100644 --- a/tests/Feature/Business/StoreReceivingBalanceOverviewEndpointTest.php +++ b/tests/Feature/Business/StoreReceivingBalanceOverviewEndpointTest.php @@ -80,6 +80,83 @@ class StoreReceivingBalanceOverviewEndpointTest extends FeatureTestCase ->assertJsonPath('summary.complete', true); } + public function test_daily_balance_endpoint_returns_platform_and_store_rows(): void + { + $this->user->attachPermission( + Permission::where('name', 'read-admin-panel')->firstOrFail() + ); + + $payload = [ + 'month' => '2026-10', + 'period' => ['start' => '2026-10-01', 'end' => '2026-10-31'], + 'summary' => [ + 'opening_balance' => 100.0, + 'income' => 30.0, + 'expense' => 10.0, + 'balance' => 120.0, + 'platform_count' => 8, + 'available_platform_count' => 8, + 'complete' => true, + ], + 'platforms' => [[ + 'slug' => 'taobao-alipay', + 'name' => '淘系支付宝账户', + 'daily' => [ + '2026-10-01' => [ + 'date' => '2026-10-01', + 'opening' => 100.0, + 'income' => 30.0, + 'expense' => 10.0, + 'closing' => 120.0, + 'available' => true, + ], + ], + ]], + 'dates' => ['2026-10-01'], + 'daily_summary' => [ + '2026-10-01' => [ + 'date' => '2026-10-01', + 'opening' => 100.0, + 'income' => 30.0, + 'expense' => 10.0, + 'closing' => 120.0, + 'available' => true, + ], + ], + 'stores' => [[ + 'platform_slug' => 'taobao-alipay', + 'platform' => '淘系支付宝账户', + 'store_name' => '测试店铺', + 'opening_balance' => 100.0, + 'income' => 30.0, + 'expense' => 10.0, + 'amount' => 120.0, + 'available' => true, + 'daily' => [], + ]], + 'store_summary' => ['store_count' => 1, 'available_store_count' => 1], + 'daily_errors' => [], + 'daily_note' => '按账单实际发生日期滚动计算。', + ]; + $service = Mockery::mock(StoreReceivingBalanceOverviewService::class); + $service->shouldReceive('dailyBalances') + ->once() + ->with('2026-10-01', '2026-10-31') + ->andReturn($payload); + $this->app->instance(StoreReceivingBalanceOverviewService::class, $service); + + $this->loginAs() + ->getJson(route('ecommerce-finance.account-bills.overview.daily-balance', [ + 'start' => '2026-10-01', + 'end' => '2026-10-31', + ])) + ->assertOk() + ->assertJsonPath('dates.0', '2026-10-01') + ->assertJsonPath('platforms.0.daily.2026-10-01.closing', 120) + ->assertJsonPath('stores.0.store_name', '测试店铺') + ->assertJsonPath('store_summary.available_store_count', 1); + } + public function test_overview_page_uses_the_vue_mount_point(): void { $this->user->attachPermission( diff --git a/tests/Unit/EcommerceFinance/StoreReceivingBalanceOverviewServiceTest.php b/tests/Unit/EcommerceFinance/StoreReceivingBalanceOverviewServiceTest.php index 5f3f7c07..59c3619c 100644 --- a/tests/Unit/EcommerceFinance/StoreReceivingBalanceOverviewServiceTest.php +++ b/tests/Unit/EcommerceFinance/StoreReceivingBalanceOverviewServiceTest.php @@ -377,6 +377,108 @@ class StoreReceivingBalanceOverviewServiceTest extends TestCase $this->assertSame(330.0, $result['rows'][2]['amount']); } + public function test_daily_balances_roll_platform_and_store_opening_balances(): void + { + $service = new class extends StoreReceivingBalanceOverviewService { + public function __construct() + { + } + + protected function fetchPlatformSummary(string $platform, string $start, string $end): array + { + return [ + 'opening_balance' => 100.0, + 'income' => 15.0, + 'expense' => 6.0, + ]; + } + + protected function fetchPlatformStoreBalances(string $platform, string $start, string $end): array + { + $index = array_search($platform, array_column(StoreReceivingBalanceOverviewService::PLATFORMS, 'slug'), true) + 1; + + return [[ + 'store_name' => '店铺-' . $index, + 'opening_balance' => 100.0, + 'income' => 15.0, + 'expense' => 6.0, + ]]; + } + + protected function fetchPlatformDailyRows(string $platform, string $start, string $end): iterable + { + $index = array_search($platform, array_column(StoreReceivingBalanceOverviewService::PLATFORMS, 'slug'), true) + 1; + + yield [ + 'store_name' => '店铺-' . $index, + 'occurred_at' => '2026-10-01 12:00:00', + 'income' => 10.0, + 'expense' => 2.0, + ]; + yield [ + 'store_name' => '店铺-' . $index, + 'occurred_at' => '2026-10-02 12:00:00', + 'income' => 5.0, + 'expense' => 4.0, + ]; + } + }; + + $result = $service->dailyBalances('2026-10-01', '2026-10-03'); + + $this->assertSame(['2026-10-01', '2026-10-02', '2026-10-03'], $result['dates']); + $this->assertSame(108.0, $result['daily_summary']['2026-10-01']['closing'] / 8); + $this->assertSame(109.0, $result['daily_summary']['2026-10-02']['closing'] / 8); + $this->assertSame(109.0, $result['daily_summary']['2026-10-03']['closing'] / 8); + $this->assertSame(8, $result['store_summary']['store_count']); + $this->assertSame(8, $result['store_summary']['available_store_count']); + $this->assertSame(100.0, $result['stores'][0]['opening_balance']); + $this->assertSame(109.0, $result['stores'][0]['amount']); + $this->assertTrue($result['stores'][0]['daily']['2026-10-03']['available']); + $this->assertTrue($result['platforms'][0]['daily_reconciled']); + } + + public function test_daily_store_balance_stays_unavailable_when_opening_is_missing(): void + { + $service = new class extends StoreReceivingBalanceOverviewService { + public function __construct() + { + } + + protected function fetchPlatformSummary(string $platform, string $start, string $end): array + { + return ['opening_balance' => 100.0, 'income' => 10.0, 'expense' => 2.0]; + } + + protected function fetchPlatformStoreBalances(string $platform, string $start, string $end): array + { + return [[ + 'store_name' => '待补期初店铺-' . $platform, + 'opening_balance' => null, + 'income' => 10.0, + 'expense' => 2.0, + ]]; + } + + protected function fetchPlatformDailyRows(string $platform, string $start, string $end): iterable + { + yield [ + 'store_name' => '待补期初店铺-' . $platform, + 'occurred_at' => '2026-10-01 12:00:00', + 'income' => 10.0, + 'expense' => 2.0, + ]; + } + }; + + $result = $service->dailyBalances('2026-10-01', '2026-10-01'); + + $this->assertTrue($result['daily_summary']['2026-10-01']['available']); + $this->assertFalse($result['stores'][0]['daily']['2026-10-01']['available']); + $this->assertNull($result['stores'][0]['daily']['2026-10-01']['closing']); + $this->assertSame(0, $result['store_summary']['available_store_count']); + } + private function service(callable $summary): StoreReceivingBalanceOverviewService { return new class($summary) extends StoreReceivingBalanceOverviewService { diff --git a/tests/Unit/View/StoreReceivingBalanceOverviewTest.php b/tests/Unit/View/StoreReceivingBalanceOverviewTest.php index a6895900..c4bf057d 100644 --- a/tests/Unit/View/StoreReceivingBalanceOverviewTest.php +++ b/tests/Unit/View/StoreReceivingBalanceOverviewTest.php @@ -50,43 +50,50 @@ class StoreReceivingBalanceOverviewTest extends TestCase $this->assertStringContainsString('暂不展示不完整合计', $source); } - public function test_overview_uses_seeded_rolling_data_and_exact_validation_targets(): void + public function test_overview_uses_the_real_daily_balance_endpoint(): void { $source = $this->overviewSource(); - $this->assertStringContainsString('const mulberry32 = (seed)', $source); - $this->assertStringContainsString('mulberry32(20261001)', $source); - $this->assertStringContainsString('const allocateCents = (targetCents, weights)', $source); - $this->assertStringContainsString('if ([10, 20, 31].includes(dayOfMonth)) expenseWeight *= 1.55;', $source); - $this->assertStringContainsString('const closing = runningOpening + dayIncome - dayExpense;', $source); - $this->assertStringContainsString('runningOpening = closing;', $source); - $this->assertLessThan( - strpos($source, 'const expenseByDay = allocateCents'), - strpos($source, 'const incomeByDay = allocateCents'), - ); + $this->assertStringContainsString('${this.apiBase}/daily-balance', $source); + $this->assertStringContainsString('this.dailySummary = body.daily_summary || {}', $source); + $this->assertStringContainsString("this.stores = Array.isArray(body.stores) ? body.stores : []", $source); + $this->assertStringContainsString('dailyLoading', $source); + $this->assertStringContainsString('每日余额按账单实际发生日期滚动计算', $source); + $this->assertStringNotContainsString('const mulberry32 = (seed)', $source); + $this->assertStringNotContainsString('buildSeededTrend', $source); } - public function test_overview_renders_svg_chart_tooltip_and_sticky_table(): void + public function test_overview_renders_dimension_tables_and_day_detail(): void + { + $source = $this->overviewSource(); + + $this->assertStringContainsString("label: '汇总'", $source); + $this->assertStringContainsString("label: '平台'", $source); + $this->assertStringContainsString("label: '店铺'", $source); + $this->assertStringContainsString('class="trend-matrix-table"', $source); + $this->assertStringContainsString('class="trend-store-filters"', $source); + $this->assertStringContainsString('v-model="storePlatformFilter"', $source); + $this->assertStringContainsString('v-model.trim="storeKeyword"', $source); + $this->assertStringContainsString('@click="openDailyDetail(\'store\', store, date)"', $source); + $this->assertStringContainsString('v-if="selectedDailyDetail"', $source); + $this->assertStringContainsString('dailyDetailMoney(\'opening\')', $source); + $this->assertStringContainsString('dailyDetailSigned(\'income\')', $source); + $this->assertStringContainsString('dailyDetailSigned(\'expense\')', $source); + $this->assertStringContainsString('dailyDetailMoney(\'closing\')', $source); + $this->assertStringContainsString('trend-store-pagination', $source); + } + + public function test_overview_keeps_chart_and_summary_table(): void { $source = $this->overviewSource(); $this->assertStringContainsString('assertStringContainsString('class="trend-line"', $source); - $this->assertStringContainsString('class="trend-area"', $source); $this->assertStringContainsString('balance-area-gradient', $source); $this->assertStringContainsString('@mouseenter="showTooltip($event, point.index)"', $source); - $this->assertStringContainsString('role="tooltip"', $source); - $this->assertStringContainsString('期初 ', $source); - $this->assertStringContainsString('收入 ', $source); - $this->assertStringContainsString('支出 ', $source); - $this->assertStringContainsString('期末 ', $source); $this->assertStringContainsString('每日余额明细', $source); $this->assertStringContainsString('position: sticky;', $source); - $this->assertStringContainsString('max-height: 18.75rem;', $source); - $this->assertStringContainsString( - '注:顶部汇总卡片取自账户余额总览实际数据;每日曲线与明细为演示数据,接入真实流水后自动替换', - $source, - ); + $this->assertStringContainsString('{{ dailyNote }}', $source); } public function test_overview_tab_is_placed_before_taobao_alipay_navigation(): void