11 Commits

Author SHA1 Message Date
29a18ffbc6 feat(appSubscription): 实现Dashboard订阅到期显示及扫码支付功能
- dashboard订阅到期时间信息支持三态渲染:激活显示剩余天数和已激活标签、待支付显示金额及去支付按钮、无订阅显示立即订阅按钮
- 通过租户ID查询应用产品,实现按租户过滤的订阅展示逻辑
- 新增appProduct分页接口及类型定义,提供应用列表获取能力
- 实现「立即订阅」流程,支持免费应用直接激活,付费应用生成微信扫码支付二维码及轮询订单状态
- 实现待支付订阅复用支付接口生成支付二维码,避免重复创建订阅
- 小程序端扫码支付流程支持订单号查询及支付确认,后端使用Redis标记支付成功状态
- 修复后端generatePayQrcode接口缺少priceType字段导致的数据库报错,前端兼容现有逻辑无需修改
- 移除dashboard中siteInfo旧的expirationTime字段相关代码,改为读订阅expireTime
- 新增订阅及支付相关样式,优化界面体验
- 支付状态轮询实现超时提示及自动停止机制,提升用户支付体验
- 组件卸载时确保支付轮询停止,避免内存泄漏
- 独立加载订阅信息,不影响其他数据请求,避免页面加载失败影响订阅展示
2026-07-15 14:11:14 +08:00
e0d27f67d5 feat(shopOrder): 新增确认线下收款上传支付凭证功能
- 重构确认线下收款为独立组件 OfflinePaymentModal.vue
- 新增支付凭证字段 paymentVoucher,支持图片上传与预览
- 上传限制为 jpg/png 格式,单张图片最大 10MB
- API confirmOfflinePayment 新增 paymentVoucher 参数
- 页面移除原 Modal.confirm 逻辑,改为调用新组件弹窗
- 修复 buyerRemarks 和 merchantRemarks 类型错误
- 后端 shop_order 表待新增 payment_voucher 字段和接口支持
- 同步更新相关接口模型与视图交互逻辑

feat(shopGoodsBrowse): 新增用户商品浏览记录管理功能

- 新增 ShopGoodsBrowse 接口模型及分页查询、删除接口
- 前端新增浏览记录管理页面,实现列表展示和删除
- 支持基于用户ID、商品ID、浏览来源和日期范围搜索
- 列表显示商品图片、名称、价格、浏览次数及时间等信息
- 添加图片预览和操作确认弹窗,保障操作体验和安全
2026-07-15 13:37:27 +08:00
a59d428e78 feat(shopOrder): 新增确认线下收款上传支付凭证功能
- 重构确认线下收款为独立组件 OfflinePaymentModal.vue
- 新增支付凭证字段 paymentVoucher,支持图片上传与预览
- 上传限制为 jpg/png 格式,单张图片最大 10MB
- API confirmOfflinePayment 新增 paymentVoucher 参数
- 页面移除原 Modal.confirm 逻辑,改为调用新组件弹窗
- 修复 buyerRemarks 和 merchantRemarks 类型错误
- 后端 shop_order 表待新增 payment_voucher 字段和接口支持
- 同步更新相关接口模型与视图交互逻辑

feat(shopGoodsBrowse): 新增用户商品浏览记录管理功能

- 新增 ShopGoodsBrowse 接口模型及分页查询、删除接口
- 前端新增浏览记录管理页面,实现列表展示和删除
- 支持基于用户ID、商品ID、浏览来源和日期范围搜索
- 列表显示商品图片、名称、价格、浏览次数及时间等信息
- 添加图片预览和操作确认弹窗,保障操作体验和安全
2026-07-15 13:30:14 +08:00
9e65007e65 feat(appSubscription): 新增应用订阅模块及商城欢迎横幅Logo支持
- 新增 useAppSubscriptionStore,封装 websopy 特殊接口的应用订阅功能
- 实现订阅列表分页查询、详情获取、支付状态查询、订阅管理等接口调用
- 适配不同支付方式,支持余额支付、微信支付及小程序支付预支付流程
- 在商城 Dashboard 欢迎横幅左侧新增商城 Logo 显示,读取商城设置的 shopLogo 字段
- 使用图像压缩接口处理 Logo 大小和质量,优化加载体验
- 优化 Dashboard 待处理事项展示,恢复退款和优惠券使用项
- 统一订阅接口调用地址为独立域名,复用请求工具共享认证和错误处理
2026-07-15 12:49:05 +08:00
e2dd8dbc18 feat(cms): 更新系统名称并优化租户信息获取逻辑
- 将系统名称由“小程序开发”修改为“小程序商城”
- 修改多处组件中系统名称的引用,统一使用系统信息对象
- 调整快捷入口路由,更新优惠券和会员管理的跳转路径
- 使用 tenantStore 替代原有的接口调用,统一获取租户公司信息
- 优化租户创建时间的计算方式,直接从 store 获取数据
- 移除不再使用的 getTenantInfo 方法,改为通过 pinia 状态管理获取
- 调整部分模板数据绑定,修正创建时间显示逻辑
2026-07-15 12:04:34 +08:00
08b697556b feat(cms): 更新系统名称并优化租户信息获取逻辑
- 将系统名称由“小程序开发”修改为“小程序商城”
- 修改多处组件中系统名称的引用,统一使用系统信息对象
- 调整快捷入口路由,更新优惠券和会员管理的跳转路径
- 使用 tenantStore 替代原有的接口调用,统一获取租户公司信息
- 优化租户创建时间的计算方式,直接从 store 获取数据
- 移除不再使用的 getTenantInfo 方法,改为通过 pinia 状态管理获取
- 调整部分模板数据绑定,修正创建时间显示逻辑
2026-07-15 12:00:14 +08:00
b0ff82599a feat(shop): 新增Dashboard待付款订单统计及支持
- Dashboard待处理事项新增“待付款订单”项,使用statusFilter=0查询
- 点击待付款订单跳转至/shop/shopOrder?tab=unpaid页面
- shopOrder页面恢复“待付款”标签页,validTabs列表包含unpaid
- shopOrder页面根据路由query初始化活动标签,支持unpaid选项
- 新增dot-gold样式用于待付款订单高亮显示
- 订单数量接口新增待付款订单数获取及异常处理逻辑
- 调整组件中待处理事项列表,支持待付款订单数据响应式更新
2026-07-15 03:46:23 +08:00
57b584df1b feat(shop): 支持Dashboard订单总数点击跳转指定tab
- 修改Dashboard中订单总数和总营业额跳转链接,默认携带tab参数
- 订单总数点击跳转至/shop/shopOrder?tab=all页面
- 待发货订单跳转至/shop/shopOrder?tab=undelivered,退款申请跳转至?tab=refunded
- shopOrder页面根据路由查询参数初始化激活tab,确保页面首次加载可正确显示对应订单列表
- 为无效或缺省tab参数设置默认值undelivered
- 简化订单页面tab切换逻辑复用公共状态映射函数
2026-07-15 02:35:01 +08:00
6350a9b5a9 fix(shopOrder): 调整商品头像显示尺寸并优化图片压缩
- 修改订单商品头像大小,从80调整为50
- 调整图片压缩函数调用,设置压缩宽度为100
- 修正商品信息组件中头像图片的压缩调用,统一宽度参数
- 引入图片压缩工具方法以支持新参数调用
2026-07-15 01:40:12 +08:00
614e843673 fix(shopOrder): 修复初次加载订单状态筛选问题
- 提取 getStatusFilterByTab 函数实现 tab key 与 statusFilter 的映射
- datasource 函数中当 statusFilter 未设置时,自动根据 activeKey 推导赋值
- onTabs 函数简化为复用 getStatusFilterByTab 函数,减少重复代码
- 确保初次加载时待发货等状态的 tab 能正确筛选订单数据
2026-07-15 01:29:44 +08:00
894592c290 feat(shop): 新增线下付款支持及优化Dashboard数据统计
- 新增线下付款(payType=9)支付方式,支持订单中标识和确认收款操作
- 实现商家确认线下付款后订单进入待发货状态功能
- 更新支付方式组件和订单列表及详情页的支付状态显示
- 优化shop/dashboard快捷操作按钮为商城常用功能,修正快速入口路由路径
- 修复Dashboard待发货订单数统计时未过滤商城订单导致数据不准的问题
- 修复Dashboard运行天数为0的异常,将租户信息请求独立处理,避免某些请求失败影响
- 修复statisticsStore中couponUsedCount与getter同名冲突,改名为safeCouponUsedCount并同步更新引用
2026-07-14 22:17:39 +08:00
24 changed files with 2435 additions and 115 deletions

View File

@@ -6,3 +6,27 @@
-`src/views/shop/dashboard/index.vue` 的欢迎横幅右侧添加新订单提醒开关栏(开关 + 测试按钮),检测到新订单后自动调用 loadData() 刷新 Dashboard 数据。
-`src/views/cms/dashboard/index.vue` 的概况卡片标题栏添加新订单提醒控件,同样检测到新订单后刷新数据。
- 提取了 CMS Dashboard 的 loadData 函数使其可复用。
## 更新 shop/dashboard 快捷操作按钮为商城常用功能
- 快捷操作按钮从原来的通用功能(参数配置/用户管理/站点管理/登录日志)改为商城系统常用功能:订单管理、商品管理、商品分类、优惠券管理、会员管理、商城设置、清除缓存。
- 路由路径统一使用 `/shop/shopXxx` 格式(与 `/shop/shopOrder` 等已确认路径一致),修复了快速入口中 `/shopGoods``/shop/shopGoods` 的路径不一致问题。
- 快速入口九宫格也同步改为商城相关入口。
- 图标导入更新:移除 UngroupOutlined/CalendarOutlined/UserOutlined/FileTextOutlined新增 ShoppingCartOutlined/AppstoreOutlined/GiftOutlined/TeamOutlined/SettingOutlined。
## 修复 shop/dashboard 待发货订单数量统计不准确
- 根因:订单列表页 datasource 中 `where.type = 0`(只查商城订单),但 Dashboard 统计未传 `type: 0`,导致把预定订单/外卖(type=1)和会员卡订单(type=2)也计入。
- 修复:为 pendingShipmentCount 和 pendingRefundCount 查询都加上 `type: 0`
## 修复 Dashboard 运行天数为 0 的问题
- 根因:`getTenantInfo()` 被放在 `await Promise.all([...])` 之后,如果 `statisticsStore.fetchStatistics()` 抛异常(`couponUsedCount` 错误),`Promise.all` reject 后直接跳到 `catch``getTenantInfo` 根本不会执行,`tenantCreateTime` 永远是空值。
- 修复:在 `shop/dashboard/index.vue``cms/dashboard/index.vue``loadData` 中,把 `getTenantInfo()` 放到 `Promise.all` 外面,用 `.then` 独立执行,不受其他请求失败影响。
- 运行天数计算基于 `getTenantInfo()` 返回的 `Company.createTime`(租户创建时间)。
## 修复 statisticsStore couponUsedCount 冲突
- 根因:`couponUsedCount` 同时被定义成 state 属性和 getterPinia 中同名冲突导致 action 里 `this.couponUsedCount = ...` 报错:`'set' on proxy: trap returned falsish`
- 修复:将 getter 改名为 `safeCouponUsedCount``shop/dashboard/index.vue` 中同步更新引用(该引用当前被注释,但保持一致性)。

View File

@@ -0,0 +1,80 @@
# 2026-07-15
## 修复 shopOrder 页面默认待发货tab数据不正确
- 根因:`activeKey` 默认为 `'undelivered'`,但 `datasource` 函数只设了 `where.type = 0`,没有设 `statusFilter``statusFilter` 只在用户点击 tab 触发 `onTabs` 时才设置。所以页面初次加载时查的是全部订单而非待发货订单。
- 修复:提取 `getStatusFilterByTab(key)` 公共映射函数,在 `datasource` 中当 `where.statusFilter` 未设置时从 `activeKey` 自动推导。`onTabs` 也简化为复用同一函数。
- 文件:`src/views/shop/shopOrder/index.vue`
## Dashboard 订单总数点击跳转支持指定 tab
- Dashboard 中"订单总数"/"总营业额"跳转链接改为 `/shop/shopOrder?tab=all`"待发货订单"改为 `?tab=undelivered`"退款申请"改为 `?tab=refunded`
- shopOrder 页面读取 `route.query.tab` 初始化 `activeKey`,无效值回退到 `'undelivered'`
- 文件:`src/views/shop/dashboard/index.vue``src/views/shop/shopOrder/index.vue`
## Dashboard 待处理事项新增"待付款订单"
- 在待发货订单上方新增"待付款订单"统计项,使用 `statusFilter=0` 查询,点击跳转 `/shop/shopOrder?tab=unpaid`
- shopOrder 页面取消注释"待付款"tab`validTabs` 加入 `unpaid`
- 新增 `dot-gold` 样式。
- 文件:`src/views/shop/dashboard/index.vue``src/views/shop/shopOrder/index.vue`
## Dashboard 引入 useTenantStore创建时间读租户信息
- 引入 `useTenantStore``loadData` 中调用 `tenantStore.fetchTenantInfo()` 替代直接调用 `getTenantInfo()` API。
- 基本信息"创建时间"改为读取 `tenantStore.company?.createTime`
- 运行天数也改为从 `tenantStore.company?.createTime` 计算,移除独立的 `tenantCreateTime` ref。
- 文件:`src/views/shop/dashboard/index.vue`
## Dashboard 欢迎横幅新增商城Logo
- 通过 `getShopSettingCategoryValues('basic')` 获取商城设置,读取 `shopLogo` 字段。
- 使用 `getCompressedImageUrl(shopLogo, { width: 200, quality: 90 })` 压缩图片。
- 在 welcome-banner 左侧用 `a-avatar` (64px, square) 展示,无 Logo 时不显示。
- 文件:`src/views/shop/dashboard/index.vue`
## 新增 useAppSubscriptionStorewebsopy 应用订阅特殊接口)
- 新增 `src/api/app/appSubscription/model.ts`AppSubscription 实体及参数/返回类型,对照后端 `com.gxwebsoft.app.entity.AppSubscription`
- 新增 `src/api/app/appSubscription/index.ts`:封装 `AppSubscriptionController` 全部 14 个接口。
- 特殊接口域名 `https://websopy-api.websoft.top/api`(与项目主 API 域名不同),复用 `@/utils/request`(共享登录态 token、401 处理),传绝对 URL。
- 后端无 context-pathbaseURL=`https://websopy-api.websoft.top/api`,接口路径用 `/app/subscription/xxx`
- 后端 `BaseController` 成功 code=0`success(IPage)` 转成 `PageResult{list,count}`,与项目 `@/api` 的 PageResult 结构一致。
- 新增 `src/store/modules/appSubscription.ts``useAppSubscriptionStore`Pinia Options API 风格,对齐 site.ts/statistics.ts聚合列表/详情/支付状态/订阅管理方法。列表/详情缓存5分钟`checkStatus`/`checkPurchased` 实时请求;订阅/支付/管理类操作成功后调 `invalidateCache()` 失效缓存。
## 确认线下收款新增上传凭证功能
- 背景:原"确认线下收款"用 `Modal.confirm` + `createVNode` 动态拼一个 input只有备注没有上传凭证。用户需要加凭证上传。
- 字段决策:新增 `paymentVoucher?: string` 字段(不复用 comments/merchantRemarks因为凭证是图片URL非文本。顺带修复 `buyerRemarks`/`merchantRemarks` 类型 bug`undefined``string?`)。
- 重构为独立组件 `src/views/shop/shopOrder/components/OfflinePaymentModal.vue`
-`<a-modal>` + `<a-form>` + `<a-upload list-type="picture-card">` 单张图片上传。
- 上传走 `uploadOss``src/api/system/file`),存储返回的 `path`(与项目 `UploadCert` 组件约定一致),预览用 `getUrl(path)` 补全。
- 凭证必填,备注可选;校验 jpg/png、≤10MB支持点击预览大图。
- API `confirmOfflinePayment(id, remarks?, paymentVoucher?)` 新增第三参数,通过 query params 传给后端。
- `index.vue`:移除原 `Modal.confirm`/`createVNode` 逻辑,改为打开新组件(`v-model:visible` + `:data="current"` + `@done="reload"`),与 `DeliveryModal` 模式一致。
- 类型检查:新增 0 错误,顺带消掉原 `okType: 'success'` 的类型错误antdv4 ButtonType 不含 success新组件去掉了 ok-type
- 改动文件:`src/api/shop/shopOrder/model/index.ts``src/api/shop/shopOrder/index.ts``src/views/shop/shopOrder/components/OfflinePaymentModal.vue`(新增)、`src/views/shop/shopOrder/index.vue`
- 后端待办(已完成):后端项目 `/Users/gxwebsoft/JAVA/guilixu-java`MyBatis-Plus 3.4.3.3,无 Flyway/LiquibaseDDL 手动管理SQL 脚本放 `sql/` 目录):
- `ShopOrder.java` 实体新增 `paymentVoucher` 字段payTime 之后)。
- `ShopOrderController.confirmOfflinePayment` 新增 `@RequestParam paymentVoucher`
- `ShopOrderService` 接口 + `ShopOrderServiceImpl` 实现方法签名加 `paymentVoucher` 参数lambdaUpdate 加 `.set(paymentVoucher 非空, ShopOrder::getPaymentVoucher, paymentVoucher)`
- DDL 脚本 `sql/shop_order_payment_voucher.sql``ALTER TABLE shop_order ADD COLUMN payment_voucher VARCHAR(500) NULL ... AFTER pay_time`
- 注意:方法签名从 2 参变 3 参,全项目仅 Controller 一处调用,无断裂。
## Dashboard 到期时间显示订阅信息 + 立即订阅/扫码支付
- 改造 `src/views/shop/dashboard/index.vue` 基本信息「到期时间」行三态渲染active 显示 expireTime + 已激活 tag + ≤7天到期提醒pending 显示待支付 + 去支付;无订阅显示立即订阅)。
- **productId 关联条件**`app_product.tenantId = userStore.info.tenantId`(非 siteInfo.appId。通过 `pageProducts({tenantId,current:1,size:1})` 取该租户应用。
- 新增 `src/api/app/appProduct/{model.ts,index.ts}`AppProduct 类型 + `pageProducts` 接口GET /api/app/product/page分页参数 current/size注意与项目 page/limit 不同)。
- 「立即订阅」流程:选 month/year → 免费应用调 `subscribe()` 直接激活;付费应用调 `generatePayQrcode()` 生成小程序码 → Modal 展示二维码 → 每 2.5s 轮询 `checkStatus(subscriptionNo)`paid 后关闭+刷新(最多 5 分钟。envVersion 按 `import.meta.env.DEV` 自动判断 trial/release。
- pending 订阅「去支付」复用 `subscriptionStore.pay(id,'wechat')`(用 `'miniappQrcode' in result` 类型守卫窄化)生成小程序码,不重复创建订阅。
- 小程序端支付页 `websopy-taro/src/passport/pay/index.tsx`:扫码 scene=subscriptionNo → detail-by-no → mp-prepay → requestPayment → mp-confirm后端写 Redis `wxpay:paid:{no}=1`Web 端 checkStatus 据此感知。
- 移除 dashboard 不再使用的 `siteInfo` 解构(原到期时间读 `siteInfo.expirationTime`,已改为订阅 expireTime修复 noUnusedLocals 报错。
## 修复后端 generatePayQrcode 报错 "Field 'price_type' doesn't have a default value"
- 现象dashboard 点「立即订阅」付费应用调 `generatePayQrcode` 时,后端 insert app_subscription 报 `price_type` 无默认值。
- 根因:后端 `AppSubscriptionController.generatePayQrcode`websopy-java创建订阅时漏了 `setPriceType()`,而 DB `price_type` 为 NOT NULL 无默认值。对比 `subscribe` 方法有 `setPriceType`
- 参考 `websopy-pc/app/pages/console/pay/[subscriptionNo].vue`:它用 `subscribe` 创建订阅 + `pay(id,'wechat')` 生成二维码(两步),避开了 `generatePayQrcode`,所以没遇到此 bug。
- 修复(后端 `AppSubscriptionController.java` generatePayQrcode 方法):补全 `setPriceType(product.getPriceType())` + `setOriginalPrice`/`setPayStatus(0)`/`setTenantId`,对齐 subscribe。**前端无需改动**,重启后端即可。
- 注意:`subscribe` 价格计算用 `price/100`(当分转元),`generatePayQrcode` 直接用 `price`当元两者不一致schema 标注 price 为「元」,故 `generatePayQrcode` 价格逻辑更合理,保留不动。

View File

@@ -0,0 +1,43 @@
import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api';
import type { AppProduct, AppProductQueryParam } from './model';
/**
* websopy 特殊接口域名
* 后端 Controller: com.gxwebsoft.app.controller.AppProductController
* @RequestMapping("/api/app/product"),后端无 context-path
* 完整 URL = https://websopy-api.websoft.top/api/app/product/xxx
*/
const WEBSOPY_API_BASE = 'https://websopy-api.websoft.top/api';
const BASE = `${WEBSOPY_API_BASE}/app/product`;
/**
* 分页查询应用列表
* GET /app/product/page
* 支持按 tenantId 过滤(管理后台按租户查询应用)
* 注意:分页参数为 current/size非 page/limit
*/
export async function pageProducts(
params: AppProductQueryParam
): Promise<PageResult<AppProduct>> {
const res = await request.get<ApiResult<PageResult<AppProduct>>>(
`${BASE}/page`,
{ params }
);
if (res.data.code === 0) {
return res.data.data || { list: [], count: 0 };
}
return Promise.reject(new Error(res.data.message));
}
/**
* 获取应用详情
* GET /app/product/detail/{id}
*/
export async function getProductDetail(id: number): Promise<AppProduct> {
const res = await request.get<ApiResult<AppProduct>>(`${BASE}/detail/${id}`);
if (res.data.code === 0) {
return res.data.data as AppProduct;
}
return Promise.reject(new Error(res.data.message));
}

View File

@@ -0,0 +1,143 @@
/**
* 应用产品实体(对应表 app_product
* 字段对照后端 com.gxwebsoft.app.entity.AppProduct
*/
export interface AppProduct {
// 应用ID主键
productId?: number;
// 应用名称
productName?: string;
// 应用标识(唯一)
productCode?: string;
// 应用密钥
productSecret?: string;
// 应用类型: 10网站 20微信小程序 30抖音小程序 40百度小程序 50支付宝小程序 60Android 70iOS 80macOS 90Windows 100插件
appType?: number;
// 应用类型名称(关联查询)
appTypeName?: string;
// 分类ID
categoryId?: number;
// 行业类型(父级)
industryParent?: string;
// 行业类型(子级)
industryChild?: string;
// 应用Logo
logo?: string;
// 应用图标
icon?: string;
// 二维码
qrcode?: string;
// 应用截图(JSON数组)
screenshots?: string;
// 应用简介
description?: string;
// 详细说明
content?: string;
// 关键词
keywords?: string;
// 域名
domain?: string;
// 域名前缀
prefix?: string;
// 包名/AppID
packageName?: string;
// 后台地址
adminUrl?: string;
// API地址
apiUrl?: string;
// 下载地址
downloadUrl?: string;
// 版本号
version?: string;
// 版本: standard标准版 professional专业版 perpetual永久授权
edition?: string;
// 最低版本要求
minVersion?: string;
// 定价: free免费 one_time一次性 subscription订阅
priceType?: string;
// 价格(元)
price?: number;
// 划线价格
linePrice?: number;
// 续费价格
renewPrice?: number;
// 交付方式: 1源码 2托管 3授权
deliveryMethod?: number;
// 计费方式: 1按年 2按月 3一次性
chargingMethod?: number;
// 订阅周期: month/year
subscriptionPeriod?: string;
// 发布状态: developing pending_review published rejected deprecated
publishStatus?: string;
// 发布时间
publishTime?: string;
// 审核时间
reviewTime?: string;
// 审核人ID
reviewerId?: number;
// 拒绝原因
rejectReason?: string;
// 浏览次数
clicks?: number;
// 安装次数
installs?: number;
// 下载次数
downloads?: number;
// 评分(1-5)
rating?: number;
// 点赞数
likes?: number;
// 开发者
developer?: string;
// 开发者电话
developerPhone?: string;
// 开发者邮箱
developerEmail?: string;
// 是否推荐: 0否 1是
recommend?: number;
// 是否官方: 0否 1是
official?: number;
// 是否上架市场: 0否 1是
market?: number;
// 是否显示首页: 0否 1是
showIndex?: number;
// 是否可搜索: 0否 1是
searchEnabled?: number;
// 模板ID
templateId?: number;
// 租户ID
tenantId?: number;
// 创建时间
createTime?: string;
// 更新时间
updateTime?: string;
}
/**
* 应用产品分页查询参数
* 注意:后端 AppProductController.page 的分页参数为 current/size非 page/limit
*/
export interface AppProductQueryParam {
// 页码
current?: number;
// 每页条数
size?: number;
// 应用名称
productName?: string;
// 应用标识
productCode?: string;
// 应用类型
appType?: number;
// 分类ID
categoryId?: number;
// 发布状态
publishStatus?: string;
// 状态
status?: number;
// 用户ID
userId?: number;
// 租户ID按租户查询应用
tenantId?: number;
// 关键词搜索(同时搜索应用名称和应用标识)
keywords?: string;
}

View File

@@ -0,0 +1,269 @@
import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api';
import type {
AppSubscription,
AppSubscriptionQueryParam,
SubscribeParam,
SubscribeResult,
GeneratePayQrcodeParam,
GeneratePayQrcodeResult,
CheckStatusResult,
PayResult,
WechatNativePayResult,
MpPrepayParam,
MpPrepayResult,
MpConfirmParam,
BalanceResult
} from './model';
/**
* websopy 特殊接口域名(与项目主 API 域名不同)
* 后端 Controller: com.gxwebsoft.app.controller.AppSubscriptionController
* @RequestMapping("/api/app/subscription"),后端无 context-path
* 因此完整 URL = https://websopy-api.websoft.top + /api/app/subscription/xxx
*/
const WEBSOPY_API_BASE = 'https://websopy-api.websoft.top/api';
const BASE = `${WEBSOPY_API_BASE}/app/subscription`;
/**
* 我的订阅列表(分页)
* GET /app/subscription/my/page
*/
export async function pageMySubscriptions(
params: AppSubscriptionQueryParam
): Promise<PageResult<AppSubscription>> {
const res = await request.get<ApiResult<PageResult<AppSubscription>>>(
`${BASE}/my/page`,
{ params }
);
if (res.data.code === 0) {
return (
res.data.data || { list: [], count: 0 }
);
}
return Promise.reject(new Error(res.data.message));
}
/**
* 订阅详情按ID
* GET /app/subscription/detail/{id}
*/
export async function getSubscriptionDetail(
id: number
): Promise<AppSubscription> {
const res = await request.get<ApiResult<AppSubscription>>(
`${BASE}/detail/${id}`
);
if (res.data.code === 0) {
return res.data.data as AppSubscription;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 根据订阅编号查询详情(小程序入口用)
* GET /app/subscription/detail-by-no/{subscriptionNo}
*/
export async function getSubscriptionDetailByNo(
subscriptionNo: string
): Promise<AppSubscription> {
const res = await request.get<ApiResult<AppSubscription>>(
`${BASE}/detail-by-no/${subscriptionNo}`
);
if (res.data.code === 0) {
return res.data.data as AppSubscription;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 查询支付状态(前端轮询用)
* GET /app/subscription/check-status/{subscriptionNo}
*/
export async function checkSubscriptionStatus(
subscriptionNo: string
): Promise<CheckStatusResult> {
const res = await request.get<ApiResult<CheckStatusResult>>(
`${BASE}/check-status/${subscriptionNo}`
);
if (res.data.code === 0) {
return res.data.data as CheckStatusResult;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 检查是否已购买某应用
* GET /app/subscription/check-purchased/{productId}
* 返回 boolean
*/
export async function checkPurchased(
productId: number
): Promise<boolean> {
const res = await request.get<ApiResult<boolean>>(
`${BASE}/check-purchased/${productId}`
);
if (res.data.code === 0) {
return res.data.data === true;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 获取当前用户余额
* GET /app/subscription/balance
*/
export async function getBalance(): Promise<BalanceResult> {
const res = await request.get<ApiResult<BalanceResult>>(`${BASE}/balance`);
if (res.data.code === 0) {
return (
res.data.data || { balance: 0 }
);
}
return Promise.reject(new Error(res.data.message));
}
/**
* 创建订阅
* POST /app/subscription/subscribe
* 免费应用直接激活,付费应用创建待支付记录
*/
export async function subscribe(
data: SubscribeParam
): Promise<SubscribeResult> {
const res = await request.post<ApiResult<SubscribeResult>>(
`${BASE}/subscribe`,
data
);
if (res.data.code === 0) {
return res.data.data as SubscribeResult;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 生成支付小程序码(同时创建订阅记录)
* POST /app/subscription/generate-pay-qrcode
*/
export async function generatePayQrcode(
data: GeneratePayQrcodeParam
): Promise<GeneratePayQrcodeResult> {
const res = await request.post<ApiResult<GeneratePayQrcodeResult>>(
`${BASE}/generate-pay-qrcode`,
data
);
if (res.data.code === 0) {
return res.data.data as GeneratePayQrcodeResult;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 发起支付
* POST /app/subscription/pay/{id}?method=balance|wechat&envVersion=xxx
* - method=balance余额支付返回 PayResult
* - method=wechat微信 Native 支付,返回小程序码 WechatNativePayResult
*/
export async function paySubscription(
id: number,
method: 'balance' | 'wechat' = 'wechat',
envVersion?: string
): Promise<PayResult | WechatNativePayResult> {
const res = await request.post<ApiResult<PayResult | WechatNativePayResult>>(
`${BASE}/pay/${id}`,
undefined,
{ params: { method, envVersion } }
);
if (res.data.code === 0) {
return res.data.data as PayResult | WechatNativePayResult;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 小程序 JSAPI 预支付下单
* POST /app/subscription/mp-prepay/{id}
* Body: { openid }
*/
export async function mpPrepay(
id: number,
data: MpPrepayParam
): Promise<MpPrepayResult> {
const res = await request.post<ApiResult<MpPrepayResult>>(
`${BASE}/mp-prepay/${id}`,
data
);
if (res.data.code === 0) {
return res.data.data as MpPrepayResult;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 小程序支付成功确认
* POST /app/subscription/mp-confirm/{subscriptionNo}
* Body: { transactionId? }
*/
export async function mpConfirm(
subscriptionNo: string,
data?: MpConfirmParam
): Promise<PayResult> {
const res = await request.post<ApiResult<PayResult>>(
`${BASE}/mp-confirm/${subscriptionNo}`,
data
);
if (res.data.code === 0) {
return (
res.data.data || { paid: true, subscriptionNo }
);
}
return Promise.reject(new Error(res.data.message));
}
/**
* 续费
* POST /app/subscription/renew/{id}?period=month|year
*/
export async function renewSubscription(
id: number,
period: 'month' | 'year' = 'month'
): Promise<string> {
const res = await request.post<ApiResult<string>>(`${BASE}/renew/${id}`, undefined, {
params: { period }
});
if (res.data.code === 0) {
return res.data.message || '续费成功';
}
return Promise.reject(new Error(res.data.message));
}
/**
* 退订/取消
* POST /app/subscription/cancel/{id}
*/
export async function cancelSubscription(id: number): Promise<string> {
const res = await request.post<ApiResult<string>>(`${BASE}/cancel/${id}`);
if (res.data.code === 0) {
return res.data.message || '退订成功';
}
return Promise.reject(new Error(res.data.message));
}
/**
* 启用/禁用
* POST /app/subscription/toggle-enable/{id}?enabled=true|false
*/
export async function toggleEnable(
id: number,
enabled: boolean
): Promise<string> {
const res = await request.post<ApiResult<string>>(
`${BASE}/toggle-enable/${id}`,
undefined,
{ params: { enabled } }
);
if (res.data.code === 0) {
return res.data.message || (enabled ? '已启用' : '已禁用');
}
return Promise.reject(new Error(res.data.message));
}

View File

@@ -0,0 +1,219 @@
import type { PageParam } from '@/api';
/**
* 订阅状态: pending-待支付 active-已激活 expired-已过期 cancelled-已取消
*/
export type SubscriptionStatus =
| 'pending'
| 'active'
| 'expired'
| 'cancelled';
/**
* 价格类型: free-免费 one_time-买断 subscription-订阅
*/
export type PriceType = 'free' | 'one_time' | 'subscription';
/**
* 订阅周期: month-月 quarter-季 year-年
*/
export type SubscriptionPeriod = 'month' | 'quarter' | 'year';
/**
* 支付方式: 0-余额 1-微信 2-支付宝 12-免费
*/
export type PayType = 0 | 1 | 2 | 12;
/**
* 应用订阅实体(对应表 app_subscription
* 字段对照后端 com.gxwebsoft.app.entity.AppSubscription
*/
export interface AppSubscription {
// 主键ID
id?: number;
// 订阅编号(业务唯一)
subscriptionNo?: string;
// 购买用户ID
userId?: number;
// 应用产品ID
productId?: number;
// 租户ID
tenantId?: number;
// 订阅状态
status?: SubscriptionStatus;
// 价格类型
priceType?: PriceType;
// 原价(单位:元)
originalPrice?: number;
// 实付金额(单位:元)
payPrice?: number;
// 支付方式
payType?: PayType;
// 支付状态: 0-未支付 1-已支付
payStatus?: number;
// 支付时间
payTime?: string;
// 第三方交易号
transactionId?: string;
// 订阅周期
subscriptionPeriod?: SubscriptionPeriod;
// 生效时间
startTime?: string;
// 到期时间(订阅型)
expireTime?: string;
// 是否自动续费 0-否 1-是
autoRenew?: number;
// 分配的域名
instanceDomain?: string;
// 实例管理后台URL
instanceAdminUrl?: string;
// 实例配置JSON
instanceConfig?: string;
// 关联的支付订单号
orderNo?: string;
// 关联的支付订单ID
orderId?: number;
// 备注
remark?: string;
// 排序
sortNumber?: number;
// 创建时间
createTime?: string;
// 更新时间
updateTime?: string;
// ===== 关联查询字段(非数据库字段) =====
productName?: string;
productIcon?: string;
productLogo?: string;
productAppType?: number;
productDescription?: string;
developerName?: string;
}
/**
* 我的订阅分页查询参数
*/
export interface AppSubscriptionQueryParam extends PageParam {
// 订阅状态过滤
status?: SubscriptionStatus;
}
/**
* 创建订阅参数
*/
export interface SubscribeParam {
// 应用产品ID
productId: number;
// 订阅周期,默认 month
subscriptionPeriod?: SubscriptionPeriod;
}
/**
* 生成支付小程序码参数
*/
export interface GeneratePayQrcodeParam {
// 应用产品ID
productId: number;
// 订阅周期,默认 month
subscriptionPeriod?: SubscriptionPeriod;
// 小程序版本develop / trial / release默认 trial
envVersion?: string;
}
/**
* 创建订阅返回结果
*/
export interface SubscribeResult {
subscriptionId: number;
subscriptionNo: string;
status: SubscriptionStatus;
message: string;
payPrice?: number;
orderNo?: string;
}
/**
* 生成支付小程序码返回结果
*/
export interface GeneratePayQrcodeResult {
subscriptionNo: string;
subscriptionId: number;
qrcodeBase64: string;
productName: string;
payPrice: number;
}
/**
* 查询支付状态返回结果
*/
export interface CheckStatusResult {
paid: boolean;
payStatus: number;
status: SubscriptionStatus;
payTime?: string;
transactionId?: string;
id: number;
subscriptionNo: string;
productId: number;
productName?: string;
productLogo?: string;
priceType?: PriceType;
payPrice?: number;
subscriptionPeriod?: SubscriptionPeriod;
}
/**
* 余额支付返回结果
*/
export interface PayResult {
paid: boolean;
balance?: number;
subscriptionNo: string;
}
/**
* 微信 Native 支付Web 端)返回结果
*/
export interface WechatNativePayResult {
subscriptionId: number;
subscriptionNo: string;
miniappQrcode: string;
miniappPagePath: string;
payPrice: number;
}
/**
* 小程序 JSAPI 预支付返回结果
*/
export interface MpPrepayResult {
subscriptionId: number;
subscriptionNo: string;
outTradeNo: string;
timeStamp: string;
nonceStr: string;
package: string;
signType: string;
paySign: string;
payPrice: number;
}
/**
* 获取余额返回结果
*/
export interface BalanceResult {
balance: number;
}
/**
* 小程序预支付参数
*/
export interface MpPrepayParam {
openid: string;
}
/**
* 小程序支付确认参数
*/
export interface MpConfirmParam {
transactionId?: string;
}

View File

@@ -0,0 +1,30 @@
import request from '@/utils/request';
import type { ApiResult, PageResult } from '@/api';
import type { ShopGoodsBrowse, ShopGoodsBrowseParam } from './model';
/**
* 后台管理:分页查询浏览记录
*/
export async function pageShopGoodsBrowse(params: ShopGoodsBrowseParam) {
const res = await request.get<ApiResult<PageResult<ShopGoodsBrowse>>>(
'/shop/shop-goods-browse/admin/page',
{ params }
);
if (res.data.code === 0) {
return res.data.data;
}
return Promise.reject(new Error(res.data.message));
}
/**
* 后台管理:删除单条浏览记录
*/
export async function removeShopGoodsBrowse(id?: number) {
const res = await request.delete<ApiResult<unknown>>(
'/shop/shop-goods-browse/admin/' + id
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}

View File

@@ -0,0 +1,42 @@
import type { PageParam } from '@/api';
/**
* 用户商品浏览记录
*/
export interface ShopGoodsBrowse {
id?: number;
userId?: number;
goodsId?: number;
tenantId?: number;
merchantId?: number;
/** 浏览次数 */
visitCount?: number;
/** 最后浏览时间 */
lastVisitTime?: string;
/** 浏览来源 */
browseSource?: string;
createTime?: string;
updateTime?: string;
/** 商品名称(关联查询) */
goodsName?: string;
/** 商品封面图(关联查询) */
goodsImage?: string;
/** 商品价格(关联查询) */
price?: string;
/** 市场价(关联查询) */
salePrice?: string;
}
/**
* 浏览记录查询参数
*/
export interface ShopGoodsBrowseParam extends PageParam {
id?: number;
userId?: number;
goodsId?: number;
merchantId?: number;
tenantId?: number;
browseSource?: string;
startTime?: string;
endTime?: string;
}

View File

@@ -150,3 +150,26 @@ export async function refundShopOrder(data: ShopOrder) {
}
return Promise.reject(new Error(res.data.message));
}
/**
* 确认线下付款收款
* 商家确认已收到线下转账(微信转账/银行汇款等),确认后订单进入待发货状态
* @param id 订单ID
* @param remarks 备注(可选)
* @param paymentVoucher 支付凭证图片地址(可选)
*/
export async function confirmOfflinePayment(
id: number,
remarks?: string,
paymentVoucher?: string
) {
const res = await request.put<ApiResult<unknown>>(
MODULES_API_URL + '/shop/shop-order/confirm-offline-payment/' + id,
null,
{ params: { remarks, paymentVoucher } }
);
if (res.data.code === 0) {
return res.data.message;
}
return Promise.reject(new Error(res.data.message));
}

View File

@@ -85,9 +85,9 @@ export interface ShopOrder {
coachId?: number;
// 支付的用户id
payUserId?: number;
// 0余额支付, 1微信支付, 2支付宝, 3银联支付, 4现金支付, 5POS机支付, 6免费, 7积分支付, 8货到付款, 9~18 已废弃
// 0余额支付, 1微信支付, 2支付宝, 3银联支付, 4现金支付, 5POS机支付, 6免费, 7积分支付, 8货到付款, 9线下付款, 10~18 已废弃
payType?: number;
// 代付支付方式, 0余额支付, 1微信支付, 2支付宝, 3银联支付, 4现金支付, 5POS机支付, 6免费, 7积分支付, 8货到付款, 9~18 已废弃
// 代付支付方式, 0余额支付, 1微信支付, 2支付宝, 3银联支付, 4现金支付, 5POS机支付, 6免费, 7积分支付, 8货到付款, 9线下付款, 10~18 已废弃
friendPayType?: number;
// 0未付款1已付款
payStatus?: number;
@@ -129,6 +129,8 @@ export interface ShopOrder {
invoiceNo?: string;
// 支付时间
payTime?: string;
// 线下收款支付凭证(图片地址,确认线下收款时上传)
paymentVoucher?: string;
// 退款时间
refundTime?: string;
// 申请退款时间
@@ -142,9 +144,9 @@ export interface ShopOrder {
// 系统版本号 0当前版本 value=其他版本
version?: number;
// 买家备注
buyerRemarks: undefined;
buyerRemarks?: string;
// 商家备注
merchantRemarks: undefined;
merchantRemarks?: string;
// 用户id
userId?: number;
// 备注

View File

@@ -84,6 +84,12 @@
label: '货到付款',
key: 'codPay',
icon: 'IdcardOutlined'
},
{
value: 9,
label: '线下付款',
key: 'offlinePay',
icon: 'IdcardOutlined'
}
]);

View File

@@ -1,7 +1,7 @@
const storeName = localStorage.getItem('StoreName') || 'WebSoft Inc';
/* 主框架 */
export default {
system: '小程序开发',
system: '小程序商城',
home: '主页',
header: {
profile: '个人资料',

View File

@@ -0,0 +1,368 @@
/**
* 应用订阅 store
* 数据来源websopy 特殊接口db_websopy.app_subscription 表)
* 接口域名https://websopy-api.websoft.top/api
* 后端com.gxwebsoft.app.controller.AppSubscriptionController
*/
import { defineStore } from 'pinia';
import {
pageMySubscriptions,
getSubscriptionDetail,
getSubscriptionDetailByNo,
checkSubscriptionStatus,
checkPurchased,
getBalance,
subscribe,
generatePayQrcode,
paySubscription,
mpPrepay,
mpConfirm,
renewSubscription,
cancelSubscription,
toggleEnable
} from '@/api/app/appSubscription';
import type {
AppSubscription,
AppSubscriptionQueryParam,
SubscribeParam,
SubscribeResult,
GeneratePayQrcodeParam,
GeneratePayQrcodeResult,
CheckStatusResult,
PayResult,
WechatNativePayResult,
MpPrepayResult
} from '@/api/app/appSubscription/model';
import type { PageResult } from '@/api';
export interface AppSubscriptionState {
// 我的订阅列表
subscriptionList: AppSubscription[];
// 总数量
total: number;
// 当前查看的订阅详情
currentSubscription: AppSubscription | null;
// 用户余额
balance: number;
// 加载状态
loading: boolean;
// 最后更新时间
lastUpdateTime: number | null;
// 缓存有效期(毫秒)
cacheExpiry: number;
}
export const useAppSubscriptionStore = defineStore('appSubscription', {
state: (): AppSubscriptionState => ({
subscriptionList: [],
total: 0,
currentSubscription: null,
balance: 0,
loading: false,
lastUpdateTime: null,
// 默认缓存5分钟订阅涉及支付状态不宜过长
cacheExpiry: 5 * 60 * 1000
}),
getters: {
/**
* 已激活订阅
*/
activeSubscriptions: (state): AppSubscription[] => {
return state.subscriptionList.filter((s) => s.status === 'active');
},
/**
* 待支付订阅
*/
pendingSubscriptions: (state): AppSubscription[] => {
return state.subscriptionList.filter((s) => s.status === 'pending');
},
/**
* 已过期订阅
*/
expiredSubscriptions: (state): AppSubscription[] => {
return state.subscriptionList.filter((s) => s.status === 'expired');
},
/**
* 检查缓存是否有效
*/
isCacheValid: (state): boolean => {
if (!state.lastUpdateTime) return false;
const now = Date.now();
return now - state.lastUpdateTime < state.cacheExpiry;
}
},
actions: {
// ============================================================
// 查询类
// ============================================================
/**
* 获取我的订阅列表(分页,带缓存)
* @param params 查询参数page/limit/status
* @param forceRefresh 是否强制刷新(切换 status 过滤时建议传 true
*/
async fetchMySubscriptions(
params: AppSubscriptionQueryParam = { page: 1, limit: 10 },
forceRefresh = false
): Promise<PageResult<AppSubscription>> {
// 缓存有效且不强制刷新,直接返回缓存列表
if (!forceRefresh && this.isCacheValid && this.subscriptionList.length > 0) {
return { list: this.subscriptionList, count: this.total };
}
this.loading = true;
try {
const data = await pageMySubscriptions(params);
this.subscriptionList = data.list || [];
this.total = data.count || 0;
this.lastUpdateTime = Date.now();
return data;
} catch (error) {
console.error('获取我的订阅列表失败:', error);
throw error;
} finally {
this.loading = false;
}
},
/**
* 获取订阅详情按ID
*/
async fetchDetail(id: number): Promise<AppSubscription> {
try {
const data = await getSubscriptionDetail(id);
this.currentSubscription = data;
return data;
} catch (error) {
console.error('获取订阅详情失败:', error);
throw error;
}
},
/**
* 根据订阅编号查询详情(小程序入口用)
*/
async fetchDetailByNo(subscriptionNo: string): Promise<AppSubscription> {
try {
const data = await getSubscriptionDetailByNo(subscriptionNo);
this.currentSubscription = data;
return data;
} catch (error) {
console.error('根据订阅编号查询详情失败:', error);
throw error;
}
},
/**
* 查询支付状态(前端轮询用,强制实时请求,不走缓存)
*/
async checkStatus(subscriptionNo: string): Promise<CheckStatusResult> {
return await checkSubscriptionStatus(subscriptionNo);
},
/**
* 检查是否已购买某应用(强制实时请求,不走缓存)
*/
async checkPurchased(productId: number): Promise<boolean> {
return await checkPurchased(productId);
},
/**
* 获取当前用户余额
*/
async fetchBalance(): Promise<number> {
try {
const data = await getBalance();
this.balance = data.balance;
return data.balance;
} catch (error) {
console.error('获取用户余额失败:', error);
throw error;
}
},
// ============================================================
// 订阅与支付操作
// ============================================================
/**
* 创建订阅
* 免费应用直接激活,付费应用创建待支付记录
*/
async subscribe(data: SubscribeParam): Promise<SubscribeResult> {
try {
const result = await subscribe(data);
// 订阅状态变化,失效缓存
this.invalidateCache();
return result;
} catch (error) {
console.error('创建订阅失败:', error);
throw error;
}
},
/**
* 生成支付小程序码(同时创建订阅记录)
*/
async generatePayQrcode(
data: GeneratePayQrcodeParam
): Promise<GeneratePayQrcodeResult> {
try {
const result = await generatePayQrcode(data);
// 已创建订阅记录,失效缓存
this.invalidateCache();
return result;
} catch (error) {
console.error('生成支付小程序码失败:', error);
throw error;
}
},
/**
* 发起支付
* @param id 订阅ID
* @param method 支付方式balance-余额支付 / wechat-微信支付
* @param envVersion 小程序版本微信支付时使用develop/trial/release
*/
async pay(
id: number,
method: 'balance' | 'wechat' = 'wechat',
envVersion?: string
): Promise<PayResult | WechatNativePayResult> {
try {
const result = await paySubscription(id, method, envVersion);
// 支付成功后余额/订阅状态变化,失效缓存并刷新余额
this.invalidateCache();
if (method === 'balance') {
const payResult = result as PayResult;
if (typeof payResult.balance === 'number') {
this.balance = payResult.balance;
}
}
return result;
} catch (error) {
console.error('发起支付失败:', error);
throw error;
}
},
/**
* 小程序 JSAPI 预支付下单
*/
async mpPrepay(id: number, openid: string): Promise<MpPrepayResult> {
try {
return await mpPrepay(id, { openid });
} catch (error) {
console.error('小程序预支付失败:', error);
throw error;
}
},
/**
* 小程序支付成功确认
*/
async mpConfirm(
subscriptionNo: string,
transactionId?: string
): Promise<PayResult> {
try {
const result = await mpConfirm(subscriptionNo, { transactionId });
// 支付确认后订阅状态变化,失效缓存
this.invalidateCache();
return result;
} catch (error) {
console.error('小程序支付确认失败:', error);
throw error;
}
},
// ============================================================
// 订阅管理
// ============================================================
/**
* 续费
* @param id 订阅ID
* @param period 周期month/year
*/
async renew(id: number, period: 'month' | 'year' = 'month'): Promise<string> {
try {
const msg = await renewSubscription(id, period);
this.invalidateCache();
return msg;
} catch (error) {
console.error('续费失败:', error);
throw error;
}
},
/**
* 退订/取消
*/
async cancel(id: number): Promise<string> {
try {
const msg = await cancelSubscription(id);
this.invalidateCache();
return msg;
} catch (error) {
console.error('退订失败:', error);
throw error;
}
},
/**
* 启用/禁用
*/
async toggleEnable(id: number, enabled: boolean): Promise<string> {
try {
const msg = await toggleEnable(id, enabled);
this.invalidateCache();
return msg;
} catch (error) {
console.error('启用/禁用失败:', error);
throw error;
}
},
// ============================================================
// 缓存控制
// ============================================================
/**
* 失效缓存(仅重置时间标记,保留已有数据,下次拉取时更新)
* 用于订阅/支付/管理操作后,确保下次查询获取最新数据
*/
invalidateCache() {
this.lastUpdateTime = null;
},
/**
* 清除缓存(清空数据并重置时间标记)
*/
clearCache() {
this.subscriptionList = [];
this.total = 0;
this.currentSubscription = null;
this.lastUpdateTime = null;
},
/**
* 强制刷新订阅列表
*/
async refresh() {
return await this.fetchMySubscriptions({ page: 1, limit: 10 }, true);
},
/**
* 设置缓存有效期
*/
setCacheExpiry(expiry: number) {
this.cacheExpiry = expiry;
}
}
});

View File

@@ -90,9 +90,9 @@ export const useStatisticsStore = defineStore('statistics', {
},
/**
* 获取今日使用优惠券数量
* 获取今日使用优惠券数量(安全取值)
*/
couponUsedCount: (state): number => {
safeCouponUsedCount: (state): number => {
return safeNumber(state.couponUsedCount);
},

View File

@@ -36,6 +36,10 @@ export function getPayType(index?: number): any {
{
value: 8,
label: '货到付款'
},
{
value: 9,
label: '线下付款'
}
];
if (index != null) {

View File

@@ -87,7 +87,7 @@
// 系统信息
const systemInfo = ref({
name: '小程序开发',
name: '小程序商城',
description:
'基于Spring、SpringBoot、SpringMVC等技术栈构建的前后端分离开发平台',
version: '2.0.0',

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);
@@ -225,7 +228,7 @@
// 系统信息
const systemInfo = ref({
name: '小程序开发',
name: '小程序商城',
description:
'基于Spring、SpringBoot、SpringMVC等技术栈构建的前后端分离开发平台',
version: '2.0.0',
@@ -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>

View File

@@ -2,10 +2,19 @@
<div class="shop-dashboard">
<!-- 欢迎横幅 -->
<div class="welcome-banner">
<div class="welcome-left">
<h2 class="welcome-title">🏸 {{ userStore.info?.tenantName }}</h2>
<div class="welcome-left flex flex-row gap-2 items-center">
<a-avatar
v-if="shopLogoUrl"
:src="shopLogoUrl"
:size="64"
shape="square"
class="welcome-logo"
/>
<div>
<h2 class="welcome-title">{{ userStore.info?.tenantName }}</h2>
<p class="welcome-sub">欢迎回来管理员今日数据已更新</p>
</div>
</div>
<div class="welcome-right">
<div class="welcome-actions">
<div class="order-notify-bar">
@@ -147,7 +156,7 @@
<div style="padding: 16px 18px;">
<a-descriptions :column="1" size="small">
<a-descriptions-item label="系统名称">
{{ siteStore.appName }}
{{ systemInfo.name }}
</a-descriptions-item>
<a-descriptions-item label="版本号">
{{ systemInfo.version }}
@@ -156,10 +165,30 @@
{{ siteStore.statusText || '正常' }}
</a-descriptions-item>
<a-descriptions-item label="创建时间">
{{ siteInfo?.createTime }}
{{ tenantStore.company?.createTime || '-' }}
</a-descriptions-item>
<a-descriptions-item label="到期时间">
{{ siteInfo?.expirationTime }}
<template v-if="subscriptionLoading">
<a-skeleton-input :active="true" size="small" style="width: 140px" />
</template>
<template v-else-if="currentSubscription && currentSubscription.status === 'active' && currentSubscription.expireTime">
<span>{{ formatDateTime(currentSubscription.expireTime) }}</span>
<a-tag color="green" style="margin-left: 8px">已激活</a-tag>
<span v-if="daysToExpire !== null && daysToExpire >= 0 && daysToExpire <= 7" class="expire-warn">
{{ daysToExpire }}天后到期
</span>
<span v-else-if="daysToExpire !== null && daysToExpire < 0" class="expire-warn">
已过期
</span>
</template>
<template v-else-if="currentSubscription && currentSubscription.status === 'pending'">
<span class="text-orange">待支付 ¥{{ Number(currentSubscription.payPrice || 0).toFixed(2) }}</span>
<a-button type="link" size="small" @click="repayPending" style="padding: 0 0 0 8px">去支付</a-button>
</template>
<template v-else>
<span class="text-muted">未订阅</span>
<a-button type="link" size="small" @click="onSubscribe" style="padding: 0 0 0 8px">立即订阅</a-button>
</template>
</a-descriptions-item>
<a-descriptions-item label="系统运行">
{{ runDays }}
@@ -180,27 +209,30 @@
<a-button
type="primary"
block
@click="navigateTo('/website/field')"
:loading="loading"
@click="navigateTo('/shop/shopOrder')"
>
<UngroupOutlined />
参数配置
</a-button>
<a-button block @click="navigateTo('/shop/shopOrder')">
<CalendarOutlined />
<ShoppingCartOutlined />
订单管理
</a-button>
<a-button block @click="navigateTo('/system/user')">
<UserOutlined />
用户管理
</a-button>
<a-button block @click="navigateTo('/website/index')">
<a-button block @click="navigateTo('/shop/shopGoods')">
<ShopOutlined />
站点管理
商品管理
</a-button>
<a-button block @click="navigateTo('/system/login-record')">
<FileTextOutlined />
登录日志
<a-button block @click="navigateTo('/shop/shopGoodsCategory')">
<AppstoreOutlined />
商品分类
</a-button>
<a-button block @click="navigateTo('/market/coupon')">
<GiftOutlined />
优惠券管理
</a-button>
<a-button block @click="navigateTo('/system/user')">
<TeamOutlined />
会员管理
</a-button>
<a-button block @click="navigateTo('/shop/shopSetting')">
<SettingOutlined />
商城设置
</a-button>
<a-button block @click="handleClearCache">
<ClearOutlined />
@@ -211,6 +243,80 @@
</div>
</a-col>
</a-row>
<!-- 订阅 Modal选择订阅周期 -->
<a-modal
v-model:open="subscribeModalVisible"
title="订阅应用"
:confirm-loading="subscribing"
ok-text="确认订阅"
cancel-text="取消"
:mask-closable="false"
@ok="confirmSubscribe"
>
<div class="subscribe-modal-body">
<div class="subscribe-product-name">
{{ currentProduct?.productName || '应用订阅' }}
</div>
<a-alert
v-if="isFreeProduct"
type="success"
message="该应用为免费应用,订阅后立即激活"
show-icon
style="margin-bottom: 12px"
/>
<div v-else class="period-options">
<div
class="period-option"
:class="{ active: selectedPeriod === 'month' }"
@click="selectedPeriod = 'month'"
>
<div class="period-option-label">月付</div>
<div class="period-option-price">¥{{ monthPrice.toFixed(2) }}/</div>
</div>
<div
class="period-option"
:class="{ active: selectedPeriod === 'year' }"
@click="selectedPeriod = 'year'"
>
<div class="period-option-label">年付</div>
<div class="period-option-price">¥{{ yearPrice.toFixed(2) }}/</div>
<div class="period-option-tag">更划算</div>
</div>
</div>
</div>
</a-modal>
<!-- 支付 Modal微信扫码支付 -->
<a-modal
v-model:open="payModalVisible"
title="微信扫码支付"
:footer="null"
:mask-closable="false"
@cancel="onPayModalClose"
>
<div class="pay-modal-body">
<div class="pay-product-name">{{ payProductName }}</div>
<div class="pay-amount">
<span class="pay-amount-label">支付金额</span>
<span class="pay-amount-value">¥{{ payPrice.toFixed(2) }}</span>
</div>
<div class="pay-qrcode-wrap">
<img
v-if="payQrcode"
:src="payQrcode"
alt="支付二维码"
class="pay-qrcode-img"
/>
<a-spin v-else />
</div>
<div class="pay-tip">
<QrcodeOutlined />
请使用微信扫描上方二维码完成支付
</div>
<div class="pay-order-no">订单号{{ paySubscriptionNo }}</div>
</div>
</a-modal>
</div>
</template>
@@ -221,30 +327,42 @@ import { useOrderNotify } from '@/views/shop/shopOrder/useOrderNotify';
import {
ReloadOutlined,
RightOutlined,
UngroupOutlined,
CalendarOutlined,
UserOutlined,
ShoppingCartOutlined,
ShopOutlined,
FileTextOutlined,
AppstoreOutlined,
GiftOutlined,
TeamOutlined,
SettingOutlined,
ClearOutlined,
InfoCircleOutlined
InfoCircleOutlined,
QrcodeOutlined
} from '@ant-design/icons-vue';
import { message } from 'ant-design-vue/es';
import { useSiteStore } from '@/store/modules/site';
import { useStatisticsStore } from '@/store/modules/statistics';
import { useUserStore } from '@/store/modules/user';
import { useTenantStore } from '@/store/modules/tenant';
import { useAppSubscriptionStore } from '@/store/modules/appSubscription';
import { pageShopOrder } from '@/api/shop/shopOrder';
import { getShopSettingCategoryValues } from '@/api/shop/shopSetting';
import { getCompressedImageUrl } from '@/utils/image';
import { storeToRefs } from 'pinia';
import { removeSiteInfoCache } from '@/api/cms/cmsWebsite';
import { pageProducts } from '@/api/app/appProduct';
import type { AppProduct } from '@/api/app/appProduct/model';
import type { AppSubscription } from '@/api/app/appSubscription/model';
import dayjs from 'dayjs';
// 使用状态管理
const siteStore = useSiteStore();
const statisticsStore = useStatisticsStore();
const userStore = useUserStore();
const tenantStore = useTenantStore();
const subscriptionStore = useAppSubscriptionStore();
const router = useRouter();
// 从 store 中获取响应式数据
const { siteInfo, loading: siteLoading } = storeToRefs(siteStore);
const { loading: siteLoading } = storeToRefs(siteStore);
const { loading: statisticsLoading } = storeToRefs(statisticsStore);
// 系统信息
@@ -256,8 +374,235 @@ const systemInfo = reactive({
server: 'Linux CentOS 7.9',
});
// ============================================================
// 应用订阅相关数据来源websopy app_subscription 表)
// productId 通过 当前登录用户租户ID 查询 app_product 获得
// ============================================================
// 当前应用产品按租户ID查询
const currentProduct = ref<AppProduct | null>(null);
// 当前应用的有效订阅
const currentSubscription = ref<AppSubscription | null>(null);
// 订阅信息加载中
const subscriptionLoading = ref(false);
// 订阅 Modal选择周期
const subscribeModalVisible = ref(false);
const subscribing = ref(false);
const selectedPeriod = ref<'month' | 'year'>('month');
// 支付 Modal小程序码扫码支付
const payModalVisible = ref(false);
const payQrcode = ref('');
const payPrice = ref(0);
const paySubscriptionNo = ref('');
const payProductName = ref('');
const pollingTimer = ref<ReturnType<typeof setInterval> | null>(null);
const pollCount = ref(0);
const MAX_POLL_COUNT = 120; // 2.5s * 120 = 5分钟
// 微信小程序环境版本:开发用 trial生产用 release
const envVersion = import.meta.env.DEV ? 'trial' : 'release';
// 是否免费应用
const isFreeProduct = computed(() => {
const p = currentProduct.value;
if (!p) return false;
return p.priceType === 'free' || !p.price || Number(p.price) === 0;
});
// 月付参考价格(元)
const monthPrice = computed(() => Number(currentProduct.value?.price) || 0);
// 年付参考价格按12个月
const yearPrice = computed(() => monthPrice.value * 12);
// 距到期天数负数表示已过期null 表示无到期时间
const daysToExpire = computed(() => {
const expire = currentSubscription.value?.expireTime;
if (!expire) return null;
return dayjs(expire).startOf('day').diff(dayjs().startOf('day'), 'day');
});
// 格式化时间
const formatDateTime = (dt?: string) => {
if (!dt) return '-';
return dayjs(dt).format('YYYY-MM-DD HH:mm:ss');
};
// 加载当前应用的订阅信息
const loadSubscriptionInfo = async () => {
const tenantId = userStore.info?.tenantId;
if (!tenantId) {
console.warn('无法获取租户ID跳过订阅信息加载');
return;
}
subscriptionLoading.value = true;
try {
// 1. 按租户ID查询应用产品取第一条
const productRes = await pageProducts({
tenantId,
current: 1,
size: 1
});
const product = productRes.list?.[0];
if (!product || !product.productId) {
console.warn('当前租户未找到应用产品');
return;
}
currentProduct.value = product;
// 2. 拉取我的订阅列表,过滤出该产品的订阅
const subRes = await subscriptionStore.fetchMySubscriptions(
{ page: 1, limit: 50 },
false
);
const subs = (subRes.list || []).filter(
(s) => s.productId === product.productId
);
// 优先取 active 中 expireTime 最新;否则取 pending 最新
const active = subs
.filter((s) => s.status === 'active')
.sort(
(a, b) =>
dayjs(b.expireTime).valueOf() - dayjs(a.expireTime).valueOf()
)[0];
const pending = subs
.filter((s) => s.status === 'pending')
.sort(
(a, b) => dayjs(b.createTime).valueOf() - dayjs(a.createTime).valueOf()
)[0];
currentSubscription.value = active || pending || null;
} catch (e) {
console.warn('获取订阅信息失败:', e);
} finally {
subscriptionLoading.value = false;
}
};
// 刷新订阅信息(支付成功/订阅成功后调用)
const refreshSubscription = () => {
loadSubscriptionInfo().catch(() => {});
};
// 打开订阅 Modal
const onSubscribe = () => {
if (!currentProduct.value?.productId) {
message.warning('应用信息加载中,请稍后再试');
return;
}
selectedPeriod.value = 'month';
subscribeModalVisible.value = true;
};
// 确认订阅
const confirmSubscribe = async () => {
const product = currentProduct.value;
if (!product?.productId) return;
subscribing.value = true;
try {
if (isFreeProduct.value) {
// 免费应用:直接创建并激活
await subscriptionStore.subscribe({
productId: product.productId,
subscriptionPeriod: selectedPeriod.value
});
message.success('订阅成功');
subscribeModalVisible.value = false;
refreshSubscription();
return;
}
// 付费应用:生成支付小程序码
const result = await subscriptionStore.generatePayQrcode({
productId: product.productId,
subscriptionPeriod: selectedPeriod.value,
envVersion
});
paySubscriptionNo.value = result.subscriptionNo;
payQrcode.value = result.qrcodeBase64;
payPrice.value = Number(result.payPrice) || 0;
payProductName.value =
result.productName || product.productName || '应用订阅';
subscribeModalVisible.value = false;
payModalVisible.value = true;
// 开始轮询支付状态
startPolling(result.subscriptionNo);
} catch (e: any) {
console.error('创建订阅失败:', e);
message.error(e?.message || '创建订阅失败,请重试');
} finally {
subscribing.value = false;
}
};
// 重新支付pending 订阅,复用已有订阅记录生成小程序码)
const repayPending = async () => {
const sub = currentSubscription.value;
if (!sub?.id || !sub.subscriptionNo) return;
try {
const result = await subscriptionStore.pay(sub.id, 'wechat', envVersion);
if ('miniappQrcode' in result) {
paySubscriptionNo.value = sub.subscriptionNo;
payQrcode.value = result.miniappQrcode;
payPrice.value = Number(result.payPrice) || 0;
payProductName.value =
sub.productName || currentProduct.value?.productName || '应用订阅';
payModalVisible.value = true;
startPolling(sub.subscriptionNo);
}
} catch (e: any) {
message.error(e?.message || '生成支付码失败');
}
};
// 开始轮询支付状态(每 2.5s 查一次,最多 5 分钟)
const startPolling = (subscriptionNo: string) => {
stopPolling();
pollCount.value = 0;
pollingTimer.value = setInterval(async () => {
pollCount.value++;
if (pollCount.value > MAX_POLL_COUNT) {
stopPolling();
message.warning('支付状态查询超时,如已支付请刷新页面');
return;
}
try {
const status = await subscriptionStore.checkStatus(subscriptionNo);
if (status.paid) {
stopPolling();
payModalVisible.value = false;
message.success('支付成功');
refreshSubscription();
}
} catch (e) {
console.warn('查询支付状态失败:', e);
}
}, 2500);
};
// 停止轮询
const stopPolling = () => {
if (pollingTimer.value) {
clearInterval(pollingTimer.value);
pollingTimer.value = null;
}
pollCount.value = 0;
};
// 关闭支付 Modal
const onPayModalClose = () => {
stopPolling();
payModalVisible.value = false;
payQrcode.value = '';
paySubscriptionNo.value = '';
};
// 计算属性
const runDays = computed(() => siteStore.runDays);
const now = ref(Date.now());
let runDaysTimer: ReturnType<typeof setInterval>;
const runDays = computed(() => {
const createTime = tenantStore.company?.createTime;
if (!createTime) return 0;
return Math.floor((now.value - new Date(createTime).getTime()) / (24 * 60 * 60 * 1000));
});
const userCount = computed(() => statisticsStore.userCount);
const orderCount = computed(() => statisticsStore.orderCount);
const totalSales = computed(() => statisticsStore.totalSales);
@@ -271,21 +616,29 @@ const loading = computed(() => siteLoading.value || statisticsLoading.value);
// 核心统计数据使用computed确保响应式更新
const coreStats = computed(() => [
{ icon: '🏸', label: '用户总数', value: userCount.value || 0, desc: '注册用户', color: 'blue', to: '/system/user' },
{ icon: '📦', label: '订单总数', value: orderCount.value || 0, desc: '全部订单', color: 'orange', to: '/shop/shopOrder' },
{ icon: '💰', label: '总营业额', value: totalSales.value || 0, desc: '元', color: 'purple', to: '/shop/shopOrder' },
{ icon: '📦', label: '订单总数', value: orderCount.value || 0, desc: '全部订单', color: 'orange', to: '/shop/shopOrder?tab=all' },
{ icon: '💰', label: '总营业额', value: totalSales.value || 0, desc: '元', color: 'purple', to: '/shop/shopOrder?tab=all' },
{ icon: '⏱️', label: '运行天数', value: runDays.value || 0, desc: '系统运行', color: 'green', to: '' },
]);
// 待处理事项数据
const pendingPaymentCount = ref(0);
const pendingShipmentCount = ref(0);
const pendingRefundCount = ref(0);
const couponUsedCount = computed(() => statisticsStore.couponUsedCount);
const couponUsedCount = computed(() => statisticsStore.safeCouponUsedCount);
// 商城Logo
const shopLogo = ref('');
const shopLogoUrl = computed(() =>
shopLogo.value ? getCompressedImageUrl(shopLogo.value, { width: 200, quality: 90 }) : ''
);
// 待处理事项使用computed确保响应式更新
const todoItems = computed(() => [
{ label: '待发货订单', value: pendingShipmentCount.value, to: '/shop/shopOrder', tagColor: 'blue', dotColor: 'dot-blue', urgent: pendingShipmentCount.value > 0 },
{ label: '退款申请', value: pendingRefundCount.value, to: '/shop/shopOrder', tagColor: 'orange', dotColor: 'dot-orange', urgent: pendingRefundCount.value > 0 },
// { label: '优惠券使用', value: couponUsedCount.value, to: '/market/coupon', tagColor: 'cyan', dotColor: 'dot-cyan', urgent: false },
{ label: '待付款订单', value: pendingPaymentCount.value, to: '/shop/shopOrder?tab=unpaid', tagColor: 'gold', dotColor: 'dot-gold', urgent: pendingPaymentCount.value > 0 },
{ label: '待发货订单', value: pendingShipmentCount.value, to: '/shop/shopOrder?tab=undelivered', tagColor: 'blue', dotColor: 'dot-blue', urgent: pendingShipmentCount.value > 0 },
{ label: '退款申请', value: pendingRefundCount.value, to: '/shop/shopOrder?tab=refunded', tagColor: 'orange', dotColor: 'dot-orange', urgent: pendingRefundCount.value > 0 },
{ label: '优惠券使用', value: couponUsedCount.value, to: '/market/coupon', tagColor: 'cyan', dotColor: 'dot-cyan', urgent: false },
]);
// 今日统计使用computed确保响应式更新
@@ -298,12 +651,12 @@ const todayStats = computed(() => ({
// 快速入口
const quickLinks = [
{ to: '/website/field', icon: '⚙️', label: '参数配置', bg: '#eff6ff' },
{ to: '/shop/shopOrder', icon: '📦', label: '订单管理', bg: '#f0fdf4' },
{ to: '/system/user', icon: '👥', label: '用户管理', bg: '#fff7ed' },
{ to: '/website/index', icon: '🏪', label: '站点管理', bg: '#faf5ff' },
{ to: '/shopGoods', icon: '🏸', label: '商品管理', bg: '#ecfdf5' },
{ to: '/cmsArticle', icon: '📝', label: '文章管理', bg: '#fefce8' },
{ to: '/shop/shopOrder?tab=all', icon: '📦', label: '订单管理', bg: '#f0fdf4' },
{ to: '/shop/shopGoods', icon: '🏸', label: '商品管理', bg: '#ecfdf5' },
{ to: '/shop/shopGoodsCategory', icon: '🗂️', label: '商品分类', bg: '#eff6ff' },
{ to: '/market/coupon', icon: '🎁', label: '优惠券', bg: '#fff7ed' },
{ to: '/system/user', icon: '👥', label: '会员管理', bg: '#faf5ff' },
{ to: '/shop/shopSetting', icon: '⚙️', label: '商城设置', bg: '#fefce8' },
];
// 导航跳转
@@ -348,6 +701,25 @@ const refreshStatistics = async () => {
// 加载数据
const loadData = async () => {
// 独立请求租户信息,不受其他请求失败影响
tenantStore.fetchTenantInfo().catch((e) => {
console.warn('获取租户信息失败:', e);
});
// 独立加载订阅信息(到期时间),不受其他请求失败影响
loadSubscriptionInfo().catch((e) => {
console.warn('加载订阅信息失败:', e);
});
// 独立请求商城Logo不受其他请求失败影响
getShopSettingCategoryValues('basic')
.then((values) => {
shopLogo.value = values?.shopLogo || '';
})
.catch((e) => {
console.warn('获取商城设置失败:', e);
});
try {
await Promise.all([
siteStore.fetchSiteInfo(),
@@ -356,8 +728,23 @@ const loadData = async () => {
// 获取待处理事项数据
try {
// 获取待发货订单数(使用 statusFilter=1 对应待发货
// 获取待付款订单数(type=0商城订单, statusFilter=0待付款
const paymentResult = await pageShopOrder({
type: 0,
statusFilter: 0,
page: 1,
limit: 1
});
pendingPaymentCount.value = paymentResult?.count || 0;
} catch (e) {
console.warn('获取待付款订单数失败:', e);
pendingPaymentCount.value = 0;
}
try {
// 获取待发货订单数type=0商城订单, statusFilter=1待发货
const shipmentResult = await pageShopOrder({
type: 0,
statusFilter: 1,
page: 1,
limit: 1
@@ -369,8 +756,9 @@ const loadData = async () => {
}
try {
// 获取退款/售后订单数(使用 statusFilter=6 对应退款/售后)
// 获取退款/售后订单数(type=0商城订单, statusFilter=6退款/售后)
const refundResult = await pageShopOrder({
type: 0,
statusFilter: 6,
page: 1,
limit: 1
@@ -391,11 +779,17 @@ onMounted(async () => {
// 开始自动刷新统计数据每5分钟
statisticsStore.startAutoRefresh();
// 运行天数每小时检查一次(跨天自动更新)
runDaysTimer = setInterval(() => { now.value = Date.now(); }, 60 * 60 * 1000);
});
onUnmounted(() => {
// 组件卸载时停止自动刷新
statisticsStore.stopAutoRefresh();
clearInterval(runDaysTimer);
// 停止支付状态轮询
stopPolling();
});
</script>
@@ -419,6 +813,11 @@ onUnmounted(() => {
flex-wrap: wrap;
gap: 12px;
}
.welcome-logo {
flex-shrink: 0;
border: 2px solid rgba(255,255,255,0.2);
background: rgba(255,255,255,0.1);
}
.welcome-title { font-size: 20px; font-weight: 700; color: #fff; margin: 0 0 6px; }
.welcome-sub { font-size: 14px; color: rgba(255,255,255,0.7); margin: 0; }
@@ -485,6 +884,7 @@ onUnmounted(() => {
.todo-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.dot-orange { background: #f97316; }
.dot-blue { background: #3b82f6; }
.dot-gold { background: #faad14; }
.dot-cyan { background: #06b6d4; }
.dot-purple { background: #a855f7; }
.todo-content { flex: 1; display: flex; align-items: center; }
@@ -553,4 +953,81 @@ onUnmounted(() => {
grid-template-columns: repeat(2, 1fr);
}
}
/* 到期时间状态 */
.text-muted { color: rgba(0,0,0,0.45); }
.text-orange { color: #fa8c16; }
.expire-warn { color: #ff4d4f; font-size: 12px; margin-left: 4px; }
/* 订阅 Modal */
.subscribe-modal-body { padding: 8px 0; }
.subscribe-product-name {
font-size: 16px;
font-weight: 600;
margin-bottom: 16px;
color: rgba(0,0,0,0.85);
}
.period-options {
display: flex;
gap: 16px;
}
.period-option {
flex: 1;
border: 2px solid #f0f0f0;
border-radius: 10px;
padding: 16px;
text-align: center;
cursor: pointer;
transition: all 0.2s;
position: relative;
}
.period-option:hover { border-color: #69b1ff; }
.period-option.active {
border-color: #00704A;
background: #f0fdf4;
}
.period-option-label { font-size: 14px; color: rgba(0,0,0,0.65); margin-bottom: 8px; }
.period-option-price { font-size: 18px; font-weight: 700; color: #00704A; }
.period-option-tag {
position: absolute;
top: -8px;
right: 8px;
background: #ff4d4f;
color: #fff;
font-size: 11px;
padding: 1px 8px;
border-radius: 8px;
}
/* 支付 Modal */
.pay-modal-body { text-align: center; padding: 8px 0; }
.pay-product-name {
font-size: 16px;
font-weight: 600;
margin-bottom: 12px;
color: rgba(0,0,0,0.85);
}
.pay-amount { margin-bottom: 16px; }
.pay-amount-label { font-size: 13px; color: rgba(0,0,0,0.45); margin-right: 8px; }
.pay-amount-value { font-size: 24px; font-weight: 800; color: #ff4d4f; }
.pay-qrcode-wrap {
display: flex;
justify-content: center;
margin-bottom: 12px;
}
.pay-qrcode-img {
width: 220px;
height: 220px;
border: 1px solid #f0f0f0;
border-radius: 8px;
}
.pay-tip {
font-size: 13px;
color: rgba(0,0,0,0.55);
margin-bottom: 8px;
}
.pay-order-no {
font-size: 12px;
color: rgba(0,0,0,0.35);
}
</style>

View File

@@ -0,0 +1,87 @@
<!-- 搜索表单 -->
<template>
<a-space :size="10" style="flex-wrap: wrap">
<a-input
v-model:value="where.userId"
placeholder="用户ID"
allow-clear
style="width: 130px"
@press-enter="search"
/>
<a-input
v-model:value="where.goodsId"
placeholder="商品ID"
allow-clear
style="width: 130px"
@press-enter="search"
/>
<a-select
v-model:value="where.browseSource"
placeholder="浏览来源"
allow-clear
style="width: 130px"
>
<a-select-option value="detail">商品详情</a-select-option>
<a-select-option value="home">首页</a-select-option>
<a-select-option value="category">分类</a-select-option>
<a-select-option value="search">搜索</a-select-option>
<a-select-option value="share">分享</a-select-option>
</a-select>
<a-range-picker
v-model:value="dateRange"
value-format="YYYY-MM-DD"
:placeholder="['开始日期', '结束日期']"
@change="onDateChange"
/>
<a-button type="primary" class="ele-btn-icon" @click="search">
<template #icon>
<SearchOutlined />
</template>
<span>查询</span>
</a-button>
<a-button @click="reset">重置</a-button>
</a-space>
</template>
<script lang="ts" setup>
import { ref, computed } from 'vue';
import { SearchOutlined } from '@ant-design/icons-vue';
import type { Dayjs } from 'dayjs';
import type { ShopGoodsBrowseParam } from '@/api/shop/shopGoodsBrowse/model';
const props = defineProps<{
where?: ShopGoodsBrowseParam;
}>();
const emit = defineEmits<{
(e: 'search', where?: ShopGoodsBrowseParam): void;
}>();
// 搜索条件(双向绑定)
const where = computed(() => props.where ?? {});
// 日期范围
const dateRange = ref<[Dayjs, Dayjs] | undefined>();
// 日期变化
const onDateChange = (_dates: any, formatStrings: [string, string]) => {
where.value.startTime = formatStrings[0] || undefined;
where.value.endTime = formatStrings[1] || undefined;
};
// 搜索
const search = () => {
emit('search', { ...where.value });
};
// 重置
const reset = () => {
where.value.userId = undefined;
where.value.goodsId = undefined;
where.value.browseSource = undefined;
where.value.startTime = undefined;
where.value.endTime = undefined;
dateRange.value = undefined;
emit('search', {});
};
</script>

View File

@@ -0,0 +1,196 @@
<template>
<a-card :bordered="false" :body-style="{ padding: '16px' }">
<ele-pro-table
ref="tableRef"
row-key="id"
:columns="columns"
:datasource="datasource"
tool-class="ele-toolbar-form"
class="shop-goods-browse-table"
>
<template #toolbar>
<search @search="reload" />
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'goodsImage'">
<a-image
v-if="record.goodsImage"
:src="record.goodsImage"
:width="50"
:height="50"
style="border-radius: 4px; object-fit: cover"
/>
<span v-else class="ele-text-placeholder">无图</span>
</template>
<template v-if="column.key === 'browseSource'">
<a-tag v-if="record.browseSource === 'detail'" color="blue">商品详情</a-tag>
<a-tag v-else-if="record.browseSource === 'home'" color="green">首页</a-tag>
<a-tag v-else-if="record.browseSource === 'category'" color="cyan">分类</a-tag>
<a-tag v-else-if="record.browseSource === 'search'" color="orange">搜索</a-tag>
<a-tag v-else-if="record.browseSource === 'share'" color="purple">分享</a-tag>
<span v-else>{{ record.browseSource || '-' }}</span>
</template>
<template v-if="column.key === 'visitCount'">
<a-tag color="red">{{ record.visitCount || 1 }}</a-tag>
</template>
<template v-if="column.key === 'lastVisitTime'">
{{ toDateString(record.lastVisitTime, 'yyyy-MM-dd HH:mm') }}
</template>
<template v-if="column.key === 'createTime'">
{{ toDateString(record.createTime, 'yyyy-MM-dd HH:mm') }}
</template>
<template v-if="column.key === 'action'">
<a-popconfirm
title="确定要删除此浏览记录吗?"
@confirm="remove(record)"
>
<a class="ele-text-danger">删除</a>
</a-popconfirm>
</template>
</template>
</ele-pro-table>
</a-card>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { message } from 'ant-design-vue';
import type { EleProTable } from 'ele-admin-pro';
import { toDateString } from 'ele-admin-pro';
import type {
DatasourceFunction,
ColumnItem
} from 'ele-admin-pro/es/ele-pro-table/types';
import Search from './components/search.vue';
import {
pageShopGoodsBrowse,
removeShopGoodsBrowse
} from '@/api/shop/shopGoodsBrowse';
import type {
ShopGoodsBrowse,
ShopGoodsBrowseParam
} from '@/api/shop/shopGoodsBrowse/model';
// 表格实例
const tableRef = ref<InstanceType<typeof EleProTable> | null>(null);
// 表格数据源
const datasource: DatasourceFunction = ({
page,
limit,
where,
orders
}) => {
return pageShopGoodsBrowse({
...where,
...orders,
page,
limit
});
};
// 表格列配置
const columns = ref<ColumnItem[]>([
{
title: 'ID',
dataIndex: 'id',
key: 'id',
align: 'center',
width: 70
},
{
title: '用户ID',
dataIndex: 'userId',
key: 'userId',
align: 'center',
width: 90
},
{
title: '商品图片',
key: 'goodsImage',
align: 'center',
width: 80
},
{
title: '商品名称',
dataIndex: 'goodsName',
key: 'goodsName',
align: 'center',
ellipsis: true
},
{
title: '商品价格',
dataIndex: 'price',
key: 'price',
align: 'center',
width: 100,
customRender: ({ text }) => (text ? `¥${text}` : '-')
},
{
title: '浏览次数',
dataIndex: 'visitCount',
key: 'visitCount',
align: 'center',
width: 90,
sorter: true
},
{
title: '浏览来源',
dataIndex: 'browseSource',
key: 'browseSource',
align: 'center',
width: 100
},
{
title: '最后浏览时间',
dataIndex: 'lastVisitTime',
key: 'lastVisitTime',
align: 'center',
width: 160,
sorter: true
},
{
title: '首次浏览',
dataIndex: 'createTime',
key: 'createTime',
align: 'center',
width: 160
},
{
title: '操作',
key: 'action',
width: 100,
fixed: 'right',
align: 'center',
hideInSetting: true
}
]);
/* 搜索 */
const reload = (where?: ShopGoodsBrowseParam) => {
tableRef?.value?.reload({ where: where });
};
/* 删除单条 */
const remove = (row: ShopGoodsBrowse) => {
const hide = message.loading('请求中..', 0);
removeShopGoodsBrowse(row.id)
.then((msg) => {
hide();
message.success(msg);
reload();
})
.catch((e) => {
hide();
message.error(e.message);
});
};
</script>
<script lang="ts">
export default {
name: 'ShopGoodsBrowse'
};
</script>
<style lang="less" scoped></style>

View File

@@ -0,0 +1,241 @@
<!-- 确认线下收款弹窗 -->
<template>
<a-modal
:visible="visible"
title="确认线下收款"
:width="520"
:confirm-loading="loading"
ok-text="确认收款"
@update:visible="updateVisible"
@ok="handleSubmit"
@cancel="handleCancel"
>
<a-alert
type="info"
show-icon
message="确认已收到该订单的线下付款(微信转账/银行汇款等),确认后订单将进入待发货状态。"
style="margin-bottom: 16px"
/>
<a-form
ref="formRef"
:model="form"
:rules="rules"
:label-col="{ span: 5 }"
:wrapper-col="{ span: 18 }"
>
<!-- 订单号 -->
<a-form-item label="订单号">
<span style="color: #999">{{ form.orderNo || '-' }}</span>
</a-form-item>
<!-- 支付凭证 -->
<a-form-item label="支付凭证" name="paymentVoucher">
<a-upload
list-type="picture-card"
:max-count="1"
:file-list="fileList"
:custom-request="handleUpload"
:before-upload="beforeUpload"
@remove="handleRemove"
@preview="handlePreview"
>
<div v-if="!fileList.length">
<PlusOutlined />
<div class="ant-upload-text">上传凭证</div>
</div>
</a-upload>
<div class="voucher-tip">支持 jpg/png 图片单张不超过 10MB</div>
</a-form-item>
<!-- 备注 -->
<a-form-item label="备注" name="remarks">
<a-textarea
v-model:value="form.remarks"
placeholder="可填写备注(如:微信转账已收到)"
:rows="3"
:maxlength="200"
show-count
/>
</a-form-item>
</a-form>
<!-- 图片预览 -->
<a-modal
:visible="previewVisible"
:footer="null"
title="凭证预览"
@cancel="previewVisible = false"
>
<img :src="previewImage" alt="支付凭证" style="width: 100%" />
</a-modal>
</a-modal>
</template>
<script lang="ts" setup>
import { ref, reactive, watch } from 'vue';
import { Form, message } from 'ant-design-vue';
import { PlusOutlined } from '@ant-design/icons-vue';
import type { UploadFile, UploadProps } from 'ant-design-vue';
import { ShopOrder } from '@/api/shop/shopOrder/model';
import { confirmOfflinePayment } from '@/api/shop/shopOrder';
import { uploadOss } from '@/api/system/file';
import { getUrl } from '@/utils/common';
const useForm = Form.useForm;
const props = defineProps<{
visible: boolean;
data?: ShopOrder | null;
}>();
const emit = defineEmits<{
(e: 'update:visible', visible: boolean): void;
(e: 'done'): void;
}>();
// 表单数据
const form = reactive({
orderId: undefined as number | undefined,
orderNo: '' as string,
paymentVoucher: '' as string,
remarks: '' as string
});
// 表单验证规则
const rules = {
paymentVoucher: [
{ required: true, message: '请上传支付凭证' }
]
};
const formRef = ref();
const { resetFields, validate } = useForm(form, rules);
// 状态
const loading = ref(false);
const fileList = ref<UploadFile[]>([]);
const previewVisible = ref(false);
const previewImage = ref('');
// 上传前校验
const beforeUpload: UploadProps['beforeUpload'] = (file) => {
const isImage = ['image/jpeg', 'image/png', 'image/jpg'].includes(
file.type
);
if (!isImage) {
message.error('仅支持 jpg/png 格式图片');
return false;
}
const isLt10M = file.size / 1024 / 1024 < 10;
if (!isLt10M) {
message.error('图片大小不能超过 10MB');
return false;
}
return true;
};
// 自定义上传
const handleUpload: UploadProps['customRequest'] = (options) => {
const { file, onSuccess, onError } = options;
uploadOss(file as File)
.then((data) => {
// 存储返回的 path与项目 UploadCert 组件约定一致)
form.paymentVoucher = data.path || '';
fileList.value = [
{
uid: String(data.id || Date.now()),
name: data.name || '支付凭证',
status: 'done',
url: data.url || getUrl(data.path || '')
}
];
onSuccess?.(data, file as any);
// 触发表单校验清除错误
formRef.value?.validateFields(['paymentVoucher']);
})
.catch((e) => {
message.error(e.message || '上传失败');
onError?.(e as any);
});
};
// 删除凭证
const handleRemove = () => {
form.paymentVoucher = '';
fileList.value = [];
return true;
};
// 预览凭证
const handlePreview = (file: UploadFile) => {
previewImage.value = file.url || '';
previewVisible.value = true;
};
// 更新弹窗显示状态
const updateVisible = (visible: boolean) => {
emit('update:visible', visible);
};
// 取消
const handleCancel = () => {
updateVisible(false);
};
// 提交确认收款
const handleSubmit = async () => {
try {
await validate();
if (!form.orderId) {
message.error('订单信息缺失');
return;
}
loading.value = true;
await confirmOfflinePayment(
form.orderId,
form.remarks || undefined,
form.paymentVoucher || undefined
);
message.success('确认收款成功,订单已进入待发货状态');
emit('done');
updateVisible(false);
} catch (error: any) {
if (error?.errorFields) return; // 表单校验失败,不弹错误
message.error(error.message || '确认收款失败');
} finally {
loading.value = false;
}
};
// 监听弹窗显示状态
watch(
() => props.visible,
(visible) => {
if (visible) {
// 初始化表单
form.orderId = props.data?.orderId;
form.orderNo = props.data?.orderNo || '';
form.paymentVoucher = '';
form.remarks = '';
fileList.value = [];
} else {
resetFields();
fileList.value = [];
}
}
);
</script>
<style scoped>
.voucher-tip {
color: #999;
font-size: 12px;
margin-top: 4px;
}
.ant-upload-text {
margin-top: 8px;
color: #666;
}
</style>

View File

@@ -71,9 +71,11 @@
label="支付状态"
:labelStyle="{ width: '90px', color: '#808080' }"
>
<a-tag v-if="form.payStatus == 1 && form.payType !== 8" color="green">已付款</a-tag>
<a-tag v-if="form.payStatus == 1 && form.payType !== 8 && form.payType !== 9" color="green">已付款</a-tag>
<a-tag v-if="form.payStatus == 1 && form.payType === 8" color="blue">待收货付款</a-tag>
<a-tag v-if="form.payStatus == 0">未付</a-tag>
<a-tag v-if="form.payStatus == 1 && form.payType === 9" color="green">已确认收</a-tag>
<a-tag v-if="form.payStatus == 0 && form.payType === 9" color="orange">待确认收款</a-tag>
<a-tag v-if="form.payStatus == 0 && form.payType !== 9">未付款</a-tag>
<a-tag v-if="form.payStatus == 3">未付款,占场中</a-tag>
</a-descriptions-item>
<!-- 第四排-->
@@ -147,7 +149,7 @@
</a-tag>
<a-tag v-if="form.payType == 9">
<IdcardOutlined class="tag-icon" />
IC月卡
线下付款
</a-tag>
<a-tag v-if="form.payType == 10">
<IdcardOutlined class="tag-icon" />
@@ -187,7 +189,16 @@
</a-tag>
</template>
<template v-else>
<span class="text-gray-400">未支付</span>
<!-- 线下付款未确认时也显示支付方式 -->
<a-tag v-if="form.payType == 9">
<IdcardOutlined class="tag-icon" />
线下付款
</a-tag>
<a-tag v-if="form.payType == 8">
<IdcardOutlined class="tag-icon" />
货到付款
</a-tag>
<span v-if="form.payType !== 9 && form.payType !== 8" class="text-gray-400">未支付</span>
</template>
</a-tooltip>
</a-descriptions-item>
@@ -235,7 +246,7 @@
<template v-if="column.key === 'goodsName'">
<div style="display: flex; align-items: center; gap: 12px">
<a-avatar
:src="record.image || record.goodsImage"
:src="getCompressedImageUrl(record.image, { width: 100 })"
shape="square"
:size="50"
style="flex-shrink: 0"
@@ -414,6 +425,7 @@
import { updateShopOrder, removeShopOrder, refundShopOrder } from '@/api/shop/shopOrder';
import { message, Modal } from 'ant-design-vue';
import DeliveryModal from './deliveryModal.vue';
import {getCompressedImageUrl} from "@/utils/image";
const useForm = Form.useForm;

View File

@@ -36,10 +36,10 @@
</div>
<a-tabs type="card" v-model:activeKey="activeKey" @change="onTabs">
<a-tab-pane key="all" tab="全部" />
<a-tab-pane key="unpaid" tab="待付款" />
<a-tab-pane key="undelivered" tab="待发货" />
<a-tab-pane key="unreceived" tab="待收货" />
<a-tab-pane key="completed" tab="已完成" />
<!-- <a-tab-pane key="unpaid" tab="待付款" />-->
<a-tab-pane key="refunded" tab="退货/售后" />
<a-tab-pane key="cancelled" tab="已关闭" />
</a-tabs>
@@ -93,10 +93,15 @@
v-if="record.payType === 8"
color="blue"
>货到付款</a-tag>
<!-- 线下付款标识 -->
<a-tag
v-if="record.payType === 9"
color="orange"
>线下付款</a-tag>
<!-- 支付状态 -->
<a-tag
v-if="record.payStatus == 1 && record.payType !== 8"
v-if="record.payStatus == 1 && record.payType !== 8 && record.payType !== 9"
color="green"
@click.stop="updatePayStatus(record)"
class="cursor-pointer"
@@ -109,6 +114,20 @@
class="cursor-pointer"
>待收货付款</a-tag
>
<a-tag
v-else-if="record.payStatus == 1 && record.payType === 9"
color="green"
@click.stop="updatePayStatus(record)"
class="cursor-pointer"
>已确认收款</a-tag
>
<a-tag
v-else-if="record.payStatus == 0 && record.payType === 9"
color="orange"
@click.stop="updatePayStatus(record)"
class="cursor-pointer"
>待确认收款</a-tag
>
<a-tag
v-else-if="record.payStatus == 0 || record.payStatus == null"
@click.stop="updatePayStatus(record)"
@@ -174,7 +193,7 @@
<template v-for="(item, index) in record.orderGoods" :key="index">
<div class="item py-1">
<a-space :id="`g-${index}`">
<a-avatar :src="getCompressedImageUrl(item.image)" shape="square" :size="80" />
<a-avatar :src="getCompressedImageUrl(item.image,{ width: 100 })" shape="square" :size="50" />
<span>{{ item.goodsName }}</span>
</a-space>
</div>
@@ -185,6 +204,10 @@
<template v-if="record.payType === 8">
<a-tag color="blue">货到付款</a-tag>
</template>
<!-- 线下付款特殊标识 -->
<template v-else-if="record.payType === 9">
<a-tag color="orange">线下付款</a-tag>
</template>
<template v-else>
<template v-for="item in getPayType()">
<template v-if="record.payStatus == 1">
@@ -230,8 +253,8 @@
<!-- 查看详情 - 所有状态都可以查看 -->
<a @click.stop="openEdit(record)"> <EyeOutlined /> 详情 </a>
<!-- 未付款状态的操作 -->
<template v-if="!record.payStatus && record.orderStatus === 0">
<!-- 未付款状态的操作排除线下付款 -->
<template v-if="!record.payStatus && record.orderStatus === 0 && record.payType !== 9">
<a @click.stop="handleEditOrder(record)">
<EditOutlined /> 修改
</a>
@@ -240,6 +263,16 @@
</a>
</template>
<!-- 线下付款·待确认收款状态的操作 -->
<template v-if="!record.payStatus && record.orderStatus === 0 && record.payType === 9">
<a @click.stop="handleConfirmOfflinePayment(record)" class="ele-text-success">
<CheckCircleOutlined /> 确认收款
</a>
<a @click.stop="handleCancelOrder(record)">
<span class="ele-text-warning"> <CloseOutlined /> 关闭 </span>
</a>
</template>
<!-- 已付款未发货状态的操作 -->
<template
v-if="
@@ -336,11 +369,19 @@
:data="current"
@done="reload"
/>
<!-- 确认线下收款弹窗 -->
<OfflinePaymentModal
v-model:visible="showOfflinePayment"
:data="current"
@done="reload"
/>
</a-page-header>
</template>
<script lang="ts" setup>
import { createVNode, ref } from 'vue';
import { useRoute } from 'vue-router';
import type { EleProTable } from 'ele-admin-pro';
import type {
DatasourceFunction,
@@ -365,6 +406,7 @@
import { toDateString } from 'ele-admin-pro';
import OrderInfo from './components/orderInfo.vue';
import DeliveryModal from './components/deliveryModal.vue';
import OfflinePaymentModal from './components/OfflinePaymentModal.vue';
import { ShopOrder, ShopOrderParam } from '@/api/shop/shopOrder/model';
import {
pageShopOrder,
@@ -392,15 +434,39 @@
const showMove = ref(false);
// 是否显示发货弹窗
const showDelivery = ref(false);
// 是否显示确认线下收款弹窗
const showOfflinePayment = ref(false);
// 加载状态
const loading = ref(true);
// 激活的标签
const activeKey = ref<string>('undelivered');
// 激活的标签(支持从路由参数初始化,如 /shop/shopOrder?tab=all
const route = useRoute();
const validTabs = ['all', 'unpaid', 'undelivered', 'unreceived', 'completed', 'refunded', 'cancelled'];
const tabFromQuery = route.query.tab as string;
const activeKey = ref<string>(
validTabs.includes(tabFromQuery) ? tabFromQuery : 'undelivered'
);
// ============ 新订单提醒 ============
const { enabled: notifyEnabled, toggle: onNotifyToggle, testNotify: onTestNotify } = useOrderNotify({
onNewOrder: () => reload()
});
// 根据tab key获取对应的statusFilter值
// undefined全部0待付款1待发货2待核销3待收货4待评价5已完成6已退款7已删除8已关闭
const getStatusFilterByTab = (key: string): number | undefined => {
const filterMap: Record<string, number> = {
unpaid: 0,
undelivered: 1,
unverified: 2,
unreceived: 3,
unevaluated: 4,
completed: 5,
refunded: 6,
deleted: 7,
cancelled: 8
};
return filterMap[key];
};
// 表格数据源
const datasource: DatasourceFunction = ({
page,
@@ -413,6 +479,10 @@
where.status = filters.status;
}
where.type = 0;
// 确保初次加载时也按当前tab筛选statusFilter未设置时从activeKey推导
if (where.statusFilter === undefined) {
where.statusFilter = getStatusFilterByTab(activeKey.value);
}
return pageShopOrder({
...where,
...orders,
@@ -493,54 +563,11 @@
};
const onTabs = () => {
// 使用statusFilter进行筛选这是后端专门为订单状态筛选设计的字段
const filterParams: Record<string, any> = {};
// 根据后端 statusFilter 的值对应:
// undefined全部0待付款1待发货2待核销3待收货4待评价5已完成6已退款7已删除
switch (activeKey.value) {
case 'all':
// 全部订单不传statusFilter参数
// filterParams.statusFilter = undefined; // 不设置该字段
break;
case 'unpaid':
// 待付款pay_status = false
filterParams.statusFilter = 0;
break;
case 'undelivered':
// 待发货pay_status = true AND delivery_status = 10
filterParams.statusFilter = 1;
break;
case 'unverified':
// 待核销pay_status = true AND delivery_status = 10 (与待发货相同)
filterParams.statusFilter = 2;
break;
case 'unreceived':
// 待收货pay_status = true AND delivery_status = 20
filterParams.statusFilter = 3;
break;
case 'unevaluated':
// 待评价order_status = 1 (与已完成相同)
filterParams.statusFilter = 4;
break;
case 'completed':
// 已完成order_status = 1
filterParams.statusFilter = 5;
break;
case 'cancelled':
// 已关闭order_status = 2
filterParams.statusFilter = 8;
break;
case 'refunded':
// 退款/售后order_status = 6
filterParams.statusFilter = 6;
break;
case 'deleted':
// 已删除deleted = 1
filterParams.statusFilter = 7;
break;
const sf = getStatusFilterByTab(activeKey.value);
if (sf !== undefined) {
filterParams.statusFilter = sf;
}
reload(filterParams);
};
@@ -627,6 +654,12 @@
});
};
// 确认线下付款收款
const handleConfirmOfflinePayment = (record: ShopOrder) => {
current.value = record;
showOfflinePayment.value = true;
};
// 发货处理
const handleDelivery = (record: ShopOrder) => {
current.value = record;

View File

@@ -17,9 +17,9 @@
<a-tab-pane tab="分销设置" key="dealer">
<Dealer />
</a-tab-pane>
<a-tab-pane tab="支付设置" key="payment">
<Payment />
</a-tab-pane>
<!-- <a-tab-pane tab="支付设置" key="payment">-->
<!-- <Payment />-->
<!-- </a-tab-pane>-->
<a-tab-pane tab="通知设置" key="notify">
<Notify />
</a-tab-pane>
@@ -43,7 +43,7 @@ import Basic from './components/basic.vue';
import Order from './components/order.vue';
import Points from './components/points.vue';
import Dealer from './components/dealer.vue';
import Payment from './components/payment.vue';
// import Payment from './components/payment.vue';
import Notify from './components/notify.vue';
import Upload from './components/upload.vue';
import Sms from './components/sms.vue';