ai-engineering-init 1.3.4 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/hooks/skill-forced-eval.js +2 -0
- package/.claude/settings.json +3 -3
- package/.claude/skills/add-skill/SKILL.md +79 -32
- package/.claude/skills/api-development/SKILL.md +83 -377
- package/.claude/skills/architecture-design/SKILL.md +138 -632
- package/.claude/skills/backend-annotations/SKILL.md +134 -506
- package/.claude/skills/banana-image/SKILL.md +10 -3
- package/.claude/skills/brainstorm/SKILL.md +103 -535
- package/.claude/skills/bug-detective/SKILL.md +147 -1097
- package/.claude/skills/bug-detective/references/error-patterns.md +242 -0
- package/.claude/skills/code-patterns/SKILL.md +116 -426
- package/.claude/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.claude/skills/crud-development/SKILL.md +64 -304
- package/.claude/skills/data-permission/SKILL.md +105 -412
- package/.claude/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.claude/skills/file-oss-management/SKILL.md +106 -714
- package/.claude/skills/file-oss-management/references/entities.md +105 -0
- package/.claude/skills/file-oss-management/references/service-impl.md +104 -0
- package/.claude/skills/leniu-api-development/SKILL.md +142 -626
- package/.claude/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.claude/skills/leniu-architecture-design/SKILL.md +176 -391
- package/.claude/skills/leniu-backend-annotations/SKILL.md +132 -519
- package/.claude/skills/leniu-brainstorm/SKILL.md +132 -541
- package/.claude/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.claude/skills/leniu-crud-development/SKILL.md +232 -938
- package/.claude/skills/leniu-crud-development/references/templates.md +597 -0
- package/.claude/skills/leniu-customization-location/SKILL.md +410 -0
- package/.claude/skills/leniu-data-permission/SKILL.md +70 -0
- package/.claude/skills/leniu-java-entity/SKILL.md +76 -590
- package/.claude/skills/leniu-java-entity/references/templates.md +237 -0
- package/.claude/skills/leniu-java-export/SKILL.md +94 -379
- package/.claude/skills/leniu-java-logging/SKILL.md +106 -709
- package/.claude/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.claude/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.claude/skills/leniu-java-mybatis/SKILL.md +73 -446
- package/.claude/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.claude/skills/leniu-report-customization/SKILL.md +111 -365
- package/.claude/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.claude/skills/leniu-report-standard-customization/SKILL.md +111 -334
- package/.claude/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/.claude/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/.claude/skills/leniu-security-guard/SKILL.md +133 -347
- package/.claude/skills/mysql-debug/SKILL.md +364 -0
- package/.claude/skills/openspec-apply-change/SKILL.md +10 -1
- package/.claude/skills/openspec-archive-change/SKILL.md +9 -1
- package/.claude/skills/openspec-bulk-archive-change/SKILL.md +9 -1
- package/.claude/skills/openspec-continue-change/SKILL.md +9 -1
- package/.claude/skills/openspec-explore/SKILL.md +10 -1
- package/.claude/skills/openspec-ff-change/SKILL.md +9 -1
- package/.claude/skills/openspec-new-change/SKILL.md +9 -1
- package/.claude/skills/openspec-onboard/SKILL.md +15 -130
- package/.claude/skills/openspec-sync-specs/SKILL.md +9 -1
- package/.claude/skills/openspec-verify-change/SKILL.md +9 -1
- package/.claude/skills/performance-doctor/SKILL.md +110 -434
- package/.claude/skills/redis-cache/SKILL.md +89 -595
- package/.claude/skills/redis-cache/references/listeners.md +23 -0
- package/.claude/skills/scheduled-jobs/SKILL.md +88 -407
- package/.claude/skills/security-guard/SKILL.md +137 -532
- package/.claude/skills/security-guard/references/encrypt-config.md +103 -0
- package/.claude/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.claude/skills/sms-mail/SKILL.md +116 -574
- package/.claude/skills/sms-mail/references/mail-config.md +88 -0
- package/.claude/skills/sms-mail/references/sms-config.md +74 -0
- package/.claude/skills/social-login/SKILL.md +112 -514
- package/.claude/skills/social-login/references/provider-configs.md +118 -0
- package/.claude/skills/tenant-management/SKILL.md +129 -444
- package/.claude/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.claude/skills/test-development/SKILL.md +86 -540
- package/.claude/skills/test-development/references/parameterized-examples.md +119 -0
- package/.claude/skills/utils-toolkit/SKILL.md +52 -305
- package/.claude/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.claude/skills/websocket-sse/SKILL.md +105 -550
- package/.claude/skills/workflow-engine/SKILL.md +147 -502
- package/.codex/skills/add-skill/SKILL.md +79 -32
- package/.codex/skills/api-development/SKILL.md +172 -599
- package/.codex/skills/architecture-design/SKILL.md +138 -504
- package/.codex/skills/backend-annotations/SKILL.md +134 -496
- package/.codex/skills/banana-image/SKILL.md +10 -3
- package/.codex/skills/brainstorm/SKILL.md +103 -535
- package/.codex/skills/bug-detective/SKILL.md +147 -1097
- package/.codex/skills/bug-detective/references/error-patterns.md +242 -0
- package/.codex/skills/code-patterns/SKILL.md +120 -282
- package/.codex/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.codex/skills/crud-development/SKILL.md +64 -292
- package/.codex/skills/data-permission/SKILL.md +108 -407
- package/.codex/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.codex/skills/database-ops/SKILL.md +8 -154
- package/.codex/skills/error-handler/SKILL.md +10 -0
- package/.codex/skills/file-oss-management/SKILL.md +106 -714
- package/.codex/skills/file-oss-management/references/entities.md +105 -0
- package/.codex/skills/file-oss-management/references/service-impl.md +104 -0
- package/.codex/skills/git-workflow/SKILL.md +27 -5
- package/.codex/skills/leniu-api-development/SKILL.md +142 -626
- package/.codex/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.codex/skills/leniu-architecture-design/SKILL.md +176 -391
- package/.codex/skills/leniu-backend-annotations/SKILL.md +132 -519
- package/.codex/skills/leniu-brainstorm/SKILL.md +132 -541
- package/.codex/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.codex/skills/leniu-crud-development/SKILL.md +232 -938
- package/.codex/skills/leniu-crud-development/references/templates.md +597 -0
- package/.codex/skills/leniu-customization-location/SKILL.md +410 -0
- package/.codex/skills/leniu-data-permission/SKILL.md +70 -0
- package/.codex/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.codex/skills/leniu-java-entity/SKILL.md +76 -590
- package/.codex/skills/leniu-java-entity/references/templates.md +237 -0
- package/.codex/skills/leniu-java-export/SKILL.md +94 -379
- package/.codex/skills/leniu-java-logging/SKILL.md +106 -709
- package/.codex/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.codex/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.codex/skills/leniu-java-mybatis/SKILL.md +73 -446
- package/.codex/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.codex/skills/leniu-report-customization/SKILL.md +111 -365
- package/.codex/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.codex/skills/leniu-report-standard-customization/SKILL.md +111 -334
- package/.codex/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/.codex/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/.codex/skills/leniu-security-guard/SKILL.md +133 -347
- package/.codex/skills/mysql-debug/SKILL.md +364 -0
- package/.codex/skills/openspec-apply-change/SKILL.md +10 -1
- package/.codex/skills/openspec-archive-change/SKILL.md +9 -1
- package/.codex/skills/openspec-bulk-archive-change/SKILL.md +9 -1
- package/.codex/skills/openspec-continue-change/SKILL.md +9 -1
- package/.codex/skills/openspec-explore/SKILL.md +10 -1
- package/.codex/skills/openspec-ff-change/SKILL.md +9 -1
- package/.codex/skills/openspec-new-change/SKILL.md +9 -1
- package/.codex/skills/openspec-onboard/SKILL.md +15 -130
- package/.codex/skills/openspec-sync-specs/SKILL.md +9 -1
- package/.codex/skills/openspec-verify-change/SKILL.md +9 -1
- package/.codex/skills/performance-doctor/SKILL.md +110 -434
- package/.codex/skills/project-navigator/SKILL.md +20 -1
- package/.codex/skills/redis-cache/SKILL.md +93 -589
- package/.codex/skills/redis-cache/references/listeners.md +23 -0
- package/.codex/skills/scheduled-jobs/SKILL.md +88 -407
- package/.codex/skills/security-guard/SKILL.md +141 -527
- package/.codex/skills/security-guard/references/encrypt-config.md +103 -0
- package/.codex/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.codex/skills/sms-mail/SKILL.md +116 -574
- package/.codex/skills/sms-mail/references/mail-config.md +88 -0
- package/.codex/skills/sms-mail/references/sms-config.md +74 -0
- package/.codex/skills/social-login/SKILL.md +112 -514
- package/.codex/skills/social-login/references/provider-configs.md +118 -0
- package/.codex/skills/store-pc/SKILL.md +258 -383
- package/.codex/skills/tenant-management/SKILL.md +129 -444
- package/.codex/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.codex/skills/test-development/SKILL.md +86 -540
- package/.codex/skills/test-development/references/parameterized-examples.md +119 -0
- package/.codex/skills/ui-pc/SKILL.md +350 -387
- package/.codex/skills/utils-toolkit/SKILL.md +52 -283
- package/.codex/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.codex/skills/websocket-sse/SKILL.md +105 -550
- package/.codex/skills/workflow-engine/SKILL.md +147 -502
- package/.cursor/hooks.json +3 -3
- package/.cursor/skills/add-skill/SKILL.md +79 -32
- package/.cursor/skills/api-development/SKILL.md +83 -377
- package/.cursor/skills/architecture-design/SKILL.md +138 -632
- package/.cursor/skills/backend-annotations/SKILL.md +134 -506
- package/.cursor/skills/banana-image/SKILL.md +10 -3
- package/.cursor/skills/brainstorm/SKILL.md +103 -535
- package/.cursor/skills/bug-detective/SKILL.md +147 -1097
- package/.cursor/skills/bug-detective/references/error-patterns.md +242 -0
- package/.cursor/skills/code-patterns/SKILL.md +116 -426
- package/.cursor/skills/code-patterns/references/leniu-code-patterns.md +87 -0
- package/.cursor/skills/crud-development/SKILL.md +64 -304
- package/.cursor/skills/data-permission/SKILL.md +105 -412
- package/.cursor/skills/data-permission/references/custom-data-scope.md +90 -0
- package/.cursor/skills/file-oss-management/SKILL.md +106 -714
- package/.cursor/skills/file-oss-management/references/entities.md +105 -0
- package/.cursor/skills/file-oss-management/references/service-impl.md +104 -0
- package/.cursor/skills/git-workflow/SKILL.md +27 -5
- package/.cursor/skills/leniu-api-development/SKILL.md +142 -626
- package/.cursor/skills/leniu-api-development/references/real-examples.md +273 -0
- package/.cursor/skills/leniu-architecture-design/SKILL.md +176 -391
- package/.cursor/skills/leniu-backend-annotations/SKILL.md +132 -519
- package/.cursor/skills/leniu-brainstorm/SKILL.md +132 -541
- package/.cursor/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
- package/.cursor/skills/leniu-crud-development/SKILL.md +232 -938
- package/.cursor/skills/leniu-crud-development/references/templates.md +597 -0
- package/.cursor/skills/leniu-customization-location/SKILL.md +410 -0
- package/.cursor/skills/leniu-data-permission/SKILL.md +70 -0
- package/.cursor/skills/leniu-java-code-style/SKILL.md +510 -0
- package/.cursor/skills/leniu-java-entity/SKILL.md +76 -590
- package/.cursor/skills/leniu-java-entity/references/templates.md +237 -0
- package/.cursor/skills/leniu-java-export/SKILL.md +94 -379
- package/.cursor/skills/leniu-java-logging/SKILL.md +106 -709
- package/.cursor/skills/leniu-java-logging/references/data-mask.md +46 -0
- package/.cursor/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
- package/.cursor/skills/leniu-java-mybatis/SKILL.md +73 -446
- package/.cursor/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
- package/.cursor/skills/leniu-report-customization/SKILL.md +111 -365
- package/.cursor/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.cursor/skills/leniu-report-standard-customization/SKILL.md +111 -334
- package/.cursor/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
- package/.cursor/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
- package/.cursor/skills/leniu-security-guard/SKILL.md +133 -347
- package/.cursor/skills/mysql-debug/SKILL.md +364 -0
- package/.cursor/skills/openspec-apply-change/SKILL.md +10 -1
- package/.cursor/skills/openspec-archive-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-bulk-archive-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-continue-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-explore/SKILL.md +10 -1
- package/.cursor/skills/openspec-ff-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-new-change/SKILL.md +9 -1
- package/.cursor/skills/openspec-onboard/SKILL.md +15 -130
- package/.cursor/skills/openspec-sync-specs/SKILL.md +9 -1
- package/.cursor/skills/openspec-verify-change/SKILL.md +9 -1
- package/.cursor/skills/performance-doctor/SKILL.md +110 -434
- package/.cursor/skills/redis-cache/SKILL.md +89 -595
- package/.cursor/skills/redis-cache/references/listeners.md +23 -0
- package/.cursor/skills/scheduled-jobs/SKILL.md +88 -407
- package/.cursor/skills/security-guard/SKILL.md +137 -532
- package/.cursor/skills/security-guard/references/encrypt-config.md +103 -0
- package/.cursor/skills/security-guard/references/sensitive-strategies.md +42 -0
- package/.cursor/skills/sms-mail/SKILL.md +116 -574
- package/.cursor/skills/sms-mail/references/mail-config.md +88 -0
- package/.cursor/skills/sms-mail/references/sms-config.md +74 -0
- package/.cursor/skills/social-login/SKILL.md +112 -514
- package/.cursor/skills/social-login/references/provider-configs.md +118 -0
- package/.cursor/skills/tenant-management/SKILL.md +129 -444
- package/.cursor/skills/tenant-management/references/tenant-scenarios.md +91 -0
- package/.cursor/skills/test-development/SKILL.md +86 -540
- package/.cursor/skills/test-development/references/parameterized-examples.md +119 -0
- package/.cursor/skills/utils-toolkit/SKILL.md +52 -305
- package/.cursor/skills/utils-toolkit/references/redis-utils-api.md +56 -0
- package/.cursor/skills/websocket-sse/SKILL.md +105 -550
- package/.cursor/skills/workflow-engine/SKILL.md +147 -502
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: leniu-report-customization
|
|
3
3
|
description: |
|
|
4
|
-
leniu-tengyun-core
|
|
4
|
+
leniu-tengyun-core 项目(v5.29)定制报表开发指南。基于 report_order_info / report_order_detail / report_account_flow 等报表基础表实现汇总报表。
|
|
5
5
|
|
|
6
6
|
触发场景:
|
|
7
7
|
- 基于订单数据实现定制汇总报表
|
|
@@ -13,56 +13,16 @@ description: |
|
|
|
13
13
|
触发词:定制报表、汇总报表、report_order_info、report_order_detail、report_account_flow、退款汇总、消费金额统计、订单报表、流水报表
|
|
14
14
|
---
|
|
15
15
|
|
|
16
|
-
# leniu
|
|
16
|
+
# leniu 定制报表开发指南
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
**本 skill 仅适用于 v5.29+ 版本包含5.29**。开始前必须确认项目版本。
|
|
21
|
-
|
|
22
|
-
### 如何判断当前项目版本
|
|
23
|
-
|
|
24
|
-
**方法一:查看目录结构**
|
|
25
|
-
```bash
|
|
26
|
-
# 若报表代码在 sys-canteen 内 → v5.29 版本(使用本 skill)
|
|
27
|
-
ls leniu-tengyun-core/sys-canteen/src/main/java/.../report/statistics/
|
|
28
|
-
|
|
29
|
-
# 若存在独立的 core-report 模块 → 标准版(使用 leniu-report-standard-customization)
|
|
30
|
-
ls leniu-tengyun-core/core-report/
|
|
31
|
-
```
|
|
32
|
-
|
|
33
|
-
**方法二:查看 git tag**
|
|
34
|
-
```bash
|
|
35
|
-
git tag --sort=-v:refname | head -5
|
|
36
|
-
# v5.29.x tag → v5.29 版本,使用本 skill
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
**方法三:检查 report_order_info 表字段**
|
|
40
|
-
- 有 `consume_type` 字段(1=消费,2=退款)→ v5.29 版本,使用本 skill
|
|
41
|
-
- 无 `consume_type`,有独立 `report_refund` 表 → 标准版,使用 `leniu-report-standard-customization`
|
|
42
|
-
|
|
43
|
-
### 两版本核心差异速查
|
|
44
|
-
|
|
45
|
-
| 特性 | v5.29 版本(本指南) | 标准版 |
|
|
46
|
-
|------|------------------|--------|
|
|
47
|
-
| 模块位置 | `sys-canteen` 内嵌 | `core-report` 独立模块 |
|
|
48
|
-
| 退款存储 | 合并入 `report_order_info`,`consumeType=2` | 独立 `report_refund` 表 |
|
|
49
|
-
| 退款金额 | **负数**存储,直接 SUM 即净额 | **正数**存储,需手动减退 |
|
|
50
|
-
| 第二阶段消费 | 用 `batchConsume()` 增量累加 | 用 `fix()` 按日重算 |
|
|
51
|
-
| report_order_info.consumeType | **1=消费,2=退款** | 无此字段 |
|
|
52
|
-
| 分析模块 | 无独立分析模块 | 完整引擎(6 大分析维度) |
|
|
53
|
-
|
|
54
|
-
> **标准版报表开发**请使用 `leniu-report-standard-customization` skill。
|
|
55
|
-
|
|
56
|
-
---
|
|
18
|
+
> 详细字段说明见 `references/table-fields.md`
|
|
57
19
|
|
|
58
20
|
## 概述
|
|
59
21
|
|
|
60
|
-
|
|
22
|
+
定制报表基于**报表基础表**(由 MQ 消息写入)进行二次汇总:
|
|
61
23
|
1. **订单类**:`report_order_info` + `report_order_detail`(消费/退款数据)
|
|
62
24
|
2. **账户流水类**:`report_account_flow` + `report_account_flow_detail`(钱包变动数据)
|
|
63
25
|
|
|
64
|
-
定制报表的本质是:从基础表中按维度聚合数据,写入自定义汇总表。
|
|
65
|
-
|
|
66
26
|
---
|
|
67
27
|
|
|
68
28
|
## 一、报表系统架构
|
|
@@ -95,99 +55,27 @@ Redis 计数器 `ORDER_REPORT_COUNT_KEY:{merchantId}`,每来一条 MQ 消息
|
|
|
95
55
|
|
|
96
56
|
---
|
|
97
57
|
|
|
98
|
-
##
|
|
58
|
+
## 二、核心基础表概要
|
|
99
59
|
|
|
100
60
|
### 2.1 report_order_info(报表订单主表)
|
|
101
61
|
|
|
102
|
-
>
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
| `payTime` | LocalDateTime | 支付时间(退款=审核时间) |
|
|
120
|
-
| `orderTime` | LocalDateTime | 下单时间 |
|
|
121
|
-
| `orderDate` | LocalDate | 就餐日期 |
|
|
122
|
-
| `status` | Integer | 消费状态:0=未消费,1=已消费 |
|
|
123
|
-
| `mealtimeType` | Integer | 餐次类型 |
|
|
124
|
-
| `orderType` | Integer | 订单类型(1当餐/2预订/3报餐/4扫码/5餐桌/6自助/11商城/12超市/21补扣/22外部) |
|
|
125
|
-
| `canteenId/canteenName` | Long/String | 食堂 |
|
|
126
|
-
| `stallId/stallName` | Long/String | 档口 |
|
|
127
|
-
| `areaId/areaName` | Long/String | 区域 |
|
|
128
|
-
| `custId/custName/custNum` | - | 用户信息 |
|
|
129
|
-
| `orgId/orgFullId/orgName/orgFullName` | - | 组织信息 |
|
|
130
|
-
| `payType` | Integer | 支付方式 |
|
|
131
|
-
| `payChannel` | Integer | 支付渠道 |
|
|
132
|
-
| `nuClearMode` | Integer | 核身方式(1刷卡/2刷脸/3扫码) |
|
|
133
|
-
| `sourceType` | Integer | 来源类型 |
|
|
134
|
-
| `ifOnline` | Integer | 是否在线订单(1是/2否) |
|
|
135
|
-
| `psnType/psnTypeName` | Integer/String | 用户类别 |
|
|
136
|
-
| `personType` | Integer | 人员归类(1职工/2患者/3陪护/4其他,医院版) |
|
|
137
|
-
|
|
138
|
-
### 2.2 report_order_detail(报表订单菜品明细表)
|
|
139
|
-
|
|
140
|
-
| 字段 | 类型 | 说明 |
|
|
141
|
-
|------|------|------|
|
|
142
|
-
| `detailId` | Long | 明细主键 |
|
|
143
|
-
| `orderId` | Long | 关联订单ID |
|
|
144
|
-
| `goodsDishesId/goodsDishesName` | Long/String | 菜品信息 |
|
|
145
|
-
| `salePrice` | BigDecimal | 售卖价格(分) |
|
|
146
|
-
| `prefPrice` | BigDecimal | 优惠价格(分) |
|
|
147
|
-
| `price` | BigDecimal | 计算价格(分,最终价格) |
|
|
148
|
-
| `quantity` | Integer | 数量/重量 |
|
|
149
|
-
| `totalAmount` | BigDecimal | 订单详情总金额(分) |
|
|
150
|
-
| `realAmount` | BigDecimal | 实际付款金额(分) |
|
|
151
|
-
| `detailState` | Integer | **1=正常,2=已退菜(全退),3=部分退菜** |
|
|
152
|
-
| `goodsRefundNum` | Integer | 商品已退数量 |
|
|
153
|
-
| `refundAmount` | BigDecimal | 商品退款金额(分) |
|
|
154
|
-
| `detailType` | Integer | 明细类别(1菜品/2套餐/3商品/4按键/5补扣/6报餐) |
|
|
155
|
-
| `costPrice` | BigDecimal | 成本价格 |
|
|
156
|
-
|
|
157
|
-
### 2.3 report_account_flow(账户变动流水主表)
|
|
158
|
-
|
|
159
|
-
| 字段 | 类型 | 说明 |
|
|
160
|
-
|------|------|------|
|
|
161
|
-
| `flowId` | Long | 主键(雪花ID) |
|
|
162
|
-
| `custId` | Long | 人员ID |
|
|
163
|
-
| `flowType` | Integer | 交易类型(AccTradeTypeEnum) |
|
|
164
|
-
| `flowRealAmount` | BigDecimal | 实际交易金额 |
|
|
165
|
-
| `flowAmount` | BigDecimal | 交易金额 |
|
|
166
|
-
| `accTotalBal` | BigDecimal | 所有钱包可用余额之和(不含冻结) |
|
|
167
|
-
| `accAllBal` | BigDecimal | 所有钱包总余额(含冻结) |
|
|
168
|
-
| `payTime` | LocalDateTime | 支付时间 |
|
|
169
|
-
| `ordTime` | LocalDateTime | 订单时间 |
|
|
170
|
-
| `status` | Integer | 消费状态:0=未消费,1=已消费 |
|
|
171
|
-
| `manageCost` | BigDecimal | 管理费 |
|
|
172
|
-
| `rechargeSource` | Integer | 充值来源 |
|
|
173
|
-
| `payChannel` | Integer | 支付渠道 |
|
|
174
|
-
| `payType` | Integer | 支付方式 |
|
|
175
|
-
|
|
176
|
-
> 注意:`custName`、`mobile`、`mobileSuffix` 使用 SM4 加密存储。
|
|
177
|
-
|
|
178
|
-
### 2.4 report_account_flow_detail(账户流水钱包明细表)
|
|
179
|
-
|
|
180
|
-
| 字段 | 类型 | 说明 |
|
|
181
|
-
|------|------|------|
|
|
182
|
-
| `id` | Long | 自增主键 |
|
|
183
|
-
| `flowId` | Long | 关联主流水 |
|
|
184
|
-
| `walletId` | Long | 钱包类型(AccWalletIdEnum) |
|
|
185
|
-
| `flowType` | Integer | 交易类型 |
|
|
186
|
-
| `amount` | BigDecimal | 本钱包支付金额(转出类型取负值) |
|
|
187
|
-
| `walletBal` | BigDecimal | 本钱包可用余额 |
|
|
188
|
-
| `allWalletBal` | BigDecimal | 本钱包总余额(含冻结) |
|
|
189
|
-
| `frozenBalance` | BigDecimal | 冻结余额 |
|
|
190
|
-
| `payTime` | LocalDateTime | 支付时间 |
|
|
62
|
+
> v5.29 后,正向下单和逆向退款**都存在这张表中**,通过 `consumeType` 区分。
|
|
63
|
+
|
|
64
|
+
关键字段:`orderId`(主键), `relationOrderId`(退款指向原始订单), `consumeType`(**1=消费,2=退款**), `orderRefundState`(1未退/2全退/3部分退), `realAmount`/`refundAmount`/`walletAmount`/`subsidyAmount`(金额,分), `payTime`, `orderDate`, `mealtimeType`, `orderType`, `canteenId/stallId`, `status`(0未消费/1已消费)
|
|
65
|
+
|
|
66
|
+
### 2.2 report_order_detail(菜品明细表)
|
|
67
|
+
|
|
68
|
+
关键字段:`detailId`, `orderId`, `goodsDishesId/goodsDishesName`, `price/totalAmount/realAmount`(分), `quantity`, `detailState`(**1正常/2已退菜/3部分退菜**), `goodsRefundNum`, `refundAmount`, `detailType`(1菜品/2套餐/3商品/4按键/5补扣/6报餐)
|
|
69
|
+
|
|
70
|
+
### 2.3 report_account_flow(账户流水主表)
|
|
71
|
+
|
|
72
|
+
关键字段:`flowId`, `custId`, `flowType`(AccTradeTypeEnum), `flowRealAmount/flowAmount`, `accTotalBal/accAllBal`, `payTime`, `status`(0未消费/1已消费)
|
|
73
|
+
|
|
74
|
+
> `custName`、`mobile` 使用 SM4 加密存储。
|
|
75
|
+
|
|
76
|
+
### 2.4 report_account_flow_detail(流水钱包明细)
|
|
77
|
+
|
|
78
|
+
关键字段:`flowId`, `walletId`(AccWalletIdEnum), `amount`(转出取负值), `walletBal`, `frozenBalance`
|
|
191
79
|
|
|
192
80
|
---
|
|
193
81
|
|
|
@@ -195,74 +83,42 @@ Redis 计数器 `ORDER_REPORT_COUNT_KEY:{merchantId}`,每来一条 MQ 消息
|
|
|
195
83
|
|
|
196
84
|
### 3.1 退款数据在 report_order_info 中的表现
|
|
197
85
|
|
|
198
|
-
退款记录作为**独立行**写入 `report_order_info`:
|
|
199
|
-
|
|
200
86
|
```
|
|
201
87
|
正向订单:orderId=订单ID, consumeType=1, orderRefundState=1
|
|
202
88
|
退款记录:orderId=退款单ID, consumeType=2, relationOrderId=原始订单ID
|
|
203
|
-
金额字段全部为负数(realRefundAmount、walletAmount、subsidyAmount
|
|
89
|
+
金额字段全部为负数(realRefundAmount、walletAmount、subsidyAmount 都乘以 -1)
|
|
204
90
|
payTime = 退款审核时间(checkTime)
|
|
205
91
|
```
|
|
206
92
|
|
|
207
|
-
### 3.2
|
|
93
|
+
### 3.2 净消费金额计算(3种方式)
|
|
208
94
|
|
|
209
|
-
|
|
210
|
-
|----|------|------|
|
|
211
|
-
| 1 | 未退单 | 正常消费,无退款 |
|
|
212
|
-
| 2 | 已退单(全退) | 整单退款 |
|
|
213
|
-
| 3 | 部分退单 | 部分菜品退款 |
|
|
214
|
-
|
|
215
|
-
### 3.3 汇总报表中计算"净消费金额"的标准模式
|
|
216
|
-
|
|
217
|
-
**方式一:直接利用 consumeType 和负数金额**(推荐)
|
|
218
|
-
|
|
219
|
-
因为退款记录的金额已经是负数,所以直接 SUM 即可得到净额:
|
|
95
|
+
**方式一:直接 SUM(推荐)** - 退款金额已为负数
|
|
220
96
|
|
|
221
97
|
```sql
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
SUM(real_amount) AS netAmount, -- 净实付
|
|
226
|
-
SUM(wallet_amount) AS netWalletAmount, -- 净个人钱包消费
|
|
227
|
-
SUM(subsidy_amount) AS netSubsidyAmount -- 净补贴消费
|
|
228
|
-
FROM report_order_info
|
|
229
|
-
WHERE pay_time BETWEEN #{startTime} AND #{endTime}
|
|
98
|
+
SELECT SUM(real_amount) AS netAmount,
|
|
99
|
+
SUM(wallet_amount) AS netWalletAmount
|
|
100
|
+
FROM report_order_info WHERE pay_time BETWEEN #{startTime} AND #{endTime}
|
|
230
101
|
```
|
|
231
102
|
|
|
232
103
|
**方式二:分别统计消费和退款**
|
|
233
104
|
|
|
234
105
|
```sql
|
|
235
|
-
--
|
|
236
|
-
SELECT SUM(real_amount) FROM report_order_info
|
|
237
|
-
WHERE consume_type = 1
|
|
238
|
-
AND pay_time BETWEEN #{startTime} AND #{endTime}
|
|
239
|
-
|
|
240
|
-
-- 退款总额(仅退款记录,金额为负数,取绝对值)
|
|
241
|
-
SELECT SUM(ABS(real_refund_amount)) FROM report_order_info
|
|
242
|
-
WHERE consume_type = 2
|
|
243
|
-
AND pay_time BETWEEN #{startTime} AND #{endTime}
|
|
244
|
-
|
|
106
|
+
-- 消费总额(consumeType=1)/ 退款总额(consumeType=2,取ABS)
|
|
245
107
|
-- 净额 = 消费总额 - 退款总额
|
|
246
108
|
```
|
|
247
109
|
|
|
248
|
-
|
|
110
|
+
**方式三:排除全退订单**
|
|
249
111
|
|
|
250
112
|
```sql
|
|
251
|
-
-- 排除全退订单,只统计有效消费
|
|
252
113
|
SELECT SUM(real_amount - IFNULL(refund_amount, 0)) AS netAmount
|
|
253
114
|
FROM report_order_info
|
|
254
|
-
WHERE consume_type = 1
|
|
255
|
-
AND order_refund_state IN (1, 3) -- 未退单 + 部分退单
|
|
256
|
-
AND pay_time BETWEEN #{startTime} AND #{endTime}
|
|
115
|
+
WHERE consume_type = 1 AND order_refund_state IN (1, 3)
|
|
257
116
|
```
|
|
258
117
|
|
|
259
|
-
### 3.
|
|
118
|
+
### 3.3 菜品级别退款
|
|
260
119
|
|
|
261
120
|
```
|
|
262
|
-
detailState=1
|
|
263
|
-
detailState=2(已退菜全退):该菜品已完全退款
|
|
264
|
-
detailState=3(部分退菜):goodsRefundNum 为已退数量,refundAmount 为退款金额
|
|
265
|
-
|
|
121
|
+
detailState=1(正常)/ 2(全退)/ 3(部分退)
|
|
266
122
|
菜品净销量 = quantity - IFNULL(goods_refund_num, 0)
|
|
267
123
|
菜品净金额 = total_amount - IFNULL(refund_amount, 0)
|
|
268
124
|
```
|
|
@@ -271,7 +127,7 @@ detailState=3(部分退菜):goodsRefundNum 为已退数量,refundAmount
|
|
|
271
127
|
|
|
272
128
|
## 四、钱包与交易类型枚举
|
|
273
129
|
|
|
274
|
-
### 4.1 AccWalletIdEnum
|
|
130
|
+
### 4.1 AccWalletIdEnum
|
|
275
131
|
|
|
276
132
|
| key | 枚举 | 含义 |
|
|
277
133
|
|-----|------|------|
|
|
@@ -279,45 +135,26 @@ detailState=3(部分退菜):goodsRefundNum 为已退数量,refundAmount
|
|
|
279
135
|
| 2 | SUBSIDY | 补贴钱包 |
|
|
280
136
|
| 4 | LUCK_MONEY | 红包 |
|
|
281
137
|
|
|
282
|
-
### 4.2 AccTradeTypeEnum
|
|
283
|
-
|
|
284
|
-
| key | 枚举 |
|
|
285
|
-
|
|
286
|
-
| 10 | RECHARGE |
|
|
287
|
-
|
|
|
288
|
-
|
|
|
289
|
-
|
|
|
290
|
-
|
|
|
291
|
-
|
|
|
292
|
-
|
|
|
293
|
-
|
|
|
294
|
-
|
|
|
295
|
-
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
| 110 | CONSUME | 消费 | **负** |
|
|
299
|
-
| 120 | CONSUME_REPAIR | 消费补扣 | **负** |
|
|
300
|
-
| 130 | CONSUME_REFUND | 消费退款 | 正(收入) |
|
|
301
|
-
| 131 | CONSUME_WITHHOLD | 账户预扣 | **负** |
|
|
302
|
-
| 132 | CONSUME_WITHHOLD_REFUND | 账户预扣退款 | 正(收入) |
|
|
303
|
-
| 140 | LUCK_MONEY | 红包 | 正(收入) |
|
|
304
|
-
| 141 | REVOKE_LUCK_MONEY | 撤销红包 | **负** |
|
|
305
|
-
| 142 | CLEAR_LUCK_MONEY | 红包清空 | **负** |
|
|
306
|
-
|
|
307
|
-
> `getConvertFlag()` 方法标记了需要转为负数显示的类型。
|
|
308
|
-
|
|
309
|
-
### 4.3 账户流水报表常用过滤
|
|
138
|
+
### 4.2 AccTradeTypeEnum
|
|
139
|
+
|
|
140
|
+
| key | 枚举 | 金额方向 |
|
|
141
|
+
|-----|------|---------|
|
|
142
|
+
| 10/11 | RECHARGE/RECHARGE_GIFT | 正 |
|
|
143
|
+
| 12/40/50 | 撤销赠送/撤销充值/撤销补贴 | **负** |
|
|
144
|
+
| 20 | SUBSIDY 补贴 | 正 |
|
|
145
|
+
| 30 | WITHDRAW 提现 | **负** |
|
|
146
|
+
| 60/80/100 | 转出/冻结/补贴清空 | **负** |
|
|
147
|
+
| 70/90 | 转入/解冻 | 正 |
|
|
148
|
+
| 110/120 | CONSUME/CONSUME_REPAIR | **负** |
|
|
149
|
+
| 130 | CONSUME_REFUND 退款 | 正 |
|
|
150
|
+
| 131/132 | 账户预扣/预扣退款 | **负**/正 |
|
|
151
|
+
| 140/141/142 | 红包/撤销红包/红包清空 | 正/**负**/**负** |
|
|
152
|
+
|
|
153
|
+
### 4.3 账户流水常用过滤
|
|
310
154
|
|
|
311
155
|
```java
|
|
312
|
-
//
|
|
313
|
-
|
|
314
|
-
WHERE wallet_id = #{AccWalletIdEnum.WALLET.key} // 个人钱包
|
|
315
|
-
AND flow_type = #{AccTradeTypeEnum.CONSUME.key} // 消费类型
|
|
316
|
-
|
|
317
|
-
// 统计消费+退款净额
|
|
318
|
-
WHERE wallet_id = #{walletId}
|
|
319
|
-
AND flow_type IN (110, 130) // CONSUME + CONSUME_REFUND
|
|
320
|
-
// amount 字段:消费为负,退款为正 → SUM 即为净消费额(负值)
|
|
156
|
+
// 净消费额:消费为负,退款为正 → SUM 即为净消费额(负值)
|
|
157
|
+
WHERE wallet_id = #{walletId} AND flow_type IN (110, 130)
|
|
321
158
|
```
|
|
322
159
|
|
|
323
160
|
---
|
|
@@ -327,68 +164,37 @@ WHERE wallet_id = #{walletId}
|
|
|
327
164
|
### 5.1 实现 ReportOrderConsumeService 接口
|
|
328
165
|
|
|
329
166
|
```java
|
|
330
|
-
@Service
|
|
331
|
-
@Slf4j
|
|
167
|
+
@Service @Slf4j
|
|
332
168
|
public class ReportSumXxxService implements ReportOrderConsumeService {
|
|
169
|
+
@Override public int getOrder() { return 15; } // <10基础, 10-29汇总, 30+菜品
|
|
333
170
|
|
|
334
|
-
@Override
|
|
335
|
-
|
|
336
|
-
// < 10: 基础表(同步写入)
|
|
337
|
-
// >= 10 且 < 30: 普通汇总表(批量消费)
|
|
338
|
-
// >= 30: 菜品汇总表(需要 detail 数据)
|
|
339
|
-
return 15; // 自定义汇总表一般用 10-29
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* 单条消费(第一阶段,一般汇总表不用实现)
|
|
344
|
-
*/
|
|
345
|
-
@Override
|
|
346
|
-
public void consume(OrderChangePO payload, ReportOrderInfoDTO baseInfo) {
|
|
347
|
-
// 汇总表通常留空,仅基础表实现
|
|
171
|
+
@Override public void consume(OrderChangePO payload, ReportOrderInfoDTO baseInfo) {
|
|
172
|
+
// 汇总表通常留空
|
|
348
173
|
}
|
|
349
174
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
*/
|
|
353
|
-
@Override
|
|
354
|
-
public void batchConsume(List<ReportOrderConsumeDTO> list) {
|
|
355
|
-
// 1. 按分组维度聚合(日期+食堂+档口+...)
|
|
356
|
-
// 2. 查询汇总表是否已有记录
|
|
357
|
-
// - 不存在 → INSERT
|
|
358
|
-
// - 存在 → UPDATE(累加金额)
|
|
359
|
-
// 3. 批量写入
|
|
175
|
+
@Override public void batchConsume(List<ReportOrderConsumeDTO> list) {
|
|
176
|
+
// 分组 → 查存量 → 累加/新建(见下方模板)
|
|
360
177
|
}
|
|
361
178
|
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
*/
|
|
365
|
-
@Override
|
|
366
|
-
public void fix(ReportBaseParam param) {
|
|
367
|
-
// 1. 删除时间范围内的旧汇总数据
|
|
368
|
-
// 2. 从 report_order_info 重新聚合写入
|
|
179
|
+
@Override public void fix(ReportBaseParam param) {
|
|
180
|
+
// 先删后插,从基础表重新聚合
|
|
369
181
|
}
|
|
370
182
|
}
|
|
371
183
|
```
|
|
372
184
|
|
|
373
|
-
### 5.2 batchConsume
|
|
185
|
+
### 5.2 batchConsume 模板
|
|
374
186
|
|
|
375
187
|
```java
|
|
376
188
|
@Override
|
|
377
189
|
public void batchConsume(List<ReportOrderConsumeDTO> list) {
|
|
378
|
-
// 1. 构建分组 Key(按需选择维度)
|
|
379
190
|
Map<String, List<ReportOrderConsumeDTO>> grouped = list.stream()
|
|
380
191
|
.collect(Collectors.groupingBy(e ->
|
|
381
|
-
e.getStatisticDate() + "_" + e.getCanteenId() + "_" + e.getStallId()
|
|
382
|
-
));
|
|
192
|
+
e.getStatisticDate() + "_" + e.getCanteenId() + "_" + e.getStallId()));
|
|
383
193
|
|
|
384
|
-
List<ReportSumXxx> insertList = new ArrayList<>();
|
|
385
|
-
List<ReportSumXxx> updateList = new ArrayList<>();
|
|
194
|
+
List<ReportSumXxx> insertList = new ArrayList<>(), updateList = new ArrayList<>();
|
|
386
195
|
|
|
387
|
-
for (
|
|
388
|
-
|
|
389
|
-
ReportOrderConsumeDTO first = items.get(0);
|
|
390
|
-
|
|
391
|
-
// 2. 查询是否已存在
|
|
196
|
+
for (var entry : grouped.entrySet()) {
|
|
197
|
+
ReportOrderConsumeDTO first = entry.getValue().get(0);
|
|
392
198
|
ReportSumXxx existing = mapper.selectOne(Wrappers.<ReportSumXxx>lambdaQuery()
|
|
393
199
|
.eq(ReportSumXxx::getStatisticDate, first.getStatisticDate())
|
|
394
200
|
.eq(ReportSumXxx::getCanteenId, first.getCanteenId())
|
|
@@ -397,58 +203,39 @@ public void batchConsume(List<ReportOrderConsumeDTO> list) {
|
|
|
397
203
|
if (existing == null) {
|
|
398
204
|
ReportSumXxx record = new ReportSumXxx();
|
|
399
205
|
record.setId(Id.next());
|
|
400
|
-
//
|
|
401
|
-
// 累加金额字段...
|
|
206
|
+
// 设置维度 + 累加金额
|
|
402
207
|
insertList.add(record);
|
|
403
208
|
} else {
|
|
404
|
-
//
|
|
405
|
-
// existing.setXxxAmount(existing.getXxxAmount().add(deltaAmount));
|
|
209
|
+
// existing.setXxxAmount(existing.getXxxAmount().add(delta));
|
|
406
210
|
updateList.add(existing);
|
|
407
211
|
}
|
|
408
212
|
}
|
|
409
|
-
|
|
410
|
-
if (CollUtil.isNotEmpty(
|
|
411
|
-
// 批量插入
|
|
412
|
-
}
|
|
413
|
-
if (CollUtil.isNotEmpty(updateList)) {
|
|
414
|
-
// 批量更新
|
|
415
|
-
}
|
|
213
|
+
if (CollUtil.isNotEmpty(insertList)) { /* 批量插入 */ }
|
|
214
|
+
if (CollUtil.isNotEmpty(updateList)) { /* 批量更新 */ }
|
|
416
215
|
}
|
|
417
216
|
```
|
|
418
217
|
|
|
419
|
-
### 5.3 fix
|
|
218
|
+
### 5.3 fix 方法 + SQL 模板
|
|
420
219
|
|
|
421
220
|
```java
|
|
422
221
|
@Override
|
|
423
222
|
public void fix(ReportBaseParam param) {
|
|
424
|
-
LocalDateTime startTime = param.getStartTime();
|
|
425
|
-
LocalDateTime endTime = param.getEndTime();
|
|
426
|
-
|
|
427
|
-
// 1. 删除时间范围内的旧数据(先删后插)
|
|
428
223
|
mapper.delete(Wrappers.<ReportSumXxx>lambdaQuery()
|
|
429
224
|
.between(ReportSumXxx::getStatisticDate,
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
// 2. 从 report_order_info 聚合初始化(推荐用 SQL 直接聚合)
|
|
433
|
-
mapper.initFix(null, startTime, endTime);
|
|
225
|
+
param.getStartTime().toLocalDate(), param.getEndTime().toLocalDate()));
|
|
226
|
+
mapper.initFix(null, param.getStartTime(), param.getEndTime());
|
|
434
227
|
}
|
|
435
228
|
```
|
|
436
229
|
|
|
437
|
-
### 5.4 fix SQL 模板(MyBatis XML)
|
|
438
|
-
|
|
439
230
|
```xml
|
|
440
231
|
<insert id="initFix">
|
|
441
232
|
INSERT INTO report_sum_xxx (id, statistic_date, canteen_id, canteen_name,
|
|
442
233
|
order_count, consume_amount, refund_amount, net_amount)
|
|
443
|
-
SELECT
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
COUNT(*) AS order_count,
|
|
449
|
-
SUM(CASE WHEN consume_type = 1 THEN real_amount ELSE 0 END) AS consume_amount,
|
|
450
|
-
SUM(CASE WHEN consume_type = 2 THEN ABS(real_refund_amount) ELSE 0 END) AS refund_amount,
|
|
451
|
-
SUM(real_amount) + SUM(IFNULL(real_refund_amount, 0)) AS net_amount
|
|
234
|
+
SELECT #{id}, DATE(pay_time), canteen_id, canteen_name,
|
|
235
|
+
COUNT(*),
|
|
236
|
+
SUM(CASE WHEN consume_type = 1 THEN real_amount ELSE 0 END),
|
|
237
|
+
SUM(CASE WHEN consume_type = 2 THEN ABS(real_refund_amount) ELSE 0 END),
|
|
238
|
+
SUM(real_amount) + SUM(IFNULL(real_refund_amount, 0))
|
|
452
239
|
FROM report_order_info
|
|
453
240
|
WHERE pay_time BETWEEN #{startTime} AND #{endTime}
|
|
454
241
|
GROUP BY DATE(pay_time), canteen_id, canteen_name
|
|
@@ -457,110 +244,73 @@ public void fix(ReportBaseParam param) {
|
|
|
457
244
|
|
|
458
245
|
---
|
|
459
246
|
|
|
460
|
-
##
|
|
247
|
+
## 六、数据权限集成
|
|
461
248
|
|
|
462
|
-
|
|
249
|
+
- Service 注入 `MgrAuthV2Api` 和 `ReportDataPermissionService`
|
|
250
|
+
- 查询/导出方法首行调用 `mgrAuthApi.getUserAuthPO()` + `reportDataPermissionService.getDataPermission(authPO)`
|
|
251
|
+
- Mapper 签名携带 `@Param("authPO")` 和 `@Param("dataPermission")`
|
|
252
|
+
- XML `baseWhere` 末尾引入 `<include refid="net.xnzn.core.report.statistics.common.mapper.ReportDataPermissionMapper.dataPermission"/>`
|
|
463
253
|
|
|
464
|
-
|
|
465
|
-
public PageVO<XxxVO> pageSummary(XxxParam param) {
|
|
466
|
-
// 三个异步查询并行执行
|
|
467
|
-
CompletableFuture<Long> countFuture = CompletableFuture.supplyAsync(() ->
|
|
468
|
-
mapper.selectCount(param));
|
|
469
|
-
|
|
470
|
-
CompletableFuture<List<XxxVO>> listFuture = CompletableFuture.supplyAsync(() ->
|
|
471
|
-
mapper.selectPageList(param));
|
|
254
|
+
---
|
|
472
255
|
|
|
473
|
-
|
|
474
|
-
mapper.selectTotal(param));
|
|
256
|
+
## 七、查询接口标准模式(三并行 CompletableFuture)
|
|
475
257
|
|
|
476
|
-
|
|
258
|
+
```java
|
|
259
|
+
public PageVO<XxxVO> pageSummary(XxxParam param) {
|
|
260
|
+
CompletableFuture<Long> countF = CompletableFuture.supplyAsync(() -> mapper.selectCount(param));
|
|
261
|
+
CompletableFuture<List<XxxVO>> listF = CompletableFuture.supplyAsync(() -> mapper.selectPageList(param));
|
|
262
|
+
CompletableFuture<XxxTotalVO> totalF = CompletableFuture.supplyAsync(() -> mapper.selectTotal(param));
|
|
263
|
+
CompletableFuture.allOf(countF, listF, totalF).join();
|
|
477
264
|
|
|
478
265
|
PageVO<XxxVO> pageVO = new PageVO<>();
|
|
479
|
-
pageVO.setTotal(
|
|
480
|
-
pageVO.setList(
|
|
481
|
-
pageVO.setTotalLine(
|
|
266
|
+
pageVO.setTotal(countF.join());
|
|
267
|
+
pageVO.setList(listF.join());
|
|
268
|
+
pageVO.setTotalLine(totalF.join());
|
|
482
269
|
return pageVO;
|
|
483
270
|
}
|
|
484
271
|
```
|
|
485
272
|
|
|
486
273
|
---
|
|
487
274
|
|
|
488
|
-
##
|
|
489
|
-
|
|
490
|
-
### 7.1 基于 report_account_flow 的汇总
|
|
491
|
-
|
|
492
|
-
与订单报表模式相同,但数据源不同:
|
|
275
|
+
## 八、账户流水汇总报表
|
|
493
276
|
|
|
494
|
-
|
|
495
|
-
// 实现 ReportAccountConsumeService 接口(类似 ReportOrderConsumeService)
|
|
496
|
-
// batchConsume 从 report_account_flow 查 status=0 的数据
|
|
497
|
-
// fix 从 report_account_flow 重新聚合
|
|
498
|
-
```
|
|
499
|
-
|
|
500
|
-
### 7.2 常见统计维度
|
|
277
|
+
实现 `ReportAccountConsumeService` 接口(类似 ReportOrderConsumeService),数据源为 `report_account_flow`。
|
|
501
278
|
|
|
502
279
|
```sql
|
|
503
|
-
--
|
|
504
|
-
SELECT
|
|
505
|
-
d.wallet_id,
|
|
280
|
+
-- 按钱包类型统计消费/退款
|
|
281
|
+
SELECT d.wallet_id,
|
|
506
282
|
SUM(CASE WHEN d.flow_type = 110 THEN ABS(d.amount) ELSE 0 END) AS consume_amount,
|
|
507
283
|
SUM(CASE WHEN d.flow_type = 130 THEN d.amount ELSE 0 END) AS refund_amount
|
|
508
284
|
FROM report_account_flow f
|
|
509
285
|
JOIN report_account_flow_detail d ON f.flow_id = d.flow_id
|
|
510
286
|
WHERE f.pay_time BETWEEN #{startTime} AND #{endTime}
|
|
511
287
|
GROUP BY d.wallet_id
|
|
512
|
-
|
|
513
|
-
-- 按交易类型统计
|
|
514
|
-
SELECT
|
|
515
|
-
f.flow_type,
|
|
516
|
-
SUM(f.flow_real_amount) AS total_amount,
|
|
517
|
-
COUNT(*) AS total_count
|
|
518
|
-
FROM report_account_flow f
|
|
519
|
-
WHERE f.pay_time BETWEEN #{startTime} AND #{endTime}
|
|
520
|
-
GROUP BY f.flow_type
|
|
521
288
|
```
|
|
522
289
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
```
|
|
526
|
-
消费:flowType=110 (CONSUME),amount 为负
|
|
527
|
-
退款:flowType=130 (CONSUME_REFUND),amount 为正
|
|
528
|
-
|
|
529
|
-
净消费 = ABS(SUM(CONSUME 的 amount)) - SUM(CONSUME_REFUND 的 amount)
|
|
530
|
-
或直接:ABS(SUM(flowType IN (110, 130) 的 amount))
|
|
531
|
-
```
|
|
290
|
+
流水退款:`flowType=110` amount 为负,`flowType=130` amount 为正,直接 SUM 即净额。
|
|
532
291
|
|
|
533
292
|
---
|
|
534
293
|
|
|
535
|
-
##
|
|
536
|
-
|
|
537
|
-
新建定制汇总报表时,逐项确认:
|
|
294
|
+
## 九、开发检查清单
|
|
538
295
|
|
|
539
296
|
### 建表
|
|
540
|
-
- [ ]
|
|
541
|
-
- [ ] 汇总表包含金额汇总字段(consumeAmount、refundAmount、netAmount 等)
|
|
542
|
-
- [ ] 审计字段(crby/crtime/upby/uptime/del_flag)
|
|
543
|
-
- [ ] 无 tenant_id(双库物理隔离)
|
|
297
|
+
- [ ] 分组维度字段 + 金额汇总字段 + 审计字段(crby/crtime/upby/uptime/del_flag),无 tenant_id
|
|
544
298
|
|
|
545
299
|
### 实现
|
|
546
|
-
- [ ] 实现 `ReportOrderConsumeService`(或 `
|
|
547
|
-
- [ ]
|
|
548
|
-
- [ ]
|
|
549
|
-
- [ ] 实现 `fix()` — 先删后插,从基础表重新聚合
|
|
300
|
+
- [ ] 实现 `ReportOrderConsumeService`(或 Account 版本),设置 `getOrder()`
|
|
301
|
+
- [ ] `batchConsume()` — 分组 → 查存量 → 累加/新建
|
|
302
|
+
- [ ] `fix()` — 先删后插,从基础表重新聚合
|
|
550
303
|
|
|
551
304
|
### 退款处理
|
|
552
|
-
- [ ] 确认是否需要处理退款数据
|
|
553
305
|
- [ ] 选择退款计算方式(直接 SUM 负数 / 分别统计 / 排除全退)
|
|
554
|
-
- [ ]
|
|
306
|
+
- [ ] 菜品退款关注 `detailState` 和 `goodsRefundNum`
|
|
555
307
|
|
|
556
308
|
### 查询接口
|
|
557
|
-
- [ ] 分页 +
|
|
558
|
-
- [ ] 三并行 CompletableFuture(count + list + total)
|
|
559
|
-
- [ ] 导出功能(如需要)
|
|
309
|
+
- [ ] 分页 + 合计行(PageVO + TotalVO)+ 三并行 CompletableFuture
|
|
560
310
|
|
|
561
311
|
---
|
|
562
312
|
|
|
563
|
-
##
|
|
313
|
+
## 十、关键代码位置
|
|
564
314
|
|
|
565
315
|
| 类型 | 路径 |
|
|
566
316
|
|------|------|
|
|
@@ -570,11 +320,7 @@ GROUP BY f.flow_type
|
|
|
570
320
|
| ConsumeService 接口 | `sys-canteen/.../report/statistics/config/mq/ReportOrderConsumeService.java` |
|
|
571
321
|
| 食堂汇总参考实现 | `sys-canteen/.../report/statistics/order/summary/service/ReportSumCanteenService.java` |
|
|
572
322
|
| Fix Controller | `sys-canteen/.../report/statistics/order/fix/controller/ReportFixController.java` |
|
|
573
|
-
| Fix Service | `sys-canteen/.../report/statistics/order/fix/service/ReportFixService.java` |
|
|
574
323
|
| ReportOrderInfo 实体 | `sys-canteen/.../report/statistics/order/basic/model/ReportOrderInfo.java` |
|
|
575
|
-
| ReportOrderDetail 实体 | `sys-canteen/.../report/statistics/order/basic/model/ReportOrderDetail.java` |
|
|
576
|
-
| ReportAccountFlow 实体 | `sys-canteen/.../report/statistics/account/model/ReportAccountFlow.java` |
|
|
577
|
-
| ReportAccountFlowDetail 实体 | `sys-canteen/.../report/statistics/account/model/ReportAccountFlowDetail.java` |
|
|
578
324
|
| AccTradeTypeEnum | `sys-canteen/.../account/v3/constants/AccTradeTypeEnum.java` |
|
|
579
325
|
| AccWalletIdEnum | `sys-canteen/.../account/v3/constants/AccWalletIdEnum.java` |
|
|
580
326
|
|
|
@@ -582,8 +328,8 @@ GROUP BY f.flow_type
|
|
|
582
328
|
|
|
583
329
|
## 注意
|
|
584
330
|
|
|
585
|
-
-
|
|
586
|
-
-
|
|
587
|
-
-
|
|
588
|
-
-
|
|
589
|
-
-
|
|
331
|
+
- CRUD 开发(非报表)请使用 `leniu-crud-development`
|
|
332
|
+
- MyBatis XML 编写规范请使用 `leniu-java-mybatis`
|
|
333
|
+
- 报表入参设计请使用 `leniu-java-report-query-param`
|
|
334
|
+
- 合计行实现请使用 `leniu-java-total-line`
|
|
335
|
+
- 餐次过滤请使用 `leniu-mealtime`
|