-
+
-
-
-
-
-
-
@@ -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'),