ai-engineering-init 1.3.3 → 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 +4 -1
- package/.claude/settings.json +3 -3
- package/.claude/skills/add-skill/SKILL.md +252 -116
- 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 -325
- package/.claude/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.claude/skills/leniu-report-standard-customization/SKILL.md +328 -0
- 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 +252 -116
- 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 -325
- package/.codex/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.codex/skills/leniu-report-standard-customization/SKILL.md +328 -0
- 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/rules/skill-activation.mdc +2 -0
- package/.cursor/skills/add-skill/SKILL.md +252 -116
- 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 -325
- package/.cursor/skills/leniu-report-customization/references/table-fields.md +93 -0
- package/.cursor/skills/leniu-report-standard-customization/SKILL.md +328 -0
- 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/AGENTS.md +1 -0
- 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
|
- 基于订单数据实现定制汇总报表
|
|
@@ -15,14 +15,14 @@ description: |
|
|
|
15
15
|
|
|
16
16
|
# leniu 定制报表开发指南
|
|
17
17
|
|
|
18
|
+
> 详细字段说明见 `references/table-fields.md`
|
|
19
|
+
|
|
18
20
|
## 概述
|
|
19
21
|
|
|
20
|
-
|
|
22
|
+
定制报表基于**报表基础表**(由 MQ 消息写入)进行二次汇总:
|
|
21
23
|
1. **订单类**:`report_order_info` + `report_order_detail`(消费/退款数据)
|
|
22
24
|
2. **账户流水类**:`report_account_flow` + `report_account_flow_detail`(钱包变动数据)
|
|
23
25
|
|
|
24
|
-
定制报表的本质是:从基础表中按维度聚合数据,写入自定义汇总表。
|
|
25
|
-
|
|
26
26
|
---
|
|
27
27
|
|
|
28
28
|
## 一、报表系统架构
|
|
@@ -55,99 +55,27 @@ Redis 计数器 `ORDER_REPORT_COUNT_KEY:{merchantId}`,每来一条 MQ 消息
|
|
|
55
55
|
|
|
56
56
|
---
|
|
57
57
|
|
|
58
|
-
##
|
|
58
|
+
## 二、核心基础表概要
|
|
59
59
|
|
|
60
60
|
### 2.1 report_order_info(报表订单主表)
|
|
61
61
|
|
|
62
|
-
>
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
| `payTime` | LocalDateTime | 支付时间(退款=审核时间) |
|
|
80
|
-
| `orderTime` | LocalDateTime | 下单时间 |
|
|
81
|
-
| `orderDate` | LocalDate | 就餐日期 |
|
|
82
|
-
| `status` | Integer | 消费状态:0=未消费,1=已消费 |
|
|
83
|
-
| `mealtimeType` | Integer | 餐次类型 |
|
|
84
|
-
| `orderType` | Integer | 订单类型(1当餐/2预订/3报餐/4扫码/5餐桌/6自助/11商城/12超市/21补扣/22外部) |
|
|
85
|
-
| `canteenId/canteenName` | Long/String | 食堂 |
|
|
86
|
-
| `stallId/stallName` | Long/String | 档口 |
|
|
87
|
-
| `areaId/areaName` | Long/String | 区域 |
|
|
88
|
-
| `custId/custName/custNum` | - | 用户信息 |
|
|
89
|
-
| `orgId/orgFullId/orgName/orgFullName` | - | 组织信息 |
|
|
90
|
-
| `payType` | Integer | 支付方式 |
|
|
91
|
-
| `payChannel` | Integer | 支付渠道 |
|
|
92
|
-
| `nuClearMode` | Integer | 核身方式(1刷卡/2刷脸/3扫码) |
|
|
93
|
-
| `sourceType` | Integer | 来源类型 |
|
|
94
|
-
| `ifOnline` | Integer | 是否在线订单(1是/2否) |
|
|
95
|
-
| `psnType/psnTypeName` | Integer/String | 用户类别 |
|
|
96
|
-
| `personType` | Integer | 人员归类(1职工/2患者/3陪护/4其他,医院版) |
|
|
97
|
-
|
|
98
|
-
### 2.2 report_order_detail(报表订单菜品明细表)
|
|
99
|
-
|
|
100
|
-
| 字段 | 类型 | 说明 |
|
|
101
|
-
|------|------|------|
|
|
102
|
-
| `detailId` | Long | 明细主键 |
|
|
103
|
-
| `orderId` | Long | 关联订单ID |
|
|
104
|
-
| `goodsDishesId/goodsDishesName` | Long/String | 菜品信息 |
|
|
105
|
-
| `salePrice` | BigDecimal | 售卖价格(分) |
|
|
106
|
-
| `prefPrice` | BigDecimal | 优惠价格(分) |
|
|
107
|
-
| `price` | BigDecimal | 计算价格(分,最终价格) |
|
|
108
|
-
| `quantity` | Integer | 数量/重量 |
|
|
109
|
-
| `totalAmount` | BigDecimal | 订单详情总金额(分) |
|
|
110
|
-
| `realAmount` | BigDecimal | 实际付款金额(分) |
|
|
111
|
-
| `detailState` | Integer | **1=正常,2=已退菜(全退),3=部分退菜** |
|
|
112
|
-
| `goodsRefundNum` | Integer | 商品已退数量 |
|
|
113
|
-
| `refundAmount` | BigDecimal | 商品退款金额(分) |
|
|
114
|
-
| `detailType` | Integer | 明细类别(1菜品/2套餐/3商品/4按键/5补扣/6报餐) |
|
|
115
|
-
| `costPrice` | BigDecimal | 成本价格 |
|
|
116
|
-
|
|
117
|
-
### 2.3 report_account_flow(账户变动流水主表)
|
|
118
|
-
|
|
119
|
-
| 字段 | 类型 | 说明 |
|
|
120
|
-
|------|------|------|
|
|
121
|
-
| `flowId` | Long | 主键(雪花ID) |
|
|
122
|
-
| `custId` | Long | 人员ID |
|
|
123
|
-
| `flowType` | Integer | 交易类型(AccTradeTypeEnum) |
|
|
124
|
-
| `flowRealAmount` | BigDecimal | 实际交易金额 |
|
|
125
|
-
| `flowAmount` | BigDecimal | 交易金额 |
|
|
126
|
-
| `accTotalBal` | BigDecimal | 所有钱包可用余额之和(不含冻结) |
|
|
127
|
-
| `accAllBal` | BigDecimal | 所有钱包总余额(含冻结) |
|
|
128
|
-
| `payTime` | LocalDateTime | 支付时间 |
|
|
129
|
-
| `ordTime` | LocalDateTime | 订单时间 |
|
|
130
|
-
| `status` | Integer | 消费状态:0=未消费,1=已消费 |
|
|
131
|
-
| `manageCost` | BigDecimal | 管理费 |
|
|
132
|
-
| `rechargeSource` | Integer | 充值来源 |
|
|
133
|
-
| `payChannel` | Integer | 支付渠道 |
|
|
134
|
-
| `payType` | Integer | 支付方式 |
|
|
135
|
-
|
|
136
|
-
> 注意:`custName`、`mobile`、`mobileSuffix` 使用 SM4 加密存储。
|
|
137
|
-
|
|
138
|
-
### 2.4 report_account_flow_detail(账户流水钱包明细表)
|
|
139
|
-
|
|
140
|
-
| 字段 | 类型 | 说明 |
|
|
141
|
-
|------|------|------|
|
|
142
|
-
| `id` | Long | 自增主键 |
|
|
143
|
-
| `flowId` | Long | 关联主流水 |
|
|
144
|
-
| `walletId` | Long | 钱包类型(AccWalletIdEnum) |
|
|
145
|
-
| `flowType` | Integer | 交易类型 |
|
|
146
|
-
| `amount` | BigDecimal | 本钱包支付金额(转出类型取负值) |
|
|
147
|
-
| `walletBal` | BigDecimal | 本钱包可用余额 |
|
|
148
|
-
| `allWalletBal` | BigDecimal | 本钱包总余额(含冻结) |
|
|
149
|
-
| `frozenBalance` | BigDecimal | 冻结余额 |
|
|
150
|
-
| `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`
|
|
151
79
|
|
|
152
80
|
---
|
|
153
81
|
|
|
@@ -155,74 +83,42 @@ Redis 计数器 `ORDER_REPORT_COUNT_KEY:{merchantId}`,每来一条 MQ 消息
|
|
|
155
83
|
|
|
156
84
|
### 3.1 退款数据在 report_order_info 中的表现
|
|
157
85
|
|
|
158
|
-
退款记录作为**独立行**写入 `report_order_info`:
|
|
159
|
-
|
|
160
86
|
```
|
|
161
87
|
正向订单:orderId=订单ID, consumeType=1, orderRefundState=1
|
|
162
88
|
退款记录:orderId=退款单ID, consumeType=2, relationOrderId=原始订单ID
|
|
163
|
-
金额字段全部为负数(realRefundAmount、walletAmount、subsidyAmount
|
|
89
|
+
金额字段全部为负数(realRefundAmount、walletAmount、subsidyAmount 都乘以 -1)
|
|
164
90
|
payTime = 退款审核时间(checkTime)
|
|
165
91
|
```
|
|
166
92
|
|
|
167
|
-
### 3.2
|
|
168
|
-
|
|
169
|
-
| 值 | 含义 | 说明 |
|
|
170
|
-
|----|------|------|
|
|
171
|
-
| 1 | 未退单 | 正常消费,无退款 |
|
|
172
|
-
| 2 | 已退单(全退) | 整单退款 |
|
|
173
|
-
| 3 | 部分退单 | 部分菜品退款 |
|
|
93
|
+
### 3.2 净消费金额计算(3种方式)
|
|
174
94
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
**方式一:直接利用 consumeType 和负数金额**(推荐)
|
|
178
|
-
|
|
179
|
-
因为退款记录的金额已经是负数,所以直接 SUM 即可得到净额:
|
|
95
|
+
**方式一:直接 SUM(推荐)** - 退款金额已为负数
|
|
180
96
|
|
|
181
97
|
```sql
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
SUM(real_amount) AS netAmount, -- 净实付
|
|
186
|
-
SUM(wallet_amount) AS netWalletAmount, -- 净个人钱包消费
|
|
187
|
-
SUM(subsidy_amount) AS netSubsidyAmount -- 净补贴消费
|
|
188
|
-
FROM report_order_info
|
|
189
|
-
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}
|
|
190
101
|
```
|
|
191
102
|
|
|
192
103
|
**方式二:分别统计消费和退款**
|
|
193
104
|
|
|
194
105
|
```sql
|
|
195
|
-
--
|
|
196
|
-
SELECT SUM(real_amount) FROM report_order_info
|
|
197
|
-
WHERE consume_type = 1
|
|
198
|
-
AND pay_time BETWEEN #{startTime} AND #{endTime}
|
|
199
|
-
|
|
200
|
-
-- 退款总额(仅退款记录,金额为负数,取绝对值)
|
|
201
|
-
SELECT SUM(ABS(real_refund_amount)) FROM report_order_info
|
|
202
|
-
WHERE consume_type = 2
|
|
203
|
-
AND pay_time BETWEEN #{startTime} AND #{endTime}
|
|
204
|
-
|
|
106
|
+
-- 消费总额(consumeType=1)/ 退款总额(consumeType=2,取ABS)
|
|
205
107
|
-- 净额 = 消费总额 - 退款总额
|
|
206
108
|
```
|
|
207
109
|
|
|
208
|
-
|
|
110
|
+
**方式三:排除全退订单**
|
|
209
111
|
|
|
210
112
|
```sql
|
|
211
|
-
-- 排除全退订单,只统计有效消费
|
|
212
113
|
SELECT SUM(real_amount - IFNULL(refund_amount, 0)) AS netAmount
|
|
213
114
|
FROM report_order_info
|
|
214
|
-
WHERE consume_type = 1
|
|
215
|
-
AND order_refund_state IN (1, 3) -- 未退单 + 部分退单
|
|
216
|
-
AND pay_time BETWEEN #{startTime} AND #{endTime}
|
|
115
|
+
WHERE consume_type = 1 AND order_refund_state IN (1, 3)
|
|
217
116
|
```
|
|
218
117
|
|
|
219
|
-
### 3.
|
|
118
|
+
### 3.3 菜品级别退款
|
|
220
119
|
|
|
221
120
|
```
|
|
222
|
-
detailState=1
|
|
223
|
-
detailState=2(已退菜全退):该菜品已完全退款
|
|
224
|
-
detailState=3(部分退菜):goodsRefundNum 为已退数量,refundAmount 为退款金额
|
|
225
|
-
|
|
121
|
+
detailState=1(正常)/ 2(全退)/ 3(部分退)
|
|
226
122
|
菜品净销量 = quantity - IFNULL(goods_refund_num, 0)
|
|
227
123
|
菜品净金额 = total_amount - IFNULL(refund_amount, 0)
|
|
228
124
|
```
|
|
@@ -231,7 +127,7 @@ detailState=3(部分退菜):goodsRefundNum 为已退数量,refundAmount
|
|
|
231
127
|
|
|
232
128
|
## 四、钱包与交易类型枚举
|
|
233
129
|
|
|
234
|
-
### 4.1 AccWalletIdEnum
|
|
130
|
+
### 4.1 AccWalletIdEnum
|
|
235
131
|
|
|
236
132
|
| key | 枚举 | 含义 |
|
|
237
133
|
|-----|------|------|
|
|
@@ -239,45 +135,26 @@ detailState=3(部分退菜):goodsRefundNum 为已退数量,refundAmount
|
|
|
239
135
|
| 2 | SUBSIDY | 补贴钱包 |
|
|
240
136
|
| 4 | LUCK_MONEY | 红包 |
|
|
241
137
|
|
|
242
|
-
### 4.2 AccTradeTypeEnum
|
|
243
|
-
|
|
244
|
-
| key | 枚举 |
|
|
245
|
-
|
|
246
|
-
| 10 | RECHARGE |
|
|
247
|
-
|
|
|
248
|
-
|
|
|
249
|
-
|
|
|
250
|
-
|
|
|
251
|
-
|
|
|
252
|
-
|
|
|
253
|
-
|
|
|
254
|
-
|
|
|
255
|
-
|
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
| 110 | CONSUME | 消费 | **负** |
|
|
259
|
-
| 120 | CONSUME_REPAIR | 消费补扣 | **负** |
|
|
260
|
-
| 130 | CONSUME_REFUND | 消费退款 | 正(收入) |
|
|
261
|
-
| 131 | CONSUME_WITHHOLD | 账户预扣 | **负** |
|
|
262
|
-
| 132 | CONSUME_WITHHOLD_REFUND | 账户预扣退款 | 正(收入) |
|
|
263
|
-
| 140 | LUCK_MONEY | 红包 | 正(收入) |
|
|
264
|
-
| 141 | REVOKE_LUCK_MONEY | 撤销红包 | **负** |
|
|
265
|
-
| 142 | CLEAR_LUCK_MONEY | 红包清空 | **负** |
|
|
266
|
-
|
|
267
|
-
> `getConvertFlag()` 方法标记了需要转为负数显示的类型。
|
|
268
|
-
|
|
269
|
-
### 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 账户流水常用过滤
|
|
270
154
|
|
|
271
155
|
```java
|
|
272
|
-
//
|
|
273
|
-
|
|
274
|
-
WHERE wallet_id = #{AccWalletIdEnum.WALLET.key} // 个人钱包
|
|
275
|
-
AND flow_type = #{AccTradeTypeEnum.CONSUME.key} // 消费类型
|
|
276
|
-
|
|
277
|
-
// 统计消费+退款净额
|
|
278
|
-
WHERE wallet_id = #{walletId}
|
|
279
|
-
AND flow_type IN (110, 130) // CONSUME + CONSUME_REFUND
|
|
280
|
-
// amount 字段:消费为负,退款为正 → SUM 即为净消费额(负值)
|
|
156
|
+
// 净消费额:消费为负,退款为正 → SUM 即为净消费额(负值)
|
|
157
|
+
WHERE wallet_id = #{walletId} AND flow_type IN (110, 130)
|
|
281
158
|
```
|
|
282
159
|
|
|
283
160
|
---
|
|
@@ -287,68 +164,37 @@ WHERE wallet_id = #{walletId}
|
|
|
287
164
|
### 5.1 实现 ReportOrderConsumeService 接口
|
|
288
165
|
|
|
289
166
|
```java
|
|
290
|
-
@Service
|
|
291
|
-
@Slf4j
|
|
167
|
+
@Service @Slf4j
|
|
292
168
|
public class ReportSumXxxService implements ReportOrderConsumeService {
|
|
169
|
+
@Override public int getOrder() { return 15; } // <10基础, 10-29汇总, 30+菜品
|
|
293
170
|
|
|
294
|
-
@Override
|
|
295
|
-
|
|
296
|
-
// < 10: 基础表(同步写入)
|
|
297
|
-
// >= 10 且 < 30: 普通汇总表(批量消费)
|
|
298
|
-
// >= 30: 菜品汇总表(需要 detail 数据)
|
|
299
|
-
return 15; // 自定义汇总表一般用 10-29
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
/**
|
|
303
|
-
* 单条消费(第一阶段,一般汇总表不用实现)
|
|
304
|
-
*/
|
|
305
|
-
@Override
|
|
306
|
-
public void consume(OrderChangePO payload, ReportOrderInfoDTO baseInfo) {
|
|
307
|
-
// 汇总表通常留空,仅基础表实现
|
|
171
|
+
@Override public void consume(OrderChangePO payload, ReportOrderInfoDTO baseInfo) {
|
|
172
|
+
// 汇总表通常留空
|
|
308
173
|
}
|
|
309
174
|
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
*/
|
|
313
|
-
@Override
|
|
314
|
-
public void batchConsume(List<ReportOrderConsumeDTO> list) {
|
|
315
|
-
// 1. 按分组维度聚合(日期+食堂+档口+...)
|
|
316
|
-
// 2. 查询汇总表是否已有记录
|
|
317
|
-
// - 不存在 → INSERT
|
|
318
|
-
// - 存在 → UPDATE(累加金额)
|
|
319
|
-
// 3. 批量写入
|
|
175
|
+
@Override public void batchConsume(List<ReportOrderConsumeDTO> list) {
|
|
176
|
+
// 分组 → 查存量 → 累加/新建(见下方模板)
|
|
320
177
|
}
|
|
321
178
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
*/
|
|
325
|
-
@Override
|
|
326
|
-
public void fix(ReportBaseParam param) {
|
|
327
|
-
// 1. 删除时间范围内的旧汇总数据
|
|
328
|
-
// 2. 从 report_order_info 重新聚合写入
|
|
179
|
+
@Override public void fix(ReportBaseParam param) {
|
|
180
|
+
// 先删后插,从基础表重新聚合
|
|
329
181
|
}
|
|
330
182
|
}
|
|
331
183
|
```
|
|
332
184
|
|
|
333
|
-
### 5.2 batchConsume
|
|
185
|
+
### 5.2 batchConsume 模板
|
|
334
186
|
|
|
335
187
|
```java
|
|
336
188
|
@Override
|
|
337
189
|
public void batchConsume(List<ReportOrderConsumeDTO> list) {
|
|
338
|
-
// 1. 构建分组 Key(按需选择维度)
|
|
339
190
|
Map<String, List<ReportOrderConsumeDTO>> grouped = list.stream()
|
|
340
191
|
.collect(Collectors.groupingBy(e ->
|
|
341
|
-
e.getStatisticDate() + "_" + e.getCanteenId() + "_" + e.getStallId()
|
|
342
|
-
));
|
|
343
|
-
|
|
344
|
-
List<ReportSumXxx> insertList = new ArrayList<>();
|
|
345
|
-
List<ReportSumXxx> updateList = new ArrayList<>();
|
|
192
|
+
e.getStatisticDate() + "_" + e.getCanteenId() + "_" + e.getStallId()));
|
|
346
193
|
|
|
347
|
-
|
|
348
|
-
List<ReportOrderConsumeDTO> items = entry.getValue();
|
|
349
|
-
ReportOrderConsumeDTO first = items.get(0);
|
|
194
|
+
List<ReportSumXxx> insertList = new ArrayList<>(), updateList = new ArrayList<>();
|
|
350
195
|
|
|
351
|
-
|
|
196
|
+
for (var entry : grouped.entrySet()) {
|
|
197
|
+
ReportOrderConsumeDTO first = entry.getValue().get(0);
|
|
352
198
|
ReportSumXxx existing = mapper.selectOne(Wrappers.<ReportSumXxx>lambdaQuery()
|
|
353
199
|
.eq(ReportSumXxx::getStatisticDate, first.getStatisticDate())
|
|
354
200
|
.eq(ReportSumXxx::getCanteenId, first.getCanteenId())
|
|
@@ -357,58 +203,39 @@ public void batchConsume(List<ReportOrderConsumeDTO> list) {
|
|
|
357
203
|
if (existing == null) {
|
|
358
204
|
ReportSumXxx record = new ReportSumXxx();
|
|
359
205
|
record.setId(Id.next());
|
|
360
|
-
//
|
|
361
|
-
// 累加金额字段...
|
|
206
|
+
// 设置维度 + 累加金额
|
|
362
207
|
insertList.add(record);
|
|
363
208
|
} else {
|
|
364
|
-
//
|
|
365
|
-
// existing.setXxxAmount(existing.getXxxAmount().add(deltaAmount));
|
|
209
|
+
// existing.setXxxAmount(existing.getXxxAmount().add(delta));
|
|
366
210
|
updateList.add(existing);
|
|
367
211
|
}
|
|
368
212
|
}
|
|
369
|
-
|
|
370
|
-
if (CollUtil.isNotEmpty(
|
|
371
|
-
// 批量插入
|
|
372
|
-
}
|
|
373
|
-
if (CollUtil.isNotEmpty(updateList)) {
|
|
374
|
-
// 批量更新
|
|
375
|
-
}
|
|
213
|
+
if (CollUtil.isNotEmpty(insertList)) { /* 批量插入 */ }
|
|
214
|
+
if (CollUtil.isNotEmpty(updateList)) { /* 批量更新 */ }
|
|
376
215
|
}
|
|
377
216
|
```
|
|
378
217
|
|
|
379
|
-
### 5.3 fix
|
|
218
|
+
### 5.3 fix 方法 + SQL 模板
|
|
380
219
|
|
|
381
220
|
```java
|
|
382
221
|
@Override
|
|
383
222
|
public void fix(ReportBaseParam param) {
|
|
384
|
-
LocalDateTime startTime = param.getStartTime();
|
|
385
|
-
LocalDateTime endTime = param.getEndTime();
|
|
386
|
-
|
|
387
|
-
// 1. 删除时间范围内的旧数据(先删后插)
|
|
388
223
|
mapper.delete(Wrappers.<ReportSumXxx>lambdaQuery()
|
|
389
224
|
.between(ReportSumXxx::getStatisticDate,
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
// 2. 从 report_order_info 聚合初始化(推荐用 SQL 直接聚合)
|
|
393
|
-
mapper.initFix(null, startTime, endTime);
|
|
225
|
+
param.getStartTime().toLocalDate(), param.getEndTime().toLocalDate()));
|
|
226
|
+
mapper.initFix(null, param.getStartTime(), param.getEndTime());
|
|
394
227
|
}
|
|
395
228
|
```
|
|
396
229
|
|
|
397
|
-
### 5.4 fix SQL 模板(MyBatis XML)
|
|
398
|
-
|
|
399
230
|
```xml
|
|
400
231
|
<insert id="initFix">
|
|
401
232
|
INSERT INTO report_sum_xxx (id, statistic_date, canteen_id, canteen_name,
|
|
402
233
|
order_count, consume_amount, refund_amount, net_amount)
|
|
403
|
-
SELECT
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
COUNT(*) AS order_count,
|
|
409
|
-
SUM(CASE WHEN consume_type = 1 THEN real_amount ELSE 0 END) AS consume_amount,
|
|
410
|
-
SUM(CASE WHEN consume_type = 2 THEN ABS(real_refund_amount) ELSE 0 END) AS refund_amount,
|
|
411
|
-
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))
|
|
412
239
|
FROM report_order_info
|
|
413
240
|
WHERE pay_time BETWEEN #{startTime} AND #{endTime}
|
|
414
241
|
GROUP BY DATE(pay_time), canteen_id, canteen_name
|
|
@@ -417,110 +244,73 @@ public void fix(ReportBaseParam param) {
|
|
|
417
244
|
|
|
418
245
|
---
|
|
419
246
|
|
|
420
|
-
##
|
|
421
|
-
|
|
422
|
-
### 6.1 三并行 CompletableFuture 模式
|
|
247
|
+
## 六、数据权限集成
|
|
423
248
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
mapper.selectCount(param));
|
|
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"/>`
|
|
429
253
|
|
|
430
|
-
|
|
431
|
-
mapper.selectPageList(param));
|
|
254
|
+
---
|
|
432
255
|
|
|
433
|
-
|
|
434
|
-
mapper.selectTotal(param));
|
|
256
|
+
## 七、查询接口标准模式(三并行 CompletableFuture)
|
|
435
257
|
|
|
436
|
-
|
|
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();
|
|
437
264
|
|
|
438
265
|
PageVO<XxxVO> pageVO = new PageVO<>();
|
|
439
|
-
pageVO.setTotal(
|
|
440
|
-
pageVO.setList(
|
|
441
|
-
pageVO.setTotalLine(
|
|
266
|
+
pageVO.setTotal(countF.join());
|
|
267
|
+
pageVO.setList(listF.join());
|
|
268
|
+
pageVO.setTotalLine(totalF.join());
|
|
442
269
|
return pageVO;
|
|
443
270
|
}
|
|
444
271
|
```
|
|
445
272
|
|
|
446
273
|
---
|
|
447
274
|
|
|
448
|
-
##
|
|
449
|
-
|
|
450
|
-
### 7.1 基于 report_account_flow 的汇总
|
|
275
|
+
## 八、账户流水汇总报表
|
|
451
276
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
```java
|
|
455
|
-
// 实现 ReportAccountConsumeService 接口(类似 ReportOrderConsumeService)
|
|
456
|
-
// batchConsume 从 report_account_flow 查 status=0 的数据
|
|
457
|
-
// fix 从 report_account_flow 重新聚合
|
|
458
|
-
```
|
|
459
|
-
|
|
460
|
-
### 7.2 常见统计维度
|
|
277
|
+
实现 `ReportAccountConsumeService` 接口(类似 ReportOrderConsumeService),数据源为 `report_account_flow`。
|
|
461
278
|
|
|
462
279
|
```sql
|
|
463
|
-
--
|
|
464
|
-
SELECT
|
|
465
|
-
d.wallet_id,
|
|
280
|
+
-- 按钱包类型统计消费/退款
|
|
281
|
+
SELECT d.wallet_id,
|
|
466
282
|
SUM(CASE WHEN d.flow_type = 110 THEN ABS(d.amount) ELSE 0 END) AS consume_amount,
|
|
467
283
|
SUM(CASE WHEN d.flow_type = 130 THEN d.amount ELSE 0 END) AS refund_amount
|
|
468
284
|
FROM report_account_flow f
|
|
469
285
|
JOIN report_account_flow_detail d ON f.flow_id = d.flow_id
|
|
470
286
|
WHERE f.pay_time BETWEEN #{startTime} AND #{endTime}
|
|
471
287
|
GROUP BY d.wallet_id
|
|
472
|
-
|
|
473
|
-
-- 按交易类型统计
|
|
474
|
-
SELECT
|
|
475
|
-
f.flow_type,
|
|
476
|
-
SUM(f.flow_real_amount) AS total_amount,
|
|
477
|
-
COUNT(*) AS total_count
|
|
478
|
-
FROM report_account_flow f
|
|
479
|
-
WHERE f.pay_time BETWEEN #{startTime} AND #{endTime}
|
|
480
|
-
GROUP BY f.flow_type
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
### 7.3 退款在账户流水中的体现
|
|
484
|
-
|
|
485
288
|
```
|
|
486
|
-
消费:flowType=110 (CONSUME),amount 为负
|
|
487
|
-
退款:flowType=130 (CONSUME_REFUND),amount 为正
|
|
488
289
|
|
|
489
|
-
|
|
490
|
-
或直接:ABS(SUM(flowType IN (110, 130) 的 amount))
|
|
491
|
-
```
|
|
290
|
+
流水退款:`flowType=110` amount 为负,`flowType=130` amount 为正,直接 SUM 即净额。
|
|
492
291
|
|
|
493
292
|
---
|
|
494
293
|
|
|
495
|
-
##
|
|
496
|
-
|
|
497
|
-
新建定制汇总报表时,逐项确认:
|
|
294
|
+
## 九、开发检查清单
|
|
498
295
|
|
|
499
296
|
### 建表
|
|
500
|
-
- [ ]
|
|
501
|
-
- [ ] 汇总表包含金额汇总字段(consumeAmount、refundAmount、netAmount 等)
|
|
502
|
-
- [ ] 审计字段(crby/crtime/upby/uptime/del_flag)
|
|
503
|
-
- [ ] 无 tenant_id(双库物理隔离)
|
|
297
|
+
- [ ] 分组维度字段 + 金额汇总字段 + 审计字段(crby/crtime/upby/uptime/del_flag),无 tenant_id
|
|
504
298
|
|
|
505
299
|
### 实现
|
|
506
|
-
- [ ] 实现 `ReportOrderConsumeService`(或 `
|
|
507
|
-
- [ ]
|
|
508
|
-
- [ ]
|
|
509
|
-
- [ ] 实现 `fix()` — 先删后插,从基础表重新聚合
|
|
300
|
+
- [ ] 实现 `ReportOrderConsumeService`(或 Account 版本),设置 `getOrder()`
|
|
301
|
+
- [ ] `batchConsume()` — 分组 → 查存量 → 累加/新建
|
|
302
|
+
- [ ] `fix()` — 先删后插,从基础表重新聚合
|
|
510
303
|
|
|
511
304
|
### 退款处理
|
|
512
|
-
- [ ] 确认是否需要处理退款数据
|
|
513
305
|
- [ ] 选择退款计算方式(直接 SUM 负数 / 分别统计 / 排除全退)
|
|
514
|
-
- [ ]
|
|
306
|
+
- [ ] 菜品退款关注 `detailState` 和 `goodsRefundNum`
|
|
515
307
|
|
|
516
308
|
### 查询接口
|
|
517
|
-
- [ ] 分页 +
|
|
518
|
-
- [ ] 三并行 CompletableFuture(count + list + total)
|
|
519
|
-
- [ ] 导出功能(如需要)
|
|
309
|
+
- [ ] 分页 + 合计行(PageVO + TotalVO)+ 三并行 CompletableFuture
|
|
520
310
|
|
|
521
311
|
---
|
|
522
312
|
|
|
523
|
-
##
|
|
313
|
+
## 十、关键代码位置
|
|
524
314
|
|
|
525
315
|
| 类型 | 路径 |
|
|
526
316
|
|------|------|
|
|
@@ -530,11 +320,7 @@ GROUP BY f.flow_type
|
|
|
530
320
|
| ConsumeService 接口 | `sys-canteen/.../report/statistics/config/mq/ReportOrderConsumeService.java` |
|
|
531
321
|
| 食堂汇总参考实现 | `sys-canteen/.../report/statistics/order/summary/service/ReportSumCanteenService.java` |
|
|
532
322
|
| Fix Controller | `sys-canteen/.../report/statistics/order/fix/controller/ReportFixController.java` |
|
|
533
|
-
| Fix Service | `sys-canteen/.../report/statistics/order/fix/service/ReportFixService.java` |
|
|
534
323
|
| ReportOrderInfo 实体 | `sys-canteen/.../report/statistics/order/basic/model/ReportOrderInfo.java` |
|
|
535
|
-
| ReportOrderDetail 实体 | `sys-canteen/.../report/statistics/order/basic/model/ReportOrderDetail.java` |
|
|
536
|
-
| ReportAccountFlow 实体 | `sys-canteen/.../report/statistics/account/model/ReportAccountFlow.java` |
|
|
537
|
-
| ReportAccountFlowDetail 实体 | `sys-canteen/.../report/statistics/account/model/ReportAccountFlowDetail.java` |
|
|
538
324
|
| AccTradeTypeEnum | `sys-canteen/.../account/v3/constants/AccTradeTypeEnum.java` |
|
|
539
325
|
| AccWalletIdEnum | `sys-canteen/.../account/v3/constants/AccWalletIdEnum.java` |
|
|
540
326
|
|
|
@@ -542,8 +328,8 @@ GROUP BY f.flow_type
|
|
|
542
328
|
|
|
543
329
|
## 注意
|
|
544
330
|
|
|
545
|
-
-
|
|
546
|
-
-
|
|
547
|
-
-
|
|
548
|
-
-
|
|
549
|
-
-
|
|
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`
|