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.
Files changed (226) hide show
  1. package/.claude/hooks/skill-forced-eval.js +2 -0
  2. package/.claude/settings.json +3 -3
  3. package/.claude/skills/add-skill/SKILL.md +79 -32
  4. package/.claude/skills/api-development/SKILL.md +83 -377
  5. package/.claude/skills/architecture-design/SKILL.md +138 -632
  6. package/.claude/skills/backend-annotations/SKILL.md +134 -506
  7. package/.claude/skills/banana-image/SKILL.md +10 -3
  8. package/.claude/skills/brainstorm/SKILL.md +103 -535
  9. package/.claude/skills/bug-detective/SKILL.md +147 -1097
  10. package/.claude/skills/bug-detective/references/error-patterns.md +242 -0
  11. package/.claude/skills/code-patterns/SKILL.md +116 -426
  12. package/.claude/skills/code-patterns/references/leniu-code-patterns.md +87 -0
  13. package/.claude/skills/crud-development/SKILL.md +64 -304
  14. package/.claude/skills/data-permission/SKILL.md +105 -412
  15. package/.claude/skills/data-permission/references/custom-data-scope.md +90 -0
  16. package/.claude/skills/file-oss-management/SKILL.md +106 -714
  17. package/.claude/skills/file-oss-management/references/entities.md +105 -0
  18. package/.claude/skills/file-oss-management/references/service-impl.md +104 -0
  19. package/.claude/skills/leniu-api-development/SKILL.md +142 -626
  20. package/.claude/skills/leniu-api-development/references/real-examples.md +273 -0
  21. package/.claude/skills/leniu-architecture-design/SKILL.md +176 -391
  22. package/.claude/skills/leniu-backend-annotations/SKILL.md +132 -519
  23. package/.claude/skills/leniu-brainstorm/SKILL.md +132 -541
  24. package/.claude/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
  25. package/.claude/skills/leniu-crud-development/SKILL.md +232 -938
  26. package/.claude/skills/leniu-crud-development/references/templates.md +597 -0
  27. package/.claude/skills/leniu-customization-location/SKILL.md +410 -0
  28. package/.claude/skills/leniu-data-permission/SKILL.md +70 -0
  29. package/.claude/skills/leniu-java-entity/SKILL.md +76 -590
  30. package/.claude/skills/leniu-java-entity/references/templates.md +237 -0
  31. package/.claude/skills/leniu-java-export/SKILL.md +94 -379
  32. package/.claude/skills/leniu-java-logging/SKILL.md +106 -709
  33. package/.claude/skills/leniu-java-logging/references/data-mask.md +46 -0
  34. package/.claude/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
  35. package/.claude/skills/leniu-java-mybatis/SKILL.md +73 -446
  36. package/.claude/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
  37. package/.claude/skills/leniu-report-customization/SKILL.md +111 -365
  38. package/.claude/skills/leniu-report-customization/references/table-fields.md +93 -0
  39. package/.claude/skills/leniu-report-standard-customization/SKILL.md +111 -334
  40. package/.claude/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
  41. package/.claude/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
  42. package/.claude/skills/leniu-security-guard/SKILL.md +133 -347
  43. package/.claude/skills/mysql-debug/SKILL.md +364 -0
  44. package/.claude/skills/openspec-apply-change/SKILL.md +10 -1
  45. package/.claude/skills/openspec-archive-change/SKILL.md +9 -1
  46. package/.claude/skills/openspec-bulk-archive-change/SKILL.md +9 -1
  47. package/.claude/skills/openspec-continue-change/SKILL.md +9 -1
  48. package/.claude/skills/openspec-explore/SKILL.md +10 -1
  49. package/.claude/skills/openspec-ff-change/SKILL.md +9 -1
  50. package/.claude/skills/openspec-new-change/SKILL.md +9 -1
  51. package/.claude/skills/openspec-onboard/SKILL.md +15 -130
  52. package/.claude/skills/openspec-sync-specs/SKILL.md +9 -1
  53. package/.claude/skills/openspec-verify-change/SKILL.md +9 -1
  54. package/.claude/skills/performance-doctor/SKILL.md +110 -434
  55. package/.claude/skills/redis-cache/SKILL.md +89 -595
  56. package/.claude/skills/redis-cache/references/listeners.md +23 -0
  57. package/.claude/skills/scheduled-jobs/SKILL.md +88 -407
  58. package/.claude/skills/security-guard/SKILL.md +137 -532
  59. package/.claude/skills/security-guard/references/encrypt-config.md +103 -0
  60. package/.claude/skills/security-guard/references/sensitive-strategies.md +42 -0
  61. package/.claude/skills/sms-mail/SKILL.md +116 -574
  62. package/.claude/skills/sms-mail/references/mail-config.md +88 -0
  63. package/.claude/skills/sms-mail/references/sms-config.md +74 -0
  64. package/.claude/skills/social-login/SKILL.md +112 -514
  65. package/.claude/skills/social-login/references/provider-configs.md +118 -0
  66. package/.claude/skills/tenant-management/SKILL.md +129 -444
  67. package/.claude/skills/tenant-management/references/tenant-scenarios.md +91 -0
  68. package/.claude/skills/test-development/SKILL.md +86 -540
  69. package/.claude/skills/test-development/references/parameterized-examples.md +119 -0
  70. package/.claude/skills/utils-toolkit/SKILL.md +52 -305
  71. package/.claude/skills/utils-toolkit/references/redis-utils-api.md +56 -0
  72. package/.claude/skills/websocket-sse/SKILL.md +105 -550
  73. package/.claude/skills/workflow-engine/SKILL.md +147 -502
  74. package/.codex/skills/add-skill/SKILL.md +79 -32
  75. package/.codex/skills/api-development/SKILL.md +172 -599
  76. package/.codex/skills/architecture-design/SKILL.md +138 -504
  77. package/.codex/skills/backend-annotations/SKILL.md +134 -496
  78. package/.codex/skills/banana-image/SKILL.md +10 -3
  79. package/.codex/skills/brainstorm/SKILL.md +103 -535
  80. package/.codex/skills/bug-detective/SKILL.md +147 -1097
  81. package/.codex/skills/bug-detective/references/error-patterns.md +242 -0
  82. package/.codex/skills/code-patterns/SKILL.md +120 -282
  83. package/.codex/skills/code-patterns/references/leniu-code-patterns.md +87 -0
  84. package/.codex/skills/crud-development/SKILL.md +64 -292
  85. package/.codex/skills/data-permission/SKILL.md +108 -407
  86. package/.codex/skills/data-permission/references/custom-data-scope.md +90 -0
  87. package/.codex/skills/database-ops/SKILL.md +8 -154
  88. package/.codex/skills/error-handler/SKILL.md +10 -0
  89. package/.codex/skills/file-oss-management/SKILL.md +106 -714
  90. package/.codex/skills/file-oss-management/references/entities.md +105 -0
  91. package/.codex/skills/file-oss-management/references/service-impl.md +104 -0
  92. package/.codex/skills/git-workflow/SKILL.md +27 -5
  93. package/.codex/skills/leniu-api-development/SKILL.md +142 -626
  94. package/.codex/skills/leniu-api-development/references/real-examples.md +273 -0
  95. package/.codex/skills/leniu-architecture-design/SKILL.md +176 -391
  96. package/.codex/skills/leniu-backend-annotations/SKILL.md +132 -519
  97. package/.codex/skills/leniu-brainstorm/SKILL.md +132 -541
  98. package/.codex/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
  99. package/.codex/skills/leniu-crud-development/SKILL.md +232 -938
  100. package/.codex/skills/leniu-crud-development/references/templates.md +597 -0
  101. package/.codex/skills/leniu-customization-location/SKILL.md +410 -0
  102. package/.codex/skills/leniu-data-permission/SKILL.md +70 -0
  103. package/.codex/skills/leniu-java-code-style/SKILL.md +510 -0
  104. package/.codex/skills/leniu-java-entity/SKILL.md +76 -590
  105. package/.codex/skills/leniu-java-entity/references/templates.md +237 -0
  106. package/.codex/skills/leniu-java-export/SKILL.md +94 -379
  107. package/.codex/skills/leniu-java-logging/SKILL.md +106 -709
  108. package/.codex/skills/leniu-java-logging/references/data-mask.md +46 -0
  109. package/.codex/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
  110. package/.codex/skills/leniu-java-mybatis/SKILL.md +73 -446
  111. package/.codex/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
  112. package/.codex/skills/leniu-report-customization/SKILL.md +111 -365
  113. package/.codex/skills/leniu-report-customization/references/table-fields.md +93 -0
  114. package/.codex/skills/leniu-report-standard-customization/SKILL.md +111 -334
  115. package/.codex/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
  116. package/.codex/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
  117. package/.codex/skills/leniu-security-guard/SKILL.md +133 -347
  118. package/.codex/skills/mysql-debug/SKILL.md +364 -0
  119. package/.codex/skills/openspec-apply-change/SKILL.md +10 -1
  120. package/.codex/skills/openspec-archive-change/SKILL.md +9 -1
  121. package/.codex/skills/openspec-bulk-archive-change/SKILL.md +9 -1
  122. package/.codex/skills/openspec-continue-change/SKILL.md +9 -1
  123. package/.codex/skills/openspec-explore/SKILL.md +10 -1
  124. package/.codex/skills/openspec-ff-change/SKILL.md +9 -1
  125. package/.codex/skills/openspec-new-change/SKILL.md +9 -1
  126. package/.codex/skills/openspec-onboard/SKILL.md +15 -130
  127. package/.codex/skills/openspec-sync-specs/SKILL.md +9 -1
  128. package/.codex/skills/openspec-verify-change/SKILL.md +9 -1
  129. package/.codex/skills/performance-doctor/SKILL.md +110 -434
  130. package/.codex/skills/project-navigator/SKILL.md +20 -1
  131. package/.codex/skills/redis-cache/SKILL.md +93 -589
  132. package/.codex/skills/redis-cache/references/listeners.md +23 -0
  133. package/.codex/skills/scheduled-jobs/SKILL.md +88 -407
  134. package/.codex/skills/security-guard/SKILL.md +141 -527
  135. package/.codex/skills/security-guard/references/encrypt-config.md +103 -0
  136. package/.codex/skills/security-guard/references/sensitive-strategies.md +42 -0
  137. package/.codex/skills/sms-mail/SKILL.md +116 -574
  138. package/.codex/skills/sms-mail/references/mail-config.md +88 -0
  139. package/.codex/skills/sms-mail/references/sms-config.md +74 -0
  140. package/.codex/skills/social-login/SKILL.md +112 -514
  141. package/.codex/skills/social-login/references/provider-configs.md +118 -0
  142. package/.codex/skills/store-pc/SKILL.md +258 -383
  143. package/.codex/skills/tenant-management/SKILL.md +129 -444
  144. package/.codex/skills/tenant-management/references/tenant-scenarios.md +91 -0
  145. package/.codex/skills/test-development/SKILL.md +86 -540
  146. package/.codex/skills/test-development/references/parameterized-examples.md +119 -0
  147. package/.codex/skills/ui-pc/SKILL.md +350 -387
  148. package/.codex/skills/utils-toolkit/SKILL.md +52 -283
  149. package/.codex/skills/utils-toolkit/references/redis-utils-api.md +56 -0
  150. package/.codex/skills/websocket-sse/SKILL.md +105 -550
  151. package/.codex/skills/workflow-engine/SKILL.md +147 -502
  152. package/.cursor/hooks.json +3 -3
  153. package/.cursor/skills/add-skill/SKILL.md +79 -32
  154. package/.cursor/skills/api-development/SKILL.md +83 -377
  155. package/.cursor/skills/architecture-design/SKILL.md +138 -632
  156. package/.cursor/skills/backend-annotations/SKILL.md +134 -506
  157. package/.cursor/skills/banana-image/SKILL.md +10 -3
  158. package/.cursor/skills/brainstorm/SKILL.md +103 -535
  159. package/.cursor/skills/bug-detective/SKILL.md +147 -1097
  160. package/.cursor/skills/bug-detective/references/error-patterns.md +242 -0
  161. package/.cursor/skills/code-patterns/SKILL.md +116 -426
  162. package/.cursor/skills/code-patterns/references/leniu-code-patterns.md +87 -0
  163. package/.cursor/skills/crud-development/SKILL.md +64 -304
  164. package/.cursor/skills/data-permission/SKILL.md +105 -412
  165. package/.cursor/skills/data-permission/references/custom-data-scope.md +90 -0
  166. package/.cursor/skills/file-oss-management/SKILL.md +106 -714
  167. package/.cursor/skills/file-oss-management/references/entities.md +105 -0
  168. package/.cursor/skills/file-oss-management/references/service-impl.md +104 -0
  169. package/.cursor/skills/git-workflow/SKILL.md +27 -5
  170. package/.cursor/skills/leniu-api-development/SKILL.md +142 -626
  171. package/.cursor/skills/leniu-api-development/references/real-examples.md +273 -0
  172. package/.cursor/skills/leniu-architecture-design/SKILL.md +176 -391
  173. package/.cursor/skills/leniu-backend-annotations/SKILL.md +132 -519
  174. package/.cursor/skills/leniu-brainstorm/SKILL.md +132 -541
  175. package/.cursor/skills/leniu-brainstorm/references/business-scenarios.md +162 -0
  176. package/.cursor/skills/leniu-crud-development/SKILL.md +232 -938
  177. package/.cursor/skills/leniu-crud-development/references/templates.md +597 -0
  178. package/.cursor/skills/leniu-customization-location/SKILL.md +410 -0
  179. package/.cursor/skills/leniu-data-permission/SKILL.md +70 -0
  180. package/.cursor/skills/leniu-java-code-style/SKILL.md +510 -0
  181. package/.cursor/skills/leniu-java-entity/SKILL.md +76 -590
  182. package/.cursor/skills/leniu-java-entity/references/templates.md +237 -0
  183. package/.cursor/skills/leniu-java-export/SKILL.md +94 -379
  184. package/.cursor/skills/leniu-java-logging/SKILL.md +106 -709
  185. package/.cursor/skills/leniu-java-logging/references/data-mask.md +46 -0
  186. package/.cursor/skills/leniu-java-logging/references/logging-scenarios.md +113 -0
  187. package/.cursor/skills/leniu-java-mybatis/SKILL.md +73 -446
  188. package/.cursor/skills/leniu-java-mybatis/references/report-mapper.md +88 -0
  189. package/.cursor/skills/leniu-report-customization/SKILL.md +111 -365
  190. package/.cursor/skills/leniu-report-customization/references/table-fields.md +93 -0
  191. package/.cursor/skills/leniu-report-standard-customization/SKILL.md +111 -334
  192. package/.cursor/skills/leniu-report-standard-customization/references/analysis-module.md +64 -0
  193. package/.cursor/skills/leniu-report-standard-customization/references/table-fields.md +113 -0
  194. package/.cursor/skills/leniu-security-guard/SKILL.md +133 -347
  195. package/.cursor/skills/mysql-debug/SKILL.md +364 -0
  196. package/.cursor/skills/openspec-apply-change/SKILL.md +10 -1
  197. package/.cursor/skills/openspec-archive-change/SKILL.md +9 -1
  198. package/.cursor/skills/openspec-bulk-archive-change/SKILL.md +9 -1
  199. package/.cursor/skills/openspec-continue-change/SKILL.md +9 -1
  200. package/.cursor/skills/openspec-explore/SKILL.md +10 -1
  201. package/.cursor/skills/openspec-ff-change/SKILL.md +9 -1
  202. package/.cursor/skills/openspec-new-change/SKILL.md +9 -1
  203. package/.cursor/skills/openspec-onboard/SKILL.md +15 -130
  204. package/.cursor/skills/openspec-sync-specs/SKILL.md +9 -1
  205. package/.cursor/skills/openspec-verify-change/SKILL.md +9 -1
  206. package/.cursor/skills/performance-doctor/SKILL.md +110 -434
  207. package/.cursor/skills/redis-cache/SKILL.md +89 -595
  208. package/.cursor/skills/redis-cache/references/listeners.md +23 -0
  209. package/.cursor/skills/scheduled-jobs/SKILL.md +88 -407
  210. package/.cursor/skills/security-guard/SKILL.md +137 -532
  211. package/.cursor/skills/security-guard/references/encrypt-config.md +103 -0
  212. package/.cursor/skills/security-guard/references/sensitive-strategies.md +42 -0
  213. package/.cursor/skills/sms-mail/SKILL.md +116 -574
  214. package/.cursor/skills/sms-mail/references/mail-config.md +88 -0
  215. package/.cursor/skills/sms-mail/references/sms-config.md +74 -0
  216. package/.cursor/skills/social-login/SKILL.md +112 -514
  217. package/.cursor/skills/social-login/references/provider-configs.md +118 -0
  218. package/.cursor/skills/tenant-management/SKILL.md +129 -444
  219. package/.cursor/skills/tenant-management/references/tenant-scenarios.md +91 -0
  220. package/.cursor/skills/test-development/SKILL.md +86 -540
  221. package/.cursor/skills/test-development/references/parameterized-examples.md +119 -0
  222. package/.cursor/skills/utils-toolkit/SKILL.md +52 -305
  223. package/.cursor/skills/utils-toolkit/references/redis-utils-api.md +56 -0
  224. package/.cursor/skills/websocket-sse/SKILL.md +105 -550
  225. package/.cursor/skills/workflow-engine/SKILL.md +147 -502
  226. package/package.json +1 -1
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: leniu-report-customization
3
3
  description: |
4
- leniu-tengyun-core 项目定制报表开发指南。基于 report_order_info / report_order_detail / report_account_flow 等报表基础表实现汇总报表。
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 定制报表开发指南(v5.29+版包含5.29)
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
- 本项目(v5.29)的定制报表基于**报表基础表**(由 MQ 消息写入)进行二次汇总。核心数据源有两类:
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
- > **关键**:v5.29 后,正向下单和逆向退款的数据**都存在这张表中**,通过 `consumeType` 区分。
103
-
104
- | 字段 | 类型 | 说明 |
105
- |------|------|------|
106
- | `orderId` | Long | 主键。正向=订单ID,退款=退款单ID |
107
- | `relationOrderId` | Long | 关联订单ID(退款记录指向原始订单) |
108
- | `consumeType` | Integer | **1=消费,2=退款** |
109
- | `orderRefundState` | Integer | **1=未退单,2=已退单(全退),3=部分退单** |
110
- | `payableAmount` | BigDecimal | 应付金额(分) |
111
- | `realAmount` | BigDecimal | 实付金额(分) |
112
- | `refundAmount` | BigDecimal | 累计退款金额(分) |
113
- | `realRefundAmount` | BigDecimal | 实际退款金额(分,退款记录为负数) |
114
- | `walletAmount` | BigDecimal | 个人钱包支付金额(分) |
115
- | `subsidyAmount` | BigDecimal | 补贴钱包支付金额(分) |
116
- | `redEnvelopeAmount` | BigDecimal | 红包支付金额(分) |
117
- | `accPayAmount` | BigDecimal | 账户支付金额(分) |
118
- | `outPayAmount` | BigDecimal | 外部支付金额(分) |
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、redEnvelopeAmount 都乘以 -1)
89
+ 金额字段全部为负数(realRefundAmount、walletAmount、subsidyAmount 都乘以 -1)
204
90
  payTime = 退款审核时间(checkTime)
205
91
  ```
206
92
 
207
- ### 3.2 orderRefundState 的三种状态
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
- -- 净消费金额 = SUM(所有记录的 realAmount)
223
- -- 因为:consumeType=1 的 realAmount 为正,consumeType=2 的相关金额为负
224
- SELECT
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.4 report_order_detail 的退款处理
118
+ ### 3.3 菜品级别退款
260
119
 
261
120
  ```
262
- detailState=1(正常):quantity 为原始购买数量
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
- | 11 | RECHARGE_GIFT | 赠送 | 正(收入) |
288
- | 12 | REVOKE_RECHARGE_GIFT | 撤销赠送 | **负** |
289
- | 20 | SUBSIDY | 补贴 | 正(收入) |
290
- | 30 | WITHDRAW | 提现 | **负** |
291
- | 40 | REVOKE_RECHARGE | 撤销充值 | **负** |
292
- | 50 | REVOKE_SUBSIDY | 撤销补贴 | **负** |
293
- | 60 | TRANSFER_OUT | 转出 | **负** |
294
- | 70 | TRANSFER_IN | 转入 | 正(收入) |
295
- | 80 | FREEZE | 冻结 | **负** |
296
- | 90 | UN_FREEZE | 解冻 | 正(收入) |
297
- | 100 | CLEAR | 补贴清空 | **负** |
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
- // report_account_flow_detail 过滤
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
- public int getOrder() {
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
- * fix 方法(数据修复/重新统计)
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 (Map.Entry<String, List<ReportOrderConsumeDTO>> entry : grouped.entrySet()) {
388
- List<ReportOrderConsumeDTO> items = entry.getValue();
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(insertList)) {
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
- startTime.toLocalDate(), endTime.toLocalDate()));
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
- #{id}, <!-- 或用数据库函数生成 -->
445
- DATE(pay_time) AS statistic_date,
446
- canteen_id,
447
- canteen_name,
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
- ### 6.1 三并行 CompletableFuture 模式
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
- ```java
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
- CompletableFuture<XxxTotalVO> totalFuture = CompletableFuture.supplyAsync(() ->
474
- mapper.selectTotal(param));
256
+ ## 七、查询接口标准模式(三并行 CompletableFuture
475
257
 
476
- CompletableFuture.allOf(countFuture, listFuture, totalFuture).join();
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(countFuture.join());
480
- pageVO.setList(listFuture.join());
481
- pageVO.setTotalLine(totalFuture.join()); // 合计行
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
- ```java
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
- ### 7.3 退款在账户流水中的体现
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
- - [ ] 汇总表包含分组维度字段(statisticDate、canteenId、stallId 等)
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`(或 `ReportAccountConsumeService`)接口
547
- - [ ] 设置合理的 `getOrder()` 值(10-29 普通汇总,30+ 菜品汇总)
548
- - [ ] 实现 `batchConsume()` — 分组 → 查存量 → 累加/新建
549
- - [ ] 实现 `fix()` — 先删后插,从基础表重新聚合
300
+ - [ ] 实现 `ReportOrderConsumeService`(或 Account 版本),设置 `getOrder()`
301
+ - [ ] `batchConsume()` 分组 → 查存量 → 累加/新建
302
+ - [ ] `fix()` — 先删后插,从基础表重新聚合
550
303
 
551
304
  ### 退款处理
552
- - [ ] 确认是否需要处理退款数据
553
305
  - [ ] 选择退款计算方式(直接 SUM 负数 / 分别统计 / 排除全退)
554
- - [ ] 菜品级别退款需关注 `detailState` 和 `goodsRefundNum`
306
+ - [ ] 菜品退款关注 `detailState` 和 `goodsRefundNum`
555
307
 
556
308
  ### 查询接口
557
- - [ ] 分页 + 合计行模式(PageVO + TotalVO
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
- - 如果是 CRUD 增删改查开发(非报表),请使用 `leniu-crud-development`
586
- - 如果涉及 MyBatis XML 编写规范,请使用 `leniu-java-mybatis`
587
- - 如果涉及报表查询入参 Param 类设计,请使用 `leniu-java-report-query-param`
588
- - 如果涉及合计行实现,请使用 `leniu-java-total-line`
589
- - 如果涉及餐次过滤,请使用 `leniu-mealtime`
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`