feat(shop): 新增线下付款支持及优化Dashboard数据统计

- 新增线下付款(payType=9)支付方式,支持订单中标识和确认收款操作
- 实现商家确认线下付款后订单进入待发货状态功能
- 更新支付方式组件和订单列表及详情页的支付状态显示
- 优化shop/dashboard快捷操作按钮为商城常用功能,修正快速入口路由路径
- 修复Dashboard待发货订单数统计时未过滤商城订单导致数据不准的问题
- 修复Dashboard运行天数为0的异常,将租户信息请求独立处理,避免某些请求失败影响
- 修复statisticsStore中couponUsedCount与getter同名冲突,改名为safeCouponUsedCount并同步更新引用
This commit is contained in:
2026-07-14 22:17:39 +08:00
parent 5106fe101c
commit 894592c290
11 changed files with 217 additions and 46 deletions

View File

@@ -213,11 +213,14 @@
import { openNew } from '@/utils/common';
import { useSiteStore } from '@/store/modules/site';
import { useStatisticsStore } from '@/store/modules/statistics';
import { useUserStore } from '@/store/modules/user';
import { getTenantInfo } from '@/api/layout';
import { storeToRefs } from 'pinia';
// 使用状态管理
const siteStore = useSiteStore();
const statisticsStore = useStatisticsStore();
const userStore = useUserStore();
// 从 store 中获取响应式数据
const { siteInfo, loading: siteLoading } = storeToRefs(siteStore);
@@ -238,7 +241,13 @@
});
// 计算属性
const runDays = computed(() => siteStore.runDays);
const now = ref(Date.now());
const tenantCreateTime = ref<string>('');
let runDaysTimer: ReturnType<typeof setInterval>;
const runDays = computed(() => {
if (!tenantCreateTime.value) return 0;
return Math.floor((now.value - new Date(tenantCreateTime.value).getTime()) / (24 * 60 * 60 * 1000));
});
const userCount = computed(() => statisticsStore.userCount);
const orderCount = computed(() => statisticsStore.orderCount);
const totalSales = computed(() => statisticsStore.totalSales);
@@ -248,6 +257,15 @@
// 加载数据
const loadData = async () => {
// 独立请求租户信息,不受其他请求失败影响
getTenantInfo()
.then((res) => {
tenantCreateTime.value = res?.createTime || '';
})
.catch((e) => {
console.warn('获取租户信息失败:', e);
});
try {
await Promise.all([
siteStore.fetchSiteInfo(),
@@ -267,11 +285,14 @@
await loadData();
// 开始自动刷新统计数据每5分钟
statisticsStore.startAutoRefresh();
// 运行天数每小时检查一次(跨天自动更新)
runDaysTimer = setInterval(() => { now.value = Date.now(); }, 60 * 60 * 1000);
});
onUnmounted(() => {
// 组件卸载时停止自动刷新
statisticsStore.stopAutoRefresh();
clearInterval(runDaysTimer);
});
</script>