# 商家前端账单功能 Implementation Plan > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [x]`) syntax for tracking. **Goal:** 为商家前端(foodie-store)新增"财务管理"模块,包含账单查询、汇总功能,支持按门店筛选。 **Architecture:** 后端新增 2 个商家端账单接口(列表+汇总),修改 3 个现有账单接口增加 mdId 过滤。前端商家端新增账单管理页面,集成菜单和路由。 **Tech Stack:** Java / Spring Boot / MyBatis / MySQL / Vue 2 / Element UI --- ## Technical Context **Language/Version:** Java 8+, Vue 2 **Primary Dependencies:** RuoYi framework, MyBatis, Element UI **Storage:** MySQL **Testing:** 手动测试(项目无自动化测试框架) **Target Platform:** Web (商家管理后台) **Project Type:** Web application (前后端分离) **注意事项:** - UserBilling 表已有 `md_id` 字段,无需数据库变更 - 商家(userType=1)通过 user_id 查所有门店,可选 mdId 筛选 - 摊位主(userType=4)通过 info_user.store_id 获取门店,仅查自己门店 - mdId 过滤采用 `(#{mdId} IS NULL OR md_id = #{mdId})` 模式,不传时查全部 ## Project Structure ### Documentation (this feature) ```text specs/003-merchant-billing/ ├── spec.md # 需求文档 ├── plan.md # 本文件(实施计划) └── tasks.md # 任务清单 ``` ### Source Code ```text foodie_server/ ├── ruoyi-admin/src/main/java/com/ruoyi/app/pay/ │ └── UserBillingController.java # [修改] 新增 storeBillingList、storeBillingSummary 接口 ├── ruoyi-system/src/main/java/com/ruoyi/system/ │ └── mapper/ │ └── UserBillingMapper.java # [修改] SQL 增加 mdId 过滤条件 foodie-store/ # 商家前端 ├── src/ │ ├── api/billing.js # [新建] 账单 API │ ├── views/ │ │ └── BillingManage.vue # [新建] 账单管理页面 │ ├── components/ │ │ └── Aside.vue # [修改] 侧边栏菜单 │ └── router/index.js # [修改] 路由配置 ``` --- ## Tasks ### Task 1: 后端 — 新增 storeBillingList 接口 **Files:** - Modify: `ruoyi-admin/src/main/java/com/ruoyi/app/pay/UserBillingController.java` - [x] **Step 1: 实现 storeBillingList 方法** 在 UserBillingController 中新增 `GET /billing/storeBillingList` 接口: - 参数:mdId(可选)、type(可选)、startDate/endDate(可选)、pageNum/pageSize - 权限逻辑:userType=1 按 user_id 查询,userType=4 按 store_id 查询 - 返回分页账单列表 + 门店信息 - [x] **Step 2: 验证** 使用 Postman 测试不同 userType 的查询结果。 --- ### Task 2: 后端 — 新增 storeBillingSummary 接口 **Files:** - Modify: `ruoyi-admin/src/main/java/com/ruoyi/app/pay/UserBillingController.java` - [x] **Step 1: 实现 storeBillingSummary 方法** 在 UserBillingController 中新增 `GET /billing/storeBillingSummary` 接口: - 参数同 storeBillingList - 返回 `{ totalAmount, totalDivvy, netIncome }` - [x] **Step 2: 验证** 测试汇总数据是否正确。 --- ### Task 3: 后端 — 修改 getzddaylist 增加 mdId 过滤 **Files:** - Modify: `ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserBillingMapper.java` - [x] **Step 1: getdaylist SQL 增加 mdId 条件** 添加 `(#{mdId} IS NULL OR md_id = #{mdId})` - [x] **Step 2: getdaysum SQL 增加 mdId 条件** 添加 `(#{mdId} IS NULL OR md_id = #{mdId})` - [x] **Step 3: getShDaysum SQL 增加 mdId 条件** 添加 `(#{mdId} IS NULL OR b.md_id = #{mdId})` - [x] **Step 4: 验证** 测试传入/不传 mdId 的查询结果。 --- ### Task 4: 后端 — 修改 getzdmeeklist 增加 mdId 过滤 **Files:** - Modify: `ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserBillingMapper.java` - [x] **Step 1: getmeeklist SQL 增加 mdId 条件** 添加 `(#{mdId} IS NULL OR md_id = #{mdId})` - [x] **Step 2: getmeeksum SQL 增加 mdId 条件** 添加 `(#{mdId} IS NULL OR md_id = #{mdId})` - [x] **Step 3: getShMeeksum SQL 增加 mdId 条件** 添加 `(#{mdId} IS NULL OR b.md_id = #{mdId})` - [x] **Step 4: 验证** 测试传入/不传 mdId 的查询结果。 --- ### Task 5: 后端 — 修改 getzdmatlist 增加 mdId 过滤 **Files:** - Modify: `ruoyi-system/src/main/java/com/ruoyi/system/mapper/UserBillingMapper.java` - [x] **Step 1: getmatlist SQL 增加 mdId 条件** 添加 `(#{mdId} IS NULL OR md_id = #{mdId})` - [x] **Step 2: getmatsum SQL 增加 mdId 条件** 添加 `(#{mdId} IS NULL OR md_id = #{mdId})` - [x] **Step 3: getshMonthsum SQL 增加 mdId 条件** 添加 `(#{mdId} IS NULL OR b.md_id = #{mdId})` - [x] **Step 4: 验证** 测试传入/不传 mdId 的查询结果。 --- ### Task 6: 前端 — 账单管理 API 层 **Files:** - Create: `E:\QtwCode\foodie\foodie-store\src\api\billing.js` - [x] **Step 1: 创建 billing.js** 提供 API 方法:getStoreBillingList、getStoreBillingSummary --- ### Task 7: 前端 — 账单管理页面 **Files:** - Create: `E:\QtwCode\foodie\foodie-store\src\views\BillingManage.vue` - Modify: `E:\QtwCode\foodie\foodie-store\src\router\index.js` - Modify: `E:\QtwCode\foodie\foodie-store\src\components\Aside.vue` - [x] **Step 1: 创建 BillingManage.vue 页面** 页面包含: 1. 筛选条件(门店选择、账单类型、时间范围) 2. 汇总区域(总金额、总抽成、净收入) 3. 账单列表表格(订单号、类型、金额、抽成、净收入、门店、状态、时间、说明) 4. 分页 - [x] **Step 2: 修改 router/index.js 添加账单管理路由** - [x] **Step 3: 修改 Aside.vue 添加「财务管理 > 账单管理」菜单项** - [x] **Step 4: 验证** 启动前端,登录商家账号,验证账单管理页面功能正常。 --- ### Task 8: 提交与收尾 - [x] **Step 1: 更新 spec.md 记录实现状态** - [x] **Step 2: 提交代码** ```bash git commit -m "feat(billing): 商家端账单功能 — 列表查询、汇总、mdId 过滤" ```