diff --git a/app/Console/Commands/LockFinanceLedgerMonthlyOpening.php b/app/Console/Commands/LockFinanceLedgerMonthlyOpening.php index c418d399c..dd2f78784 100644 --- a/app/Console/Commands/LockFinanceLedgerMonthlyOpening.php +++ b/app/Console/Commands/LockFinanceLedgerMonthlyOpening.php @@ -117,7 +117,7 @@ class LockFinanceLedgerMonthlyOpening extends Command ->orderBy('balance_date') ->orderBy('balance_at') ->orderBy('id') - ->get(['account_no', 'account_balance', 'available_balance']) as $row) { + ->get(['account_no', 'balance_date', 'account_balance', 'available_balance']) as $row) { $accountNo = $this->accountNo($row->account_no); if ($accountNo !== '') { $snapshotBefore[$accountNo] = $row; diff --git a/deploy/activate-incremental-release.sh b/deploy/activate-incremental-release.sh index 6be7d2e0f..e2831f367 100644 --- a/deploy/activate-incremental-release.sh +++ b/deploy/activate-incremental-release.sh @@ -253,6 +253,8 @@ CRON_TZ=Asia/Shanghai 30 2 * * * root /usr/bin/flock -w 1800 /run/caiwu-upstream-sync.lock /usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:sync-rpt --days=7 --merge --sources=store,withdrawal --quiet >/dev/null 2>&1 5 * * * * root /usr/bin/flock -w 600 /run/caiwu-upstream-sync.lock /usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:sync-rpt --days=2 --merge --sources=dingtalk,payable --quiet >/dev/null 2>&1 30 10 * * * root /usr/bin/flock -w 1800 /run/caiwu-upstream-sync.lock /usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:sync-shop-data --balance-only --quiet >/dev/null 2>&1 +# 每月 1 日按上月末最后一笔真实余额锁定月度期初,供账户总览和月度资金分析直接读取。 +20 8 1 * * root /usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:lock-monthly-opening --apply --quiet >/dev/null 2>&1 # 拼多多期初:账单导入后即时尝试,每日 11:30 再扫一次未就绪店铺;只在余额恒等式通过后写入。 30 11 * * * root /bin/sh /opt/caiwuxitong/run-finance-batch.sh pinduoduo-opening-balances:import --quiet >/dev/null 2>&1 # 财务流程明细每周完整校准一次,修正超过 48 小时重叠窗口才出现的上游改单或晚到付款。 diff --git a/deploy/activate-release.sh b/deploy/activate-release.sh index 70c3dd9ba..d2a051983 100644 --- a/deploy/activate-release.sh +++ b/deploy/activate-release.sh @@ -257,6 +257,8 @@ CRON_TZ=Asia/Shanghai 30 2 * * * root /usr/bin/flock -w 1800 /run/caiwu-upstream-sync.lock /usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:sync-rpt --days=7 --merge --sources=store,withdrawal --quiet >/dev/null 2>&1 5 * * * * root /usr/bin/flock -w 600 /run/caiwu-upstream-sync.lock /usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:sync-rpt --days=2 --merge --sources=dingtalk,payable --quiet >/dev/null 2>&1 30 10 * * * root /usr/bin/flock -w 1800 /run/caiwu-upstream-sync.lock /usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:sync-shop-data --balance-only --quiet >/dev/null 2>&1 +# 每月 1 日按上月末最后一笔真实余额锁定月度期初,供账户总览和月度资金分析直接读取。 +20 8 1 * * root /usr/bin/docker exec -u www-data caiwu_app php artisan finance-ledger:lock-monthly-opening --apply --quiet >/dev/null 2>&1 # 拼多多期初:账单导入后即时尝试,每日 11:30 再扫一次未就绪店铺;只在余额恒等式通过后写入。 30 11 * * * root /bin/sh /opt/caiwuxitong/run-finance-batch.sh pinduoduo-opening-balances:import --quiet >/dev/null 2>&1 # 财务流程明细每周完整校准一次,修正超过 48 小时重叠窗口才出现的上游改单或晚到付款。 diff --git a/modules/EcommerceFinance/View/NonStoreAccountMonitorPageData.php b/modules/EcommerceFinance/View/NonStoreAccountMonitorPageData.php index 1582f7ac6..4f6e8e66f 100644 --- a/modules/EcommerceFinance/View/NonStoreAccountMonitorPageData.php +++ b/modules/EcommerceFinance/View/NonStoreAccountMonitorPageData.php @@ -125,6 +125,9 @@ final class NonStoreAccountMonitorPageData $unretainedProgress = $this->progressSummary($unretained); $fundOverview = [ 'total_accounts' => $retainedSummary['count'], + 'opening_balance' => $retainedSummary['opening_balance'], + 'opening_accounts' => $retainedSummary['opening_accounts'], + 'opening_missing_accounts' => $retainedSummary['opening_missing_accounts'], 'current_balance' => $retainedSummary['current_balance'], 'available_balance' => $retainedSummary['available_balance'], 'blocked_balance' => $retainedSummary['blocked_balance'], @@ -888,8 +891,18 @@ final class NonStoreAccountMonitorPageData private function summary(Collection $rows): array { + $openingRows = $rows->filter( + static fn (array $row): bool => array_key_exists('opening_balance', $row) + && $row['opening_balance'] !== null, + ); + return [ 'count' => $rows->count(), + 'opening_balance' => $openingRows->isEmpty() + ? null + : round((float) $openingRows->sum('opening_balance'), 2), + 'opening_accounts' => $openingRows->count(), + 'opening_missing_accounts' => max(0, $rows->count() - $openingRows->count()), 'current_balance' => round((float) $rows->sum('current_balance'), 2), 'available_balance' => round((float) $rows->sum('available_balance'), 2), 'blocked_balance' => round((float) $rows->sum('blocked_balance'), 2), diff --git a/resources/views/business/pages/financial-operations/non-store-accounts.blade.php b/resources/views/business/pages/financial-operations/non-store-accounts.blade.php index 86370e48b..02112c026 100644 --- a/resources/views/business/pages/financial-operations/non-store-accounts.blade.php +++ b/resources/views/business/pages/financial-operations/non-store-accounts.blade.php @@ -3,6 +3,9 @@ ? '—' : number_format((float) $value, 2); $moneyWan = static fn ($value): string => number_format((float) $value / 10000, 2, '.', ','); + $moneyWanOptional = static fn ($value): string => $value === null || $value === '' + ? '—' + : $moneyWan($value); $currentUrl = $currentUrl ?? route('business.pages.show', [ 'section' => 'financial-operations', 'page' => 'non-store-accounts', @@ -185,7 +188,7 @@ .nsm-fund-overview__grid { display: grid; - grid-template-columns: repeat(4, minmax(0, 1fr)); + grid-template-columns: repeat(5, minmax(0, 1fr)); } .nsm-fund-kpi { @@ -224,6 +227,14 @@ color: var(--nsm-warning); } + .nsm-table-note { + display: block; + margin-top: .25rem; + color: var(--nsm-muted); + font-size: .625rem; + font-weight: 400; + } + .nsm-distribution-summary { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); @@ -1775,6 +1786,10 @@ .nsm-fund-kpi:nth-child(4) { border-top: 1px solid #eeeae2; } + .nsm-fund-kpi:nth-child(5) { + border-left: 0; + border-top: 1px solid #eeeae2; + } .nsm-page-head { align-items: flex-start; flex-direction: column; @@ -1803,7 +1818,8 @@ } .nsm-fund-kpi + .nsm-fund-kpi, .nsm-fund-kpi:nth-child(3), - .nsm-fund-kpi:nth-child(4) { + .nsm-fund-kpi:nth-child(4), + .nsm-fund-kpi:nth-child(5) { border-top: 1px solid #eeeae2; border-left: 0; } @@ -1823,6 +1839,9 @@ data-open-retained-on-load="{{ request()->boolean('retained') ? '1' : '0' }}" data-retained-period-from="{{ $period['from'] }}" data-retained-period-to="{{ $period['to'] }}" + data-retained-period-opening="{{ $fundOverview['opening_balance'] === null ? '' : (float) $fundOverview['opening_balance'] }}" + data-retained-period-opening-accounts="{{ (int) $fundOverview['opening_accounts'] }}" + data-retained-period-opening-missing="{{ (int) $fundOverview['opening_missing_accounts'] }}" data-retained-period-total="{{ (float) $fundOverview['current_balance'] }}" data-retained-period-available="{{ (float) $fundOverview['available_balance'] }}" data-retained-period-blocked="{{ (float) $fundOverview['blocked_balance'] }}" @@ -1948,6 +1967,14 @@ {{ number_format((int) $fundOverview['total_accounts']) }} 个账户 · 金额单位:万元