diff --git a/config/business_navigation.php b/config/business_navigation.php index e3d3d3fcd..505e9e2a6 100644 --- a/config/business_navigation.php +++ b/config/business_navigation.php @@ -1043,7 +1043,7 @@ $navigation = [ 'title' => '安装明细', 'tabs' => [ ['slug' => 'details', 'title' => '安装明细', 'icon' => 'table_view'], - ['slug' => 'fee-trend', 'title' => '安装费汇总', 'icon' => 'trending_up'], + ['slug' => 'fee-trend', 'title' => '安装公司使用趋势', 'icon' => 'trending_up'], ], ], ['slug' => 'promotion-expenses', 'title' => '推广费用'], diff --git a/modules/EcommerceFinance/View/InstallationFeeUsagePageData.php b/modules/EcommerceFinance/View/InstallationFeeUsagePageData.php index 054d0f290..f3fa381e6 100644 --- a/modules/EcommerceFinance/View/InstallationFeeUsagePageData.php +++ b/modules/EcommerceFinance/View/InstallationFeeUsagePageData.php @@ -6,7 +6,7 @@ use Illuminate\Support\Carbon; use Modules\EcommerceFinance\Repositories\InstallationDetailMirrorRepository; use Throwable; -/** 安装费汇总:按客服审核月份对比各安装公司的实际单量和结算金额。 */ +/** 安装公司使用趋势:按客服审核月份对比各安装公司的实际单量和结算金额。 */ class InstallationFeeUsagePageData { public const RANGE_OPTIONS = [ diff --git a/resources/views/business/pages/partials/installation-fee-summary.blade.php b/resources/views/business/pages/partials/installation-fee-summary.blade.php index 137f4163c..a56354d44 100644 --- a/resources/views/business/pages/partials/installation-fee-summary.blade.php +++ b/resources/views/business/pages/partials/installation-fee-summary.blade.php @@ -5,7 +5,6 @@ .installation-fee-card { --installation-fee-accent: #856632; - --installation-fee-accent-soft: #f7f0de; --installation-fee-accent-ring: rgba(133, 102, 50, 0.2); position: relative; display: flex; @@ -61,6 +60,29 @@ margin: 0.2rem 0 0.3rem; } + .installation-fee-card__amount-button { + width: 100%; + box-sizing: border-box; + padding: 0; + border: 0; + border-radius: 0.3rem; + background: transparent; + color: inherit; + cursor: pointer; + font: inherit; + text-align: left; + } + + .installation-fee-card__amount-button:hover .installation-fee-card__value, + .installation-fee-card__amount-button:focus-visible .installation-fee-card__value { + color: var(--installation-fee-accent); + } + + .installation-fee-card__amount-button:focus-visible { + box-shadow: 0 0 0 3px var(--installation-fee-accent-ring); + outline: none; + } + .installation-fee-card__value { color: #171717; font-size: 2.5rem; @@ -143,34 +165,12 @@ font-weight: 400; } - .installation-fee-card__detail-button { - display: inline-flex; - min-height: 1.55rem; - align-items: center; - justify-content: center; - gap: 0.25rem; + .installation-fee-card__drilldown { margin-left: auto; - padding: 0 0.45rem; - border: 0; - border-radius: 0.3rem; - background: transparent; color: var(--installation-fee-accent); - cursor: pointer; - font: inherit; - font-size: 0.75rem; + font-size: 0.6875rem; font-weight: 600; white-space: nowrap; - text-decoration: none; - } - - .installation-fee-card__detail-button:hover { - background: var(--installation-fee-accent-soft); - } - - .installation-fee-card__detail-button:focus-visible { - background: var(--installation-fee-accent-soft); - box-shadow: 0 0 0 3px var(--installation-fee-accent-ring); - outline: none; } @media (max-width: 720px) { @@ -199,16 +199,12 @@ padding-right: 0.85rem; padding-left: 0.95rem; } - .installation-fee-card__detail-button { - width: 100%; - justify-content: flex-end; - } } .installation-fee-dialog { --installation-fee-table-cell-padding: 0.7rem 0.65rem; --installation-fee-table-head-padding: 0.75rem 0.65rem; - width: min(68rem, calc(100vw - 2rem)); + width: min(46rem, calc(100vw - 2rem)); max-width: none; max-height: calc(100vh - 2rem); box-sizing: border-box; @@ -287,53 +283,12 @@ .installation-fee-filters { display: grid; - grid-template-columns: repeat(4, minmax(8.5rem, 1fr)); + grid-template-columns: minmax(14rem, 22rem); gap: 0.75rem; padding: 0.8rem 1.1rem; border-bottom: 1px solid #eee8dd; } - .installation-fee-tabs { - display: flex; - align-items: stretch; - gap: 1.25rem; - overflow-x: auto; - padding: 0 1.1rem; - border-bottom: 1px solid #e8e0d2; - background: #ffffff; - overscroll-behavior-inline: contain; - scrollbar-width: thin; - white-space: nowrap; - } - - .installation-fee-tab { - flex: 0 0 auto; - min-height: 2.75rem; - padding: 0 0.2rem; - border: 0; - border-bottom: 2px solid transparent; - background: transparent; - color: #595959; - cursor: pointer; - font: inherit; - font-size: 0.8125rem; - font-weight: 600; - } - - .installation-fee-tab:hover { - color: #856632; - } - - .installation-fee-tab[aria-selected="true"] { - border-bottom-color: #b9954f; - color: #856632; - } - - .installation-fee-tab:focus-visible { - outline: 3px solid rgba(133, 102, 50, 0.2); - outline-offset: -3px; - } - .installation-fee-filter span { display: block; margin-bottom: 0.25rem; @@ -389,10 +344,6 @@ background: #856632; } - .installation-fee-panel { - min-width: 100%; - } - .installation-fee-table { width: 100%; min-width: 100%; @@ -403,19 +354,11 @@ } .installation-fee-table col:nth-child(1) { - width: 34%; + width: 72%; } .installation-fee-table col:nth-child(2) { - width: 22%; - } - - .installation-fee-table col:nth-child(3) { - width: 18%; - } - - .installation-fee-table col:nth-child(4) { - width: 26%; + width: 28%; } .installation-fee-table th, @@ -451,48 +394,6 @@ text-align: center; } - .installation-fee-platform-summary { - margin: 0; - padding: 0; - } - - .installation-fee-panel[hidden] { - display: none !important; - } - - .installation-fee-panel.is-active:not([hidden]) { - display: block !important; - } - - .installation-fee-platform-summary table { - width: 100%; - min-width: 32rem; - border-collapse: collapse; - font-size: 0.75rem; - font-variant-numeric: tabular-nums; - } - - .installation-fee-platform-summary th, - .installation-fee-platform-summary td { - padding: var(--installation-fee-table-cell-padding); - border-bottom: 1px solid #eee8dd; - line-height: 1.5; - text-align: left; - vertical-align: middle; - white-space: nowrap; - } - - .installation-fee-platform-summary th { - padding: var(--installation-fee-table-head-padding); - background: #f7f0de; - color: #595959; - font-weight: 600; - } - - .installation-fee-platform-summary .is-number { - text-align: right; - } - .installation-fee-dialog__foot { padding: 0.65rem 1.1rem; border-top: 1px solid #eee8dd; @@ -500,12 +401,8 @@ font-size: 0.6875rem; } - @media (max-width: 900px) { - .installation-fee-filters { grid-template-columns: repeat(2, minmax(10rem, 1fr)); } - } - @media (max-width: 720px) { - .installation-fee-filters { grid-template-columns: 1fr; } + .installation-fee-filters { grid-template-columns: minmax(0, 1fr); } .installation-fee-dialog__head { flex-direction: column; } .installation-fee-dialog__side { width: 100%; justify-content: space-between; } } @@ -520,30 +417,25 @@ 安装费金额 请选择完整的客服审核起止日期 - + 包安装金额 0.00万元(0.0%) 不包安装金额 0.00万元(0.0%) - 使用趋势 → - @@ -551,87 +443,47 @@
-

安装费金额 · 明细汇总

-

按客服审核时间汇总店铺、安装公司和包安装分类

+

安装费金额 · 店铺汇总

+

按客服审核时间汇总各店铺的实际安装费

- 当前筛选合计(万元) + 当前筛选合计 ¥0.00
- +
-
- +
- - -
-
- -
-
- - - - - - - - -
平台结算明细金额(万元)
- -
- + + + + + + + + + + + + +
店铺名称实际安装费
+
请选择客服审核日期后查看店铺金额
- 共 0 条平台汇总 + 共 0 家店铺
@@ -654,54 +506,18 @@ var nonPackagePercent = card.querySelector('[data-installation-fee-non-package-percent]'); var subtitle = dialog.querySelector('[data-installation-fee-subtitle]'); var currentTotal = dialog.querySelector('[data-installation-fee-current-total]'); - var platformFilter = dialog.querySelector('[data-installation-fee-platform]'); var storeFilter = dialog.querySelector('[data-installation-fee-store]'); - var companyFilter = dialog.querySelector('[data-installation-fee-company]'); - var channelFilter = dialog.querySelector('[data-installation-fee-channel]'); - var rowsEl = dialog.querySelector('[data-installation-fee-rows]'); - var platformRowsEl = dialog.querySelector('[data-installation-fee-platform-rows]'); - var emptyEl = dialog.querySelector('[data-installation-fee-empty]'); - var platformEmptyEl = dialog.querySelector('[data-installation-fee-platform-empty]'); + var storeRowsEl = dialog.querySelector('[data-installation-fee-store-rows]'); + var storeEmptyEl = dialog.querySelector('[data-installation-fee-store-empty]'); var countEl = dialog.querySelector('[data-installation-fee-count]'); var scrollEl = dialog.querySelector('[data-installation-fee-scroll]'); - var tabButtons = Array.from(dialog.querySelectorAll('[data-installation-fee-tab]')); - var tabPanels = Array.from(dialog.querySelectorAll('[data-installation-fee-panel]')); var allRows = []; var loadedSignature = ''; var timer = null; var controller = null; - var detailRowCount = 0; - var platformRowCount = 0; - var activeTab = 'platform'; - function updateCount() { - var count = activeTab === 'platform' ? platformRowCount : detailRowCount; - var suffix = activeTab === 'platform' ? '平台汇总' : '明细汇总'; - countEl.textContent = '共 ' + count.toLocaleString('zh-CN') + ' 条' + suffix; - } - - function activateTab(name, focusTab) { - activeTab = name; - tabButtons.forEach(function (tab) { - var selected = tab.dataset.installationFeeTab === name; - tab.setAttribute('aria-selected', selected ? 'true' : 'false'); - tab.tabIndex = selected ? 0 : -1; - if (selected && focusTab) { - tab.focus(); - } - }); - tabPanels.forEach(function (panel) { - var selected = panel.dataset.installationFeePanel === name; - panel.hidden = !selected; - panel.classList.toggle('is-active', selected); - panel.style.display = selected ? 'block' : 'none'; - panel.setAttribute('aria-hidden', selected ? 'false' : 'true'); - }); - if (scrollEl) { - scrollEl.scrollTop = 0; - scrollEl.scrollLeft = 0; - } - updateCount(); + function updateCount(count) { + countEl.textContent = '共 ' + count.toLocaleString('zh-CN') + ' 家店铺'; } function amount(value) { @@ -719,10 +535,6 @@ return '¥' + amount(value); } - function wanYuan(value) { - return '¥' + wanAmount(value); - } - function captionRange(value) { var matchFrom = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.from); var matchTo = /^(\d{4})-(\d{2})-(\d{2})$/.exec(value.to); @@ -783,7 +595,7 @@ nonPackagePercent.textContent = '(' + percent(nonPackageRate) + '%)'; setTrend(data.change_rate); status.classList.remove('is-error'); - status.textContent = '按客服审核时间 · ' + captionRange(value) + ' · ' + rows.length + ' 单'; + status.textContent = '按客服审核时间 · ' + captionRange(value); } function resetCard(message) { @@ -826,104 +638,68 @@ select.value = ''; } - function distinct(key) { + function distinctStores() { return Array.from(new Set(allRows.map(function (row) { - return String(row[key] || '').trim(); - }).filter(Boolean))).sort(function (left, right) { + return String(row.store_name || '').trim() || '未填写店铺'; + }))).sort(function (left, right) { return left.localeCompare(right, 'zh-CN'); }); } function renderRows() { - var platform = platformFilter.value; - var store = storeFilter.value; - var company = companyFilter.value; - var channel = channelFilter.value; - var rows = allRows.filter(function (row) { - return (!platform || row.platform === platform) - && (!store || row.store_name === store) - && (!company || row.installation_company === company) - && (!channel || row.payment_channel === channel); + var byStore = {}; + allRows.forEach(function (row) { + var store = String(row.store_name || '').trim() || '未填写店铺'; + byStore[store] = (byStore[store] || 0) + Number(row.amount || 0); + }); + var selectedStore = storeFilter.value; + var rows = Object.keys(byStore).map(function (store) { + return { store_name: store, amount: byStore[store] }; + }).filter(function (row) { + return !selectedStore || row.store_name === selectedStore; + }).sort(function (left, right) { + return Math.abs(right.amount) - Math.abs(left.amount) + || left.store_name.localeCompare(right.store_name, 'zh-CN'); }); var total = rows.reduce(function (sum, row) { return sum + Number(row.amount || 0); }, 0); - rowsEl.replaceChildren(); + storeRowsEl.replaceChildren(); rows.forEach(function (row) { var tr = document.createElement('tr'); - [row.store_name || '—', row.installation_company || '—', row.payment_channel || '—'].forEach(function (value) { - var td = document.createElement('td'); - td.textContent = value; - tr.appendChild(td); - }); + var store = document.createElement('td'); + store.textContent = row.store_name; + tr.appendChild(store); var amount = document.createElement('td'); amount.className = 'is-number'; - amount.textContent = wanYuan(row.amount); + amount.textContent = rawYuan(row.amount); amount.title = rawYuan(row.amount); tr.appendChild(amount); - rowsEl.appendChild(tr); + storeRowsEl.appendChild(tr); }); - var byPlatform = {}; - rows.forEach(function (row) { - var key = row.platform || '其他'; - byPlatform[key] ??= 0; - byPlatform[key] += Number(row.amount || 0); - }); - detailRowCount = rows.length; - platformRowCount = Object.keys(byPlatform).length; - platformRowsEl.replaceChildren(); - Object.keys(byPlatform).sort(function (left, right) { - return Math.abs(byPlatform[right]) - Math.abs(byPlatform[left]) - || left.localeCompare(right, 'zh-CN'); - }).forEach(function (name) { - var tr = document.createElement('tr'); - var platformCell = document.createElement('td'); - platformCell.textContent = name; - tr.appendChild(platformCell); - var amount = document.createElement('td'); - amount.className = 'is-number'; - amount.textContent = wanYuan(byPlatform[name]); - amount.title = rawYuan(byPlatform[name]); - tr.appendChild(amount); - platformRowsEl.appendChild(tr); - }); - - currentTotal.textContent = wanYuan(total); + currentTotal.textContent = rawYuan(total); currentTotal.title = rawYuan(total); - updateCount(); - emptyEl.hidden = rows.length > 0; - emptyEl.textContent = allRows.length - ? '当前筛选条件下没有安装费明细。' - : '当前客服审核时间内没有安装费明细。'; - platformEmptyEl.hidden = platformRowCount > 0; - platformEmptyEl.textContent = allRows.length - ? '当前筛选条件下没有平台汇总。' - : '当前客服审核时间内没有平台汇总。'; + updateCount(rows.length); + storeEmptyEl.hidden = rows.length > 0; + storeEmptyEl.textContent = allRows.length + ? '当前筛选条件下没有店铺金额。' + : '当前客服审核时间内没有店铺金额。'; } function resetDialog(message) { allRows = []; loadedSignature = ''; - detailRowCount = 0; - platformRowCount = 0; - rowsEl.replaceChildren(); - platformRowsEl.replaceChildren(); + storeRowsEl.replaceChildren(); currentTotal.textContent = '¥0.00'; - updateCount(); - emptyEl.hidden = false; - emptyEl.textContent = message; - platformEmptyEl.hidden = false; - platformEmptyEl.textContent = message; + updateCount(0); + storeEmptyEl.hidden = false; + storeEmptyEl.textContent = message; fillFilter(storeFilter, '全部店铺', []); - fillFilter(platformFilter, '全部平台', []); - fillFilter(companyFilter, '全部安装公司', []); - fillFilter(channelFilter, '全部渠道', []); } function openDialog() { - activateTab('platform', false); if (typeof dialog.showModal === 'function') { dialog.showModal(); } else { @@ -973,7 +749,7 @@ }).then(function (response) { return response.json().catch(function () { return {}; }).then(function (data) { if (!response.ok) { - throw new Error(data.message || '安装费汇总读取失败。'); + throw new Error(data.message || '店铺安装费读取失败。'); } return data; }); @@ -981,18 +757,17 @@ allRows = Array.isArray(data.rows) ? data.rows : []; loadedSignature = currentSignature; setCardValue(Number(data.total || 0), allRows, value, data); - subtitle.textContent = value.from + ' 至 ' + value.to + ' · 按客服审核时间汇总'; - fillFilter(platformFilter, '全部平台', distinct('platform')); - fillFilter(storeFilter, '全部店铺', distinct('store_name')); - fillFilter(companyFilter, '全部安装公司', distinct('installation_company')); - fillFilter(channelFilter, '全部渠道', distinct('payment_channel')); + subtitle.textContent = value.from + ' 至 ' + value.to + ' · 按客服审核时间汇总店铺金额'; + fillFilter(storeFilter, '全部店铺', distinctStores()); renderRows(); + scrollEl.scrollTop = 0; + scrollEl.scrollLeft = 0; dialog.removeAttribute('aria-busy'); return true; }).catch(function (error) { if (error && error.name === 'AbortError') { return false; } - resetCard(error.message || '安装费汇总读取失败'); - resetDialog(error.message || '安装费汇总读取失败,请稍后重试。'); + resetCard(error.message || '店铺安装费读取失败'); + resetDialog(error.message || '店铺安装费读取失败,请稍后重试。'); dialog.removeAttribute('aria-busy'); return false; }); @@ -1067,35 +842,10 @@ openDialog(); refresh(false); }); - tabButtons.forEach(function (tab, index) { - tab.addEventListener('click', function (event) { - event.preventDefault(); - activateTab(tab.dataset.installationFeeTab, false); - }); - tab.addEventListener('keydown', function (event) { - var nextIndex = null; - if (event.key === 'ArrowRight') { - nextIndex = (index + 1) % tabButtons.length; - } else if (event.key === 'ArrowLeft') { - nextIndex = (index - 1 + tabButtons.length) % tabButtons.length; - } else if (event.key === 'Home') { - nextIndex = 0; - } else if (event.key === 'End') { - nextIndex = tabButtons.length - 1; - } - if (nextIndex === null) { - return; - } - event.preventDefault(); - activateTab(tabButtons[nextIndex].dataset.installationFeeTab, true); - }); - }); [fromInput, toInput].forEach(function (input) { if (input) { input.addEventListener('change', scheduleRefresh); } }); - [platformFilter, storeFilter, companyFilter, channelFilter].forEach(function (select) { - select.addEventListener('change', renderRows); - }); + storeFilter.addEventListener('change', renderRows); dialog.querySelector('[data-installation-fee-close]').addEventListener('click', closeDialog); dialog.addEventListener('click', function (event) { if (event.target === dialog) { closeDialog(); } diff --git a/tests/Feature/Business/ManagementCrudTest.php b/tests/Feature/Business/ManagementCrudTest.php index 2a0e2290a..9fa1be419 100644 --- a/tests/Feature/Business/ManagementCrudTest.php +++ b/tests/Feature/Business/ManagementCrudTest.php @@ -362,6 +362,45 @@ class ManagementCrudTest extends FeatureTestCase $this->assertLessThan($detailTablePosition, $platformSummaryPosition); } + public function testInstallationFeeCardUsesAmountDrilldownAndStoreOnlySummary(): void + { + $mirror = Mockery::mock(InstallationDetailMirrorRepository::class); + $mirror->shouldReceive('paginate')->once()->andReturn([ + 'ready' => true, + 'total' => 0, + 'data' => [], + ]); + $this->app->instance(InstallationDetailMirrorRepository::class, $mirror); + + $this->loginAs() + ->get(route('business.pages.show', [ + 'section' => 'financial-operations', + 'page' => 'installation-details', + 'tab' => 'details', + ])) + ->assertOk() + ->assertSee('class="installation-fee-card__main installation-fee-card__amount-button"', false) + ->assertSee('aria-label="查看按店铺汇总的安装费金额"', false) + ->assertSeeText('店铺金额 →') + ->assertSeeText('安装公司使用趋势') + ->assertDontSeeText('使用趋势 →') + ->assertDontSeeText('查看明细 →') + ->assertSeeText('安装费金额 · 店铺汇总') + ->assertSeeText('店铺名称') + ->assertSeeText('实际安装费') + ->assertSee('data-installation-fee-store-rows', false) + ->assertSee('data-installation-fee-store-empty', false) + ->assertDontSee('data-installation-fee-platform', false) + ->assertDontSee('data-installation-fee-company', false) + ->assertDontSee('data-installation-fee-channel', false) + ->assertDontSeeText('平台汇总') + ->assertDontSeeText('收款渠道') + ->assertSee('var byStore = {};', false) + ->assertSee('amount.textContent = rawYuan(row.amount)', false) + ->assertSee('currentTotal.textContent = rawYuan(total)', false) + ->assertSeeText('共 0 家店铺'); + } + public function testInstallationDetailsExportUsesFiltersAndMirrorRows(): void { $row = array_fill_keys(array_keys(InstallationDetail::columnLabels()), null); diff --git a/tests/Feature/Settings/NavigationTest.php b/tests/Feature/Settings/NavigationTest.php index afb5dd992..f98ae113f 100644 --- a/tests/Feature/Settings/NavigationTest.php +++ b/tests/Feature/Settings/NavigationTest.php @@ -575,9 +575,11 @@ class NavigationTest extends FeatureTestCase $installationPage = collect($financeSection['pages'] ?? []) ->firstWhere('slug', 'installation-details'); $tabSlugs = array_column($installationPage['tabs'] ?? [], 'slug'); + $tabTitles = array_column($installationPage['tabs'] ?? [], 'title'); $this->assertNotNull($installationPage); $this->assertSame(['details', 'fee-trend'], $tabSlugs); + $this->assertSame(['安装明细', '安装公司使用趋势'], $tabTitles); $this->assertNotContains( 'installation-fee-summary', array_column($financeSection['pages'] ?? [], 'slug'),