Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| af2422c114 | |||
| 7a94145819 | |||
| 7e4035e0ae | |||
| e19324d0ef | |||
| e0e707edcb | |||
| 8ab528a74b | |||
| de7a359ead |
@@ -0,0 +1,452 @@
|
|||||||
|
# 数据统计模块 API 文档
|
||||||
|
|
||||||
|
> **文档版本**: v1.0
|
||||||
|
> **创建日期**: 2026-06-09
|
||||||
|
> **作者**: system
|
||||||
|
> **状态**: 正式发布
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 📋 目录
|
||||||
|
|
||||||
|
1. [概述](#概述)
|
||||||
|
2. [基础路径](#基础路径)
|
||||||
|
3. [统计数据接口](#统计数据接口)
|
||||||
|
- [获取综合统计数据](#获取综合统计数据)
|
||||||
|
- [获取会员统计数据](#获取会员统计数据)
|
||||||
|
- [获取预约统计数据](#获取预约统计数据)
|
||||||
|
- [获取签到统计数据](#获取签到统计数据)
|
||||||
|
- [查询历史统计数据](#查询历史统计数据)
|
||||||
|
- [导出统计数据](#导出统计数据)
|
||||||
|
4. [数据模型](#数据模型)
|
||||||
|
- [StatisticsQuery(查询条件)](#StatisticsQuery查询条件)
|
||||||
|
- [StatisticsSummary(统计汇总)](#StatisticsSummary统计汇总)
|
||||||
|
- [MemberStatistics(会员统计)](#MemberStatistics会员统计)
|
||||||
|
- [BookingStatistics(预约统计)](#BookingStatistics预约统计)
|
||||||
|
- [SignInStatistics(签到统计)](#SignInStatistics签到统计)
|
||||||
|
5. [状态码说明](#状态码说明)
|
||||||
|
6. [业务规则](#业务规则)
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 概述
|
||||||
|
|
||||||
|
数据统计模块提供健身房会员、预约、签到数据的统计功能,支持按日、周、月周期统计,并提供Excel导出功能。采用 Spring WebFlux 响应式编程,统计结果通过 Redis 缓存提高查询性能。
|
||||||
|
|
||||||
|
## 基础路径
|
||||||
|
|
||||||
|
所有接口的基础路径为: `http://{host}:{port}/api/datacount`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 统计数据接口
|
||||||
|
|
||||||
|
### 获取综合统计数据
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/datacount/summary` |
|
||||||
|
| **所属文件** | `DataStatisticsHandler.java` |
|
||||||
|
|
||||||
|
**请求参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||||
|
|--------|------|------|--------|------|
|
||||||
|
| statType | string | 否 | 空 | 统计类型筛选 |
|
||||||
|
| periodType | string | 否 | DAY | 统计周期:DAY/WEEK/MONTH |
|
||||||
|
| startTime | string | 否 | 自动计算 | 开始时间(ISO格式) |
|
||||||
|
| endTime | string | 否 | 自动计算 | 结束时间(ISO格式) |
|
||||||
|
|
||||||
|
**请求示例**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. 使用周期类型查询今日统计
|
||||||
|
GET /api/datacount/summary?periodType=DAY
|
||||||
|
|
||||||
|
# 2. 使用周期类型查询本周统计
|
||||||
|
GET /api/datacount/summary?periodType=WEEK
|
||||||
|
|
||||||
|
# 3. 使用周期类型查询本月统计
|
||||||
|
GET /api/datacount/summary?periodType=MONTH
|
||||||
|
|
||||||
|
# 4. 使用自定义时间范围查询
|
||||||
|
GET /api/datacount/summary?startTime=2026-06-01T00:00:00&endTime=2026-06-07T23:59:59
|
||||||
|
|
||||||
|
# 5. 带统计类型筛选
|
||||||
|
GET /api/datacount/summary?statType=member&periodType=WEEK
|
||||||
|
```
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"statDate": "2026-06-09",
|
||||||
|
"generatedAt": "2026-06-09T10:30:00",
|
||||||
|
"memberStatistics": {
|
||||||
|
"statDate": "2026-06-09",
|
||||||
|
"newMembers": 5,
|
||||||
|
"activeMembers": 120,
|
||||||
|
"totalMembers": 500,
|
||||||
|
"signInMembers": 85,
|
||||||
|
"bookingMembers": 45,
|
||||||
|
"cancelMembers": 5
|
||||||
|
},
|
||||||
|
"bookingStatistics": {
|
||||||
|
"statDate": "2026-06-09",
|
||||||
|
"totalBookings": 60,
|
||||||
|
"cancelBookings": 10,
|
||||||
|
"attendBookings": 45,
|
||||||
|
"absentBookings": 5,
|
||||||
|
"attendRate": 75.0,
|
||||||
|
"cancelRate": 16.67
|
||||||
|
},
|
||||||
|
"signInStatistics": {
|
||||||
|
"statDate": "2026-06-09",
|
||||||
|
"totalSignIns": 95,
|
||||||
|
"successSignIns": 92,
|
||||||
|
"failSignIns": 3,
|
||||||
|
"successRate": 96.84,
|
||||||
|
"signInTypeDistribution": {
|
||||||
|
"QR_CODE": 60,
|
||||||
|
"MANUAL": 25,
|
||||||
|
"FACE": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 获取会员统计数据
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/datacount/member` |
|
||||||
|
| **所属文件** | `DataStatisticsHandler.java` |
|
||||||
|
|
||||||
|
**请求参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||||
|
|--------|------|------|--------|------|
|
||||||
|
| periodType | string | 否 | DAY | 统计周期:DAY/WEEK/MONTH |
|
||||||
|
| startTime | string | 否 | 自动计算 | 开始时间 |
|
||||||
|
| endTime | string | 否 | 自动计算 | 结束时间 |
|
||||||
|
|
||||||
|
**请求示例**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. 查询今日会员统计
|
||||||
|
GET /api/datacount/member
|
||||||
|
|
||||||
|
# 2. 查询本周会员统计
|
||||||
|
GET /api/datacount/member?periodType=WEEK
|
||||||
|
|
||||||
|
# 3. 查询指定时间范围的会员统计
|
||||||
|
GET /api/datacount/member?startTime=2026-06-01T00:00:00&endTime=2026-06-30T23:59:59
|
||||||
|
```
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"statDate": "2026-06-09",
|
||||||
|
"newMembers": 5,
|
||||||
|
"activeMembers": 120,
|
||||||
|
"totalMembers": 500,
|
||||||
|
"signInMembers": 85,
|
||||||
|
"bookingMembers": 45,
|
||||||
|
"cancelMembers": 5
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 获取预约统计数据
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/datacount/booking` |
|
||||||
|
| **所属文件** | `DataStatisticsHandler.java` |
|
||||||
|
|
||||||
|
**请求参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||||
|
|--------|------|------|--------|------|
|
||||||
|
| periodType | string | 否 | DAY | 统计周期:DAY/WEEK/MONTH |
|
||||||
|
| startTime | string | 否 | 自动计算 | 开始时间 |
|
||||||
|
| endTime | string | 否 | 自动计算 | 结束时间 |
|
||||||
|
|
||||||
|
**请求示例**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. 查询今日预约统计
|
||||||
|
GET /api/datacount/booking
|
||||||
|
|
||||||
|
# 2. 查询本月预约统计
|
||||||
|
GET /api/datacount/booking?periodType=MONTH
|
||||||
|
|
||||||
|
# 3. 查询指定日期范围的预约统计
|
||||||
|
GET /api/datacount/booking?startTime=2026-06-01T00:00:00&endTime=2026-06-15T23:59:59
|
||||||
|
```
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"statDate": "2026-06-09",
|
||||||
|
"totalBookings": 60,
|
||||||
|
"cancelBookings": 10,
|
||||||
|
"attendBookings": 45,
|
||||||
|
"absentBookings": 5,
|
||||||
|
"attendRate": 75.0,
|
||||||
|
"cancelRate": 16.67
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 获取签到统计数据
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/datacount/signin` |
|
||||||
|
| **所属文件** | `DataStatisticsHandler.java` |
|
||||||
|
|
||||||
|
**请求参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||||
|
|--------|------|------|--------|------|
|
||||||
|
| periodType | string | 否 | DAY | 统计周期:DAY/WEEK/MONTH |
|
||||||
|
| startTime | string | 否 | 自动计算 | 开始时间 |
|
||||||
|
| endTime | string | 否 | 自动计算 | 结束时间 |
|
||||||
|
|
||||||
|
**请求示例**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. 查询今日签到统计
|
||||||
|
GET /api/datacount/signin
|
||||||
|
|
||||||
|
# 2. 查询本周签到统计
|
||||||
|
GET /api/datacount/signin?periodType=WEEK
|
||||||
|
|
||||||
|
# 3. 查询指定日期范围的签到统计
|
||||||
|
GET /api/datacount/signin?startTime=2026-06-01T00:00:00&endTime=2026-06-30T23:59:59
|
||||||
|
```
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"statDate": "2026-06-09",
|
||||||
|
"totalSignIns": 95,
|
||||||
|
"successSignIns": 92,
|
||||||
|
"failSignIns": 3,
|
||||||
|
"successRate": 96.84,
|
||||||
|
"signInTypeDistribution": {
|
||||||
|
"QR_CODE": 60,
|
||||||
|
"MANUAL": 25,
|
||||||
|
"FACE": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 查询历史统计数据
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/datacount/history` |
|
||||||
|
| **所属文件** | `DataStatisticsHandler.java` |
|
||||||
|
|
||||||
|
**请求参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||||
|
|--------|------|------|--------|------|
|
||||||
|
| statType | string | 否 | 空 | 统计类型:member/booking/signin |
|
||||||
|
| startTime | string | 是 | - | 开始日期(格式:yyyy-MM-dd) |
|
||||||
|
| endTime | string | 是 | - | 结束日期(格式:yyyy-MM-dd) |
|
||||||
|
|
||||||
|
**请求示例**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. 查询指定日期范围的签到历史统计
|
||||||
|
GET /api/datacount/history?statType=signin&startTime=2026-06-01&endTime=2026-06-30
|
||||||
|
|
||||||
|
# 2. 查询指定日期范围的会员历史统计
|
||||||
|
GET /api/datacount/history?statType=member&startTime=2026-06-01&endTime=2026-06-15
|
||||||
|
|
||||||
|
# 3. 查询指定日期范围的预约历史统计
|
||||||
|
GET /api/datacount/history?statType=booking&startTime=2026-06-01&endTime=2026-06-30
|
||||||
|
|
||||||
|
# 4. 查询所有类型的历史统计(不指定statType)
|
||||||
|
GET /api/datacount/history?startTime=2026-06-01&endTime=2026-06-07
|
||||||
|
```
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"statDate": "2026-06-07",
|
||||||
|
"totalSignIns": 88,
|
||||||
|
"successSignIns": 86,
|
||||||
|
"failSignIns": 2,
|
||||||
|
"successRate": 97.73,
|
||||||
|
"signInTypeDistribution": {
|
||||||
|
"QR_CODE": 55,
|
||||||
|
"MANUAL": 23,
|
||||||
|
"FACE": 10
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"statDate": "2026-06-08",
|
||||||
|
"totalSignIns": 92,
|
||||||
|
"successSignIns": 90,
|
||||||
|
"failSignIns": 2,
|
||||||
|
"successRate": 97.83,
|
||||||
|
"signInTypeDistribution": {
|
||||||
|
"QR_CODE": 58,
|
||||||
|
"MANUAL": 24,
|
||||||
|
"FACE": 10
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 导出统计数据
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/datacount/export` |
|
||||||
|
| **所属文件** | `DataStatisticsHandler.java` |
|
||||||
|
|
||||||
|
**请求参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||||
|
|--------|------|------|--------|------|
|
||||||
|
| periodType | string | 否 | DAY | 统计周期:DAY/WEEK/MONTH |
|
||||||
|
| startTime | string | 否 | 自动计算 | 开始时间 |
|
||||||
|
| endTime | string | 否 | 自动计算 | 结束时间 |
|
||||||
|
|
||||||
|
**请求示例**:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 1. 导出今日统计数据
|
||||||
|
GET /api/datacount/export
|
||||||
|
|
||||||
|
# 2. 导出本周统计数据
|
||||||
|
GET /api/datacount/export?periodType=WEEK
|
||||||
|
|
||||||
|
# 3. 导出本月统计数据
|
||||||
|
GET /api/datacount/export?periodType=MONTH
|
||||||
|
|
||||||
|
# 4. 导出指定时间范围的统计数据
|
||||||
|
GET /api/datacount/export?startTime=2026-06-01T00:00:00&endTime=2026-06-30T23:59:59
|
||||||
|
```
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
返回 Excel 文件(.xlsx),包含以下 Sheet:
|
||||||
|
- **会员统计**: 会员相关统计数据
|
||||||
|
- **预约统计**: 预约相关统计数据
|
||||||
|
- **签到统计**: 签到相关统计数据
|
||||||
|
|
||||||
|
**Content-Type**: `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 数据模型
|
||||||
|
|
||||||
|
### StatisticsQuery(查询条件)
|
||||||
|
|
||||||
|
| 字段名 | 类型 | 说明 |
|
||||||
|
|--------|------|------|
|
||||||
|
| statType | String | 统计类型筛选 |
|
||||||
|
| periodType | String | 统计周期:DAY/WEEK/MONTH |
|
||||||
|
| startTime | LocalDateTime | 开始时间 |
|
||||||
|
| endTime | LocalDateTime | 结束时间 |
|
||||||
|
|
||||||
|
### StatisticsSummary(统计汇总)
|
||||||
|
|
||||||
|
| 字段名 | 类型 | 说明 |
|
||||||
|
|--------|------|------|
|
||||||
|
| statDate | String | 统计日期 |
|
||||||
|
| generatedAt | String | 生成时间 |
|
||||||
|
| memberStatistics | MemberStatistics | 会员统计数据 |
|
||||||
|
| bookingStatistics | BookingStatistics | 预约统计数据 |
|
||||||
|
| signInStatistics | SignInStatistics | 签到统计数据 |
|
||||||
|
|
||||||
|
### MemberStatistics(会员统计)
|
||||||
|
|
||||||
|
| 字段名 | 类型 | 说明 |
|
||||||
|
|--------|------|------|
|
||||||
|
| statDate | String | 统计日期 |
|
||||||
|
| newMembers | Long | 新增会员数 |
|
||||||
|
| activeMembers | Long | 活跃会员数 |
|
||||||
|
| totalMembers | Long | 累计会员总数 |
|
||||||
|
| signInMembers | Long | 签到会员数 |
|
||||||
|
| bookingMembers | Long | 预约会员数 |
|
||||||
|
| cancelMembers | Long | 取消预约会员数 |
|
||||||
|
|
||||||
|
### BookingStatistics(预约统计)
|
||||||
|
|
||||||
|
| 字段名 | 类型 | 说明 |
|
||||||
|
|--------|------|------|
|
||||||
|
| statDate | String | 统计日期 |
|
||||||
|
| totalBookings | Long | 预约总数 |
|
||||||
|
| cancelBookings | Long | 取消预约数 |
|
||||||
|
| attendBookings | Long | 出席预约数 |
|
||||||
|
| absentBookings | Long | 缺席预约数 |
|
||||||
|
| attendRate | Double | 出席率(%) |
|
||||||
|
| cancelRate | Double | 取消率(%) |
|
||||||
|
|
||||||
|
### SignInStatistics(签到统计)
|
||||||
|
|
||||||
|
| 字段名 | 类型 | 说明 |
|
||||||
|
|--------|------|------|
|
||||||
|
| statDate | String | 统计日期 |
|
||||||
|
| totalSignIns | Long | 签到总次数 |
|
||||||
|
| successSignIns | Long | 成功签到次数 |
|
||||||
|
| failSignIns | Long | 失败签到次数 |
|
||||||
|
| successRate | Double | 签到成功率(%) |
|
||||||
|
| signInTypeDistribution | Map<String, Long> | 签到类型分布 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 状态码说明
|
||||||
|
|
||||||
|
| 状态码 | 说明 |
|
||||||
|
|--------|------|
|
||||||
|
| 200 | 请求成功 |
|
||||||
|
| 400 | 请求参数错误 |
|
||||||
|
| 500 | 服务器内部错误 |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 业务规则
|
||||||
|
|
||||||
|
1. **统计周期**: 支持按日、周、月统计
|
||||||
|
- DAY: 当天 00:00:00 - 当前时间
|
||||||
|
- WEEK: 本周一 00:00:00 - 本周日 23:59:59
|
||||||
|
- MONTH: 本月1日 00:00:00 - 本月最后一天 23:59:59
|
||||||
|
|
||||||
|
2. **数据保留**: 统计数据缓存30天,业务记录永久保存
|
||||||
|
|
||||||
|
3. **缓存策略**: 查询结果缓存1小时,统计数据缓存30天
|
||||||
|
|
||||||
|
4. **定时任务**:
|
||||||
|
- 每日凌晨2点执行前一天的日统计
|
||||||
|
- 每周一凌晨3点执行上周的周统计
|
||||||
|
- 每月1日凌晨3点执行上月的月统计
|
||||||
|
- 每月15日凌晨4点清理30天前的旧数据
|
||||||
|
|
||||||
|
5. **数据导出**: 支持Excel格式导出,包含会员、预约、签到三个Sheet
|
||||||
@@ -26,11 +26,32 @@
|
|||||||
- [查询会员预约记录](#查询会员预约记录)
|
- [查询会员预约记录](#查询会员预约记录)
|
||||||
- [查询预约详情](#查询预约详情)
|
- [查询预约详情](#查询预约详情)
|
||||||
- [查询课程预约记录](#查询课程预约记录)
|
- [查询课程预约记录](#查询课程预约记录)
|
||||||
5. [数据模型](#数据模型)
|
5. [团课类型管理接口](#团课类型管理接口)
|
||||||
|
- [获取所有团课类型](#获取所有团课类型)
|
||||||
|
- [根据ID获取团课类型](#根据ID获取团课类型)
|
||||||
|
- [搜索团课类型](#搜索团课类型)
|
||||||
|
- [根据分类获取团课类型](#根据分类获取团课类型)
|
||||||
|
- [获取所有分类](#获取所有分类)
|
||||||
|
- [创建团课类型](#创建团课类型)
|
||||||
|
- [更新团课类型](#更新团课类型)
|
||||||
|
- [删除团课类型](#删除团课类型)
|
||||||
|
6. [团课标签管理接口](#团课标签管理接口)
|
||||||
|
- [获取所有标签](#获取所有标签)
|
||||||
|
- [根据ID获取标签](#根据ID获取标签)
|
||||||
|
- [搜索标签](#搜索标签)
|
||||||
|
- [获取类型的标签](#获取类型的标签)
|
||||||
|
- [创建标签](#创建标签)
|
||||||
|
- [更新标签](#更新标签)
|
||||||
|
- [删除标签](#删除标签)
|
||||||
|
- [为类型添加标签](#为类型添加标签)
|
||||||
|
- [从类型移除标签](#从类型移除标签)
|
||||||
|
- [清空类型标签](#清空类型标签)
|
||||||
|
7. [数据模型](#数据模型)
|
||||||
- [GroupCourse(团课)](#GroupCourse团课)
|
- [GroupCourse(团课)](#GroupCourse团课)
|
||||||
- [GroupCourseBooking(团课预约)](#GroupCourseBooking团课预约)
|
- [GroupCourseBooking(团课预约)](#GroupCourseBooking团课预约)
|
||||||
6. [状态码说明](#状态码说明)
|
- [GroupCourseType(团课类型)](#GroupCourseType团课类型)
|
||||||
7. [业务规则](#业务规则)
|
7. [状态码说明](#状态码说明)
|
||||||
|
8. [业务规则](#业务规则)
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -178,6 +199,78 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
### 根据ID获取团课完整信息
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/groupCourse/{id}/detail` |
|
||||||
|
| **所属文件** | `GroupCourseHandler.java` |
|
||||||
|
|
||||||
|
**路径参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| id | Long | 是 | 团课ID |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"courseName": "瑜伽入门",
|
||||||
|
"coachId": 1,
|
||||||
|
"courseType": 1,
|
||||||
|
"startTime": "2026-06-02T09:00:00",
|
||||||
|
"endTime": "2026-06-02T10:00:00",
|
||||||
|
"maxMembers": 20,
|
||||||
|
"currentMembers": 15,
|
||||||
|
"status": 0,
|
||||||
|
"location": "健身房A区",
|
||||||
|
"coverImage": "https://example.com/yoga.jpg",
|
||||||
|
"description": "适合初学者的瑜伽课程",
|
||||||
|
"pointCardAmount": 1,
|
||||||
|
"storedValueAmount": 50.00,
|
||||||
|
"typeName": "瑜伽入门",
|
||||||
|
"typeCategory": "柔韧与平衡类",
|
||||||
|
"baseDifficulty": 2,
|
||||||
|
"difficultyLevel": "初级",
|
||||||
|
"calculatedDifficulty": 2,
|
||||||
|
"typeInfo": {
|
||||||
|
"id": 1,
|
||||||
|
"typeName": "瑜伽入门",
|
||||||
|
"baseDifficulty": 2,
|
||||||
|
"calculatedDifficulty": 2,
|
||||||
|
"difficultyLevel": "初级",
|
||||||
|
"description": "适合初学者的瑜伽课程,注重基础体式",
|
||||||
|
"category": "柔韧与平衡类",
|
||||||
|
"labels": [
|
||||||
|
{"id": 1, "labelName": "适合新手", "color": "#52c41a"},
|
||||||
|
{"id": 3, "labelName": "减压放松", "color": "#1890ff"}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"labels": [
|
||||||
|
{"id": 1, "labelName": "适合新手", "color": "#52c41a"},
|
||||||
|
{"id": 3, "labelName": "减压放松", "color": "#1890ff"}
|
||||||
|
],
|
||||||
|
"createdAt": "2026-06-01T10:00:00",
|
||||||
|
"updatedAt": "2026-06-01T10:00:00"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**失败响应** (404 Not Found):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
|
**说明**: 此接口返回团课的完整信息,包括:
|
||||||
|
- 团课基础信息
|
||||||
|
- 团课对应的类型信息(包含基础难度、综合难度、难度等级等)
|
||||||
|
- 该类型的所有标签信息
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
### 创建团课
|
### 创建团课
|
||||||
|
|
||||||
| 属性 | 值 |
|
| 属性 | 值 |
|
||||||
@@ -628,6 +721,625 @@
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## 团课类型管理接口
|
||||||
|
|
||||||
|
### 获取所有团课类型
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/groupCourse/types` |
|
||||||
|
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||||
|
|
||||||
|
**请求参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||||
|
|--------|------|------|--------|------|
|
||||||
|
| includeDeleted | boolean | 否 | false | 是否包含已删除的类型 |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"typeName": "瑜伽入门",
|
||||||
|
"baseDifficulty": 2,
|
||||||
|
"calculatedDifficulty": 2,
|
||||||
|
"difficultyLevel": "初级",
|
||||||
|
"description": "适合初学者的瑜伽课程,注重基础体式",
|
||||||
|
"category": "柔韧与平衡类",
|
||||||
|
"createdAt": "2026-06-01T10:00:00",
|
||||||
|
"updatedAt": "2026-06-01T10:00:00"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 根据ID获取团课类型
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/groupCourse/types/{id}` |
|
||||||
|
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||||
|
|
||||||
|
**路径参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| id | Long | 是 | 团课类型ID |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"typeName": "瑜伽入门",
|
||||||
|
"baseDifficulty": 2,
|
||||||
|
"calculatedDifficulty": 2,
|
||||||
|
"difficultyLevel": "初级",
|
||||||
|
"description": "适合初学者的瑜伽课程,注重基础体式",
|
||||||
|
"category": "柔韧与平衡类",
|
||||||
|
"createdAt": "2026-06-01T10:00:00",
|
||||||
|
"updatedAt": "2026-06-01T10:00:00"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**失败响应** (404 Not Found):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 搜索团课类型
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/groupCourse/types/search` |
|
||||||
|
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||||
|
|
||||||
|
**请求参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||||
|
|--------|------|------|--------|------|
|
||||||
|
| keyword | string | 否 | - | 搜索关键词(匹配类型名称) |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"typeName": "瑜伽入门",
|
||||||
|
"baseDifficulty": 2,
|
||||||
|
"difficultyLevel": "初级",
|
||||||
|
"category": "柔韧与平衡类"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 根据分类获取团课类型
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/groupCourse/types/category/{category}` |
|
||||||
|
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||||
|
|
||||||
|
**路径参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| category | String | 是 | 分类名称 |
|
||||||
|
|
||||||
|
**请求参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||||
|
|--------|------|------|--------|------|
|
||||||
|
| keyword | string | 否 | - | 搜索关键词 |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"typeName": "瑜伽入门",
|
||||||
|
"baseDifficulty": 2,
|
||||||
|
"difficultyLevel": "初级",
|
||||||
|
"category": "柔韧与平衡类"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 获取所有分类
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/groupCourse/types/categories` |
|
||||||
|
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
["基础有氧与热身", "固定器械训练", "自重基础动作", "自由重量杠铃/哑铃", "高强度与爆发力", "柔韧与平衡类"]
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 创建团课类型
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | POST |
|
||||||
|
| **接口路径** | `/api/groupCourse/types` |
|
||||||
|
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||||
|
|
||||||
|
**请求体**:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"typeName": "核心力量训练",
|
||||||
|
"baseDifficulty": 4,
|
||||||
|
"description": "针对核心肌群的专项训练课程",
|
||||||
|
"category": "自重基础动作"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||||
|
|--------|------|------|--------|------|
|
||||||
|
| typeName | String | **是** | - | 类型名称 |
|
||||||
|
| baseDifficulty | Integer | 否 | 1 | 基础难度(1-10) |
|
||||||
|
| description | String | 否 | - | 类型描述 |
|
||||||
|
| category | String | 否 | - | 分类 |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"message": "团课类型创建成功",
|
||||||
|
"data": {
|
||||||
|
"id": 40,
|
||||||
|
"typeName": "核心力量训练",
|
||||||
|
"baseDifficulty": 4,
|
||||||
|
"calculatedDifficulty": 4,
|
||||||
|
"difficultyLevel": "中级",
|
||||||
|
"description": "针对核心肌群的专项训练课程",
|
||||||
|
"category": "自重基础动作"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**失败响应** (400 Bad Request):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success": false,
|
||||||
|
"message": "类型名称不能为空"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 更新团课类型
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | PUT |
|
||||||
|
| **接口路径** | `/api/groupCourse/types/{id}` |
|
||||||
|
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||||
|
|
||||||
|
**路径参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| id | Long | 是 | 团课类型ID |
|
||||||
|
|
||||||
|
**请求体**:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"typeName": "核心力量训练进阶",
|
||||||
|
"baseDifficulty": 6,
|
||||||
|
"description": "进阶核心训练课程"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| typeName | String | 否 | 类型名称 |
|
||||||
|
| baseDifficulty | Integer | 否 | 基础难度(1-10) |
|
||||||
|
| description | String | 否 | 类型描述 |
|
||||||
|
| category | String | 否 | 分类 |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"message": "团课类型更新成功",
|
||||||
|
"data": {
|
||||||
|
"id": 40,
|
||||||
|
"typeName": "核心力量训练进阶",
|
||||||
|
"baseDifficulty": 6,
|
||||||
|
"calculatedDifficulty": 6,
|
||||||
|
"difficultyLevel": "中高级",
|
||||||
|
"description": "进阶核心训练课程",
|
||||||
|
"category": "自重基础动作"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 删除团课类型
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | DELETE |
|
||||||
|
| **接口路径** | `/api/groupCourse/types/{id}` |
|
||||||
|
| **所属文件** | `GroupCourseTypeHandler.java` |
|
||||||
|
|
||||||
|
**路径参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| id | Long | 是 | 团课类型ID |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"message": "团课类型删除成功"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 团课标签管理接口
|
||||||
|
|
||||||
|
### 获取所有标签
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/groupCourse/labels` |
|
||||||
|
| **所属文件** | `CourseLabelHandler.java` |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"labelName": "适合新手",
|
||||||
|
"color": "#52c41a",
|
||||||
|
"createdAt": "2026-06-01T10:00:00",
|
||||||
|
"updatedAt": "2026-06-01T10:00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 2,
|
||||||
|
"labelName": "中级过渡",
|
||||||
|
"color": "#faad14",
|
||||||
|
"createdAt": "2026-06-01T10:00:00",
|
||||||
|
"updatedAt": "2026-06-01T10:00:00"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 根据ID获取标签
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/groupCourse/labels/{id}` |
|
||||||
|
| **所属文件** | `CourseLabelHandler.java` |
|
||||||
|
|
||||||
|
**路径参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| id | Long | 是 | 标签ID |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"labelName": "适合新手",
|
||||||
|
"color": "#52c41a",
|
||||||
|
"createdAt": "2026-06-01T10:00:00",
|
||||||
|
"updatedAt": "2026-06-01T10:00:00"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**失败响应** (404 Not Found):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 搜索标签
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/groupCourse/labels/search` |
|
||||||
|
| **所属文件** | `CourseLabelHandler.java` |
|
||||||
|
|
||||||
|
**请求参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||||
|
|--------|------|------|--------|------|
|
||||||
|
| keyword | string | 否 | - | 搜索关键词(匹配标签名称) |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"labelName": "适合新手",
|
||||||
|
"color": "#52c41a"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 获取类型的标签
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | GET |
|
||||||
|
| **接口路径** | `/api/groupCourse/types/{typeId}/labels` |
|
||||||
|
| **所属文件** | `CourseLabelHandler.java` |
|
||||||
|
|
||||||
|
**路径参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| typeId | Long | 是 | 团课类型ID |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"id": 1,
|
||||||
|
"labelName": "适合新手",
|
||||||
|
"color": "#52c41a"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": 3,
|
||||||
|
"labelName": "减压放松",
|
||||||
|
"color": "#1890ff"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 创建标签
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | POST |
|
||||||
|
| **接口路径** | `/api/groupCourse/labels` |
|
||||||
|
| **所属文件** | `CourseLabelHandler.java` |
|
||||||
|
|
||||||
|
**请求体**:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"labelName": "燃脂塑形",
|
||||||
|
"color": "#f5222d"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 默认值 | 说明 |
|
||||||
|
|--------|------|------|--------|------|
|
||||||
|
| labelName | String | **是** | - | 标签名称(最大50字符) |
|
||||||
|
| color | String | 否 | #1890ff | 标签颜色(十六进制颜色值) |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"message": "标签创建成功",
|
||||||
|
"data": {
|
||||||
|
"id": 15,
|
||||||
|
"labelName": "燃脂塑形",
|
||||||
|
"color": "#f5222d"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
**失败响应** (400 Bad Request):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success": false,
|
||||||
|
"message": "标签名称已存在"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 更新标签
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | PUT |
|
||||||
|
| **接口路径** | `/api/groupCourse/labels/{id}` |
|
||||||
|
| **所属文件** | `CourseLabelHandler.java` |
|
||||||
|
|
||||||
|
**路径参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| id | Long | 是 | 标签ID |
|
||||||
|
|
||||||
|
**请求体**:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"labelName": "燃脂塑形进阶",
|
||||||
|
"color": "#fa541c"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| labelName | String | 否 | 标签名称(最大50字符) |
|
||||||
|
| color | String | 否 | 标签颜色(十六进制颜色值) |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"message": "标签更新成功",
|
||||||
|
"data": {
|
||||||
|
"id": 15,
|
||||||
|
"labelName": "燃脂塑形进阶",
|
||||||
|
"color": "#fa541c"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 删除标签
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | DELETE |
|
||||||
|
| **接口路径** | `/api/groupCourse/labels/{id}` |
|
||||||
|
| **所属文件** | `CourseLabelHandler.java` |
|
||||||
|
|
||||||
|
**路径参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| id | Long | 是 | 标签ID |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"message": "标签删除成功"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 为类型添加标签
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | POST |
|
||||||
|
| **接口路径** | `/api/groupCourse/types/{typeId}/labels` |
|
||||||
|
| **所属文件** | `CourseLabelHandler.java` |
|
||||||
|
|
||||||
|
**路径参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| typeId | Long | 是 | 团课类型ID |
|
||||||
|
|
||||||
|
**请求体**:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"labelIds": [1, 3, 5]
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| labelIds | List\<Long\> | **是** | 要添加的标签ID列表 |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"message": "标签添加成功"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 从类型移除标签
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | DELETE |
|
||||||
|
| **接口路径** | `/api/groupCourse/types/{typeId}/labels/{labelId}` |
|
||||||
|
| **所属文件** | `CourseLabelHandler.java` |
|
||||||
|
|
||||||
|
**路径参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| typeId | Long | 是 | 团课类型ID |
|
||||||
|
| labelId | Long | 是 | 标签ID |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"message": "标签移除成功"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### 清空类型标签
|
||||||
|
|
||||||
|
| 属性 | 值 |
|
||||||
|
|------|-----|
|
||||||
|
| **HTTP方法** | DELETE |
|
||||||
|
| **接口路径** | `/api/groupCourse/types/{typeId}/labels` |
|
||||||
|
| **所属文件** | `CourseLabelHandler.java` |
|
||||||
|
|
||||||
|
**路径参数**:
|
||||||
|
|
||||||
|
| 参数名 | 类型 | 必填 | 说明 |
|
||||||
|
|--------|------|------|------|
|
||||||
|
| typeId | Long | 是 | 团课类型ID |
|
||||||
|
|
||||||
|
**成功响应** (200 OK):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"message": "标签清空成功"
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 数据模型
|
## 数据模型
|
||||||
|
|
||||||
### GroupCourse(团课)
|
### GroupCourse(团课)
|
||||||
@@ -675,6 +1387,84 @@
|
|||||||
| updatedAt | LocalDateTime | 更新时间 |
|
| updatedAt | LocalDateTime | 更新时间 |
|
||||||
| deletedAt | LocalDateTime | 删除时间(软删除) |
|
| deletedAt | LocalDateTime | 删除时间(软删除) |
|
||||||
|
|
||||||
|
### GroupCourseType(团课类型)
|
||||||
|
|
||||||
|
| 字段名 | 类型 | 说明 |
|
||||||
|
|--------|------|------|
|
||||||
|
| id | Long | 主键ID |
|
||||||
|
| typeName | String | 类型名称 |
|
||||||
|
| baseDifficulty | Integer | 基础难度(1-10) |
|
||||||
|
| calculatedDifficulty | Integer | 综合难度系数(预留扩展字段) |
|
||||||
|
| difficultyLevel | String | 难度等级描述(初级/中级/中高级/高级/专家级) |
|
||||||
|
| description | String | 类型描述 |
|
||||||
|
| category | String | 分类(如:有氧、力量、柔韧等) |
|
||||||
|
| labels | List\<CourseLabel\> | 标签列表 |
|
||||||
|
| createdBy | String | 创建人 |
|
||||||
|
| updatedBy | String | 更新人 |
|
||||||
|
| createdAt | LocalDateTime | 创建时间 |
|
||||||
|
| updatedAt | LocalDateTime | 更新时间 |
|
||||||
|
| deletedAt | LocalDateTime | 删除时间(软删除) |
|
||||||
|
|
||||||
|
### CourseLabel(团课标签)
|
||||||
|
|
||||||
|
| 字段名 | 类型 | 说明 |
|
||||||
|
|--------|------|------|
|
||||||
|
| id | Long | 主键ID |
|
||||||
|
| labelName | String | 标签名称(最大50字符) |
|
||||||
|
| color | String | 标签颜色(十六进制颜色值,默认#1890ff) |
|
||||||
|
| createdBy | String | 创建人 |
|
||||||
|
| updatedBy | String | 更新人 |
|
||||||
|
| createdAt | LocalDateTime | 创建时间 |
|
||||||
|
| updatedAt | LocalDateTime | 更新时间 |
|
||||||
|
| deletedAt | LocalDateTime | 删除时间(软删除) |
|
||||||
|
|
||||||
|
### GroupCourseDetail(团课完整信息)
|
||||||
|
|
||||||
|
| 字段名 | 类型 | 说明 |
|
||||||
|
|--------|------|------|
|
||||||
|
| id | Long | 主键ID |
|
||||||
|
| courseName | String | 课程名称 |
|
||||||
|
| coachId | Long | 教练ID |
|
||||||
|
| courseType | Long | 课程类型ID |
|
||||||
|
| startTime | LocalDateTime | 开始时间 |
|
||||||
|
| endTime | LocalDateTime | 结束时间 |
|
||||||
|
| maxMembers | Integer | 最大参与人数 |
|
||||||
|
| currentMembers | Integer | 当前参与人数 |
|
||||||
|
| status | Long | 状态(0-正常,1-已取消,2-已结束) |
|
||||||
|
| location | String | 上课地点 |
|
||||||
|
| coverImage | String | 封面图URL |
|
||||||
|
| description | String | 课程描述 |
|
||||||
|
| pointCardAmount | Integer | 点卡额度(消耗次数) |
|
||||||
|
| storedValueAmount | BigDecimal | 储值卡额度(消耗金额) |
|
||||||
|
| typeName | String | 类型名称(快捷访问) |
|
||||||
|
| typeCategory | String | 类型分类(快捷访问) |
|
||||||
|
| baseDifficulty | Integer | 基础难度(快捷访问) |
|
||||||
|
| difficultyLevel | String | 难度等级描述(快捷访问) |
|
||||||
|
| calculatedDifficulty | Integer | 综合难度系数(快捷访问) |
|
||||||
|
| typeInfo | GroupCourseType | 类型信息 |
|
||||||
|
| labels | List\<CourseLabel\> | 标签列表 |
|
||||||
|
| createdAt | LocalDateTime | 创建时间 |
|
||||||
|
| updatedAt | LocalDateTime | 更新时间 |
|
||||||
|
|
||||||
|
**难度等级对应关系**:
|
||||||
|
|
||||||
|
| 基础难度 | 难度等级 |
|
||||||
|
|----------|----------|
|
||||||
|
| 1-2 | 初级 |
|
||||||
|
| 3-4 | 中级 |
|
||||||
|
| 5-6 | 中高级 |
|
||||||
|
| 7-8 | 高级 |
|
||||||
|
| 9-10 | 专家级 |
|
||||||
|
|
||||||
|
**难度扩展说明**:
|
||||||
|
|
||||||
|
`calculatedDifficulty` 字段为预留扩展字段,当前实现仅返回 `baseDifficulty`。未来可扩展的影响因素包括:
|
||||||
|
|
||||||
|
1. **课程时长系数**:时长越长难度越高
|
||||||
|
2. **教练难度调整系数**:教练可根据实际情况微调
|
||||||
|
3. **会员等级适配系数**:根据会员等级动态调整显示难度
|
||||||
|
4. **课程强度系数**:高强度课程难度加成
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 状态码说明
|
## 状态码说明
|
||||||
|
|||||||
@@ -0,0 +1,87 @@
|
|||||||
|
一、基础有氧与热身(难度 1-3)
|
||||||
|
|
||||||
|
主要是低冲击、低技巧,用于建立运动基础。
|
||||||
|
|
||||||
|
慢走/椭圆机轻松模式:1(几乎无难度,适合所有人)
|
||||||
|
|
||||||
|
固定自行车(低阻力):2(注意座椅高度调节即可)
|
||||||
|
|
||||||
|
跑步机慢跑:3(需要基本协调性,膝盖有压力)
|
||||||
|
|
||||||
|
跳绳(连续基础跳):3(需要手脚配合,心肺要求明显)
|
||||||
|
|
||||||
|
二、固定器械训练(难度 2-5)
|
||||||
|
|
||||||
|
轨迹固定,主要考验力量和耐力,技巧要求低。
|
||||||
|
|
||||||
|
坐姿腿屈伸/腿弯举:2(很容易找到发力感)
|
||||||
|
|
||||||
|
坐姿推胸机:3(需注意肩胛后收,避免耸肩)
|
||||||
|
|
||||||
|
高位下拉(坐姿):3(需控制不要过度后仰)
|
||||||
|
|
||||||
|
史密斯机深蹲:4(轨迹固定,但需保持核心稳定)
|
||||||
|
|
||||||
|
蝴蝶机夹胸:3(易用肘关节代偿,需锁定肩关节)
|
||||||
|
|
||||||
|
三、自重基础动作(难度 3-7)
|
||||||
|
|
||||||
|
需要一定的力量-体重比和身体控制能力。
|
||||||
|
|
||||||
|
平板支撑:3(耐力考验,技巧低)
|
||||||
|
|
||||||
|
跪姿俯卧撑:3(上肢力量较弱者首选)
|
||||||
|
|
||||||
|
标准俯卧撑:5(需核心收紧,身体成直线)
|
||||||
|
|
||||||
|
引体向上(弹力带辅助):6(背部和手臂力量要求高)
|
||||||
|
|
||||||
|
标准引体向上:8(力量-体重比极高,多数男性无法完成1次)
|
||||||
|
|
||||||
|
徒手深蹲:3(注意膝盖方向与背部直立)
|
||||||
|
|
||||||
|
单腿深蹲(手枪蹲):8(需要极高下肢力量、柔韧性和平衡)
|
||||||
|
|
||||||
|
四、自由重量杠铃/哑铃(难度 5-9)
|
||||||
|
|
||||||
|
技巧风险最高,需要神经系统协调和长期动作打磨。
|
||||||
|
|
||||||
|
哑铃二头弯举:4(容易晃动借力,但较安全)
|
||||||
|
|
||||||
|
哑铃侧平举:5(极易用斜方肌代偿,真正练到三角肌中束很难)
|
||||||
|
|
||||||
|
杠铃卧推:7(肩关节压力大,起桥、沉肩、稳定手腕均有技巧,有压伤风险)
|
||||||
|
|
||||||
|
杠铃深蹲(颈后):8(全身协调性、核心抗压、杠位放置、呼吸模式,学习曲线陡峭)
|
||||||
|
|
||||||
|
传统硬拉:9(风险极高,需要精确的脊柱中立、髋铰链、背阔肌收紧,错误时伤腰)
|
||||||
|
|
||||||
|
高翻/抓举(奥运举重):10(需要爆发力、柔韧、精准衔接,非数月训练不能掌握)
|
||||||
|
|
||||||
|
五、高强度与爆发力(难度 6-10)
|
||||||
|
|
||||||
|
对心肺、神经系统和恢复能力要求极高。
|
||||||
|
|
||||||
|
波比跳(标准版):6(连续做时心肺压力极大)
|
||||||
|
|
||||||
|
冲刺跑(短跑):7(对腘绳肌和脚踝爆发力要求高)
|
||||||
|
|
||||||
|
跳箱(合理高度):6(需要落地缓冲技巧)
|
||||||
|
|
||||||
|
负重雪橇推:6(主要考验腿部耐力和意志力)
|
||||||
|
|
||||||
|
双力臂(引体向上后翻腕上杠):9(需要爆发引体 + 极高相对力量)
|
||||||
|
|
||||||
|
六、柔韧与平衡类(难度 3-8)
|
||||||
|
|
||||||
|
考验本体感觉和关节活动度。
|
||||||
|
|
||||||
|
静态拉伸(坐姿体前屈):2(无风险,但需要坚持)
|
||||||
|
|
||||||
|
瑜伽下犬式:3(常见,但需背部与手臂对齐)
|
||||||
|
|
||||||
|
单腿罗马尼亚硬拉(徒手):6(极考验平衡和髋稳定)
|
||||||
|
|
||||||
|
全深蹲(脚跟贴地,亚洲蹲):5(踝关节灵活度限制多数人)
|
||||||
|
|
||||||
|
竖叉/横叉:8(需要数月甚至数年拉伸)
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>cn.novalon.gym.manage</groupId>
|
||||||
|
<artifactId>gym-manage-api</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<relativePath>../pom.xml</relativePath>
|
||||||
|
</parent>
|
||||||
|
<groupId>cn.novalon.gym.manage</groupId>
|
||||||
|
<artifactId>gym-coupon</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<name>gym-coupon</name>
|
||||||
|
<description>Coupon Management Module</description>
|
||||||
|
<url/>
|
||||||
|
<licenses>
|
||||||
|
<license/>
|
||||||
|
</licenses>
|
||||||
|
<developers>
|
||||||
|
<developer/>
|
||||||
|
</developers>
|
||||||
|
<scm>
|
||||||
|
<connection/>
|
||||||
|
<developerConnection/>
|
||||||
|
<tag/>
|
||||||
|
<url/>
|
||||||
|
</scm>
|
||||||
|
<properties>
|
||||||
|
<java.version>21</java.version>
|
||||||
|
</properties>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.novalon.gym.manage</groupId>
|
||||||
|
<artifactId>manage-common</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.novalon.gym.manage</groupId>
|
||||||
|
<artifactId>manage-sys</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.novalon.gym.manage</groupId>
|
||||||
|
<artifactId>manage-db</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-webflux</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-data-r2dbc</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-validation</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springdoc</groupId>
|
||||||
|
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.swagger.core.v3</groupId>
|
||||||
|
<artifactId>swagger-annotations-jakarta</artifactId>
|
||||||
|
<version>2.2.43</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>cn.novalon.gym.manage</groupId>
|
||||||
|
<artifactId>gym-member</artifactId>
|
||||||
|
<version>${project.version}</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
||||||
+75
@@ -0,0 +1,75 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.converter;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.novalon.gym.manage.coupon.domain.CouponTemplate;
|
||||||
|
import cn.novalon.gym.manage.coupon.domain.MemberCoupon;
|
||||||
|
import cn.novalon.gym.manage.coupon.entity.CouponTemplateEntity;
|
||||||
|
import cn.novalon.gym.manage.coupon.entity.MemberCouponEntity;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠券相关转换器
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class CouponConverter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将优惠券模板实体转换为领域模型
|
||||||
|
*/
|
||||||
|
public CouponTemplate toCouponTemplate(CouponTemplateEntity entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
CouponTemplate couponTemplate = new CouponTemplate();
|
||||||
|
BeanUtil.copyProperties(entity, couponTemplate);
|
||||||
|
log.debug("转换优惠券模板实体到领域模型:couponId={}", entity.getId());
|
||||||
|
return couponTemplate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将优惠券模板领域模型转换为实体
|
||||||
|
*/
|
||||||
|
public CouponTemplateEntity toCouponTemplateEntity(CouponTemplate domain) {
|
||||||
|
if (domain == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
CouponTemplateEntity entity = new CouponTemplateEntity();
|
||||||
|
BeanUtil.copyProperties(domain, entity);
|
||||||
|
if (domain.getId() != null) {
|
||||||
|
entity.markNotNew();
|
||||||
|
}
|
||||||
|
log.debug("转换优惠券模板领域模型到实体:couponId={}", domain.getId());
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将会员优惠券实体转换为领域模型
|
||||||
|
*/
|
||||||
|
public MemberCoupon toMemberCoupon(MemberCouponEntity entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MemberCoupon memberCoupon = new MemberCoupon();
|
||||||
|
BeanUtil.copyProperties(entity, memberCoupon);
|
||||||
|
log.debug("转换会员优惠券实体到领域模型:memberCouponId={}", entity.getId());
|
||||||
|
return memberCoupon;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将会员优惠券领域模型转换为实体
|
||||||
|
*/
|
||||||
|
public MemberCouponEntity toMemberCouponEntity(MemberCoupon domain) {
|
||||||
|
if (domain == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MemberCouponEntity entity = new MemberCouponEntity();
|
||||||
|
BeanUtil.copyProperties(domain, entity);
|
||||||
|
if (domain.getId() != null) {
|
||||||
|
entity.markNotNew();
|
||||||
|
}
|
||||||
|
log.debug("转换会员优惠券领域模型到实体:memberCouponId={}", domain.getId());
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
+43
@@ -0,0 +1,43 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.dao;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.entity.CouponTemplateEntity;
|
||||||
|
import org.springframework.data.r2dbc.repository.Modifying;
|
||||||
|
import org.springframework.data.r2dbc.repository.Query;
|
||||||
|
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface CouponTemplateDao extends R2dbcRepository<CouponTemplateEntity, Long> {
|
||||||
|
|
||||||
|
Mono<CouponTemplateEntity> findByIdIsAndDeletedAtIsNull(Long id);
|
||||||
|
|
||||||
|
Flux<CouponTemplateEntity> findAllByDeletedAtIsNull();
|
||||||
|
|
||||||
|
Flux<CouponTemplateEntity> findByNameContainingAndDeletedAtIsNull(String name);
|
||||||
|
|
||||||
|
Flux<CouponTemplateEntity> findByCouponTypeAndDeletedAtIsNull(String couponType);
|
||||||
|
|
||||||
|
Flux<CouponTemplateEntity> findByStatusAndDeletedAtIsNull(String status);
|
||||||
|
|
||||||
|
Mono<CouponTemplateEntity> findByClaimCodeAndDeletedAtIsNull(String claimCode);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE coupon_template SET deleted_at = :deletedAt WHERE id = :id")
|
||||||
|
Mono<Integer> softDelete(Long id, LocalDateTime deletedAt);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE coupon_template SET status = :status, updated_at = :updatedAt WHERE id = :id")
|
||||||
|
Mono<Integer> updateStatus(Long id, String status, LocalDateTime updatedAt);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE coupon_template SET issued_count = issued_count + :count, updated_at = :updatedAt WHERE id = :id")
|
||||||
|
Mono<Integer> incrementIssuedCount(Long id, int count, LocalDateTime updatedAt);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE coupon_template SET used_count = used_count + :count, updated_at = :updatedAt WHERE id = :id")
|
||||||
|
Mono<Integer> incrementUsedCount(Long id, int count, LocalDateTime updatedAt);
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.dao;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.entity.MemberCouponEntity;
|
||||||
|
import org.springframework.data.r2dbc.repository.Modifying;
|
||||||
|
import org.springframework.data.r2dbc.repository.Query;
|
||||||
|
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface MemberCouponDao extends R2dbcRepository<MemberCouponEntity, Long> {
|
||||||
|
|
||||||
|
Flux<MemberCouponEntity> findByTemplateIdAndDeletedAtIsNull(Long templateId);
|
||||||
|
|
||||||
|
Flux<MemberCouponEntity> findByMemberIdAndDeletedAtIsNull(Long memberId);
|
||||||
|
|
||||||
|
Mono<Long> countByTemplateIdAndMemberIdAndDeletedAtIsNull(Long templateId, Long memberId);
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(*) FROM member_coupon WHERE template_id = :templateId AND status = :status AND deleted_at IS NULL")
|
||||||
|
Mono<Long> countByTemplateIdAndStatus(Long templateId, String status);
|
||||||
|
|
||||||
|
Mono<MemberCouponEntity> findByCouponCodeAndDeletedAtIsNull(String couponCode);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE member_coupon SET status = 'EXPIRED', updated_at = :now WHERE status = 'AVAILABLE' AND expire_at < :now AND deleted_at IS NULL")
|
||||||
|
Mono<Integer> expireAvailableCoupons(java.time.LocalDateTime now);
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
@Schema(description = "领取码兑换优惠券请求")
|
||||||
|
public class ClaimCouponRequest {
|
||||||
|
|
||||||
|
@Schema(description = "会员ID", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private Long memberId;
|
||||||
|
|
||||||
|
@Schema(description = "领取码", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private String claimCode;
|
||||||
|
|
||||||
|
public Long getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(Long memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClaimCode() {
|
||||||
|
return claimCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClaimCode(String claimCode) {
|
||||||
|
this.claimCode = claimCode;
|
||||||
|
}
|
||||||
|
}
|
||||||
+86
@@ -0,0 +1,86 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Schema(description = "优惠券统计数据")
|
||||||
|
public class CouponStatistics {
|
||||||
|
|
||||||
|
@Schema(description = "优惠券模板ID")
|
||||||
|
private Long templateId;
|
||||||
|
|
||||||
|
@Schema(description = "已发放数量")
|
||||||
|
private long issuedCount;
|
||||||
|
|
||||||
|
@Schema(description = "已使用数量")
|
||||||
|
private long usedCount;
|
||||||
|
|
||||||
|
@Schema(description = "可用数量")
|
||||||
|
private long availableCount;
|
||||||
|
|
||||||
|
@Schema(description = "已过期数量")
|
||||||
|
private long expiredCount;
|
||||||
|
|
||||||
|
@Schema(description = "核销率(百分比)")
|
||||||
|
private BigDecimal redemptionRate;
|
||||||
|
|
||||||
|
@Schema(description = "累计优惠金额")
|
||||||
|
private BigDecimal totalDiscountAmount;
|
||||||
|
|
||||||
|
public Long getTemplateId() {
|
||||||
|
return templateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemplateId(Long templateId) {
|
||||||
|
this.templateId = templateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getIssuedCount() {
|
||||||
|
return issuedCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIssuedCount(long issuedCount) {
|
||||||
|
this.issuedCount = issuedCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getUsedCount() {
|
||||||
|
return usedCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsedCount(long usedCount) {
|
||||||
|
this.usedCount = usedCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getAvailableCount() {
|
||||||
|
return availableCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvailableCount(long availableCount) {
|
||||||
|
this.availableCount = availableCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getExpiredCount() {
|
||||||
|
return expiredCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpiredCount(long expiredCount) {
|
||||||
|
this.expiredCount = expiredCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getRedemptionRate() {
|
||||||
|
return redemptionRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRedemptionRate(BigDecimal redemptionRate) {
|
||||||
|
this.redemptionRate = redemptionRate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getTotalDiscountAmount() {
|
||||||
|
return totalDiscountAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalDiscountAmount(BigDecimal totalDiscountAmount) {
|
||||||
|
this.totalDiscountAmount = totalDiscountAmount;
|
||||||
|
}
|
||||||
|
}
|
||||||
+209
@@ -0,0 +1,209 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.domain;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "优惠券模板")
|
||||||
|
public class CouponTemplate extends BaseDomain {
|
||||||
|
|
||||||
|
//优惠券名称
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "优惠券描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "优惠券类型:CASH/DISCOUNT/COURSE/EXPERIENCE", example = "CASH")
|
||||||
|
private String couponType;
|
||||||
|
|
||||||
|
@Schema(description = "优惠值:满减/课程/体验为金额,折扣券为比例(0.9=9折)", example = "20.00")
|
||||||
|
private BigDecimal discountValue;
|
||||||
|
|
||||||
|
@Schema(description = "使用门槛金额", example = "100.00")
|
||||||
|
private BigDecimal thresholdAmount;
|
||||||
|
|
||||||
|
@Schema(description = "有效期类型:FIXED_DATE/DAYS_AFTER_CLAIM", example = "FIXED_DATE")
|
||||||
|
private String validityType;
|
||||||
|
|
||||||
|
@Schema(description = "固定有效期开始时间")
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
|
||||||
|
@Schema(description = "固定有效期结束时间")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@Schema(description = "领取后有效天数")
|
||||||
|
private Integer validDays;
|
||||||
|
|
||||||
|
@Schema(description = "适用商品范围:ALL/SPECIFIC", example = "ALL")
|
||||||
|
private String applyScope;
|
||||||
|
|
||||||
|
@Schema(description = "指定商品ID列表(JSON数组字符串)")
|
||||||
|
private String applyProductIds;
|
||||||
|
|
||||||
|
@Schema(description = "发放总量,-1表示不限量", example = "1000")
|
||||||
|
private Integer totalQuantity;
|
||||||
|
|
||||||
|
@Schema(description = "每人限领数量", example = "1")
|
||||||
|
private Integer perUserLimit;
|
||||||
|
|
||||||
|
@Schema(description = "是否可叠加使用", example = "false")
|
||||||
|
private Boolean stackable;
|
||||||
|
|
||||||
|
@Schema(description = "领取码")
|
||||||
|
private String claimCode;
|
||||||
|
|
||||||
|
@Schema(description = "状态:DRAFT/ACTIVE/TERMINATED/EXPIRED", example = "DRAFT")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Schema(description = "已发放数量")
|
||||||
|
private Integer issuedCount;
|
||||||
|
|
||||||
|
@Schema(description = "已使用数量")
|
||||||
|
private Integer usedCount;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCouponType() {
|
||||||
|
return couponType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCouponType(String couponType) {
|
||||||
|
this.couponType = couponType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getDiscountValue() {
|
||||||
|
return discountValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiscountValue(BigDecimal discountValue) {
|
||||||
|
this.discountValue = discountValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getThresholdAmount() {
|
||||||
|
return thresholdAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setThresholdAmount(BigDecimal thresholdAmount) {
|
||||||
|
this.thresholdAmount = thresholdAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValidityType() {
|
||||||
|
return validityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValidityType(String validityType) {
|
||||||
|
this.validityType = validityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(LocalDateTime startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime(LocalDateTime endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getValidDays() {
|
||||||
|
return validDays;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValidDays(Integer validDays) {
|
||||||
|
this.validDays = validDays;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApplyScope() {
|
||||||
|
return applyScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApplyScope(String applyScope) {
|
||||||
|
this.applyScope = applyScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApplyProductIds() {
|
||||||
|
return applyProductIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApplyProductIds(String applyProductIds) {
|
||||||
|
this.applyProductIds = applyProductIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTotalQuantity() {
|
||||||
|
return totalQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalQuantity(Integer totalQuantity) {
|
||||||
|
this.totalQuantity = totalQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPerUserLimit() {
|
||||||
|
return perUserLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPerUserLimit(Integer perUserLimit) {
|
||||||
|
this.perUserLimit = perUserLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getStackable() {
|
||||||
|
return stackable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStackable(Boolean stackable) {
|
||||||
|
this.stackable = stackable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClaimCode() {
|
||||||
|
return claimCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClaimCode(String claimCode) {
|
||||||
|
this.claimCode = claimCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIssuedCount() {
|
||||||
|
return issuedCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIssuedCount(Integer issuedCount) {
|
||||||
|
this.issuedCount = issuedCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUsedCount() {
|
||||||
|
return usedCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsedCount(Integer usedCount) {
|
||||||
|
this.usedCount = usedCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Schema(description = "优惠券发放请求")
|
||||||
|
public class DistributeCouponRequest {
|
||||||
|
|
||||||
|
@Schema(description = "目标会员ID列表", requiredMode = Schema.RequiredMode.REQUIRED)
|
||||||
|
private List<Long> memberIds;
|
||||||
|
|
||||||
|
@Schema(description = "发放方式:MANUAL/BATCH,默认MANUAL", example = "MANUAL")
|
||||||
|
private String distributeType;
|
||||||
|
|
||||||
|
public List<Long> getMemberIds() {
|
||||||
|
return memberIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberIds(List<Long> memberIds) {
|
||||||
|
this.memberIds = memberIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDistributeType() {
|
||||||
|
return distributeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistributeType(String distributeType) {
|
||||||
|
this.distributeType = distributeType;
|
||||||
|
}
|
||||||
|
}
|
||||||
+49
@@ -0,0 +1,49 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
@Schema(description = "优惠券发放结果")
|
||||||
|
public class DistributeCouponResult {
|
||||||
|
|
||||||
|
@Schema(description = "成功发放数量")
|
||||||
|
private int successCount;
|
||||||
|
|
||||||
|
@Schema(description = "失败数量")
|
||||||
|
private int failCount;
|
||||||
|
|
||||||
|
@Schema(description = "提示信息")
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
public DistributeCouponResult() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DistributeCouponResult(int successCount, int failCount, String message) {
|
||||||
|
this.successCount = successCount;
|
||||||
|
this.failCount = failCount;
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSuccessCount() {
|
||||||
|
return successCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuccessCount(int successCount) {
|
||||||
|
this.successCount = successCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getFailCount() {
|
||||||
|
return failCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFailCount(int failCount) {
|
||||||
|
this.failCount = failCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage() {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMessage(String message) {
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
}
|
||||||
+109
@@ -0,0 +1,109 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.domain;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "会员优惠券")
|
||||||
|
public class MemberCoupon extends BaseDomain {
|
||||||
|
|
||||||
|
@Schema(description = "优惠券模板ID")
|
||||||
|
private Long templateId;
|
||||||
|
|
||||||
|
@Schema(description = "会员ID")
|
||||||
|
private Long memberId;
|
||||||
|
|
||||||
|
@Schema(description = "优惠券码")
|
||||||
|
private String couponCode;
|
||||||
|
|
||||||
|
@Schema(description = "状态:AVAILABLE/USED/EXPIRED/INVALID")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Schema(description = "发放方式:MANUAL/BATCH/AUTO/CLAIM")
|
||||||
|
private String distributeType;
|
||||||
|
|
||||||
|
@Schema(description = "领取时间")
|
||||||
|
private LocalDateTime receivedAt;
|
||||||
|
|
||||||
|
@Schema(description = "过期时间")
|
||||||
|
private LocalDateTime expireAt;
|
||||||
|
|
||||||
|
@Schema(description = "使用时间")
|
||||||
|
private LocalDateTime usedAt;
|
||||||
|
|
||||||
|
@Schema(description = "关联订单ID")
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
|
public Long getTemplateId() {
|
||||||
|
return templateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemplateId(Long templateId) {
|
||||||
|
this.templateId = templateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(Long memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCouponCode() {
|
||||||
|
return couponCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCouponCode(String couponCode) {
|
||||||
|
this.couponCode = couponCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDistributeType() {
|
||||||
|
return distributeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistributeType(String distributeType) {
|
||||||
|
this.distributeType = distributeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getReceivedAt() {
|
||||||
|
return receivedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReceivedAt(LocalDateTime receivedAt) {
|
||||||
|
this.receivedAt = receivedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getExpireAt() {
|
||||||
|
return expireAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpireAt(LocalDateTime expireAt) {
|
||||||
|
this.expireAt = expireAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getUsedAt() {
|
||||||
|
return usedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsedAt(LocalDateTime usedAt) {
|
||||||
|
this.usedAt = usedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getOrderId() {
|
||||||
|
return orderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderId(Long orderId) {
|
||||||
|
this.orderId = orderId;
|
||||||
|
}
|
||||||
|
}
|
||||||
+210
@@ -0,0 +1,210 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.entity;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.db.entity.BaseEntity;
|
||||||
|
import org.springframework.data.relational.core.mapping.Column;
|
||||||
|
import org.springframework.data.relational.core.mapping.Table;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Table("coupon_template")
|
||||||
|
public class CouponTemplateEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@Column("name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Column("description")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Column("coupon_type")
|
||||||
|
private String couponType;
|
||||||
|
|
||||||
|
@Column("discount_value")
|
||||||
|
private BigDecimal discountValue;
|
||||||
|
|
||||||
|
@Column("threshold_amount")
|
||||||
|
private BigDecimal thresholdAmount;
|
||||||
|
|
||||||
|
@Column("validity_type")
|
||||||
|
private String validityType;
|
||||||
|
|
||||||
|
@Column("start_time")
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
|
||||||
|
@Column("end_time")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@Column("valid_days")
|
||||||
|
private Integer validDays;
|
||||||
|
|
||||||
|
@Column("apply_scope")
|
||||||
|
private String applyScope;
|
||||||
|
|
||||||
|
@Column("apply_product_ids")
|
||||||
|
private String applyProductIds;
|
||||||
|
|
||||||
|
@Column("total_quantity")
|
||||||
|
private Integer totalQuantity;
|
||||||
|
|
||||||
|
@Column("per_user_limit")
|
||||||
|
private Integer perUserLimit;
|
||||||
|
|
||||||
|
@Column("stackable")
|
||||||
|
private Boolean stackable;
|
||||||
|
|
||||||
|
@Column("claim_code")
|
||||||
|
private String claimCode;
|
||||||
|
|
||||||
|
@Column("status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Column("issued_count")
|
||||||
|
private Integer issuedCount;
|
||||||
|
|
||||||
|
@Column("used_count")
|
||||||
|
private Integer usedCount;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCouponType() {
|
||||||
|
return couponType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCouponType(String couponType) {
|
||||||
|
this.couponType = couponType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getDiscountValue() {
|
||||||
|
return discountValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiscountValue(BigDecimal discountValue) {
|
||||||
|
this.discountValue = discountValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getThresholdAmount() {
|
||||||
|
return thresholdAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setThresholdAmount(BigDecimal thresholdAmount) {
|
||||||
|
this.thresholdAmount = thresholdAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValidityType() {
|
||||||
|
return validityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValidityType(String validityType) {
|
||||||
|
this.validityType = validityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(LocalDateTime startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime(LocalDateTime endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getValidDays() {
|
||||||
|
return validDays;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValidDays(Integer validDays) {
|
||||||
|
this.validDays = validDays;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApplyScope() {
|
||||||
|
return applyScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApplyScope(String applyScope) {
|
||||||
|
this.applyScope = applyScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApplyProductIds() {
|
||||||
|
return applyProductIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApplyProductIds(String applyProductIds) {
|
||||||
|
this.applyProductIds = applyProductIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTotalQuantity() {
|
||||||
|
return totalQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalQuantity(Integer totalQuantity) {
|
||||||
|
this.totalQuantity = totalQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPerUserLimit() {
|
||||||
|
return perUserLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPerUserLimit(Integer perUserLimit) {
|
||||||
|
this.perUserLimit = perUserLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getStackable() {
|
||||||
|
return stackable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStackable(Boolean stackable) {
|
||||||
|
this.stackable = stackable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getClaimCode() {
|
||||||
|
return claimCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setClaimCode(String claimCode) {
|
||||||
|
this.claimCode = claimCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getIssuedCount() {
|
||||||
|
return issuedCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIssuedCount(Integer issuedCount) {
|
||||||
|
this.issuedCount = issuedCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUsedCount() {
|
||||||
|
return usedCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsedCount(Integer usedCount) {
|
||||||
|
this.usedCount = usedCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
+110
@@ -0,0 +1,110 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.entity;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.db.entity.BaseEntity;
|
||||||
|
import org.springframework.data.relational.core.mapping.Column;
|
||||||
|
import org.springframework.data.relational.core.mapping.Table;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Table("member_coupon")
|
||||||
|
public class MemberCouponEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@Column("template_id")
|
||||||
|
private Long templateId;
|
||||||
|
|
||||||
|
@Column("member_id")
|
||||||
|
private Long memberId;
|
||||||
|
|
||||||
|
@Column("coupon_code")
|
||||||
|
private String couponCode;
|
||||||
|
|
||||||
|
@Column("status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Column("distribute_type")
|
||||||
|
private String distributeType;
|
||||||
|
|
||||||
|
@Column("received_at")
|
||||||
|
private LocalDateTime receivedAt;
|
||||||
|
|
||||||
|
@Column("expire_at")
|
||||||
|
private LocalDateTime expireAt;
|
||||||
|
|
||||||
|
@Column("used_at")
|
||||||
|
private LocalDateTime usedAt;
|
||||||
|
|
||||||
|
@Column("order_id")
|
||||||
|
private Long orderId;
|
||||||
|
|
||||||
|
public Long getTemplateId() {
|
||||||
|
return templateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTemplateId(Long templateId) {
|
||||||
|
this.templateId = templateId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(Long memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCouponCode() {
|
||||||
|
return couponCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCouponCode(String couponCode) {
|
||||||
|
this.couponCode = couponCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDistributeType() {
|
||||||
|
return distributeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistributeType(String distributeType) {
|
||||||
|
this.distributeType = distributeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getReceivedAt() {
|
||||||
|
return receivedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setReceivedAt(LocalDateTime receivedAt) {
|
||||||
|
this.receivedAt = receivedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getExpireAt() {
|
||||||
|
return expireAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpireAt(LocalDateTime expireAt) {
|
||||||
|
this.expireAt = expireAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getUsedAt() {
|
||||||
|
return usedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsedAt(LocalDateTime usedAt) {
|
||||||
|
this.usedAt = usedAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getOrderId() {
|
||||||
|
return orderId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderId(Long orderId) {
|
||||||
|
this.orderId = orderId;
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠券适用商品范围
|
||||||
|
*/
|
||||||
|
public enum ApplyScope {
|
||||||
|
/** 全场通用 */
|
||||||
|
ALL,
|
||||||
|
/** 指定商品 */
|
||||||
|
SPECIFIC
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠券模板状态
|
||||||
|
*/
|
||||||
|
public enum CouponTemplateStatus {
|
||||||
|
/** 草稿 */
|
||||||
|
DRAFT,
|
||||||
|
/** 进行中 */
|
||||||
|
ACTIVE,
|
||||||
|
/** 已终止 */
|
||||||
|
TERMINATED,
|
||||||
|
/** 已过期 */
|
||||||
|
EXPIRED
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠券类型
|
||||||
|
*/
|
||||||
|
public enum CouponType {
|
||||||
|
/** 满减券 */
|
||||||
|
CASH,
|
||||||
|
/** 折扣券 */
|
||||||
|
DISCOUNT,
|
||||||
|
/** 课程券 */
|
||||||
|
COURSE,
|
||||||
|
/** 体验券(会员体验专用) */
|
||||||
|
EXPERIENCE
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠券发放方式
|
||||||
|
*/
|
||||||
|
public enum DistributeType {
|
||||||
|
/** 手动发放(指定会员) */
|
||||||
|
MANUAL,
|
||||||
|
/** 批量发放(按会员分组) */
|
||||||
|
BATCH,
|
||||||
|
/** 自动发放(触发规则) */
|
||||||
|
AUTO,
|
||||||
|
/** 领取码/二维码领取 */
|
||||||
|
CLAIM
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员优惠券状态
|
||||||
|
*/
|
||||||
|
public enum MemberCouponStatus {
|
||||||
|
/** 可用 */
|
||||||
|
AVAILABLE,
|
||||||
|
/** 已使用 */
|
||||||
|
USED,
|
||||||
|
/** 已过期 */
|
||||||
|
EXPIRED,
|
||||||
|
/** 已作废 */
|
||||||
|
INVALID
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优惠券有效期类型
|
||||||
|
*/
|
||||||
|
public enum ValidityType {
|
||||||
|
/** 固定日期 */
|
||||||
|
FIXED_DATE,
|
||||||
|
/** 领取后X天 */
|
||||||
|
DAYS_AFTER_CLAIM
|
||||||
|
}
|
||||||
+77
@@ -0,0 +1,77 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.converter;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleItem;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleOrder;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.entity.FlashSaleActivityEntity;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.entity.FlashSaleItemEntity;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.entity.FlashSaleOrderEntity;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class FlashSaleConverter {
|
||||||
|
|
||||||
|
public FlashSaleActivity toActivity(FlashSaleActivityEntity entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
FlashSaleActivity domain = new FlashSaleActivity();
|
||||||
|
BeanUtil.copyProperties(entity, domain);
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlashSaleActivityEntity toActivityEntity(FlashSaleActivity domain) {
|
||||||
|
if (domain == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
FlashSaleActivityEntity entity = new FlashSaleActivityEntity();
|
||||||
|
BeanUtil.copyProperties(domain, entity);
|
||||||
|
if (domain.getId() != null) {
|
||||||
|
entity.markNotNew();
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlashSaleItem toItem(FlashSaleItemEntity entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
FlashSaleItem domain = new FlashSaleItem();
|
||||||
|
BeanUtil.copyProperties(entity, domain);
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlashSaleItemEntity toItemEntity(FlashSaleItem domain) {
|
||||||
|
if (domain == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
FlashSaleItemEntity entity = new FlashSaleItemEntity();
|
||||||
|
BeanUtil.copyProperties(domain, entity);
|
||||||
|
if (domain.getId() != null) {
|
||||||
|
entity.markNotNew();
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlashSaleOrder toOrder(FlashSaleOrderEntity entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
FlashSaleOrder domain = new FlashSaleOrder();
|
||||||
|
BeanUtil.copyProperties(entity, domain);
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public FlashSaleOrderEntity toOrderEntity(FlashSaleOrder domain) {
|
||||||
|
if (domain == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
FlashSaleOrderEntity entity = new FlashSaleOrderEntity();
|
||||||
|
BeanUtil.copyProperties(domain, entity);
|
||||||
|
if (domain.getId() != null) {
|
||||||
|
entity.markNotNew();
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.dao;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.entity.FlashSaleActivityEntity;
|
||||||
|
import org.springframework.data.r2dbc.repository.Modifying;
|
||||||
|
import org.springframework.data.r2dbc.repository.Query;
|
||||||
|
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface FlashSaleActivityDao extends R2dbcRepository<FlashSaleActivityEntity, Long> {
|
||||||
|
|
||||||
|
Mono<FlashSaleActivityEntity> findByIdIsAndDeletedAtIsNull(Long id);
|
||||||
|
|
||||||
|
Flux<FlashSaleActivityEntity> findAllByDeletedAtIsNull();
|
||||||
|
|
||||||
|
Flux<FlashSaleActivityEntity> findByNameContainingAndDeletedAtIsNull(String name);
|
||||||
|
|
||||||
|
Flux<FlashSaleActivityEntity> findByStatusAndDeletedAtIsNull(String status);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE flash_sale_activity SET deleted_at = :deletedAt WHERE id = :id")
|
||||||
|
Mono<Integer> softDelete(Long id, LocalDateTime deletedAt);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE flash_sale_activity SET status = :status, updated_at = :updatedAt WHERE id = :id")
|
||||||
|
Mono<Integer> updateStatus(Long id, String status, LocalDateTime updatedAt);
|
||||||
|
}
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.dao;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.entity.FlashSaleItemEntity;
|
||||||
|
import org.springframework.data.r2dbc.repository.Modifying;
|
||||||
|
import org.springframework.data.r2dbc.repository.Query;
|
||||||
|
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface FlashSaleItemDao extends R2dbcRepository<FlashSaleItemEntity, Long> {
|
||||||
|
|
||||||
|
Mono<FlashSaleItemEntity> findByIdIsAndDeletedAtIsNull(Long id);
|
||||||
|
|
||||||
|
Flux<FlashSaleItemEntity> findByActivityIdAndDeletedAtIsNull(Long activityId);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE flash_sale_item SET stock = stock - :quantity, updated_at = :updatedAt WHERE id = :id AND stock >= :quantity")
|
||||||
|
Mono<Integer> deductStock(Long id, int quantity, LocalDateTime updatedAt);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE flash_sale_item SET stock = stock + :quantity, updated_at = :updatedAt WHERE id = :id")
|
||||||
|
Mono<Integer> restoreStock(Long id, int quantity, LocalDateTime updatedAt);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE flash_sale_item SET sold_count = sold_count + :count, updated_at = :updatedAt WHERE id = :id")
|
||||||
|
Mono<Integer> incrementSoldCount(Long id, int count, LocalDateTime updatedAt);
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.dao;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.entity.FlashSaleOrderEntity;
|
||||||
|
import org.springframework.data.r2dbc.repository.Modifying;
|
||||||
|
import org.springframework.data.r2dbc.repository.Query;
|
||||||
|
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface FlashSaleOrderDao extends R2dbcRepository<FlashSaleOrderEntity, Long> {
|
||||||
|
|
||||||
|
Mono<FlashSaleOrderEntity> findByIdIsAndDeletedAtIsNull(Long id);
|
||||||
|
|
||||||
|
Flux<FlashSaleOrderEntity> findByMemberIdAndDeletedAtIsNull(Long memberId);
|
||||||
|
|
||||||
|
Flux<FlashSaleOrderEntity> findByActivityIdAndDeletedAtIsNull(Long activityId);
|
||||||
|
|
||||||
|
Mono<Long> countByActivityIdAndMemberIdAndStatusAndDeletedAtIsNull(
|
||||||
|
Long activityId, Long memberId, String status);
|
||||||
|
|
||||||
|
Mono<Long> countByItemIdAndMemberIdAndStatusInAndDeletedAtIsNull(
|
||||||
|
Long itemId, Long memberId, java.util.Collection<String> statuses);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM flash_sale_order WHERE status = :status AND expire_at < :now AND deleted_at IS NULL")
|
||||||
|
Flux<FlashSaleOrderEntity> findExpiredPendingOrders(String status, LocalDateTime now);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE flash_sale_order SET status = :status, updated_at = :updatedAt WHERE id = :id")
|
||||||
|
Mono<Integer> updateStatus(Long id, String status, LocalDateTime updatedAt);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE flash_sale_order SET status = :status, pay_at = :payAt, updated_at = :updatedAt WHERE id = :id")
|
||||||
|
Mono<Integer> markPaid(Long id, String status, LocalDateTime payAt, LocalDateTime updatedAt);
|
||||||
|
}
|
||||||
+74
@@ -0,0 +1,74 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.domain;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "秒杀活动")
|
||||||
|
public class FlashSaleActivity extends BaseDomain {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
private Integer payTimeoutMinutes;
|
||||||
|
private Integer perUserLimit;
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(LocalDateTime startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime(LocalDateTime endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPayTimeoutMinutes() {
|
||||||
|
return payTimeoutMinutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPayTimeoutMinutes(Integer payTimeoutMinutes) {
|
||||||
|
this.payTimeoutMinutes = payTimeoutMinutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPerUserLimit() {
|
||||||
|
return perUserLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPerUserLimit(Integer perUserLimit) {
|
||||||
|
this.perUserLimit = perUserLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
+92
@@ -0,0 +1,92 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.domain;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Schema(description = "秒杀商品")
|
||||||
|
public class FlashSaleItem extends BaseDomain {
|
||||||
|
|
||||||
|
private Long activityId;
|
||||||
|
private String productType;
|
||||||
|
private Long productId;
|
||||||
|
private String productName;
|
||||||
|
private BigDecimal originalPrice;
|
||||||
|
private BigDecimal seckillPrice;
|
||||||
|
private Integer stock;
|
||||||
|
private Integer soldCount;
|
||||||
|
private Integer perUserLimit;
|
||||||
|
|
||||||
|
public Long getActivityId() {
|
||||||
|
return activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityId(Long activityId) {
|
||||||
|
this.activityId = activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductType() {
|
||||||
|
return productType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductType(String productType) {
|
||||||
|
this.productType = productType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getProductId() {
|
||||||
|
return productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductId(Long productId) {
|
||||||
|
this.productId = productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductName() {
|
||||||
|
return productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductName(String productName) {
|
||||||
|
this.productName = productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getOriginalPrice() {
|
||||||
|
return originalPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOriginalPrice(BigDecimal originalPrice) {
|
||||||
|
this.originalPrice = originalPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getSeckillPrice() {
|
||||||
|
return seckillPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSeckillPrice(BigDecimal seckillPrice) {
|
||||||
|
this.seckillPrice = seckillPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStock() {
|
||||||
|
return stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStock(Integer stock) {
|
||||||
|
this.stock = stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSoldCount() {
|
||||||
|
return soldCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSoldCount(Integer soldCount) {
|
||||||
|
this.soldCount = soldCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPerUserLimit() {
|
||||||
|
return perUserLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPerUserLimit(Integer perUserLimit) {
|
||||||
|
this.perUserLimit = perUserLimit;
|
||||||
|
}
|
||||||
|
}
|
||||||
+84
@@ -0,0 +1,84 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.domain;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "秒杀订单")
|
||||||
|
public class FlashSaleOrder extends BaseDomain {
|
||||||
|
|
||||||
|
private Long activityId;
|
||||||
|
private Long itemId;
|
||||||
|
private Long memberId;
|
||||||
|
private Integer quantity;
|
||||||
|
private BigDecimal payAmount;
|
||||||
|
private String status;
|
||||||
|
private LocalDateTime expireAt;
|
||||||
|
private LocalDateTime payAt;
|
||||||
|
|
||||||
|
public Long getActivityId() {
|
||||||
|
return activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityId(Long activityId) {
|
||||||
|
this.activityId = activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getItemId() {
|
||||||
|
return itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemId(Long itemId) {
|
||||||
|
this.itemId = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(Long memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getQuantity() {
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantity(Integer quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getPayAmount() {
|
||||||
|
return payAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPayAmount(BigDecimal payAmount) {
|
||||||
|
this.payAmount = payAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getExpireAt() {
|
||||||
|
return expireAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpireAt(LocalDateTime expireAt) {
|
||||||
|
this.expireAt = expireAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getPayAt() {
|
||||||
|
return payAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPayAt(LocalDateTime payAt) {
|
||||||
|
this.payAt = payAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
+82
@@ -0,0 +1,82 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Schema(description = "秒杀统计数据")
|
||||||
|
public class FlashSaleStatistics {
|
||||||
|
|
||||||
|
private Long activityId;
|
||||||
|
private long totalOrders;
|
||||||
|
private long pendingOrders;
|
||||||
|
private long paidOrders;
|
||||||
|
private long cancelledOrders;
|
||||||
|
private long expiredOrders;
|
||||||
|
private long totalSoldQuantity;
|
||||||
|
private BigDecimal totalRevenue;
|
||||||
|
|
||||||
|
public Long getActivityId() {
|
||||||
|
return activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityId(Long activityId) {
|
||||||
|
this.activityId = activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalOrders() {
|
||||||
|
return totalOrders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalOrders(long totalOrders) {
|
||||||
|
this.totalOrders = totalOrders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getPendingOrders() {
|
||||||
|
return pendingOrders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPendingOrders(long pendingOrders) {
|
||||||
|
this.pendingOrders = pendingOrders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getPaidOrders() {
|
||||||
|
return paidOrders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPaidOrders(long paidOrders) {
|
||||||
|
this.paidOrders = paidOrders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCancelledOrders() {
|
||||||
|
return cancelledOrders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelledOrders(long cancelledOrders) {
|
||||||
|
this.cancelledOrders = cancelledOrders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getExpiredOrders() {
|
||||||
|
return expiredOrders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpiredOrders(long expiredOrders) {
|
||||||
|
this.expiredOrders = expiredOrders;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalSoldQuantity() {
|
||||||
|
return totalSoldQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalSoldQuantity(long totalSoldQuantity) {
|
||||||
|
this.totalSoldQuantity = totalSoldQuantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getTotalRevenue() {
|
||||||
|
return totalRevenue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalRevenue(BigDecimal totalRevenue) {
|
||||||
|
this.totalRevenue = totalRevenue;
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
@Schema(description = "秒杀抢购请求")
|
||||||
|
public class GrabRequest {
|
||||||
|
|
||||||
|
private Long itemId;
|
||||||
|
private Long memberId;
|
||||||
|
private Integer quantity;
|
||||||
|
|
||||||
|
public Long getItemId() {
|
||||||
|
return itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemId(Long itemId) {
|
||||||
|
this.itemId = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(Long memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getQuantity() {
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantity(Integer quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
}
|
||||||
+88
@@ -0,0 +1,88 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.entity;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.db.entity.BaseEntity;
|
||||||
|
import org.springframework.data.relational.core.mapping.Column;
|
||||||
|
import org.springframework.data.relational.core.mapping.Table;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Table("flash_sale_activity")
|
||||||
|
public class FlashSaleActivityEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@Column("name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Column("description")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Column("start_time")
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
|
||||||
|
@Column("end_time")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@Column("pay_timeout_minutes")
|
||||||
|
private Integer payTimeoutMinutes;
|
||||||
|
|
||||||
|
@Column("per_user_limit")
|
||||||
|
private Integer perUserLimit;
|
||||||
|
|
||||||
|
@Column("status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(LocalDateTime startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime(LocalDateTime endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPayTimeoutMinutes() {
|
||||||
|
return payTimeoutMinutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPayTimeoutMinutes(Integer payTimeoutMinutes) {
|
||||||
|
this.payTimeoutMinutes = payTimeoutMinutes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPerUserLimit() {
|
||||||
|
return perUserLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPerUserLimit(Integer perUserLimit) {
|
||||||
|
this.perUserLimit = perUserLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
+110
@@ -0,0 +1,110 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.entity;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.db.entity.BaseEntity;
|
||||||
|
import org.springframework.data.relational.core.mapping.Column;
|
||||||
|
import org.springframework.data.relational.core.mapping.Table;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Table("flash_sale_item")
|
||||||
|
public class FlashSaleItemEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@Column("activity_id")
|
||||||
|
private Long activityId;
|
||||||
|
|
||||||
|
@Column("product_type")
|
||||||
|
private String productType;
|
||||||
|
|
||||||
|
@Column("product_id")
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
@Column("product_name")
|
||||||
|
private String productName;
|
||||||
|
|
||||||
|
@Column("original_price")
|
||||||
|
private BigDecimal originalPrice;
|
||||||
|
|
||||||
|
@Column("seckill_price")
|
||||||
|
private BigDecimal seckillPrice;
|
||||||
|
|
||||||
|
@Column("stock")
|
||||||
|
private Integer stock;
|
||||||
|
|
||||||
|
@Column("sold_count")
|
||||||
|
private Integer soldCount;
|
||||||
|
|
||||||
|
@Column("per_user_limit")
|
||||||
|
private Integer perUserLimit;
|
||||||
|
|
||||||
|
public Long getActivityId() {
|
||||||
|
return activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityId(Long activityId) {
|
||||||
|
this.activityId = activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductType() {
|
||||||
|
return productType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductType(String productType) {
|
||||||
|
this.productType = productType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getProductId() {
|
||||||
|
return productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductId(Long productId) {
|
||||||
|
this.productId = productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductName() {
|
||||||
|
return productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductName(String productName) {
|
||||||
|
this.productName = productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getOriginalPrice() {
|
||||||
|
return originalPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOriginalPrice(BigDecimal originalPrice) {
|
||||||
|
this.originalPrice = originalPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getSeckillPrice() {
|
||||||
|
return seckillPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSeckillPrice(BigDecimal seckillPrice) {
|
||||||
|
this.seckillPrice = seckillPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStock() {
|
||||||
|
return stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStock(Integer stock) {
|
||||||
|
this.stock = stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSoldCount() {
|
||||||
|
return soldCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSoldCount(Integer soldCount) {
|
||||||
|
this.soldCount = soldCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPerUserLimit() {
|
||||||
|
return perUserLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPerUserLimit(Integer perUserLimit) {
|
||||||
|
this.perUserLimit = perUserLimit;
|
||||||
|
}
|
||||||
|
}
|
||||||
+100
@@ -0,0 +1,100 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.entity;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.db.entity.BaseEntity;
|
||||||
|
import org.springframework.data.relational.core.mapping.Column;
|
||||||
|
import org.springframework.data.relational.core.mapping.Table;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Table("flash_sale_order")
|
||||||
|
public class FlashSaleOrderEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@Column("activity_id")
|
||||||
|
private Long activityId;
|
||||||
|
|
||||||
|
@Column("item_id")
|
||||||
|
private Long itemId;
|
||||||
|
|
||||||
|
@Column("member_id")
|
||||||
|
private Long memberId;
|
||||||
|
|
||||||
|
@Column("quantity")
|
||||||
|
private Integer quantity;
|
||||||
|
|
||||||
|
@Column("pay_amount")
|
||||||
|
private BigDecimal payAmount;
|
||||||
|
|
||||||
|
@Column("status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Column("expire_at")
|
||||||
|
private LocalDateTime expireAt;
|
||||||
|
|
||||||
|
@Column("pay_at")
|
||||||
|
private LocalDateTime payAt;
|
||||||
|
|
||||||
|
public Long getActivityId() {
|
||||||
|
return activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityId(Long activityId) {
|
||||||
|
this.activityId = activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getItemId() {
|
||||||
|
return itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setItemId(Long itemId) {
|
||||||
|
this.itemId = itemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(Long memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getQuantity() {
|
||||||
|
return quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setQuantity(Integer quantity) {
|
||||||
|
this.quantity = quantity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getPayAmount() {
|
||||||
|
return payAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPayAmount(BigDecimal payAmount) {
|
||||||
|
this.payAmount = payAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getExpireAt() {
|
||||||
|
return expireAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpireAt(LocalDateTime expireAt) {
|
||||||
|
this.expireAt = expireAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getPayAt() {
|
||||||
|
return payAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPayAt(LocalDateTime payAt) {
|
||||||
|
this.payAt = payAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 秒杀活动状态
|
||||||
|
*/
|
||||||
|
public enum FlashSaleActivityStatus {
|
||||||
|
DRAFT,
|
||||||
|
ACTIVE,
|
||||||
|
TERMINATED,
|
||||||
|
EXPIRED
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 秒杀订单状态
|
||||||
|
*/
|
||||||
|
public enum FlashSaleOrderStatus {
|
||||||
|
PENDING,
|
||||||
|
PAID,
|
||||||
|
CANCELLED,
|
||||||
|
EXPIRED
|
||||||
|
}
|
||||||
+219
@@ -0,0 +1,219 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.handler;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleItem;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleOrder;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.GrabRequest;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.service.IFlashSaleActivityService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||||
|
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Tag(name = "秒杀管理", description = "秒杀相关操作")
|
||||||
|
public class FlashSaleHandler {
|
||||||
|
|
||||||
|
private final IFlashSaleActivityService flashSaleService;
|
||||||
|
|
||||||
|
public FlashSaleHandler(IFlashSaleActivityService flashSaleService) {
|
||||||
|
this.flashSaleService = flashSaleService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取所有秒杀活动")
|
||||||
|
public Mono<ServerResponse> getAllActivities(ServerRequest request) {
|
||||||
|
boolean includeDeleted = Boolean.parseBoolean(request.queryParam("includeDeleted").orElse("false"));
|
||||||
|
return ServerResponse.ok()
|
||||||
|
.body(flashSaleService.findAll(includeDeleted), FlashSaleActivity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "分页获取秒杀活动")
|
||||||
|
public Mono<ServerResponse> getActivitiesByPage(ServerRequest request) {
|
||||||
|
return request.bodyToMono(PageRequest.class)
|
||||||
|
.flatMap(pageRequest -> {
|
||||||
|
String status = request.queryParam("status").orElse(null);
|
||||||
|
normalizePageRequest(pageRequest);
|
||||||
|
return flashSaleService.findByPage(pageRequest, status)
|
||||||
|
.flatMap(response -> ServerResponse.ok().bodyValue(response));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "搜索秒杀活动")
|
||||||
|
public Mono<ServerResponse> searchActivities(ServerRequest request) {
|
||||||
|
String keyword = request.queryParam("keyword").orElse("");
|
||||||
|
String status = request.queryParam("status").orElse(null);
|
||||||
|
return ServerResponse.ok()
|
||||||
|
.body(flashSaleService.findByKeywordAndStatus(keyword, status), FlashSaleActivity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "根据ID获取秒杀活动")
|
||||||
|
public Mono<ServerResponse> getActivityById(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
return flashSaleService.findById(id)
|
||||||
|
.flatMap(activity -> ServerResponse.ok().bodyValue(activity))
|
||||||
|
.switchIfEmpty(ServerResponse.notFound().build());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "创建秒杀活动")
|
||||||
|
public Mono<ServerResponse> createActivity(ServerRequest request) {
|
||||||
|
return request.bodyToMono(FlashSaleActivity.class)
|
||||||
|
.flatMap(activity -> {
|
||||||
|
if (activity.getName() == null || activity.getName().isEmpty()) {
|
||||||
|
return badRequest("活动名称不能为空");
|
||||||
|
}
|
||||||
|
return flashSaleService.create(activity)
|
||||||
|
.flatMap(created -> successResponse("秒杀活动创建成功", created))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新秒杀活动")
|
||||||
|
public Mono<ServerResponse> updateActivity(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
return request.bodyToMono(FlashSaleActivity.class)
|
||||||
|
.flatMap(activity -> flashSaleService.update(id, activity)
|
||||||
|
.flatMap(updated -> successResponse("秒杀活动更新成功", updated))
|
||||||
|
.onErrorResume(this::errorResponse));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除秒杀活动")
|
||||||
|
public Mono<ServerResponse> deleteActivity(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
return flashSaleService.delete(id)
|
||||||
|
.then(Mono.defer(() -> successResponse("秒杀活动删除成功", null)))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "发布秒杀活动")
|
||||||
|
public Mono<ServerResponse> publishActivity(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
return flashSaleService.publish(id)
|
||||||
|
.flatMap(activity -> successResponse("秒杀活动发布成功", activity))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "终止秒杀活动")
|
||||||
|
public Mono<ServerResponse> terminateActivity(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
return flashSaleService.terminate(id)
|
||||||
|
.flatMap(activity -> successResponse("秒杀活动已终止", activity))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取秒杀统计")
|
||||||
|
public Mono<ServerResponse> getStatistics(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
return flashSaleService.getStatistics(id)
|
||||||
|
.flatMap(stats -> ServerResponse.ok().bodyValue(stats))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取秒杀商品列表")
|
||||||
|
public Mono<ServerResponse> getItems(ServerRequest request) {
|
||||||
|
String activityIdStr = request.queryParam("activityId").orElse(null);
|
||||||
|
if (activityIdStr == null) {
|
||||||
|
return badRequest("activityId不能为空");
|
||||||
|
}
|
||||||
|
Long activityId = Long.valueOf(activityIdStr);
|
||||||
|
return ServerResponse.ok()
|
||||||
|
.body(flashSaleService.findItemsByActivityId(activityId), FlashSaleItem.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "创建秒杀商品")
|
||||||
|
public Mono<ServerResponse> createItem(ServerRequest request) {
|
||||||
|
return request.bodyToMono(FlashSaleItem.class)
|
||||||
|
.flatMap(item -> flashSaleService.createItem(item)
|
||||||
|
.flatMap(created -> successResponse("秒杀商品创建成功", created))
|
||||||
|
.onErrorResume(this::errorResponse));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新秒杀商品")
|
||||||
|
public Mono<ServerResponse> updateItem(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
return request.bodyToMono(FlashSaleItem.class)
|
||||||
|
.flatMap(item -> flashSaleService.updateItem(id, item)
|
||||||
|
.flatMap(updated -> successResponse("秒杀商品更新成功", updated))
|
||||||
|
.onErrorResume(this::errorResponse));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "秒杀抢购")
|
||||||
|
public Mono<ServerResponse> grab(ServerRequest request) {
|
||||||
|
return request.bodyToMono(GrabRequest.class)
|
||||||
|
.flatMap(body -> {
|
||||||
|
if (body.getItemId() == null || body.getMemberId() == null) {
|
||||||
|
return badRequest("itemId和memberId不能为空");
|
||||||
|
}
|
||||||
|
return flashSaleService.grab(body)
|
||||||
|
.flatMap(order -> successResponse("抢购成功,请尽快支付", order))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "支付秒杀订单")
|
||||||
|
public Mono<ServerResponse> payOrder(ServerRequest request) {
|
||||||
|
Long orderId = Long.valueOf(request.pathVariable("orderId"));
|
||||||
|
return flashSaleService.payOrder(orderId)
|
||||||
|
.flatMap(order -> successResponse("支付成功", order))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "取消秒杀订单")
|
||||||
|
public Mono<ServerResponse> cancelOrder(ServerRequest request) {
|
||||||
|
Long orderId = Long.valueOf(request.pathVariable("orderId"));
|
||||||
|
return flashSaleService.cancelOrder(orderId)
|
||||||
|
.flatMap(order -> successResponse("订单已取消", order))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取会员秒杀订单")
|
||||||
|
public Mono<ServerResponse> getOrdersByMember(ServerRequest request) {
|
||||||
|
Long memberId = Long.valueOf(request.pathVariable("memberId"));
|
||||||
|
return ServerResponse.ok()
|
||||||
|
.body(flashSaleService.findOrdersByMemberId(memberId), FlashSaleOrder.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void normalizePageRequest(PageRequest pageRequest) {
|
||||||
|
if (pageRequest.getPage() < 0) {
|
||||||
|
pageRequest.setPage(0);
|
||||||
|
}
|
||||||
|
if (pageRequest.getSize() <= 0 || pageRequest.getSize() > 100) {
|
||||||
|
pageRequest.setSize(10);
|
||||||
|
}
|
||||||
|
if (pageRequest.getSort() == null || pageRequest.getSort().isEmpty()) {
|
||||||
|
pageRequest.setSort("id");
|
||||||
|
}
|
||||||
|
if (pageRequest.getOrder() == null || pageRequest.getOrder().isEmpty()) {
|
||||||
|
pageRequest.setOrder("desc");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<ServerResponse> successResponse(String message, Object data) {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", true);
|
||||||
|
response.put("message", message);
|
||||||
|
if (data != null) {
|
||||||
|
response.put("data", data);
|
||||||
|
}
|
||||||
|
return ServerResponse.ok().bodyValue(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<ServerResponse> badRequest(String message) {
|
||||||
|
Map<String, Object> error = new HashMap<>();
|
||||||
|
error.put("success", false);
|
||||||
|
error.put("message", message);
|
||||||
|
return ServerResponse.badRequest().bodyValue(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<ServerResponse> errorResponse(Throwable error) {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.repository;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleActivity;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
public interface IFlashSaleActivityRepository {
|
||||||
|
|
||||||
|
Mono<FlashSaleActivity> findById(Long id);
|
||||||
|
|
||||||
|
Flux<FlashSaleActivity> findAll(boolean includeDeleted);
|
||||||
|
|
||||||
|
Flux<FlashSaleActivity> findByKeyword(String keyword);
|
||||||
|
|
||||||
|
Flux<FlashSaleActivity> findByStatus(String status);
|
||||||
|
|
||||||
|
Flux<FlashSaleActivity> findByKeywordAndStatus(String keyword, String status);
|
||||||
|
|
||||||
|
Mono<FlashSaleActivity> save(FlashSaleActivity activity);
|
||||||
|
|
||||||
|
Mono<FlashSaleActivity> update(FlashSaleActivity activity);
|
||||||
|
|
||||||
|
Mono<Void> deleteById(Long id);
|
||||||
|
|
||||||
|
Mono<Void> updateStatus(Long id, String status);
|
||||||
|
}
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.repository;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleItem;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
public interface IFlashSaleItemRepository {
|
||||||
|
|
||||||
|
Mono<FlashSaleItem> findById(Long id);
|
||||||
|
|
||||||
|
Flux<FlashSaleItem> findByActivityId(Long activityId);
|
||||||
|
|
||||||
|
Mono<FlashSaleItem> save(FlashSaleItem item);
|
||||||
|
|
||||||
|
Mono<FlashSaleItem> update(FlashSaleItem item);
|
||||||
|
|
||||||
|
Mono<Boolean> deductStock(Long id, int quantity);
|
||||||
|
|
||||||
|
Mono<Void> restoreStock(Long id, int quantity);
|
||||||
|
|
||||||
|
Mono<Void> incrementSoldCount(Long id, int count);
|
||||||
|
}
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.repository;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleOrder;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public interface IFlashSaleOrderRepository {
|
||||||
|
|
||||||
|
Mono<FlashSaleOrder> findById(Long id);
|
||||||
|
|
||||||
|
Flux<FlashSaleOrder> findByMemberId(Long memberId);
|
||||||
|
|
||||||
|
Flux<FlashSaleOrder> findByActivityId(Long activityId);
|
||||||
|
|
||||||
|
Flux<FlashSaleOrder> findExpiredPendingOrders();
|
||||||
|
|
||||||
|
Mono<Long> countByItemIdAndMemberIdAndStatusIn(Long itemId, Long memberId, Collection<String> statuses);
|
||||||
|
|
||||||
|
Mono<FlashSaleOrder> save(FlashSaleOrder order);
|
||||||
|
|
||||||
|
Mono<Void> updateStatus(Long id, String status);
|
||||||
|
|
||||||
|
Mono<Void> markPaid(Long id, String status);
|
||||||
|
}
|
||||||
+109
@@ -0,0 +1,109 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.repository.impl;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.converter.FlashSaleConverter;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.dao.FlashSaleActivityDao;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.entity.FlashSaleActivityEntity;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.repository.IFlashSaleActivityRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@Transactional
|
||||||
|
public class FlashSaleActivityRepository implements IFlashSaleActivityRepository {
|
||||||
|
|
||||||
|
private final FlashSaleActivityDao activityDao;
|
||||||
|
private final FlashSaleConverter converter;
|
||||||
|
|
||||||
|
public FlashSaleActivityRepository(FlashSaleActivityDao activityDao, FlashSaleConverter converter) {
|
||||||
|
this.activityDao = activityDao;
|
||||||
|
this.converter = converter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleActivity> findById(Long id) {
|
||||||
|
return activityDao.findByIdIsAndDeletedAtIsNull(id).map(converter::toActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<FlashSaleActivity> findAll(boolean includeDeleted) {
|
||||||
|
if (includeDeleted) {
|
||||||
|
return activityDao.findAll().map(converter::toActivity);
|
||||||
|
}
|
||||||
|
return activityDao.findAllByDeletedAtIsNull().map(converter::toActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<FlashSaleActivity> findByKeyword(String keyword) {
|
||||||
|
if (keyword == null || keyword.isEmpty()) {
|
||||||
|
return findAll(false);
|
||||||
|
}
|
||||||
|
return activityDao.findByNameContainingAndDeletedAtIsNull(keyword).map(converter::toActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<FlashSaleActivity> findByStatus(String status) {
|
||||||
|
if (status == null || status.isEmpty()) {
|
||||||
|
return findAll(false);
|
||||||
|
}
|
||||||
|
return activityDao.findByStatusAndDeletedAtIsNull(status).map(converter::toActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<FlashSaleActivity> findByKeywordAndStatus(String keyword, String status) {
|
||||||
|
Flux<FlashSaleActivity> result = findByKeyword(keyword);
|
||||||
|
if (status != null && !status.isEmpty()) {
|
||||||
|
result = result.filter(a -> status.equals(a.getStatus()));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleActivity> save(FlashSaleActivity activity) {
|
||||||
|
return activityDao.save(converter.toActivityEntity(activity)).map(converter::toActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleActivity> update(FlashSaleActivity activity) {
|
||||||
|
return activityDao.findByIdIsAndDeletedAtIsNull(activity.getId())
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("秒杀活动不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
existing.markNotNew();
|
||||||
|
if (activity.getName() != null) {
|
||||||
|
existing.setName(activity.getName());
|
||||||
|
}
|
||||||
|
if (activity.getDescription() != null) {
|
||||||
|
existing.setDescription(activity.getDescription());
|
||||||
|
}
|
||||||
|
if (activity.getStartTime() != null) {
|
||||||
|
existing.setStartTime(activity.getStartTime());
|
||||||
|
}
|
||||||
|
if (activity.getEndTime() != null) {
|
||||||
|
existing.setEndTime(activity.getEndTime());
|
||||||
|
}
|
||||||
|
if (activity.getPayTimeoutMinutes() != null) {
|
||||||
|
existing.setPayTimeoutMinutes(activity.getPayTimeoutMinutes());
|
||||||
|
}
|
||||||
|
if (activity.getPerUserLimit() != null) {
|
||||||
|
existing.setPerUserLimit(activity.getPerUserLimit());
|
||||||
|
}
|
||||||
|
existing.setUpdatedAt(LocalDateTime.now());
|
||||||
|
return activityDao.save(existing);
|
||||||
|
})
|
||||||
|
.map(converter::toActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> deleteById(Long id) {
|
||||||
|
return activityDao.softDelete(id, LocalDateTime.now()).then();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> updateStatus(Long id, String status) {
|
||||||
|
return activityDao.updateStatus(id, status, LocalDateTime.now()).then();
|
||||||
|
}
|
||||||
|
}
|
||||||
+90
@@ -0,0 +1,90 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.repository.impl;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.converter.FlashSaleConverter;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.dao.FlashSaleItemDao;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleItem;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.entity.FlashSaleItemEntity;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.repository.IFlashSaleItemRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@Transactional
|
||||||
|
public class FlashSaleItemRepository implements IFlashSaleItemRepository {
|
||||||
|
|
||||||
|
private final FlashSaleItemDao itemDao;
|
||||||
|
private final FlashSaleConverter converter;
|
||||||
|
|
||||||
|
public FlashSaleItemRepository(FlashSaleItemDao itemDao, FlashSaleConverter converter) {
|
||||||
|
this.itemDao = itemDao;
|
||||||
|
this.converter = converter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleItem> findById(Long id) {
|
||||||
|
return itemDao.findByIdIsAndDeletedAtIsNull(id).map(converter::toItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<FlashSaleItem> findByActivityId(Long activityId) {
|
||||||
|
return itemDao.findByActivityIdAndDeletedAtIsNull(activityId).map(converter::toItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleItem> save(FlashSaleItem item) {
|
||||||
|
return itemDao.save(converter.toItemEntity(item)).map(converter::toItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleItem> update(FlashSaleItem item) {
|
||||||
|
return itemDao.findByIdIsAndDeletedAtIsNull(item.getId())
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("秒杀商品不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
existing.markNotNew();
|
||||||
|
if (item.getProductType() != null) {
|
||||||
|
existing.setProductType(item.getProductType());
|
||||||
|
}
|
||||||
|
if (item.getProductId() != null) {
|
||||||
|
existing.setProductId(item.getProductId());
|
||||||
|
}
|
||||||
|
if (item.getProductName() != null) {
|
||||||
|
existing.setProductName(item.getProductName());
|
||||||
|
}
|
||||||
|
if (item.getOriginalPrice() != null) {
|
||||||
|
existing.setOriginalPrice(item.getOriginalPrice());
|
||||||
|
}
|
||||||
|
if (item.getSeckillPrice() != null) {
|
||||||
|
existing.setSeckillPrice(item.getSeckillPrice());
|
||||||
|
}
|
||||||
|
if (item.getStock() != null) {
|
||||||
|
existing.setStock(item.getStock());
|
||||||
|
}
|
||||||
|
if (item.getPerUserLimit() != null) {
|
||||||
|
existing.setPerUserLimit(item.getPerUserLimit());
|
||||||
|
}
|
||||||
|
existing.setUpdatedAt(LocalDateTime.now());
|
||||||
|
return itemDao.save(existing);
|
||||||
|
})
|
||||||
|
.map(converter::toItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Boolean> deductStock(Long id, int quantity) {
|
||||||
|
return itemDao.deductStock(id, quantity, LocalDateTime.now())
|
||||||
|
.map(rows -> rows != null && rows > 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> restoreStock(Long id, int quantity) {
|
||||||
|
return itemDao.restoreStock(id, quantity, LocalDateTime.now()).then();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> incrementSoldCount(Long id, int count) {
|
||||||
|
return itemDao.incrementSoldCount(id, count, LocalDateTime.now()).then();
|
||||||
|
}
|
||||||
|
}
|
||||||
+68
@@ -0,0 +1,68 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.repository.impl;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.converter.FlashSaleConverter;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.dao.FlashSaleOrderDao;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleOrder;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.enums.FlashSaleOrderStatus;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.repository.IFlashSaleOrderRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@Transactional
|
||||||
|
public class FlashSaleOrderRepository implements IFlashSaleOrderRepository {
|
||||||
|
|
||||||
|
private final FlashSaleOrderDao orderDao;
|
||||||
|
private final FlashSaleConverter converter;
|
||||||
|
|
||||||
|
public FlashSaleOrderRepository(FlashSaleOrderDao orderDao, FlashSaleConverter converter) {
|
||||||
|
this.orderDao = orderDao;
|
||||||
|
this.converter = converter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleOrder> findById(Long id) {
|
||||||
|
return orderDao.findByIdIsAndDeletedAtIsNull(id).map(converter::toOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<FlashSaleOrder> findByMemberId(Long memberId) {
|
||||||
|
return orderDao.findByMemberIdAndDeletedAtIsNull(memberId).map(converter::toOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<FlashSaleOrder> findByActivityId(Long activityId) {
|
||||||
|
return orderDao.findByActivityIdAndDeletedAtIsNull(activityId).map(converter::toOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<FlashSaleOrder> findExpiredPendingOrders() {
|
||||||
|
return orderDao.findExpiredPendingOrders(
|
||||||
|
FlashSaleOrderStatus.PENDING.name(), LocalDateTime.now()).map(converter::toOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Long> countByItemIdAndMemberIdAndStatusIn(Long itemId, Long memberId, Collection<String> statuses) {
|
||||||
|
return orderDao.countByItemIdAndMemberIdAndStatusInAndDeletedAtIsNull(itemId, memberId, statuses);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleOrder> save(FlashSaleOrder order) {
|
||||||
|
return orderDao.save(converter.toOrderEntity(order)).map(converter::toOrder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> updateStatus(Long id, String status) {
|
||||||
|
return orderDao.updateStatus(id, status, LocalDateTime.now()).then();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> markPaid(Long id, String status) {
|
||||||
|
return orderDao.markPaid(id, status, LocalDateTime.now(), LocalDateTime.now()).then();
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.scheduler;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.service.IFlashSaleActivityService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 秒杀订单过期定时任务
|
||||||
|
*
|
||||||
|
* 功能:定期检查已过期的待支付订单,取消订单并恢复库存
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class FlashSaleOrderExpireScheduler {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(FlashSaleOrderExpireScheduler.class);
|
||||||
|
|
||||||
|
private final IFlashSaleActivityService flashSaleService;
|
||||||
|
|
||||||
|
public FlashSaleOrderExpireScheduler(IFlashSaleActivityService flashSaleService) {
|
||||||
|
this.flashSaleService = flashSaleService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(fixedRate = 60000)
|
||||||
|
public void processExpiredOrders() {
|
||||||
|
logger.debug("定时任务开始检查过期秒杀订单");
|
||||||
|
|
||||||
|
flashSaleService.processExpiredOrders()
|
||||||
|
.subscribe(
|
||||||
|
count -> logger.debug("定时任务完成,处理了 {} 个过期秒杀订单", count),
|
||||||
|
error -> logger.error("秒杀订单过期定时任务执行失败:{}", error.getMessage(), error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+50
@@ -0,0 +1,50 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.service;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageResponse;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleItem;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleOrder;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleStatistics;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.GrabRequest;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
public interface IFlashSaleActivityService {
|
||||||
|
|
||||||
|
Mono<FlashSaleActivity> findById(Long id);
|
||||||
|
|
||||||
|
Flux<FlashSaleActivity> findAll(boolean includeDeleted);
|
||||||
|
|
||||||
|
Flux<FlashSaleActivity> findByKeywordAndStatus(String keyword, String status);
|
||||||
|
|
||||||
|
Mono<PageResponse<FlashSaleActivity>> findByPage(PageRequest pageRequest, String status);
|
||||||
|
|
||||||
|
Mono<FlashSaleActivity> create(FlashSaleActivity activity);
|
||||||
|
|
||||||
|
Mono<FlashSaleActivity> update(Long id, FlashSaleActivity activity);
|
||||||
|
|
||||||
|
Mono<Void> delete(Long id);
|
||||||
|
|
||||||
|
Mono<FlashSaleActivity> publish(Long id);
|
||||||
|
|
||||||
|
Mono<FlashSaleActivity> terminate(Long id);
|
||||||
|
|
||||||
|
Flux<FlashSaleItem> findItemsByActivityId(Long activityId);
|
||||||
|
|
||||||
|
Mono<FlashSaleItem> createItem(FlashSaleItem item);
|
||||||
|
|
||||||
|
Mono<FlashSaleItem> updateItem(Long id, FlashSaleItem item);
|
||||||
|
|
||||||
|
Mono<FlashSaleOrder> grab(GrabRequest request);
|
||||||
|
|
||||||
|
Mono<FlashSaleOrder> payOrder(Long orderId);
|
||||||
|
|
||||||
|
Mono<FlashSaleOrder> cancelOrder(Long orderId);
|
||||||
|
|
||||||
|
Flux<FlashSaleOrder> findOrdersByMemberId(Long memberId);
|
||||||
|
|
||||||
|
Mono<FlashSaleStatistics> getStatistics(Long id);
|
||||||
|
|
||||||
|
Mono<Long> processExpiredOrders();
|
||||||
|
}
|
||||||
+390
@@ -0,0 +1,390 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.flashsale.service.impl;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageResponse;
|
||||||
|
import cn.novalon.gym.manage.common.util.SnowflakeId;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleItem;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleOrder;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.FlashSaleStatistics;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.domain.GrabRequest;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.enums.FlashSaleActivityStatus;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.enums.FlashSaleOrderStatus;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.repository.IFlashSaleActivityRepository;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.repository.IFlashSaleItemRepository;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.repository.IFlashSaleOrderRepository;
|
||||||
|
import cn.novalon.gym.manage.coupon.flashsale.service.IFlashSaleActivityService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class FlashSaleActivityService implements IFlashSaleActivityService {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(FlashSaleActivityService.class);
|
||||||
|
|
||||||
|
private final IFlashSaleActivityRepository activityRepository;
|
||||||
|
private final IFlashSaleItemRepository itemRepository;
|
||||||
|
private final IFlashSaleOrderRepository orderRepository;
|
||||||
|
|
||||||
|
public FlashSaleActivityService(IFlashSaleActivityRepository activityRepository,
|
||||||
|
IFlashSaleItemRepository itemRepository,
|
||||||
|
IFlashSaleOrderRepository orderRepository) {
|
||||||
|
this.activityRepository = activityRepository;
|
||||||
|
this.itemRepository = itemRepository;
|
||||||
|
this.orderRepository = orderRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleActivity> findById(Long id) {
|
||||||
|
return activityRepository.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<FlashSaleActivity> findAll(boolean includeDeleted) {
|
||||||
|
return activityRepository.findAll(includeDeleted);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<FlashSaleActivity> findByKeywordAndStatus(String keyword, String status) {
|
||||||
|
return activityRepository.findByKeywordAndStatus(keyword, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<PageResponse<FlashSaleActivity>> findByPage(PageRequest pageRequest, String status) {
|
||||||
|
int page = Math.max(pageRequest.getPage(), 0);
|
||||||
|
int size = pageRequest.getSize() <= 0 || pageRequest.getSize() > 100 ? 10 : pageRequest.getSize();
|
||||||
|
String keyword = pageRequest.getKeyword();
|
||||||
|
|
||||||
|
return activityRepository.findByKeywordAndStatus(keyword, status)
|
||||||
|
.sort(Comparator.comparing(FlashSaleActivity::getCreatedAt,
|
||||||
|
Comparator.nullsLast(Comparator.reverseOrder())))
|
||||||
|
.collectList()
|
||||||
|
.map(list -> {
|
||||||
|
long total = list.size();
|
||||||
|
int fromIndex = Math.min(page * size, list.size());
|
||||||
|
int toIndex = Math.min(fromIndex + size, list.size());
|
||||||
|
List<FlashSaleActivity> content = list.subList(fromIndex, toIndex);
|
||||||
|
int totalPages = size == 0 ? 0 : (int) Math.ceil((double) total / size);
|
||||||
|
return new PageResponse<>(content, totalPages, total, page, size);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleActivity> create(FlashSaleActivity activity) {
|
||||||
|
return validateActivity(activity)
|
||||||
|
.flatMap(validated -> {
|
||||||
|
validated.generateId();
|
||||||
|
validated.setStatus(FlashSaleActivityStatus.DRAFT.name());
|
||||||
|
applyDefaults(validated);
|
||||||
|
return activityRepository.save(validated);
|
||||||
|
})
|
||||||
|
.doOnSuccess(a -> logger.info("秒杀活动创建成功 - id={}, name={}", a.getId(), a.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleActivity> update(Long id, FlashSaleActivity activity) {
|
||||||
|
return activityRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("秒杀活动不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
if (!FlashSaleActivityStatus.DRAFT.name().equals(existing.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("仅草稿状态的秒杀活动可编辑"));
|
||||||
|
}
|
||||||
|
activity.setId(id);
|
||||||
|
return validateActivity(activity)
|
||||||
|
.flatMap(activityRepository::update);
|
||||||
|
})
|
||||||
|
.doOnSuccess(a -> logger.info("秒杀活动更新成功 - id={}", id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> delete(Long id) {
|
||||||
|
return activityRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("秒杀活动不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
if (!FlashSaleActivityStatus.DRAFT.name().equals(existing.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("仅草稿状态的秒杀活动可删除"));
|
||||||
|
}
|
||||||
|
return activityRepository.deleteById(id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleActivity> publish(Long id) {
|
||||||
|
return activityRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("秒杀活动不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
if (!FlashSaleActivityStatus.DRAFT.name().equals(existing.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("仅草稿状态的秒杀活动可发布"));
|
||||||
|
}
|
||||||
|
return validateActivity(existing)
|
||||||
|
.flatMap(validated -> activityRepository.updateStatus(id, FlashSaleActivityStatus.ACTIVE.name())
|
||||||
|
.then(activityRepository.findById(id)));
|
||||||
|
})
|
||||||
|
.doOnSuccess(a -> logger.info("秒杀活动发布成功 - id={}", id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleActivity> terminate(Long id) {
|
||||||
|
return activityRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("秒杀活动不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
if (!FlashSaleActivityStatus.ACTIVE.name().equals(existing.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("仅进行中的秒杀活动可终止"));
|
||||||
|
}
|
||||||
|
return activityRepository.updateStatus(id, FlashSaleActivityStatus.TERMINATED.name())
|
||||||
|
.then(activityRepository.findById(id));
|
||||||
|
})
|
||||||
|
.doOnSuccess(a -> logger.info("秒杀活动已终止 - id={}", id));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<FlashSaleItem> findItemsByActivityId(Long activityId) {
|
||||||
|
return itemRepository.findByActivityId(activityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleItem> createItem(FlashSaleItem item) {
|
||||||
|
return validateItem(item)
|
||||||
|
.flatMap(validated -> activityRepository.findById(validated.getActivityId())
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("秒杀活动不存在")))
|
||||||
|
.flatMap(activity -> {
|
||||||
|
if (!FlashSaleActivityStatus.DRAFT.name().equals(activity.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("仅草稿状态的秒杀活动可添加商品"));
|
||||||
|
}
|
||||||
|
validated.setId(SnowflakeId.nextId());
|
||||||
|
validated.setSoldCount(0);
|
||||||
|
if (validated.getPerUserLimit() == null) {
|
||||||
|
validated.setPerUserLimit(activity.getPerUserLimit() != null ? activity.getPerUserLimit() : 1);
|
||||||
|
}
|
||||||
|
return itemRepository.save(validated);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleItem> updateItem(Long id, FlashSaleItem item) {
|
||||||
|
return itemRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("秒杀商品不存在")))
|
||||||
|
.flatMap(existing -> activityRepository.findById(existing.getActivityId())
|
||||||
|
.flatMap(activity -> {
|
||||||
|
if (!FlashSaleActivityStatus.DRAFT.name().equals(activity.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("活动已发布,不可修改商品"));
|
||||||
|
}
|
||||||
|
item.setId(id);
|
||||||
|
return validateItem(item)
|
||||||
|
.flatMap(itemRepository::update);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleOrder> grab(GrabRequest request) {
|
||||||
|
if (request.getItemId() == null || request.getMemberId() == null) {
|
||||||
|
return Mono.error(new RuntimeException("itemId和memberId不能为空"));
|
||||||
|
}
|
||||||
|
int quantity = request.getQuantity() != null && request.getQuantity() > 0 ? request.getQuantity() : 1;
|
||||||
|
|
||||||
|
return itemRepository.findById(request.getItemId())
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("秒杀商品不存在")))
|
||||||
|
.flatMap(item -> activityRepository.findById(item.getActivityId())
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("秒杀活动不存在")))
|
||||||
|
.flatMap(activity -> validateActivityForGrab(activity)
|
||||||
|
.then(checkUserLimit(item, activity, request.getMemberId(), quantity))
|
||||||
|
.then(itemRepository.deductStock(item.getId(), quantity))
|
||||||
|
.flatMap(success -> {
|
||||||
|
if (!success) {
|
||||||
|
return Mono.error(new RuntimeException("库存不足"));
|
||||||
|
}
|
||||||
|
return createOrder(item, activity, request.getMemberId(), quantity)
|
||||||
|
.onErrorResume(e -> itemRepository.restoreStock(item.getId(), quantity)
|
||||||
|
.then(Mono.error(e)));
|
||||||
|
})));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleOrder> payOrder(Long orderId) {
|
||||||
|
return orderRepository.findById(orderId)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("秒杀订单不存在")))
|
||||||
|
.flatMap(order -> {
|
||||||
|
if (!FlashSaleOrderStatus.PENDING.name().equals(order.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("订单状态不允许支付"));
|
||||||
|
}
|
||||||
|
if (order.getExpireAt() != null && order.getExpireAt().isBefore(LocalDateTime.now())) {
|
||||||
|
return Mono.error(new RuntimeException("订单已过期"));
|
||||||
|
}
|
||||||
|
return orderRepository.markPaid(orderId, FlashSaleOrderStatus.PAID.name())
|
||||||
|
.then(itemRepository.incrementSoldCount(order.getItemId(), order.getQuantity()))
|
||||||
|
.then(orderRepository.findById(orderId));
|
||||||
|
})
|
||||||
|
.doOnSuccess(o -> logger.info("秒杀订单支付成功 - orderId={}", orderId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleOrder> cancelOrder(Long orderId) {
|
||||||
|
return orderRepository.findById(orderId)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("秒杀订单不存在")))
|
||||||
|
.flatMap(order -> {
|
||||||
|
if (!FlashSaleOrderStatus.PENDING.name().equals(order.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("仅待支付订单可取消"));
|
||||||
|
}
|
||||||
|
return orderRepository.updateStatus(orderId, FlashSaleOrderStatus.CANCELLED.name())
|
||||||
|
.then(itemRepository.restoreStock(order.getItemId(), order.getQuantity()))
|
||||||
|
.then(orderRepository.findById(orderId));
|
||||||
|
})
|
||||||
|
.doOnSuccess(o -> logger.info("秒杀订单已取消 - orderId={}", orderId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<FlashSaleOrder> findOrdersByMemberId(Long memberId) {
|
||||||
|
return orderRepository.findByMemberId(memberId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<FlashSaleStatistics> getStatistics(Long id) {
|
||||||
|
return activityRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("秒杀活动不存在")))
|
||||||
|
.flatMap(activity -> orderRepository.findByActivityId(id)
|
||||||
|
.collectList()
|
||||||
|
.map(orders -> {
|
||||||
|
FlashSaleStatistics stats = new FlashSaleStatistics();
|
||||||
|
stats.setActivityId(id);
|
||||||
|
stats.setTotalOrders(orders.size());
|
||||||
|
stats.setPendingOrders(countByStatus(orders, FlashSaleOrderStatus.PENDING));
|
||||||
|
stats.setPaidOrders(countByStatus(orders, FlashSaleOrderStatus.PAID));
|
||||||
|
stats.setCancelledOrders(countByStatus(orders, FlashSaleOrderStatus.CANCELLED));
|
||||||
|
stats.setExpiredOrders(countByStatus(orders, FlashSaleOrderStatus.EXPIRED));
|
||||||
|
|
||||||
|
long soldQty = orders.stream()
|
||||||
|
.filter(o -> FlashSaleOrderStatus.PAID.name().equals(o.getStatus()))
|
||||||
|
.mapToLong(o -> o.getQuantity() != null ? o.getQuantity() : 0)
|
||||||
|
.sum();
|
||||||
|
stats.setTotalSoldQuantity(soldQty);
|
||||||
|
|
||||||
|
BigDecimal revenue = orders.stream()
|
||||||
|
.filter(o -> FlashSaleOrderStatus.PAID.name().equals(o.getStatus()))
|
||||||
|
.map(o -> o.getPayAmount() != null ? o.getPayAmount() : BigDecimal.ZERO)
|
||||||
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
|
stats.setTotalRevenue(revenue);
|
||||||
|
|
||||||
|
return stats;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Long> processExpiredOrders() {
|
||||||
|
return orderRepository.findExpiredPendingOrders()
|
||||||
|
.flatMap(order -> orderRepository.updateStatus(order.getId(), FlashSaleOrderStatus.EXPIRED.name())
|
||||||
|
.then(itemRepository.restoreStock(order.getItemId(), order.getQuantity()))
|
||||||
|
.thenReturn(1L))
|
||||||
|
.reduce(0L, Long::sum)
|
||||||
|
.doOnSuccess(count -> {
|
||||||
|
if (count > 0) {
|
||||||
|
logger.info("已处理 {} 个过期秒杀订单", count);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<FlashSaleOrder> createOrder(FlashSaleItem item, FlashSaleActivity activity,
|
||||||
|
Long memberId, int quantity) {
|
||||||
|
int timeoutMinutes = activity.getPayTimeoutMinutes() != null ? activity.getPayTimeoutMinutes() : 5;
|
||||||
|
BigDecimal payAmount = item.getSeckillPrice().multiply(BigDecimal.valueOf(quantity));
|
||||||
|
|
||||||
|
FlashSaleOrder order = new FlashSaleOrder();
|
||||||
|
order.setId(SnowflakeId.nextId());
|
||||||
|
order.setActivityId(activity.getId());
|
||||||
|
order.setItemId(item.getId());
|
||||||
|
order.setMemberId(memberId);
|
||||||
|
order.setQuantity(quantity);
|
||||||
|
order.setPayAmount(payAmount);
|
||||||
|
order.setStatus(FlashSaleOrderStatus.PENDING.name());
|
||||||
|
order.setExpireAt(LocalDateTime.now().plusMinutes(timeoutMinutes));
|
||||||
|
|
||||||
|
return orderRepository.save(order);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<Void> checkUserLimit(FlashSaleItem item, FlashSaleActivity activity,
|
||||||
|
Long memberId, int quantity) {
|
||||||
|
int itemLimit = item.getPerUserLimit() != null ? item.getPerUserLimit() : 1;
|
||||||
|
int activityLimit = activity.getPerUserLimit() != null ? activity.getPerUserLimit() : 1;
|
||||||
|
int effectiveLimit = Math.min(itemLimit, activityLimit);
|
||||||
|
|
||||||
|
return orderRepository.countByItemIdAndMemberIdAndStatusIn(
|
||||||
|
item.getId(), memberId,
|
||||||
|
Arrays.asList(FlashSaleOrderStatus.PENDING.name(), FlashSaleOrderStatus.PAID.name()))
|
||||||
|
.flatMap(count -> {
|
||||||
|
if (count + quantity > effectiveLimit) {
|
||||||
|
return Mono.error(new RuntimeException("超出每人限购数量"));
|
||||||
|
}
|
||||||
|
return Mono.empty();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<Void> validateActivityForGrab(FlashSaleActivity activity) {
|
||||||
|
if (!FlashSaleActivityStatus.ACTIVE.name().equals(activity.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("秒杀活动未开始或已结束"));
|
||||||
|
}
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
if (activity.getStartTime() != null && now.isBefore(activity.getStartTime())) {
|
||||||
|
return Mono.error(new RuntimeException("秒杀活动尚未开始"));
|
||||||
|
}
|
||||||
|
if (activity.getEndTime() != null && now.isAfter(activity.getEndTime())) {
|
||||||
|
return Mono.error(new RuntimeException("秒杀活动已结束"));
|
||||||
|
}
|
||||||
|
return Mono.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<FlashSaleActivity> validateActivity(FlashSaleActivity activity) {
|
||||||
|
if (activity.getName() == null || activity.getName().isBlank()) {
|
||||||
|
return Mono.error(new RuntimeException("活动名称不能为空"));
|
||||||
|
}
|
||||||
|
if (activity.getStartTime() == null || activity.getEndTime() == null) {
|
||||||
|
return Mono.error(new RuntimeException("活动开始和结束时间不能为空"));
|
||||||
|
}
|
||||||
|
if (activity.getEndTime().isBefore(activity.getStartTime())) {
|
||||||
|
return Mono.error(new RuntimeException("结束时间不能早于开始时间"));
|
||||||
|
}
|
||||||
|
return Mono.just(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<FlashSaleItem> validateItem(FlashSaleItem item) {
|
||||||
|
if (item.getActivityId() == null) {
|
||||||
|
return Mono.error(new RuntimeException("活动ID不能为空"));
|
||||||
|
}
|
||||||
|
if (item.getProductType() == null || item.getProductName() == null) {
|
||||||
|
return Mono.error(new RuntimeException("商品类型和名称不能为空"));
|
||||||
|
}
|
||||||
|
if (item.getProductId() == null) {
|
||||||
|
return Mono.error(new RuntimeException("商品ID不能为空"));
|
||||||
|
}
|
||||||
|
if (item.getOriginalPrice() == null || item.getSeckillPrice() == null) {
|
||||||
|
return Mono.error(new RuntimeException("原价和秒杀价不能为空"));
|
||||||
|
}
|
||||||
|
if (item.getSeckillPrice().compareTo(item.getOriginalPrice()) >= 0) {
|
||||||
|
return Mono.error(new RuntimeException("秒杀价必须低于原价"));
|
||||||
|
}
|
||||||
|
if (item.getStock() == null || item.getStock() < 0) {
|
||||||
|
return Mono.error(new RuntimeException("库存不能为空且不能为负数"));
|
||||||
|
}
|
||||||
|
return Mono.just(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyDefaults(FlashSaleActivity activity) {
|
||||||
|
if (activity.getPayTimeoutMinutes() == null) {
|
||||||
|
activity.setPayTimeoutMinutes(5);
|
||||||
|
}
|
||||||
|
if (activity.getPerUserLimit() == null) {
|
||||||
|
activity.setPerUserLimit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private long countByStatus(List<FlashSaleOrder> orders, FlashSaleOrderStatus status) {
|
||||||
|
return orders.stream().filter(o -> status.name().equals(o.getStatus())).count();
|
||||||
|
}
|
||||||
|
}
|
||||||
+77
@@ -0,0 +1,77 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.converter;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyParticipant;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyTeam;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.entity.GroupBuyActivityEntity;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.entity.GroupBuyParticipantEntity;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.entity.GroupBuyTeamEntity;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class GroupBuyConverter {
|
||||||
|
|
||||||
|
public GroupBuyActivity toActivity(GroupBuyActivityEntity entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
GroupBuyActivity domain = new GroupBuyActivity();
|
||||||
|
BeanUtil.copyProperties(entity, domain);
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupBuyActivityEntity toActivityEntity(GroupBuyActivity domain) {
|
||||||
|
if (domain == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
GroupBuyActivityEntity entity = new GroupBuyActivityEntity();
|
||||||
|
BeanUtil.copyProperties(domain, entity);
|
||||||
|
if (domain.getId() != null) {
|
||||||
|
entity.markNotNew();
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupBuyTeam toTeam(GroupBuyTeamEntity entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
GroupBuyTeam domain = new GroupBuyTeam();
|
||||||
|
BeanUtil.copyProperties(entity, domain);
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupBuyTeamEntity toTeamEntity(GroupBuyTeam domain) {
|
||||||
|
if (domain == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
GroupBuyTeamEntity entity = new GroupBuyTeamEntity();
|
||||||
|
BeanUtil.copyProperties(domain, entity);
|
||||||
|
if (domain.getId() != null) {
|
||||||
|
entity.markNotNew();
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupBuyParticipant toParticipant(GroupBuyParticipantEntity entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
GroupBuyParticipant domain = new GroupBuyParticipant();
|
||||||
|
BeanUtil.copyProperties(entity, domain);
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupBuyParticipantEntity toParticipantEntity(GroupBuyParticipant domain) {
|
||||||
|
if (domain == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
GroupBuyParticipantEntity entity = new GroupBuyParticipantEntity();
|
||||||
|
BeanUtil.copyProperties(domain, entity);
|
||||||
|
if (domain.getId() != null) {
|
||||||
|
entity.markNotNew();
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.dao;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.entity.GroupBuyActivityEntity;
|
||||||
|
import org.springframework.data.r2dbc.repository.Modifying;
|
||||||
|
import org.springframework.data.r2dbc.repository.Query;
|
||||||
|
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface GroupBuyActivityDao extends R2dbcRepository<GroupBuyActivityEntity, Long> {
|
||||||
|
|
||||||
|
Mono<GroupBuyActivityEntity> findByIdIsAndDeletedAtIsNull(Long id);
|
||||||
|
|
||||||
|
Flux<GroupBuyActivityEntity> findAllByDeletedAtIsNull();
|
||||||
|
|
||||||
|
Flux<GroupBuyActivityEntity> findByNameContainingAndDeletedAtIsNull(String name);
|
||||||
|
|
||||||
|
Flux<GroupBuyActivityEntity> findByStatusAndDeletedAtIsNull(String status);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE group_buy_activity SET deleted_at = :deletedAt WHERE id = :id")
|
||||||
|
Mono<Integer> softDelete(Long id, LocalDateTime deletedAt);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE group_buy_activity SET status = :status, updated_at = :updatedAt WHERE id = :id")
|
||||||
|
Mono<Integer> updateStatus(Long id, String status, LocalDateTime updatedAt);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE group_buy_activity SET sold_count = sold_count + :count, updated_at = :updatedAt WHERE id = :id")
|
||||||
|
Mono<Integer> incrementSoldCount(Long id, int count, LocalDateTime updatedAt);
|
||||||
|
}
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.dao;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.entity.GroupBuyParticipantEntity;
|
||||||
|
import org.springframework.data.r2dbc.repository.Modifying;
|
||||||
|
import org.springframework.data.r2dbc.repository.Query;
|
||||||
|
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface GroupBuyParticipantDao extends R2dbcRepository<GroupBuyParticipantEntity, Long> {
|
||||||
|
|
||||||
|
Flux<GroupBuyParticipantEntity> findByTeamIdAndDeletedAtIsNull(Long teamId);
|
||||||
|
|
||||||
|
Flux<GroupBuyParticipantEntity> findByActivityIdAndDeletedAtIsNull(Long activityId);
|
||||||
|
|
||||||
|
@Query("""
|
||||||
|
SELECT p.* FROM group_buy_participant p
|
||||||
|
INNER JOIN group_buy_team t ON p.team_id = t.id
|
||||||
|
WHERE p.activity_id = :activityId AND p.member_id = :memberId
|
||||||
|
AND p.status = :participantStatus AND t.status = :teamStatus
|
||||||
|
AND p.deleted_at IS NULL AND t.deleted_at IS NULL
|
||||||
|
""")
|
||||||
|
Flux<GroupBuyParticipantEntity> findActiveParticipantInFormingTeam(
|
||||||
|
Long activityId, Long memberId, String participantStatus, String teamStatus);
|
||||||
|
|
||||||
|
Mono<Long> countByActivityIdAndDeletedAtIsNull(Long activityId);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE group_buy_participant SET status = :status, updated_at = :updatedAt WHERE team_id = :teamId")
|
||||||
|
Mono<Integer> updateStatusByTeamId(Long teamId, String status, LocalDateTime updatedAt);
|
||||||
|
}
|
||||||
+38
@@ -0,0 +1,38 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.dao;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.entity.GroupBuyTeamEntity;
|
||||||
|
import org.springframework.data.r2dbc.repository.Modifying;
|
||||||
|
import org.springframework.data.r2dbc.repository.Query;
|
||||||
|
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface GroupBuyTeamDao extends R2dbcRepository<GroupBuyTeamEntity, Long> {
|
||||||
|
|
||||||
|
Mono<GroupBuyTeamEntity> findByIdIsAndDeletedAtIsNull(Long id);
|
||||||
|
|
||||||
|
Flux<GroupBuyTeamEntity> findByActivityIdAndDeletedAtIsNull(Long activityId);
|
||||||
|
|
||||||
|
Flux<GroupBuyTeamEntity> findByActivityIdAndStatusAndDeletedAtIsNull(Long activityId, String status);
|
||||||
|
|
||||||
|
Flux<GroupBuyTeamEntity> findByStatusAndDeletedAtIsNull(String status);
|
||||||
|
|
||||||
|
@Query("SELECT * FROM group_buy_team WHERE status = :status AND expire_at < :now AND deleted_at IS NULL")
|
||||||
|
Flux<GroupBuyTeamEntity> findExpiredFormingTeams(String status, LocalDateTime now);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE group_buy_team SET status = :status, updated_at = :updatedAt WHERE id = :id")
|
||||||
|
Mono<Integer> updateStatus(Long id, String status, LocalDateTime updatedAt);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE group_buy_team SET current_members = current_members + :count, updated_at = :updatedAt WHERE id = :id")
|
||||||
|
Mono<Integer> incrementCurrentMembers(Long id, int count, LocalDateTime updatedAt);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE group_buy_team SET status = :status, success_at = :successAt, updated_at = :updatedAt WHERE id = :id")
|
||||||
|
Mono<Integer> markSuccess(Long id, String status, LocalDateTime successAt, LocalDateTime updatedAt);
|
||||||
|
}
|
||||||
+26
@@ -0,0 +1,26 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
@Schema(description = "创建拼团团队请求")
|
||||||
|
public class CreateTeamRequest {
|
||||||
|
|
||||||
|
private Long activityId;
|
||||||
|
private Long memberId;
|
||||||
|
|
||||||
|
public Long getActivityId() {
|
||||||
|
return activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityId(Long activityId) {
|
||||||
|
this.activityId = activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(Long memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
}
|
||||||
+138
@@ -0,0 +1,138 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.domain;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "拼团活动")
|
||||||
|
public class GroupBuyActivity extends BaseDomain {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
private String description;
|
||||||
|
private String productType;
|
||||||
|
private Long productId;
|
||||||
|
private String productName;
|
||||||
|
private BigDecimal originalPrice;
|
||||||
|
private BigDecimal groupPrice;
|
||||||
|
private Integer requiredMembers;
|
||||||
|
private Integer validHours;
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
private Integer stock;
|
||||||
|
private Integer soldCount;
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductType() {
|
||||||
|
return productType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductType(String productType) {
|
||||||
|
this.productType = productType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getProductId() {
|
||||||
|
return productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductId(Long productId) {
|
||||||
|
this.productId = productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductName() {
|
||||||
|
return productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductName(String productName) {
|
||||||
|
this.productName = productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getOriginalPrice() {
|
||||||
|
return originalPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOriginalPrice(BigDecimal originalPrice) {
|
||||||
|
this.originalPrice = originalPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getGroupPrice() {
|
||||||
|
return groupPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupPrice(BigDecimal groupPrice) {
|
||||||
|
this.groupPrice = groupPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getRequiredMembers() {
|
||||||
|
return requiredMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequiredMembers(Integer requiredMembers) {
|
||||||
|
this.requiredMembers = requiredMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getValidHours() {
|
||||||
|
return validHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValidHours(Integer validHours) {
|
||||||
|
this.validHours = validHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(LocalDateTime startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime(LocalDateTime endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStock() {
|
||||||
|
return stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStock(Integer stock) {
|
||||||
|
this.stock = stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSoldCount() {
|
||||||
|
return soldCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSoldCount(Integer soldCount) {
|
||||||
|
this.soldCount = soldCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
+65
@@ -0,0 +1,65 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.domain;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "拼团参与人")
|
||||||
|
public class GroupBuyParticipant extends BaseDomain {
|
||||||
|
|
||||||
|
private Long teamId;
|
||||||
|
private Long activityId;
|
||||||
|
private Long memberId;
|
||||||
|
private Boolean isLeader;
|
||||||
|
private String status;
|
||||||
|
private LocalDateTime joinAt;
|
||||||
|
|
||||||
|
public Long getTeamId() {
|
||||||
|
return teamId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTeamId(Long teamId) {
|
||||||
|
this.teamId = teamId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getActivityId() {
|
||||||
|
return activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityId(Long activityId) {
|
||||||
|
this.activityId = activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(Long memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getIsLeader() {
|
||||||
|
return isLeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsLeader(Boolean isLeader) {
|
||||||
|
this.isLeader = isLeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getJoinAt() {
|
||||||
|
return joinAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJoinAt(LocalDateTime joinAt) {
|
||||||
|
this.joinAt = joinAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
+91
@@ -0,0 +1,91 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Schema(description = "拼团统计数据")
|
||||||
|
public class GroupBuyStatistics {
|
||||||
|
|
||||||
|
private Long activityId;
|
||||||
|
private long totalTeams;
|
||||||
|
private long formingTeams;
|
||||||
|
private long successTeams;
|
||||||
|
private long failedTeams;
|
||||||
|
private long cancelledTeams;
|
||||||
|
private long totalParticipants;
|
||||||
|
private long soldCount;
|
||||||
|
private BigDecimal totalRevenue;
|
||||||
|
|
||||||
|
public Long getActivityId() {
|
||||||
|
return activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityId(Long activityId) {
|
||||||
|
this.activityId = activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalTeams() {
|
||||||
|
return totalTeams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalTeams(long totalTeams) {
|
||||||
|
this.totalTeams = totalTeams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getFormingTeams() {
|
||||||
|
return formingTeams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFormingTeams(long formingTeams) {
|
||||||
|
this.formingTeams = formingTeams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSuccessTeams() {
|
||||||
|
return successTeams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuccessTeams(long successTeams) {
|
||||||
|
this.successTeams = successTeams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getFailedTeams() {
|
||||||
|
return failedTeams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFailedTeams(long failedTeams) {
|
||||||
|
this.failedTeams = failedTeams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getCancelledTeams() {
|
||||||
|
return cancelledTeams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelledTeams(long cancelledTeams) {
|
||||||
|
this.cancelledTeams = cancelledTeams;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalParticipants() {
|
||||||
|
return totalParticipants;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalParticipants(long totalParticipants) {
|
||||||
|
this.totalParticipants = totalParticipants;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getSoldCount() {
|
||||||
|
return soldCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSoldCount(long soldCount) {
|
||||||
|
this.soldCount = soldCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getTotalRevenue() {
|
||||||
|
return totalRevenue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalRevenue(BigDecimal totalRevenue) {
|
||||||
|
this.totalRevenue = totalRevenue;
|
||||||
|
}
|
||||||
|
}
|
||||||
+74
@@ -0,0 +1,74 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.domain;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "拼团团队")
|
||||||
|
public class GroupBuyTeam extends BaseDomain {
|
||||||
|
|
||||||
|
private Long activityId;
|
||||||
|
private Long leaderMemberId;
|
||||||
|
private Integer requiredMembers;
|
||||||
|
private Integer currentMembers;
|
||||||
|
private String status;
|
||||||
|
private LocalDateTime expireAt;
|
||||||
|
private LocalDateTime successAt;
|
||||||
|
|
||||||
|
public Long getActivityId() {
|
||||||
|
return activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityId(Long activityId) {
|
||||||
|
this.activityId = activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getLeaderMemberId() {
|
||||||
|
return leaderMemberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeaderMemberId(Long leaderMemberId) {
|
||||||
|
this.leaderMemberId = leaderMemberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getRequiredMembers() {
|
||||||
|
return requiredMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequiredMembers(Integer requiredMembers) {
|
||||||
|
this.requiredMembers = requiredMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCurrentMembers() {
|
||||||
|
return currentMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentMembers(Integer currentMembers) {
|
||||||
|
this.currentMembers = currentMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getExpireAt() {
|
||||||
|
return expireAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpireAt(LocalDateTime expireAt) {
|
||||||
|
this.expireAt = expireAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getSuccessAt() {
|
||||||
|
return successAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuccessAt(LocalDateTime successAt) {
|
||||||
|
this.successAt = successAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
+17
@@ -0,0 +1,17 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
@Schema(description = "加入拼团团队请求")
|
||||||
|
public class JoinTeamRequest {
|
||||||
|
|
||||||
|
private Long memberId;
|
||||||
|
|
||||||
|
public Long getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(Long memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
}
|
||||||
+166
@@ -0,0 +1,166 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.entity;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.db.entity.BaseEntity;
|
||||||
|
import org.springframework.data.relational.core.mapping.Column;
|
||||||
|
import org.springframework.data.relational.core.mapping.Table;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Table("group_buy_activity")
|
||||||
|
public class GroupBuyActivityEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@Column("name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Column("description")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Column("product_type")
|
||||||
|
private String productType;
|
||||||
|
|
||||||
|
@Column("product_id")
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
@Column("product_name")
|
||||||
|
private String productName;
|
||||||
|
|
||||||
|
@Column("original_price")
|
||||||
|
private BigDecimal originalPrice;
|
||||||
|
|
||||||
|
@Column("group_price")
|
||||||
|
private BigDecimal groupPrice;
|
||||||
|
|
||||||
|
@Column("required_members")
|
||||||
|
private Integer requiredMembers;
|
||||||
|
|
||||||
|
@Column("valid_hours")
|
||||||
|
private Integer validHours;
|
||||||
|
|
||||||
|
@Column("start_time")
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
|
||||||
|
@Column("end_time")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@Column("stock")
|
||||||
|
private Integer stock;
|
||||||
|
|
||||||
|
@Column("sold_count")
|
||||||
|
private Integer soldCount;
|
||||||
|
|
||||||
|
@Column("status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductType() {
|
||||||
|
return productType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductType(String productType) {
|
||||||
|
this.productType = productType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getProductId() {
|
||||||
|
return productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductId(Long productId) {
|
||||||
|
this.productId = productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductName() {
|
||||||
|
return productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductName(String productName) {
|
||||||
|
this.productName = productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getOriginalPrice() {
|
||||||
|
return originalPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOriginalPrice(BigDecimal originalPrice) {
|
||||||
|
this.originalPrice = originalPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getGroupPrice() {
|
||||||
|
return groupPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGroupPrice(BigDecimal groupPrice) {
|
||||||
|
this.groupPrice = groupPrice;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getRequiredMembers() {
|
||||||
|
return requiredMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequiredMembers(Integer requiredMembers) {
|
||||||
|
this.requiredMembers = requiredMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getValidHours() {
|
||||||
|
return validHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValidHours(Integer validHours) {
|
||||||
|
this.validHours = validHours;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(LocalDateTime startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime(LocalDateTime endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStock() {
|
||||||
|
return stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStock(Integer stock) {
|
||||||
|
this.stock = stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSoldCount() {
|
||||||
|
return soldCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSoldCount(Integer soldCount) {
|
||||||
|
this.soldCount = soldCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
+77
@@ -0,0 +1,77 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.entity;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.db.entity.BaseEntity;
|
||||||
|
import org.springframework.data.relational.core.mapping.Column;
|
||||||
|
import org.springframework.data.relational.core.mapping.Table;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Table("group_buy_participant")
|
||||||
|
public class GroupBuyParticipantEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@Column("team_id")
|
||||||
|
private Long teamId;
|
||||||
|
|
||||||
|
@Column("activity_id")
|
||||||
|
private Long activityId;
|
||||||
|
|
||||||
|
@Column("member_id")
|
||||||
|
private Long memberId;
|
||||||
|
|
||||||
|
@Column("is_leader")
|
||||||
|
private Boolean isLeader;
|
||||||
|
|
||||||
|
@Column("status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Column("join_at")
|
||||||
|
private LocalDateTime joinAt;
|
||||||
|
|
||||||
|
public Long getTeamId() {
|
||||||
|
return teamId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTeamId(Long teamId) {
|
||||||
|
this.teamId = teamId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getActivityId() {
|
||||||
|
return activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityId(Long activityId) {
|
||||||
|
this.activityId = activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(Long memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getIsLeader() {
|
||||||
|
return isLeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIsLeader(Boolean isLeader) {
|
||||||
|
this.isLeader = isLeader;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getJoinAt() {
|
||||||
|
return joinAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJoinAt(LocalDateTime joinAt) {
|
||||||
|
this.joinAt = joinAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
+88
@@ -0,0 +1,88 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.entity;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.db.entity.BaseEntity;
|
||||||
|
import org.springframework.data.relational.core.mapping.Column;
|
||||||
|
import org.springframework.data.relational.core.mapping.Table;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Table("group_buy_team")
|
||||||
|
public class GroupBuyTeamEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@Column("activity_id")
|
||||||
|
private Long activityId;
|
||||||
|
|
||||||
|
@Column("leader_member_id")
|
||||||
|
private Long leaderMemberId;
|
||||||
|
|
||||||
|
@Column("required_members")
|
||||||
|
private Integer requiredMembers;
|
||||||
|
|
||||||
|
@Column("current_members")
|
||||||
|
private Integer currentMembers;
|
||||||
|
|
||||||
|
@Column("status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
@Column("expire_at")
|
||||||
|
private LocalDateTime expireAt;
|
||||||
|
|
||||||
|
@Column("success_at")
|
||||||
|
private LocalDateTime successAt;
|
||||||
|
|
||||||
|
public Long getActivityId() {
|
||||||
|
return activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityId(Long activityId) {
|
||||||
|
this.activityId = activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getLeaderMemberId() {
|
||||||
|
return leaderMemberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeaderMemberId(Long leaderMemberId) {
|
||||||
|
this.leaderMemberId = leaderMemberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getRequiredMembers() {
|
||||||
|
return requiredMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRequiredMembers(Integer requiredMembers) {
|
||||||
|
this.requiredMembers = requiredMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getCurrentMembers() {
|
||||||
|
return currentMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrentMembers(Integer currentMembers) {
|
||||||
|
this.currentMembers = currentMembers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getExpireAt() {
|
||||||
|
return expireAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setExpireAt(LocalDateTime expireAt) {
|
||||||
|
this.expireAt = expireAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getSuccessAt() {
|
||||||
|
return successAt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSuccessAt(LocalDateTime successAt) {
|
||||||
|
this.successAt = successAt;
|
||||||
|
}
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼团活动状态
|
||||||
|
*/
|
||||||
|
public enum GroupBuyActivityStatus {
|
||||||
|
DRAFT,
|
||||||
|
ACTIVE,
|
||||||
|
TERMINATED,
|
||||||
|
EXPIRED
|
||||||
|
}
|
||||||
+9
@@ -0,0 +1,9 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼团参与人状态
|
||||||
|
*/
|
||||||
|
public enum GroupBuyParticipantStatus {
|
||||||
|
JOINED,
|
||||||
|
CANCELLED
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼团团队状态
|
||||||
|
*/
|
||||||
|
public enum GroupBuyTeamStatus {
|
||||||
|
FORMING,
|
||||||
|
SUCCESS,
|
||||||
|
FAILED,
|
||||||
|
CANCELLED
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 商品类型
|
||||||
|
*/
|
||||||
|
public enum ProductType {
|
||||||
|
COURSE,
|
||||||
|
MEMBER_CARD,
|
||||||
|
PRODUCT
|
||||||
|
}
|
||||||
+220
@@ -0,0 +1,220 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.handler;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.CreateTeamRequest;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyTeam;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.JoinTeamRequest;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.service.IGroupBuyActivityService;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.service.IGroupBuyTeamService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||||
|
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Tag(name = "拼团管理", description = "拼团相关操作")
|
||||||
|
public class GroupBuyHandler {
|
||||||
|
|
||||||
|
private final IGroupBuyActivityService activityService;
|
||||||
|
private final IGroupBuyTeamService teamService;
|
||||||
|
|
||||||
|
public GroupBuyHandler(IGroupBuyActivityService activityService, IGroupBuyTeamService teamService) {
|
||||||
|
this.activityService = activityService;
|
||||||
|
this.teamService = teamService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取所有拼团活动")
|
||||||
|
public Mono<ServerResponse> getAllActivities(ServerRequest request) {
|
||||||
|
boolean includeDeleted = Boolean.parseBoolean(request.queryParam("includeDeleted").orElse("false"));
|
||||||
|
return ServerResponse.ok()
|
||||||
|
.body(activityService.findAll(includeDeleted), GroupBuyActivity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "分页获取拼团活动")
|
||||||
|
public Mono<ServerResponse> getActivitiesByPage(ServerRequest request) {
|
||||||
|
return request.bodyToMono(PageRequest.class)
|
||||||
|
.flatMap(pageRequest -> {
|
||||||
|
String status = request.queryParam("status").orElse(null);
|
||||||
|
normalizePageRequest(pageRequest);
|
||||||
|
return activityService.findByPage(pageRequest, status)
|
||||||
|
.flatMap(response -> ServerResponse.ok().bodyValue(response));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "搜索拼团活动")
|
||||||
|
public Mono<ServerResponse> searchActivities(ServerRequest request) {
|
||||||
|
String keyword = request.queryParam("keyword").orElse("");
|
||||||
|
String status = request.queryParam("status").orElse(null);
|
||||||
|
return ServerResponse.ok()
|
||||||
|
.body(activityService.findByKeywordAndStatus(keyword, status), GroupBuyActivity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "根据ID获取拼团活动")
|
||||||
|
public Mono<ServerResponse> getActivityById(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
return activityService.findById(id)
|
||||||
|
.flatMap(activity -> ServerResponse.ok().bodyValue(activity))
|
||||||
|
.switchIfEmpty(ServerResponse.notFound().build());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "创建拼团活动")
|
||||||
|
public Mono<ServerResponse> createActivity(ServerRequest request) {
|
||||||
|
return request.bodyToMono(GroupBuyActivity.class)
|
||||||
|
.flatMap(activity -> {
|
||||||
|
if (activity.getName() == null || activity.getName().isEmpty()) {
|
||||||
|
return badRequest("活动名称不能为空");
|
||||||
|
}
|
||||||
|
return activityService.create(activity)
|
||||||
|
.flatMap(created -> successResponse("拼团活动创建成功", created))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新拼团活动")
|
||||||
|
public Mono<ServerResponse> updateActivity(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
return request.bodyToMono(GroupBuyActivity.class)
|
||||||
|
.flatMap(activity -> activityService.update(id, activity)
|
||||||
|
.flatMap(updated -> successResponse("拼团活动更新成功", updated))
|
||||||
|
.onErrorResume(this::errorResponse));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除拼团活动")
|
||||||
|
public Mono<ServerResponse> deleteActivity(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
return activityService.delete(id)
|
||||||
|
.then(Mono.defer(() -> successResponse("拼团活动删除成功", null)))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "发布拼团活动")
|
||||||
|
public Mono<ServerResponse> publishActivity(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
return activityService.publish(id)
|
||||||
|
.flatMap(activity -> successResponse("拼团活动发布成功", activity))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "终止拼团活动")
|
||||||
|
public Mono<ServerResponse> terminateActivity(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
return activityService.terminate(id)
|
||||||
|
.flatMap(activity -> successResponse("拼团活动已终止", activity))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取拼团统计")
|
||||||
|
public Mono<ServerResponse> getStatistics(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
return activityService.getStatistics(id)
|
||||||
|
.flatMap(stats -> ServerResponse.ok().bodyValue(stats))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "创建拼团团队")
|
||||||
|
public Mono<ServerResponse> createTeam(ServerRequest request) {
|
||||||
|
return request.bodyToMono(CreateTeamRequest.class)
|
||||||
|
.flatMap(body -> {
|
||||||
|
if (body.getActivityId() == null || body.getMemberId() == null) {
|
||||||
|
return badRequest("activityId和memberId不能为空");
|
||||||
|
}
|
||||||
|
return teamService.createTeam(body)
|
||||||
|
.flatMap(team -> successResponse("拼团团队创建成功", team))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "加入拼团团队")
|
||||||
|
public Mono<ServerResponse> joinTeam(ServerRequest request) {
|
||||||
|
Long teamId = Long.valueOf(request.pathVariable("teamId"));
|
||||||
|
return request.bodyToMono(JoinTeamRequest.class)
|
||||||
|
.flatMap(body -> {
|
||||||
|
if (body.getMemberId() == null) {
|
||||||
|
return badRequest("memberId不能为空");
|
||||||
|
}
|
||||||
|
return teamService.joinTeam(teamId, body)
|
||||||
|
.flatMap(team -> successResponse("加入拼团成功", team))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "取消拼团团队")
|
||||||
|
public Mono<ServerResponse> cancelTeam(ServerRequest request) {
|
||||||
|
Long teamId = Long.valueOf(request.pathVariable("teamId"));
|
||||||
|
return teamService.cancelTeam(teamId)
|
||||||
|
.flatMap(team -> successResponse("拼团团队已取消", team))
|
||||||
|
.onErrorResume(this::errorResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "查询拼团团队列表")
|
||||||
|
public Mono<ServerResponse> getTeams(ServerRequest request) {
|
||||||
|
String activityIdStr = request.queryParam("activityId").orElse(null);
|
||||||
|
if (activityIdStr == null) {
|
||||||
|
return badRequest("activityId不能为空");
|
||||||
|
}
|
||||||
|
Long activityId = Long.valueOf(activityIdStr);
|
||||||
|
String status = request.queryParam("status").orElse(null);
|
||||||
|
return ServerResponse.ok()
|
||||||
|
.body(teamService.findTeams(activityId, status), GroupBuyTeam.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取拼团团队详情")
|
||||||
|
public Mono<ServerResponse> getTeamById(ServerRequest request) {
|
||||||
|
Long teamId = Long.valueOf(request.pathVariable("teamId"));
|
||||||
|
return teamService.findTeamById(teamId)
|
||||||
|
.flatMap(team -> teamService.findParticipantsByTeamId(teamId)
|
||||||
|
.collectList()
|
||||||
|
.flatMap(participants -> {
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
result.put("team", team);
|
||||||
|
result.put("participants", participants);
|
||||||
|
return ServerResponse.ok().bodyValue(result);
|
||||||
|
}))
|
||||||
|
.switchIfEmpty(ServerResponse.notFound().build());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void normalizePageRequest(PageRequest pageRequest) {
|
||||||
|
if (pageRequest.getPage() < 0) {
|
||||||
|
pageRequest.setPage(0);
|
||||||
|
}
|
||||||
|
if (pageRequest.getSize() <= 0 || pageRequest.getSize() > 100) {
|
||||||
|
pageRequest.setSize(10);
|
||||||
|
}
|
||||||
|
if (pageRequest.getSort() == null || pageRequest.getSort().isEmpty()) {
|
||||||
|
pageRequest.setSort("id");
|
||||||
|
}
|
||||||
|
if (pageRequest.getOrder() == null || pageRequest.getOrder().isEmpty()) {
|
||||||
|
pageRequest.setOrder("desc");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<ServerResponse> successResponse(String message, Object data) {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", true);
|
||||||
|
response.put("message", message);
|
||||||
|
if (data != null) {
|
||||||
|
response.put("data", data);
|
||||||
|
}
|
||||||
|
return ServerResponse.ok().bodyValue(response);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<ServerResponse> badRequest(String message) {
|
||||||
|
Map<String, Object> error = new HashMap<>();
|
||||||
|
error.put("success", false);
|
||||||
|
error.put("message", message);
|
||||||
|
return ServerResponse.badRequest().bodyValue(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<ServerResponse> errorResponse(Throwable error) {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
}
|
||||||
|
}
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.repository;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyActivity;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
public interface IGroupBuyActivityRepository {
|
||||||
|
|
||||||
|
Mono<GroupBuyActivity> findById(Long id);
|
||||||
|
|
||||||
|
Flux<GroupBuyActivity> findAll(boolean includeDeleted);
|
||||||
|
|
||||||
|
Flux<GroupBuyActivity> findByKeyword(String keyword);
|
||||||
|
|
||||||
|
Flux<GroupBuyActivity> findByStatus(String status);
|
||||||
|
|
||||||
|
Flux<GroupBuyActivity> findByKeywordAndStatus(String keyword, String status);
|
||||||
|
|
||||||
|
Mono<GroupBuyActivity> save(GroupBuyActivity activity);
|
||||||
|
|
||||||
|
Mono<GroupBuyActivity> update(GroupBuyActivity activity);
|
||||||
|
|
||||||
|
Mono<Void> deleteById(Long id);
|
||||||
|
|
||||||
|
Mono<Void> updateStatus(Long id, String status);
|
||||||
|
|
||||||
|
Mono<Void> incrementSoldCount(Long id, int count);
|
||||||
|
}
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.repository;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyParticipant;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
public interface IGroupBuyParticipantRepository {
|
||||||
|
|
||||||
|
Flux<GroupBuyParticipant> findByTeamId(Long teamId);
|
||||||
|
|
||||||
|
Flux<GroupBuyParticipant> findByActivityId(Long activityId);
|
||||||
|
|
||||||
|
Mono<Boolean> existsInFormingTeam(Long activityId, Long memberId);
|
||||||
|
|
||||||
|
Mono<Long> countByActivityId(Long activityId);
|
||||||
|
|
||||||
|
Mono<GroupBuyParticipant> save(GroupBuyParticipant participant);
|
||||||
|
|
||||||
|
Mono<Void> updateStatusByTeamId(Long teamId, String status);
|
||||||
|
}
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.repository;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyTeam;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
public interface IGroupBuyTeamRepository {
|
||||||
|
|
||||||
|
Mono<GroupBuyTeam> findById(Long id);
|
||||||
|
|
||||||
|
Flux<GroupBuyTeam> findByActivityId(Long activityId);
|
||||||
|
|
||||||
|
Flux<GroupBuyTeam> findByActivityIdAndStatus(Long activityId, String status);
|
||||||
|
|
||||||
|
Flux<GroupBuyTeam> findExpiredFormingTeams();
|
||||||
|
|
||||||
|
Mono<GroupBuyTeam> save(GroupBuyTeam team);
|
||||||
|
|
||||||
|
Mono<Void> updateStatus(Long id, String status);
|
||||||
|
|
||||||
|
Mono<Void> incrementCurrentMembers(Long id, int count);
|
||||||
|
|
||||||
|
Mono<Void> markSuccess(Long id, String status);
|
||||||
|
}
|
||||||
+133
@@ -0,0 +1,133 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.repository.impl;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.converter.GroupBuyConverter;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.dao.GroupBuyActivityDao;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.entity.GroupBuyActivityEntity;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.repository.IGroupBuyActivityRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@Transactional
|
||||||
|
public class GroupBuyActivityRepository implements IGroupBuyActivityRepository {
|
||||||
|
|
||||||
|
private final GroupBuyActivityDao activityDao;
|
||||||
|
private final GroupBuyConverter converter;
|
||||||
|
|
||||||
|
public GroupBuyActivityRepository(GroupBuyActivityDao activityDao, GroupBuyConverter converter) {
|
||||||
|
this.activityDao = activityDao;
|
||||||
|
this.converter = converter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyActivity> findById(Long id) {
|
||||||
|
return activityDao.findByIdIsAndDeletedAtIsNull(id).map(converter::toActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<GroupBuyActivity> findAll(boolean includeDeleted) {
|
||||||
|
if (includeDeleted) {
|
||||||
|
return activityDao.findAll().map(converter::toActivity);
|
||||||
|
}
|
||||||
|
return activityDao.findAllByDeletedAtIsNull().map(converter::toActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<GroupBuyActivity> findByKeyword(String keyword) {
|
||||||
|
if (keyword == null || keyword.isEmpty()) {
|
||||||
|
return findAll(false);
|
||||||
|
}
|
||||||
|
return activityDao.findByNameContainingAndDeletedAtIsNull(keyword).map(converter::toActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<GroupBuyActivity> findByStatus(String status) {
|
||||||
|
if (status == null || status.isEmpty()) {
|
||||||
|
return findAll(false);
|
||||||
|
}
|
||||||
|
return activityDao.findByStatusAndDeletedAtIsNull(status).map(converter::toActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<GroupBuyActivity> findByKeywordAndStatus(String keyword, String status) {
|
||||||
|
Flux<GroupBuyActivity> result = findByKeyword(keyword);
|
||||||
|
if (status != null && !status.isEmpty()) {
|
||||||
|
result = result.filter(a -> status.equals(a.getStatus()));
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyActivity> save(GroupBuyActivity activity) {
|
||||||
|
GroupBuyActivityEntity entity = converter.toActivityEntity(activity);
|
||||||
|
return activityDao.save(entity).map(converter::toActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyActivity> update(GroupBuyActivity activity) {
|
||||||
|
return activityDao.findByIdIsAndDeletedAtIsNull(activity.getId())
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("拼团活动不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
existing.markNotNew();
|
||||||
|
if (activity.getName() != null) {
|
||||||
|
existing.setName(activity.getName());
|
||||||
|
}
|
||||||
|
if (activity.getDescription() != null) {
|
||||||
|
existing.setDescription(activity.getDescription());
|
||||||
|
}
|
||||||
|
if (activity.getProductType() != null) {
|
||||||
|
existing.setProductType(activity.getProductType());
|
||||||
|
}
|
||||||
|
if (activity.getProductId() != null) {
|
||||||
|
existing.setProductId(activity.getProductId());
|
||||||
|
}
|
||||||
|
if (activity.getProductName() != null) {
|
||||||
|
existing.setProductName(activity.getProductName());
|
||||||
|
}
|
||||||
|
if (activity.getOriginalPrice() != null) {
|
||||||
|
existing.setOriginalPrice(activity.getOriginalPrice());
|
||||||
|
}
|
||||||
|
if (activity.getGroupPrice() != null) {
|
||||||
|
existing.setGroupPrice(activity.getGroupPrice());
|
||||||
|
}
|
||||||
|
if (activity.getRequiredMembers() != null) {
|
||||||
|
existing.setRequiredMembers(activity.getRequiredMembers());
|
||||||
|
}
|
||||||
|
if (activity.getValidHours() != null) {
|
||||||
|
existing.setValidHours(activity.getValidHours());
|
||||||
|
}
|
||||||
|
if (activity.getStartTime() != null) {
|
||||||
|
existing.setStartTime(activity.getStartTime());
|
||||||
|
}
|
||||||
|
if (activity.getEndTime() != null) {
|
||||||
|
existing.setEndTime(activity.getEndTime());
|
||||||
|
}
|
||||||
|
if (activity.getStock() != null) {
|
||||||
|
existing.setStock(activity.getStock());
|
||||||
|
}
|
||||||
|
existing.setUpdatedAt(LocalDateTime.now());
|
||||||
|
return activityDao.save(existing);
|
||||||
|
})
|
||||||
|
.map(converter::toActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> deleteById(Long id) {
|
||||||
|
return activityDao.softDelete(id, LocalDateTime.now()).then();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> updateStatus(Long id, String status) {
|
||||||
|
return activityDao.updateStatus(id, status, LocalDateTime.now()).then();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> incrementSoldCount(Long id, int count) {
|
||||||
|
return activityDao.incrementSoldCount(id, count, LocalDateTime.now()).then();
|
||||||
|
}
|
||||||
|
}
|
||||||
+61
@@ -0,0 +1,61 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.repository.impl;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.converter.GroupBuyConverter;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.dao.GroupBuyParticipantDao;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyParticipant;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.enums.GroupBuyParticipantStatus;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.enums.GroupBuyTeamStatus;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.repository.IGroupBuyParticipantRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@Transactional
|
||||||
|
public class GroupBuyParticipantRepository implements IGroupBuyParticipantRepository {
|
||||||
|
|
||||||
|
private final GroupBuyParticipantDao participantDao;
|
||||||
|
private final GroupBuyConverter converter;
|
||||||
|
|
||||||
|
public GroupBuyParticipantRepository(GroupBuyParticipantDao participantDao, GroupBuyConverter converter) {
|
||||||
|
this.participantDao = participantDao;
|
||||||
|
this.converter = converter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<GroupBuyParticipant> findByTeamId(Long teamId) {
|
||||||
|
return participantDao.findByTeamIdAndDeletedAtIsNull(teamId).map(converter::toParticipant);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<GroupBuyParticipant> findByActivityId(Long activityId) {
|
||||||
|
return participantDao.findByActivityIdAndDeletedAtIsNull(activityId).map(converter::toParticipant);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Boolean> existsInFormingTeam(Long activityId, Long memberId) {
|
||||||
|
return participantDao.findActiveParticipantInFormingTeam(
|
||||||
|
activityId, memberId,
|
||||||
|
GroupBuyParticipantStatus.JOINED.name(),
|
||||||
|
GroupBuyTeamStatus.FORMING.name())
|
||||||
|
.hasElements();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Long> countByActivityId(Long activityId) {
|
||||||
|
return participantDao.countByActivityIdAndDeletedAtIsNull(activityId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyParticipant> save(GroupBuyParticipant participant) {
|
||||||
|
return participantDao.save(converter.toParticipantEntity(participant)).map(converter::toParticipant);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> updateStatusByTeamId(Long teamId, String status) {
|
||||||
|
return participantDao.updateStatusByTeamId(teamId, status, LocalDateTime.now()).then();
|
||||||
|
}
|
||||||
|
}
|
||||||
+70
@@ -0,0 +1,70 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.repository.impl;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.converter.GroupBuyConverter;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.dao.GroupBuyTeamDao;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyTeam;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.enums.GroupBuyTeamStatus;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.repository.IGroupBuyTeamRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@Transactional
|
||||||
|
public class GroupBuyTeamRepository implements IGroupBuyTeamRepository {
|
||||||
|
|
||||||
|
private final GroupBuyTeamDao teamDao;
|
||||||
|
private final GroupBuyConverter converter;
|
||||||
|
|
||||||
|
public GroupBuyTeamRepository(GroupBuyTeamDao teamDao, GroupBuyConverter converter) {
|
||||||
|
this.teamDao = teamDao;
|
||||||
|
this.converter = converter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyTeam> findById(Long id) {
|
||||||
|
return teamDao.findByIdIsAndDeletedAtIsNull(id).map(converter::toTeam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<GroupBuyTeam> findByActivityId(Long activityId) {
|
||||||
|
return teamDao.findByActivityIdAndDeletedAtIsNull(activityId).map(converter::toTeam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<GroupBuyTeam> findByActivityIdAndStatus(Long activityId, String status) {
|
||||||
|
if (status == null || status.isEmpty()) {
|
||||||
|
return findByActivityId(activityId);
|
||||||
|
}
|
||||||
|
return teamDao.findByActivityIdAndStatusAndDeletedAtIsNull(activityId, status).map(converter::toTeam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<GroupBuyTeam> findExpiredFormingTeams() {
|
||||||
|
return teamDao.findExpiredFormingTeams(
|
||||||
|
GroupBuyTeamStatus.FORMING.name(), LocalDateTime.now()).map(converter::toTeam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyTeam> save(GroupBuyTeam team) {
|
||||||
|
return teamDao.save(converter.toTeamEntity(team)).map(converter::toTeam);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> updateStatus(Long id, String status) {
|
||||||
|
return teamDao.updateStatus(id, status, LocalDateTime.now()).then();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> incrementCurrentMembers(Long id, int count) {
|
||||||
|
return teamDao.incrementCurrentMembers(id, count, LocalDateTime.now()).then();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> markSuccess(Long id, String status) {
|
||||||
|
return teamDao.markSuccess(id, status, LocalDateTime.now(), LocalDateTime.now()).then();
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.scheduler;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.service.IGroupBuyTeamService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.scheduling.annotation.Scheduled;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拼团过期团队定时任务
|
||||||
|
*
|
||||||
|
* 功能:定期检查已过期的拼团中团队,标记为失败
|
||||||
|
*/
|
||||||
|
@Component
|
||||||
|
public class GroupBuyTeamExpireScheduler {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(GroupBuyTeamExpireScheduler.class);
|
||||||
|
|
||||||
|
private final IGroupBuyTeamService teamService;
|
||||||
|
|
||||||
|
public GroupBuyTeamExpireScheduler(IGroupBuyTeamService teamService) {
|
||||||
|
this.teamService = teamService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Scheduled(fixedRate = 60000)
|
||||||
|
public void processExpiredTeams() {
|
||||||
|
logger.debug("定时任务开始检查过期拼团团队");
|
||||||
|
|
||||||
|
teamService.processExpiredTeams()
|
||||||
|
.subscribe(
|
||||||
|
count -> logger.debug("定时任务完成,处理了 {} 个过期拼团团队", count),
|
||||||
|
error -> logger.error("拼团过期定时任务执行失败:{}", error.getMessage(), error)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.service;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageResponse;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyStatistics;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
public interface IGroupBuyActivityService {
|
||||||
|
|
||||||
|
Mono<GroupBuyActivity> findById(Long id);
|
||||||
|
|
||||||
|
Flux<GroupBuyActivity> findAll(boolean includeDeleted);
|
||||||
|
|
||||||
|
Flux<GroupBuyActivity> findByKeywordAndStatus(String keyword, String status);
|
||||||
|
|
||||||
|
Mono<PageResponse<GroupBuyActivity>> findByPage(PageRequest pageRequest, String status);
|
||||||
|
|
||||||
|
Mono<GroupBuyActivity> create(GroupBuyActivity activity);
|
||||||
|
|
||||||
|
Mono<GroupBuyActivity> update(Long id, GroupBuyActivity activity);
|
||||||
|
|
||||||
|
Mono<Void> delete(Long id);
|
||||||
|
|
||||||
|
Mono<GroupBuyActivity> publish(Long id);
|
||||||
|
|
||||||
|
Mono<GroupBuyActivity> terminate(Long id);
|
||||||
|
|
||||||
|
Mono<GroupBuyStatistics> getStatistics(Long id);
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.service;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.CreateTeamRequest;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyParticipant;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyTeam;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.JoinTeamRequest;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
public interface IGroupBuyTeamService {
|
||||||
|
|
||||||
|
Mono<GroupBuyTeam> createTeam(CreateTeamRequest request);
|
||||||
|
|
||||||
|
Mono<GroupBuyTeam> joinTeam(Long teamId, JoinTeamRequest request);
|
||||||
|
|
||||||
|
Mono<GroupBuyTeam> cancelTeam(Long teamId);
|
||||||
|
|
||||||
|
Flux<GroupBuyTeam> findTeams(Long activityId, String status);
|
||||||
|
|
||||||
|
Mono<GroupBuyTeam> findTeamById(Long teamId);
|
||||||
|
|
||||||
|
Flux<GroupBuyParticipant> findParticipantsByTeamId(Long teamId);
|
||||||
|
|
||||||
|
Mono<Long> processExpiredTeams();
|
||||||
|
}
|
||||||
+226
@@ -0,0 +1,226 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.service.impl;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageResponse;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyStatistics;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyTeam;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.enums.GroupBuyActivityStatus;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.enums.GroupBuyTeamStatus;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.repository.IGroupBuyActivityRepository;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.repository.IGroupBuyParticipantRepository;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.repository.IGroupBuyTeamRepository;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.service.IGroupBuyActivityService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GroupBuyActivityService implements IGroupBuyActivityService {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(GroupBuyActivityService.class);
|
||||||
|
|
||||||
|
private final IGroupBuyActivityRepository activityRepository;
|
||||||
|
private final IGroupBuyTeamRepository teamRepository;
|
||||||
|
private final IGroupBuyParticipantRepository participantRepository;
|
||||||
|
|
||||||
|
public GroupBuyActivityService(IGroupBuyActivityRepository activityRepository,
|
||||||
|
IGroupBuyTeamRepository teamRepository,
|
||||||
|
IGroupBuyParticipantRepository participantRepository) {
|
||||||
|
this.activityRepository = activityRepository;
|
||||||
|
this.teamRepository = teamRepository;
|
||||||
|
this.participantRepository = participantRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyActivity> findById(Long id) {
|
||||||
|
return activityRepository.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<GroupBuyActivity> findAll(boolean includeDeleted) {
|
||||||
|
return activityRepository.findAll(includeDeleted);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<GroupBuyActivity> findByKeywordAndStatus(String keyword, String status) {
|
||||||
|
return activityRepository.findByKeywordAndStatus(keyword, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<PageResponse<GroupBuyActivity>> findByPage(PageRequest pageRequest, String status) {
|
||||||
|
int page = Math.max(pageRequest.getPage(), 0);
|
||||||
|
int size = pageRequest.getSize() <= 0 || pageRequest.getSize() > 100 ? 10 : pageRequest.getSize();
|
||||||
|
String keyword = pageRequest.getKeyword();
|
||||||
|
|
||||||
|
return activityRepository.findByKeywordAndStatus(keyword, status)
|
||||||
|
.sort(Comparator.comparing(GroupBuyActivity::getCreatedAt,
|
||||||
|
Comparator.nullsLast(Comparator.reverseOrder())))
|
||||||
|
.collectList()
|
||||||
|
.map(list -> {
|
||||||
|
long total = list.size();
|
||||||
|
int fromIndex = Math.min(page * size, list.size());
|
||||||
|
int toIndex = Math.min(fromIndex + size, list.size());
|
||||||
|
List<GroupBuyActivity> content = list.subList(fromIndex, toIndex);
|
||||||
|
int totalPages = size == 0 ? 0 : (int) Math.ceil((double) total / size);
|
||||||
|
return new PageResponse<>(content, totalPages, total, page, size);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyActivity> create(GroupBuyActivity activity) {
|
||||||
|
return validateActivity(activity)
|
||||||
|
.flatMap(validated -> {
|
||||||
|
validated.generateId();
|
||||||
|
validated.setStatus(GroupBuyActivityStatus.DRAFT.name());
|
||||||
|
validated.setSoldCount(0);
|
||||||
|
applyDefaults(validated);
|
||||||
|
return activityRepository.save(validated);
|
||||||
|
})
|
||||||
|
.doOnSuccess(a -> logger.info("拼团活动创建成功 - id={}, name={}", a.getId(), a.getName()))
|
||||||
|
.doOnError(error -> logger.error("拼团活动创建失败 - error: {}", error.getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyActivity> update(Long id, GroupBuyActivity activity) {
|
||||||
|
return activityRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("拼团活动不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
if (!GroupBuyActivityStatus.DRAFT.name().equals(existing.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("仅草稿状态的拼团活动可编辑"));
|
||||||
|
}
|
||||||
|
activity.setId(id);
|
||||||
|
return validateActivity(activity)
|
||||||
|
.flatMap(activityRepository::update);
|
||||||
|
})
|
||||||
|
.doOnSuccess(a -> logger.info("拼团活动更新成功 - id={}", id))
|
||||||
|
.doOnError(error -> logger.error("拼团活动更新失败 - id={}, error: {}", id, error.getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> delete(Long id) {
|
||||||
|
return activityRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("拼团活动不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
if (!GroupBuyActivityStatus.DRAFT.name().equals(existing.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("仅草稿状态的拼团活动可删除"));
|
||||||
|
}
|
||||||
|
return activityRepository.deleteById(id);
|
||||||
|
})
|
||||||
|
.doOnSuccess(v -> logger.info("拼团活动删除成功 - id={}", id))
|
||||||
|
.doOnError(error -> logger.error("拼团活动删除失败 - id={}, error: {}", id, error.getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyActivity> publish(Long id) {
|
||||||
|
return activityRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("拼团活动不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
if (!GroupBuyActivityStatus.DRAFT.name().equals(existing.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("仅草稿状态的拼团活动可发布"));
|
||||||
|
}
|
||||||
|
return validateActivity(existing)
|
||||||
|
.flatMap(validated -> activityRepository.updateStatus(id, GroupBuyActivityStatus.ACTIVE.name())
|
||||||
|
.then(activityRepository.findById(id)));
|
||||||
|
})
|
||||||
|
.doOnSuccess(a -> logger.info("拼团活动发布成功 - id={}", id))
|
||||||
|
.doOnError(error -> logger.error("拼团活动发布失败 - id={}, error: {}", id, error.getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyActivity> terminate(Long id) {
|
||||||
|
return activityRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("拼团活动不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
if (!GroupBuyActivityStatus.ACTIVE.name().equals(existing.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("仅进行中的拼团活动可终止"));
|
||||||
|
}
|
||||||
|
return activityRepository.updateStatus(id, GroupBuyActivityStatus.TERMINATED.name())
|
||||||
|
.then(activityRepository.findById(id));
|
||||||
|
})
|
||||||
|
.doOnSuccess(a -> logger.info("拼团活动已终止 - id={}", id))
|
||||||
|
.doOnError(error -> logger.error("拼团活动终止失败 - id={}, error: {}", id, error.getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyStatistics> getStatistics(Long id) {
|
||||||
|
return activityRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("拼团活动不存在")))
|
||||||
|
.flatMap(activity -> teamRepository.findByActivityId(id)
|
||||||
|
.collectList()
|
||||||
|
.zipWith(participantRepository.countByActivityId(id))
|
||||||
|
.map(tuple -> {
|
||||||
|
List<GroupBuyTeam> teams = tuple.getT1();
|
||||||
|
long participants = tuple.getT2();
|
||||||
|
|
||||||
|
GroupBuyStatistics stats = new GroupBuyStatistics();
|
||||||
|
stats.setActivityId(id);
|
||||||
|
stats.setTotalTeams(teams.size());
|
||||||
|
stats.setFormingTeams(teams.stream()
|
||||||
|
.filter(t -> GroupBuyTeamStatus.FORMING.name().equals(t.getStatus())).count());
|
||||||
|
stats.setSuccessTeams(teams.stream()
|
||||||
|
.filter(t -> GroupBuyTeamStatus.SUCCESS.name().equals(t.getStatus())).count());
|
||||||
|
stats.setFailedTeams(teams.stream()
|
||||||
|
.filter(t -> GroupBuyTeamStatus.FAILED.name().equals(t.getStatus())).count());
|
||||||
|
stats.setCancelledTeams(teams.stream()
|
||||||
|
.filter(t -> GroupBuyTeamStatus.CANCELLED.name().equals(t.getStatus())).count());
|
||||||
|
stats.setTotalParticipants(participants);
|
||||||
|
stats.setSoldCount(activity.getSoldCount() != null ? activity.getSoldCount() : 0);
|
||||||
|
|
||||||
|
BigDecimal groupPrice = activity.getGroupPrice() != null ? activity.getGroupPrice() : BigDecimal.ZERO;
|
||||||
|
stats.setTotalRevenue(groupPrice.multiply(
|
||||||
|
BigDecimal.valueOf(stats.getSuccessTeams() * activity.getRequiredMembers())));
|
||||||
|
|
||||||
|
return stats;
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<GroupBuyActivity> validateActivity(GroupBuyActivity activity) {
|
||||||
|
if (activity.getName() == null || activity.getName().isBlank()) {
|
||||||
|
return Mono.error(new RuntimeException("活动名称不能为空"));
|
||||||
|
}
|
||||||
|
if (activity.getProductType() == null || activity.getProductType().isBlank()) {
|
||||||
|
return Mono.error(new RuntimeException("商品类型不能为空"));
|
||||||
|
}
|
||||||
|
if (activity.getProductId() == null) {
|
||||||
|
return Mono.error(new RuntimeException("商品ID不能为空"));
|
||||||
|
}
|
||||||
|
if (activity.getOriginalPrice() == null || activity.getGroupPrice() == null) {
|
||||||
|
return Mono.error(new RuntimeException("原价和拼团价不能为空"));
|
||||||
|
}
|
||||||
|
if (activity.getGroupPrice().compareTo(activity.getOriginalPrice()) >= 0) {
|
||||||
|
return Mono.error(new RuntimeException("拼团价必须低于原价"));
|
||||||
|
}
|
||||||
|
if (activity.getRequiredMembers() == null || activity.getRequiredMembers() < 2) {
|
||||||
|
return Mono.error(new RuntimeException("成团人数至少为2人"));
|
||||||
|
}
|
||||||
|
if (activity.getValidHours() == null || activity.getValidHours() <= 0) {
|
||||||
|
return Mono.error(new RuntimeException("拼团有效时长必须大于0"));
|
||||||
|
}
|
||||||
|
if (activity.getStartTime() == null || activity.getEndTime() == null) {
|
||||||
|
return Mono.error(new RuntimeException("活动开始和结束时间不能为空"));
|
||||||
|
}
|
||||||
|
if (activity.getEndTime().isBefore(activity.getStartTime())) {
|
||||||
|
return Mono.error(new RuntimeException("结束时间不能早于开始时间"));
|
||||||
|
}
|
||||||
|
return Mono.just(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyDefaults(GroupBuyActivity activity) {
|
||||||
|
if (activity.getRequiredMembers() == null) {
|
||||||
|
activity.setRequiredMembers(2);
|
||||||
|
}
|
||||||
|
if (activity.getValidHours() == null) {
|
||||||
|
activity.setValidHours(24);
|
||||||
|
}
|
||||||
|
if (activity.getStock() == null) {
|
||||||
|
activity.setStock(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+200
@@ -0,0 +1,200 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.groupbuy.service.impl;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.common.util.SnowflakeId;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.CreateTeamRequest;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyParticipant;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.GroupBuyTeam;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.domain.JoinTeamRequest;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.enums.GroupBuyActivityStatus;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.enums.GroupBuyParticipantStatus;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.enums.GroupBuyTeamStatus;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.repository.IGroupBuyActivityRepository;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.repository.IGroupBuyParticipantRepository;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.repository.IGroupBuyTeamRepository;
|
||||||
|
import cn.novalon.gym.manage.coupon.groupbuy.service.IGroupBuyTeamService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class GroupBuyTeamService implements IGroupBuyTeamService {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(GroupBuyTeamService.class);
|
||||||
|
|
||||||
|
private final IGroupBuyActivityRepository activityRepository;
|
||||||
|
private final IGroupBuyTeamRepository teamRepository;
|
||||||
|
private final IGroupBuyParticipantRepository participantRepository;
|
||||||
|
|
||||||
|
public GroupBuyTeamService(IGroupBuyActivityRepository activityRepository,
|
||||||
|
IGroupBuyTeamRepository teamRepository,
|
||||||
|
IGroupBuyParticipantRepository participantRepository) {
|
||||||
|
this.activityRepository = activityRepository;
|
||||||
|
this.teamRepository = teamRepository;
|
||||||
|
this.participantRepository = participantRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyTeam> createTeam(CreateTeamRequest request) {
|
||||||
|
if (request.getActivityId() == null || request.getMemberId() == null) {
|
||||||
|
return Mono.error(new RuntimeException("activityId和memberId不能为空"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return activityRepository.findById(request.getActivityId())
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("拼团活动不存在")))
|
||||||
|
.flatMap(activity -> validateActivityForTeam(activity)
|
||||||
|
.then(checkMemberNotInFormingTeam(activity.getId(), request.getMemberId()))
|
||||||
|
.then(createTeamInternal(activity, request.getMemberId())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyTeam> joinTeam(Long teamId, JoinTeamRequest request) {
|
||||||
|
if (request.getMemberId() == null) {
|
||||||
|
return Mono.error(new RuntimeException("memberId不能为空"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return teamRepository.findById(teamId)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("拼团团队不存在")))
|
||||||
|
.flatMap(team -> {
|
||||||
|
if (!GroupBuyTeamStatus.FORMING.name().equals(team.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("该团不在拼团中,无法加入"));
|
||||||
|
}
|
||||||
|
if (team.getExpireAt() != null && team.getExpireAt().isBefore(LocalDateTime.now())) {
|
||||||
|
return Mono.error(new RuntimeException("该团已过期"));
|
||||||
|
}
|
||||||
|
return activityRepository.findById(team.getActivityId())
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("拼团活动不存在")))
|
||||||
|
.flatMap(activity -> validateActivityForTeam(activity)
|
||||||
|
.then(checkMemberNotInFormingTeam(activity.getId(), request.getMemberId()))
|
||||||
|
.then(addParticipant(team, activity, request.getMemberId(), false))
|
||||||
|
.flatMap(updatedTeam -> checkAndCompleteTeam(updatedTeam, activity)));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyTeam> cancelTeam(Long teamId) {
|
||||||
|
return teamRepository.findById(teamId)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("拼团团队不存在")))
|
||||||
|
.flatMap(team -> {
|
||||||
|
if (!GroupBuyTeamStatus.FORMING.name().equals(team.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("仅拼团中的团队可取消"));
|
||||||
|
}
|
||||||
|
return teamRepository.updateStatus(teamId, GroupBuyTeamStatus.CANCELLED.name())
|
||||||
|
.then(participantRepository.updateStatusByTeamId(
|
||||||
|
teamId, GroupBuyParticipantStatus.CANCELLED.name()))
|
||||||
|
.then(teamRepository.findById(teamId));
|
||||||
|
})
|
||||||
|
.doOnSuccess(t -> logger.info("拼团团队已取消 - teamId={}", teamId));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<GroupBuyTeam> findTeams(Long activityId, String status) {
|
||||||
|
if (activityId == null) {
|
||||||
|
return Flux.error(new RuntimeException("activityId不能为空"));
|
||||||
|
}
|
||||||
|
return teamRepository.findByActivityIdAndStatus(activityId, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<GroupBuyTeam> findTeamById(Long teamId) {
|
||||||
|
return teamRepository.findById(teamId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<GroupBuyParticipant> findParticipantsByTeamId(Long teamId) {
|
||||||
|
return participantRepository.findByTeamId(teamId);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Long> processExpiredTeams() {
|
||||||
|
return teamRepository.findExpiredFormingTeams()
|
||||||
|
.flatMap(team -> teamRepository.updateStatus(team.getId(), GroupBuyTeamStatus.FAILED.name())
|
||||||
|
.then(participantRepository.updateStatusByTeamId(
|
||||||
|
team.getId(), GroupBuyParticipantStatus.CANCELLED.name()))
|
||||||
|
.thenReturn(1L))
|
||||||
|
.reduce(0L, Long::sum)
|
||||||
|
.doOnSuccess(count -> {
|
||||||
|
if (count > 0) {
|
||||||
|
logger.info("已处理 {} 个过期拼团团队", count);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<GroupBuyTeam> createTeamInternal(GroupBuyActivity activity, Long leaderMemberId) {
|
||||||
|
int validHours = activity.getValidHours() != null ? activity.getValidHours() : 24;
|
||||||
|
|
||||||
|
GroupBuyTeam team = new GroupBuyTeam();
|
||||||
|
team.setId(SnowflakeId.nextId());
|
||||||
|
team.setActivityId(activity.getId());
|
||||||
|
team.setLeaderMemberId(leaderMemberId);
|
||||||
|
team.setRequiredMembers(activity.getRequiredMembers());
|
||||||
|
team.setCurrentMembers(1);
|
||||||
|
team.setStatus(GroupBuyTeamStatus.FORMING.name());
|
||||||
|
team.setExpireAt(LocalDateTime.now().plusHours(validHours));
|
||||||
|
|
||||||
|
return teamRepository.save(team)
|
||||||
|
.flatMap(saved -> addParticipant(saved, activity, leaderMemberId, true));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<GroupBuyTeam> addParticipant(GroupBuyTeam team, GroupBuyActivity activity,
|
||||||
|
Long memberId, boolean isLeader) {
|
||||||
|
GroupBuyParticipant participant = new GroupBuyParticipant();
|
||||||
|
participant.setId(SnowflakeId.nextId());
|
||||||
|
participant.setTeamId(team.getId());
|
||||||
|
participant.setActivityId(activity.getId());
|
||||||
|
participant.setMemberId(memberId);
|
||||||
|
participant.setIsLeader(isLeader);
|
||||||
|
participant.setStatus(GroupBuyParticipantStatus.JOINED.name());
|
||||||
|
participant.setJoinAt(LocalDateTime.now());
|
||||||
|
|
||||||
|
Mono<GroupBuyTeam> teamUpdate = isLeader
|
||||||
|
? Mono.just(team)
|
||||||
|
: teamRepository.incrementCurrentMembers(team.getId(), 1)
|
||||||
|
.then(teamRepository.findById(team.getId()));
|
||||||
|
|
||||||
|
return participantRepository.save(participant)
|
||||||
|
.then(teamUpdate);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<GroupBuyTeam> checkAndCompleteTeam(GroupBuyTeam team, GroupBuyActivity activity) {
|
||||||
|
return teamRepository.findById(team.getId())
|
||||||
|
.flatMap(updated -> {
|
||||||
|
if (updated.getCurrentMembers() >= updated.getRequiredMembers()) {
|
||||||
|
return teamRepository.markSuccess(updated.getId(), GroupBuyTeamStatus.SUCCESS.name())
|
||||||
|
.then(activityRepository.incrementSoldCount(activity.getId(), updated.getRequiredMembers()))
|
||||||
|
.then(teamRepository.findById(updated.getId()));
|
||||||
|
}
|
||||||
|
return Mono.just(updated);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<Void> validateActivityForTeam(GroupBuyActivity activity) {
|
||||||
|
if (!GroupBuyActivityStatus.ACTIVE.name().equals(activity.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("拼团活动未开始或已结束"));
|
||||||
|
}
|
||||||
|
LocalDateTime now = LocalDateTime.now();
|
||||||
|
if (activity.getStartTime() != null && now.isBefore(activity.getStartTime())) {
|
||||||
|
return Mono.error(new RuntimeException("拼团活动尚未开始"));
|
||||||
|
}
|
||||||
|
if (activity.getEndTime() != null && now.isAfter(activity.getEndTime())) {
|
||||||
|
return Mono.error(new RuntimeException("拼团活动已结束"));
|
||||||
|
}
|
||||||
|
int stock = activity.getStock() != null ? activity.getStock() : -1;
|
||||||
|
int sold = activity.getSoldCount() != null ? activity.getSoldCount() : 0;
|
||||||
|
if (stock >= 0 && sold >= stock) {
|
||||||
|
return Mono.error(new RuntimeException("拼团活动库存不足"));
|
||||||
|
}
|
||||||
|
return Mono.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<Void> checkMemberNotInFormingTeam(Long activityId, Long memberId) {
|
||||||
|
return participantRepository.existsInFormingTeam(activityId, memberId)
|
||||||
|
.flatMap(exists -> exists
|
||||||
|
? Mono.error(new RuntimeException("您已在该活动的拼团中,不能重复参团"))
|
||||||
|
: Mono.empty());
|
||||||
|
}
|
||||||
|
}
|
||||||
+227
@@ -0,0 +1,227 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.handler;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||||
|
import cn.novalon.gym.manage.coupon.domain.CouponTemplate;
|
||||||
|
import cn.novalon.gym.manage.coupon.domain.DistributeCouponRequest;
|
||||||
|
import cn.novalon.gym.manage.coupon.service.ICouponTemplateService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||||
|
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Tag(name = "优惠券管理", description = "优惠券相关操作")
|
||||||
|
public class CouponHandler {
|
||||||
|
|
||||||
|
private final ICouponTemplateService couponTemplateService;
|
||||||
|
|
||||||
|
public CouponHandler(ICouponTemplateService couponTemplateService) {
|
||||||
|
this.couponTemplateService = couponTemplateService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取所有优惠券", description = "获取系统中所有优惠券列表")
|
||||||
|
public Mono<ServerResponse> getAllCoupons(ServerRequest request) {
|
||||||
|
boolean includeDeleted = Boolean.parseBoolean(request.queryParam("includeDeleted").orElse("false"));
|
||||||
|
return ServerResponse.ok()
|
||||||
|
.body(couponTemplateService.findAll(includeDeleted), CouponTemplate.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "分页获取优惠券", description = "根据分页参数获取优惠券列表")
|
||||||
|
public Mono<ServerResponse> getCouponsByPage(ServerRequest request) {
|
||||||
|
return request.bodyToMono(PageRequest.class)
|
||||||
|
.flatMap(pageRequest -> {
|
||||||
|
String couponType = request.queryParam("couponType").orElse(null);
|
||||||
|
String status = request.queryParam("status").orElse(null);
|
||||||
|
|
||||||
|
if (pageRequest.getPage() < 0) {
|
||||||
|
pageRequest.setPage(0);
|
||||||
|
}
|
||||||
|
if (pageRequest.getSize() <= 0 || pageRequest.getSize() > 100) {
|
||||||
|
pageRequest.setSize(10);
|
||||||
|
}
|
||||||
|
if (pageRequest.getSort() == null || pageRequest.getSort().isEmpty()) {
|
||||||
|
pageRequest.setSort("id");
|
||||||
|
}
|
||||||
|
if (pageRequest.getOrder() == null || pageRequest.getOrder().isEmpty()) {
|
||||||
|
pageRequest.setOrder("desc");
|
||||||
|
}
|
||||||
|
|
||||||
|
return couponTemplateService.findByPage(pageRequest, couponType, status)
|
||||||
|
.flatMap(response -> ServerResponse.ok().bodyValue(response));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "搜索优惠券", description = "根据关键词、类型、状态搜索优惠券")
|
||||||
|
public Mono<ServerResponse> searchCoupons(ServerRequest request) {
|
||||||
|
String keyword = request.queryParam("keyword").orElse("");
|
||||||
|
String couponType = request.queryParam("couponType").orElse(null);
|
||||||
|
String status = request.queryParam("status").orElse(null);
|
||||||
|
return ServerResponse.ok()
|
||||||
|
.body(couponTemplateService.findByCouponTypeAndKeyword(couponType, keyword, status), CouponTemplate.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "根据ID获取优惠券", description = "根据ID获取优惠券详情")
|
||||||
|
public Mono<ServerResponse> getCouponById(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
return couponTemplateService.findById(id)
|
||||||
|
.flatMap(coupon -> ServerResponse.ok().bodyValue(coupon))
|
||||||
|
.switchIfEmpty(ServerResponse.notFound().build());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "创建优惠券", description = "创建新的优惠券")
|
||||||
|
public Mono<ServerResponse> createCoupon(ServerRequest request) {
|
||||||
|
return request.bodyToMono(CouponTemplate.class)
|
||||||
|
.flatMap(couponTemplate -> {
|
||||||
|
if (couponTemplate.getName() == null || couponTemplate.getName().isEmpty()) {
|
||||||
|
Map<String, Object> error = new HashMap<>();
|
||||||
|
error.put("success", false);
|
||||||
|
error.put("message", "优惠券名称不能为空");
|
||||||
|
return ServerResponse.badRequest().bodyValue(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return couponTemplateService.create(couponTemplate)
|
||||||
|
.flatMap(coupon -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", true);
|
||||||
|
response.put("message", "优惠券创建成功");
|
||||||
|
response.put("data", coupon);
|
||||||
|
return ServerResponse.ok().bodyValue(response);
|
||||||
|
})
|
||||||
|
.onErrorResume(error -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新优惠券", description = "更新指定优惠券信息")
|
||||||
|
public Mono<ServerResponse> updateCoupon(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
|
||||||
|
return request.bodyToMono(CouponTemplate.class)
|
||||||
|
.flatMap(couponTemplate -> couponTemplateService.update(id, couponTemplate)
|
||||||
|
.flatMap(coupon -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", true);
|
||||||
|
response.put("message", "优惠券更新成功");
|
||||||
|
response.put("data", coupon);
|
||||||
|
return ServerResponse.ok().bodyValue(response);
|
||||||
|
})
|
||||||
|
.onErrorResume(error -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除优惠券", description = "删除指定优惠券(软删除)")
|
||||||
|
public Mono<ServerResponse> deleteCoupon(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
|
||||||
|
return couponTemplateService.delete(id)
|
||||||
|
.then(Mono.defer(() -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", true);
|
||||||
|
response.put("message", "优惠券删除成功");
|
||||||
|
return ServerResponse.ok().bodyValue(response);
|
||||||
|
}))
|
||||||
|
.onErrorResume(error -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "发布优惠券", description = "发布优惠券使其可进行发放")
|
||||||
|
public Mono<ServerResponse> publishCoupon(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
|
||||||
|
return couponTemplateService.publish(id)
|
||||||
|
.flatMap(coupon -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", true);
|
||||||
|
response.put("message", "优惠券发布成功");
|
||||||
|
response.put("data", coupon);
|
||||||
|
return ServerResponse.ok().bodyValue(response);
|
||||||
|
})
|
||||||
|
.onErrorResume(error -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "终止优惠券", description = "提前终止优惠券活动")
|
||||||
|
public Mono<ServerResponse> terminateCoupon(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
|
||||||
|
return couponTemplateService.terminate(id)
|
||||||
|
.flatMap(coupon -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", true);
|
||||||
|
response.put("message", "优惠券已终止");
|
||||||
|
response.put("data", coupon);
|
||||||
|
return ServerResponse.ok().bodyValue(response);
|
||||||
|
})
|
||||||
|
.onErrorResume(error -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "发放优惠券", description = "手动或批量发放优惠券给指定会员")
|
||||||
|
public Mono<ServerResponse> distributeCoupon(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
|
||||||
|
return request.bodyToMono(DistributeCouponRequest.class)
|
||||||
|
.flatMap(body -> {
|
||||||
|
if (body.getMemberIds() == null || body.getMemberIds().isEmpty()) {
|
||||||
|
Map<String, Object> error = new HashMap<>();
|
||||||
|
error.put("success", false);
|
||||||
|
error.put("message", "memberIds不能为空");
|
||||||
|
return ServerResponse.badRequest().bodyValue(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return couponTemplateService.distribute(id, body)
|
||||||
|
.flatMap(result -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", true);
|
||||||
|
response.put("message", result.getMessage());
|
||||||
|
response.put("data", result);
|
||||||
|
return ServerResponse.ok().bodyValue(response);
|
||||||
|
})
|
||||||
|
.onErrorResume(error -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取优惠券统计", description = "获取优惠券领取、使用等统计数据")
|
||||||
|
public Mono<ServerResponse> getCouponStatistics(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
|
||||||
|
return couponTemplateService.getStatistics(id)
|
||||||
|
.flatMap(stats -> ServerResponse.ok().bodyValue(stats))
|
||||||
|
.onErrorResume(error -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
+67
@@ -0,0 +1,67 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.handler;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.domain.ClaimCouponRequest;
|
||||||
|
import cn.novalon.gym.manage.coupon.domain.MemberCoupon;
|
||||||
|
import cn.novalon.gym.manage.coupon.service.IMemberCouponService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||||
|
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Tag(name = "会员优惠券", description = "会员优惠券领取与查询")
|
||||||
|
public class MemberCouponHandler {
|
||||||
|
|
||||||
|
private final IMemberCouponService memberCouponService;
|
||||||
|
|
||||||
|
public MemberCouponHandler(IMemberCouponService memberCouponService) {
|
||||||
|
this.memberCouponService = memberCouponService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "查询会员优惠券", description = "查询指定会员的优惠券列表")
|
||||||
|
public Mono<ServerResponse> getMemberCoupons(ServerRequest request) {
|
||||||
|
Long memberId = Long.valueOf(request.pathVariable("memberId"));
|
||||||
|
String status = request.queryParam("status").orElse(null);
|
||||||
|
return ServerResponse.ok()
|
||||||
|
.body(memberCouponService.findByMemberIdAndStatus(memberId, status), MemberCoupon.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "领取码兑换优惠券", description = "会员通过领取码/二维码兑换优惠券")
|
||||||
|
public Mono<ServerResponse> claimCoupon(ServerRequest request) {
|
||||||
|
return request.bodyToMono(ClaimCouponRequest.class)
|
||||||
|
.flatMap(body -> {
|
||||||
|
if (body.getMemberId() == null) {
|
||||||
|
Map<String, Object> error = new HashMap<>();
|
||||||
|
error.put("success", false);
|
||||||
|
error.put("message", "memberId不能为空");
|
||||||
|
return ServerResponse.badRequest().bodyValue(error);
|
||||||
|
}
|
||||||
|
if (body.getClaimCode() == null || body.getClaimCode().isBlank()) {
|
||||||
|
Map<String, Object> error = new HashMap<>();
|
||||||
|
error.put("success", false);
|
||||||
|
error.put("message", "claimCode不能为空");
|
||||||
|
return ServerResponse.badRequest().bodyValue(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return memberCouponService.claimByCode(body.getMemberId(), body.getClaimCode())
|
||||||
|
.flatMap(coupon -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", true);
|
||||||
|
response.put("message", "优惠券领取成功");
|
||||||
|
response.put("data", coupon);
|
||||||
|
return ServerResponse.ok().bodyValue(response);
|
||||||
|
})
|
||||||
|
.onErrorResume(error -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.marketing.converter;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.domain.MarketingActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.entity.MarketingActivityEntity;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class MarketingConverter {
|
||||||
|
|
||||||
|
public MarketingActivity toMarketingActivity(MarketingActivityEntity entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MarketingActivity domain = new MarketingActivity();
|
||||||
|
BeanUtil.copyProperties(entity, domain);
|
||||||
|
log.debug("转换营销活动实体到领域模型:activityId={}", entity.getId());
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MarketingActivityEntity toMarketingActivityEntity(MarketingActivity domain) {
|
||||||
|
if (domain == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MarketingActivityEntity entity = new MarketingActivityEntity();
|
||||||
|
BeanUtil.copyProperties(domain, entity);
|
||||||
|
if (domain.getId() != null) {
|
||||||
|
entity.markNotNew();
|
||||||
|
}
|
||||||
|
log.debug("转换营销活动领域模型到实体:activityId={}", domain.getId());
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.marketing.dao;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.entity.MarketingActivityEntity;
|
||||||
|
import org.springframework.data.r2dbc.repository.Modifying;
|
||||||
|
import org.springframework.data.r2dbc.repository.Query;
|
||||||
|
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface MarketingActivityDao extends R2dbcRepository<MarketingActivityEntity, Long> {
|
||||||
|
|
||||||
|
Mono<MarketingActivityEntity> findByIdIsAndDeletedAtIsNull(Long id);
|
||||||
|
|
||||||
|
Flux<MarketingActivityEntity> findAllByDeletedAtIsNull();
|
||||||
|
|
||||||
|
Flux<MarketingActivityEntity> findByNameContainingAndDeletedAtIsNull(String name);
|
||||||
|
|
||||||
|
Flux<MarketingActivityEntity> findByActivityTypeAndDeletedAtIsNull(String activityType);
|
||||||
|
|
||||||
|
Flux<MarketingActivityEntity> findByStatusAndDeletedAtIsNull(String status);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE marketing_activity SET deleted_at = :deletedAt WHERE id = :id")
|
||||||
|
Mono<Integer> softDelete(Long id, LocalDateTime deletedAt);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE marketing_activity SET status = :status, updated_at = :updatedAt WHERE id = :id")
|
||||||
|
Mono<Integer> updateStatus(Long id, String status, LocalDateTime updatedAt);
|
||||||
|
}
|
||||||
+176
@@ -0,0 +1,176 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.marketing.domain;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Schema(description = "会员营销活动")
|
||||||
|
public class MarketingActivity extends BaseDomain {
|
||||||
|
|
||||||
|
@Schema(description = "活动名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "活动描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "活动类型:GIFT/TIME_DISCOUNT/TIERED_DISCOUNT/GROUP_DISCOUNT/LIMITED_OFFER/RECOMMEND_REWARD")
|
||||||
|
private String activityType;
|
||||||
|
|
||||||
|
@Schema(description = "开始时间")
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
|
||||||
|
@Schema(description = "结束时间")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@Schema(description = "折扣值")
|
||||||
|
private BigDecimal discountValue;
|
||||||
|
|
||||||
|
@Schema(description = "门槛金额")
|
||||||
|
private BigDecimal thresholdAmount;
|
||||||
|
|
||||||
|
@Schema(description = "赠品描述")
|
||||||
|
private String giftDescription;
|
||||||
|
|
||||||
|
@Schema(description = "适用范围:ALL/SPECIFIC")
|
||||||
|
private String applyScope;
|
||||||
|
|
||||||
|
@Schema(description = "指定商品ID列表(JSON数组字符串)")
|
||||||
|
private String applyProductIds;
|
||||||
|
|
||||||
|
@Schema(description = "活动规则JSON配置")
|
||||||
|
private String rulesJson;
|
||||||
|
|
||||||
|
@Schema(description = "参与人数")
|
||||||
|
private Integer participantCount;
|
||||||
|
|
||||||
|
@Schema(description = "订单数")
|
||||||
|
private Integer orderCount;
|
||||||
|
|
||||||
|
@Schema(description = "累计优惠金额")
|
||||||
|
private BigDecimal totalDiscountAmount;
|
||||||
|
|
||||||
|
@Schema(description = "状态:DRAFT/ACTIVE/TERMINATED/EXPIRED")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActivityType() {
|
||||||
|
return activityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityType(String activityType) {
|
||||||
|
this.activityType = activityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(LocalDateTime startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime(LocalDateTime endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getDiscountValue() {
|
||||||
|
return discountValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiscountValue(BigDecimal discountValue) {
|
||||||
|
this.discountValue = discountValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getThresholdAmount() {
|
||||||
|
return thresholdAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setThresholdAmount(BigDecimal thresholdAmount) {
|
||||||
|
this.thresholdAmount = thresholdAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGiftDescription() {
|
||||||
|
return giftDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGiftDescription(String giftDescription) {
|
||||||
|
this.giftDescription = giftDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApplyScope() {
|
||||||
|
return applyScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApplyScope(String applyScope) {
|
||||||
|
this.applyScope = applyScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApplyProductIds() {
|
||||||
|
return applyProductIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApplyProductIds(String applyProductIds) {
|
||||||
|
this.applyProductIds = applyProductIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRulesJson() {
|
||||||
|
return rulesJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRulesJson(String rulesJson) {
|
||||||
|
this.rulesJson = rulesJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getParticipantCount() {
|
||||||
|
return participantCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParticipantCount(Integer participantCount) {
|
||||||
|
this.participantCount = participantCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOrderCount() {
|
||||||
|
return orderCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderCount(Integer orderCount) {
|
||||||
|
this.orderCount = orderCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getTotalDiscountAmount() {
|
||||||
|
return totalDiscountAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalDiscountAmount(BigDecimal totalDiscountAmount) {
|
||||||
|
this.totalDiscountAmount = totalDiscountAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
+75
@@ -0,0 +1,75 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.marketing.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Schema(description = "营销活动统计数据")
|
||||||
|
public class MarketingActivityStatistics {
|
||||||
|
|
||||||
|
@Schema(description = "活动ID")
|
||||||
|
private Long activityId;
|
||||||
|
|
||||||
|
@Schema(description = "活动名称")
|
||||||
|
private String activityName;
|
||||||
|
|
||||||
|
@Schema(description = "参与人数")
|
||||||
|
private Integer participantCount;
|
||||||
|
|
||||||
|
@Schema(description = "订单数")
|
||||||
|
private Integer orderCount;
|
||||||
|
|
||||||
|
@Schema(description = "累计优惠金额")
|
||||||
|
private BigDecimal totalDiscountAmount;
|
||||||
|
|
||||||
|
@Schema(description = "活动状态")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
public Long getActivityId() {
|
||||||
|
return activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityId(Long activityId) {
|
||||||
|
this.activityId = activityId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActivityName() {
|
||||||
|
return activityName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityName(String activityName) {
|
||||||
|
this.activityName = activityName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getParticipantCount() {
|
||||||
|
return participantCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParticipantCount(Integer participantCount) {
|
||||||
|
this.participantCount = participantCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOrderCount() {
|
||||||
|
return orderCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderCount(Integer orderCount) {
|
||||||
|
this.orderCount = orderCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getTotalDiscountAmount() {
|
||||||
|
return totalDiscountAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalDiscountAmount(BigDecimal totalDiscountAmount) {
|
||||||
|
this.totalDiscountAmount = totalDiscountAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
+177
@@ -0,0 +1,177 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.marketing.entity;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.db.entity.BaseEntity;
|
||||||
|
import org.springframework.data.relational.core.mapping.Column;
|
||||||
|
import org.springframework.data.relational.core.mapping.Table;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Table("marketing_activity")
|
||||||
|
public class MarketingActivityEntity extends BaseEntity {
|
||||||
|
|
||||||
|
@Column("name")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Column("description")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Column("activity_type")
|
||||||
|
private String activityType;
|
||||||
|
|
||||||
|
@Column("start_time")
|
||||||
|
private LocalDateTime startTime;
|
||||||
|
|
||||||
|
@Column("end_time")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@Column("discount_value")
|
||||||
|
private BigDecimal discountValue;
|
||||||
|
|
||||||
|
@Column("threshold_amount")
|
||||||
|
private BigDecimal thresholdAmount;
|
||||||
|
|
||||||
|
@Column("gift_description")
|
||||||
|
private String giftDescription;
|
||||||
|
|
||||||
|
@Column("apply_scope")
|
||||||
|
private String applyScope;
|
||||||
|
|
||||||
|
@Column("apply_product_ids")
|
||||||
|
private String applyProductIds;
|
||||||
|
|
||||||
|
@Column("rules_json")
|
||||||
|
private String rulesJson;
|
||||||
|
|
||||||
|
@Column("participant_count")
|
||||||
|
private Integer participantCount;
|
||||||
|
|
||||||
|
@Column("order_count")
|
||||||
|
private Integer orderCount;
|
||||||
|
|
||||||
|
@Column("total_discount_amount")
|
||||||
|
private BigDecimal totalDiscountAmount;
|
||||||
|
|
||||||
|
@Column("status")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getActivityType() {
|
||||||
|
return activityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActivityType(String activityType) {
|
||||||
|
this.activityType = activityType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getStartTime() {
|
||||||
|
return startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStartTime(LocalDateTime startTime) {
|
||||||
|
this.startTime = startTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LocalDateTime getEndTime() {
|
||||||
|
return endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEndTime(LocalDateTime endTime) {
|
||||||
|
this.endTime = endTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getDiscountValue() {
|
||||||
|
return discountValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDiscountValue(BigDecimal discountValue) {
|
||||||
|
this.discountValue = discountValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getThresholdAmount() {
|
||||||
|
return thresholdAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setThresholdAmount(BigDecimal thresholdAmount) {
|
||||||
|
this.thresholdAmount = thresholdAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGiftDescription() {
|
||||||
|
return giftDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGiftDescription(String giftDescription) {
|
||||||
|
this.giftDescription = giftDescription;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApplyScope() {
|
||||||
|
return applyScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApplyScope(String applyScope) {
|
||||||
|
this.applyScope = applyScope;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getApplyProductIds() {
|
||||||
|
return applyProductIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setApplyProductIds(String applyProductIds) {
|
||||||
|
this.applyProductIds = applyProductIds;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRulesJson() {
|
||||||
|
return rulesJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRulesJson(String rulesJson) {
|
||||||
|
this.rulesJson = rulesJson;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getParticipantCount() {
|
||||||
|
return participantCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setParticipantCount(Integer participantCount) {
|
||||||
|
this.participantCount = participantCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getOrderCount() {
|
||||||
|
return orderCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrderCount(Integer orderCount) {
|
||||||
|
this.orderCount = orderCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getTotalDiscountAmount() {
|
||||||
|
return totalDiscountAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalDiscountAmount(BigDecimal totalDiscountAmount) {
|
||||||
|
this.totalDiscountAmount = totalDiscountAmount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
@@ -0,0 +1,15 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.marketing.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 营销活动状态
|
||||||
|
*/
|
||||||
|
public enum MarketingActivityStatus {
|
||||||
|
/** 草稿 */
|
||||||
|
DRAFT,
|
||||||
|
/** 进行中 */
|
||||||
|
ACTIVE,
|
||||||
|
/** 已终止 */
|
||||||
|
TERMINATED,
|
||||||
|
/** 已过期 */
|
||||||
|
EXPIRED
|
||||||
|
}
|
||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.marketing.enums;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员营销活动类型
|
||||||
|
*/
|
||||||
|
public enum MarketingActivityType {
|
||||||
|
/** 赠品活动 */
|
||||||
|
GIFT,
|
||||||
|
/** 限时折扣 */
|
||||||
|
TIME_DISCOUNT,
|
||||||
|
/** 阶梯折扣 */
|
||||||
|
TIERED_DISCOUNT,
|
||||||
|
/** 团购折扣 */
|
||||||
|
GROUP_DISCOUNT,
|
||||||
|
/** 限量特惠 */
|
||||||
|
LIMITED_OFFER,
|
||||||
|
/** 推荐奖励 */
|
||||||
|
RECOMMEND_REWARD
|
||||||
|
}
|
||||||
+197
@@ -0,0 +1,197 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.marketing.handler;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.domain.MarketingActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.service.IMarketingActivityService;
|
||||||
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.reactive.function.server.ServerRequest;
|
||||||
|
import org.springframework.web.reactive.function.server.ServerResponse;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Tag(name = "会员营销活动", description = "会员营销活动相关操作")
|
||||||
|
public class MarketingActivityHandler {
|
||||||
|
|
||||||
|
private final IMarketingActivityService marketingActivityService;
|
||||||
|
|
||||||
|
public MarketingActivityHandler(IMarketingActivityService marketingActivityService) {
|
||||||
|
this.marketingActivityService = marketingActivityService;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取所有营销活动", description = "获取系统中所有营销活动列表")
|
||||||
|
public Mono<ServerResponse> getAllActivities(ServerRequest request) {
|
||||||
|
boolean includeDeleted = Boolean.parseBoolean(request.queryParam("includeDeleted").orElse("false"));
|
||||||
|
return ServerResponse.ok()
|
||||||
|
.body(marketingActivityService.findAll(includeDeleted), MarketingActivity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "分页获取营销活动", description = "根据分页参数获取营销活动列表")
|
||||||
|
public Mono<ServerResponse> getActivitiesByPage(ServerRequest request) {
|
||||||
|
return request.bodyToMono(PageRequest.class)
|
||||||
|
.flatMap(pageRequest -> {
|
||||||
|
String activityType = request.queryParam("activityType").orElse(null);
|
||||||
|
String status = request.queryParam("status").orElse(null);
|
||||||
|
|
||||||
|
if (pageRequest.getPage() < 0) {
|
||||||
|
pageRequest.setPage(0);
|
||||||
|
}
|
||||||
|
if (pageRequest.getSize() <= 0 || pageRequest.getSize() > 100) {
|
||||||
|
pageRequest.setSize(10);
|
||||||
|
}
|
||||||
|
if (pageRequest.getSort() == null || pageRequest.getSort().isEmpty()) {
|
||||||
|
pageRequest.setSort("id");
|
||||||
|
}
|
||||||
|
if (pageRequest.getOrder() == null || pageRequest.getOrder().isEmpty()) {
|
||||||
|
pageRequest.setOrder("desc");
|
||||||
|
}
|
||||||
|
|
||||||
|
return marketingActivityService.findByPage(pageRequest, activityType, status)
|
||||||
|
.flatMap(response -> ServerResponse.ok().bodyValue(response));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "搜索营销活动", description = "根据关键词、类型、状态搜索营销活动")
|
||||||
|
public Mono<ServerResponse> searchActivities(ServerRequest request) {
|
||||||
|
String keyword = request.queryParam("keyword").orElse("");
|
||||||
|
String activityType = request.queryParam("activityType").orElse(null);
|
||||||
|
String status = request.queryParam("status").orElse(null);
|
||||||
|
return ServerResponse.ok()
|
||||||
|
.body(marketingActivityService.findByActivityTypeAndKeyword(activityType, keyword, status),
|
||||||
|
MarketingActivity.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "根据ID获取营销活动", description = "根据ID获取营销活动详情")
|
||||||
|
public Mono<ServerResponse> getActivityById(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
return marketingActivityService.findById(id)
|
||||||
|
.flatMap(activity -> ServerResponse.ok().bodyValue(activity))
|
||||||
|
.switchIfEmpty(ServerResponse.notFound().build());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "创建营销活动", description = "创建新的营销活动")
|
||||||
|
public Mono<ServerResponse> createActivity(ServerRequest request) {
|
||||||
|
return request.bodyToMono(MarketingActivity.class)
|
||||||
|
.flatMap(activity -> {
|
||||||
|
if (activity.getName() == null || activity.getName().isEmpty()) {
|
||||||
|
Map<String, Object> error = new HashMap<>();
|
||||||
|
error.put("success", false);
|
||||||
|
error.put("message", "活动名称不能为空");
|
||||||
|
return ServerResponse.badRequest().bodyValue(error);
|
||||||
|
}
|
||||||
|
|
||||||
|
return marketingActivityService.create(activity)
|
||||||
|
.flatMap(created -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", true);
|
||||||
|
response.put("message", "营销活动创建成功");
|
||||||
|
response.put("data", created);
|
||||||
|
return ServerResponse.ok().bodyValue(response);
|
||||||
|
})
|
||||||
|
.onErrorResume(error -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "更新营销活动", description = "更新指定营销活动信息")
|
||||||
|
public Mono<ServerResponse> updateActivity(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
|
||||||
|
return request.bodyToMono(MarketingActivity.class)
|
||||||
|
.flatMap(activity -> marketingActivityService.update(id, activity)
|
||||||
|
.flatMap(updated -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", true);
|
||||||
|
response.put("message", "营销活动更新成功");
|
||||||
|
response.put("data", updated);
|
||||||
|
return ServerResponse.ok().bodyValue(response);
|
||||||
|
})
|
||||||
|
.onErrorResume(error -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "删除营销活动", description = "删除指定营销活动(软删除)")
|
||||||
|
public Mono<ServerResponse> deleteActivity(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
|
||||||
|
return marketingActivityService.delete(id)
|
||||||
|
.then(Mono.defer(() -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", true);
|
||||||
|
response.put("message", "营销活动删除成功");
|
||||||
|
return ServerResponse.ok().bodyValue(response);
|
||||||
|
}))
|
||||||
|
.onErrorResume(error -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "发布营销活动", description = "发布营销活动使其生效")
|
||||||
|
public Mono<ServerResponse> publishActivity(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
|
||||||
|
return marketingActivityService.publish(id)
|
||||||
|
.flatMap(activity -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", true);
|
||||||
|
response.put("message", "营销活动发布成功");
|
||||||
|
response.put("data", activity);
|
||||||
|
return ServerResponse.ok().bodyValue(response);
|
||||||
|
})
|
||||||
|
.onErrorResume(error -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "终止营销活动", description = "提前终止营销活动")
|
||||||
|
public Mono<ServerResponse> terminateActivity(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
|
||||||
|
return marketingActivityService.terminate(id)
|
||||||
|
.flatMap(activity -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", true);
|
||||||
|
response.put("message", "营销活动已终止");
|
||||||
|
response.put("data", activity);
|
||||||
|
return ServerResponse.ok().bodyValue(response);
|
||||||
|
})
|
||||||
|
.onErrorResume(error -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "获取营销活动统计", description = "获取营销活动参与、订单等统计数据")
|
||||||
|
public Mono<ServerResponse> getActivityStatistics(ServerRequest request) {
|
||||||
|
Long id = Long.valueOf(request.pathVariable("id"));
|
||||||
|
|
||||||
|
return marketingActivityService.getStatistics(id)
|
||||||
|
.flatMap(stats -> ServerResponse.ok().bodyValue(stats))
|
||||||
|
.onErrorResume(error -> {
|
||||||
|
Map<String, Object> response = new HashMap<>();
|
||||||
|
response.put("success", false);
|
||||||
|
response.put("message", error.getMessage());
|
||||||
|
return ServerResponse.badRequest().bodyValue(response);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
+30
@@ -0,0 +1,30 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.marketing.repository;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.domain.MarketingActivity;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
public interface IMarketingActivityRepository {
|
||||||
|
|
||||||
|
Mono<MarketingActivity> findById(Long id);
|
||||||
|
|
||||||
|
Flux<MarketingActivity> findAll();
|
||||||
|
|
||||||
|
Flux<MarketingActivity> findAll(boolean includeDeleted);
|
||||||
|
|
||||||
|
Flux<MarketingActivity> findByKeyword(String keyword);
|
||||||
|
|
||||||
|
Flux<MarketingActivity> findByActivityType(String activityType);
|
||||||
|
|
||||||
|
Flux<MarketingActivity> findByStatus(String status);
|
||||||
|
|
||||||
|
Flux<MarketingActivity> findByActivityTypeAndKeyword(String activityType, String keyword, String status);
|
||||||
|
|
||||||
|
Mono<MarketingActivity> save(MarketingActivity activity);
|
||||||
|
|
||||||
|
Mono<MarketingActivity> update(MarketingActivity activity);
|
||||||
|
|
||||||
|
Mono<Void> deleteById(Long id);
|
||||||
|
|
||||||
|
Mono<Void> updateStatus(Long id, String status);
|
||||||
|
}
|
||||||
+164
@@ -0,0 +1,164 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.marketing.repository.impl;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.converter.MarketingConverter;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.dao.MarketingActivityDao;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.domain.MarketingActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.entity.MarketingActivityEntity;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.repository.IMarketingActivityRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
@Transactional
|
||||||
|
public class MarketingActivityRepository implements IMarketingActivityRepository {
|
||||||
|
|
||||||
|
private final MarketingActivityDao marketingActivityDao;
|
||||||
|
private final MarketingConverter converter;
|
||||||
|
|
||||||
|
public MarketingActivityRepository(MarketingActivityDao marketingActivityDao, MarketingConverter converter) {
|
||||||
|
this.marketingActivityDao = marketingActivityDao;
|
||||||
|
this.converter = converter;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<MarketingActivity> findById(Long id) {
|
||||||
|
return marketingActivityDao.findByIdIsAndDeletedAtIsNull(id)
|
||||||
|
.map(converter::toMarketingActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<MarketingActivity> findAll() {
|
||||||
|
return marketingActivityDao.findAllByDeletedAtIsNull()
|
||||||
|
.map(converter::toMarketingActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<MarketingActivity> findAll(boolean includeDeleted) {
|
||||||
|
if (includeDeleted) {
|
||||||
|
return marketingActivityDao.findAll()
|
||||||
|
.map(converter::toMarketingActivity);
|
||||||
|
}
|
||||||
|
return findAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<MarketingActivity> findByKeyword(String keyword) {
|
||||||
|
if (keyword == null || keyword.isEmpty()) {
|
||||||
|
return findAll(false);
|
||||||
|
}
|
||||||
|
return marketingActivityDao.findByNameContainingAndDeletedAtIsNull(keyword)
|
||||||
|
.map(converter::toMarketingActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<MarketingActivity> findByActivityType(String activityType) {
|
||||||
|
if (activityType == null || activityType.isEmpty()) {
|
||||||
|
return findAll(false);
|
||||||
|
}
|
||||||
|
return marketingActivityDao.findByActivityTypeAndDeletedAtIsNull(activityType)
|
||||||
|
.map(converter::toMarketingActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<MarketingActivity> findByStatus(String status) {
|
||||||
|
if (status == null || status.isEmpty()) {
|
||||||
|
return findAll(false);
|
||||||
|
}
|
||||||
|
return marketingActivityDao.findByStatusAndDeletedAtIsNull(status)
|
||||||
|
.map(converter::toMarketingActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<MarketingActivity> findByActivityTypeAndKeyword(String activityType, String keyword, String status) {
|
||||||
|
Flux<MarketingActivity> result;
|
||||||
|
|
||||||
|
if (activityType != null && !activityType.isEmpty()) {
|
||||||
|
result = findByActivityType(activityType);
|
||||||
|
} else if (status != null && !status.isEmpty()) {
|
||||||
|
result = findByStatus(status);
|
||||||
|
} else {
|
||||||
|
result = findAll(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (keyword != null && !keyword.isEmpty()) {
|
||||||
|
result = result.filter(activity -> activity.getName() != null
|
||||||
|
&& activity.getName().toLowerCase().contains(keyword.toLowerCase()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (status != null && !status.isEmpty()) {
|
||||||
|
result = result.filter(activity -> status.equals(activity.getStatus()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (activityType != null && !activityType.isEmpty()) {
|
||||||
|
result = result.filter(activity -> activityType.equals(activity.getActivityType()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<MarketingActivity> save(MarketingActivity activity) {
|
||||||
|
MarketingActivityEntity entity = converter.toMarketingActivityEntity(activity);
|
||||||
|
return marketingActivityDao.save(entity)
|
||||||
|
.map(converter::toMarketingActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<MarketingActivity> update(MarketingActivity activity) {
|
||||||
|
return marketingActivityDao.findByIdIsAndDeletedAtIsNull(activity.getId())
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("营销活动不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
existing.markNotNew();
|
||||||
|
if (activity.getName() != null) {
|
||||||
|
existing.setName(activity.getName());
|
||||||
|
}
|
||||||
|
if (activity.getDescription() != null) {
|
||||||
|
existing.setDescription(activity.getDescription());
|
||||||
|
}
|
||||||
|
if (activity.getActivityType() != null) {
|
||||||
|
existing.setActivityType(activity.getActivityType());
|
||||||
|
}
|
||||||
|
if (activity.getStartTime() != null) {
|
||||||
|
existing.setStartTime(activity.getStartTime());
|
||||||
|
}
|
||||||
|
if (activity.getEndTime() != null) {
|
||||||
|
existing.setEndTime(activity.getEndTime());
|
||||||
|
}
|
||||||
|
if (activity.getDiscountValue() != null) {
|
||||||
|
existing.setDiscountValue(activity.getDiscountValue());
|
||||||
|
}
|
||||||
|
if (activity.getThresholdAmount() != null) {
|
||||||
|
existing.setThresholdAmount(activity.getThresholdAmount());
|
||||||
|
}
|
||||||
|
if (activity.getGiftDescription() != null) {
|
||||||
|
existing.setGiftDescription(activity.getGiftDescription());
|
||||||
|
}
|
||||||
|
if (activity.getApplyScope() != null) {
|
||||||
|
existing.setApplyScope(activity.getApplyScope());
|
||||||
|
}
|
||||||
|
if (activity.getApplyProductIds() != null) {
|
||||||
|
existing.setApplyProductIds(activity.getApplyProductIds());
|
||||||
|
}
|
||||||
|
if (activity.getRulesJson() != null) {
|
||||||
|
existing.setRulesJson(activity.getRulesJson());
|
||||||
|
}
|
||||||
|
existing.setUpdatedAt(LocalDateTime.now());
|
||||||
|
return marketingActivityDao.save(existing);
|
||||||
|
})
|
||||||
|
.map(converter::toMarketingActivity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> deleteById(Long id) {
|
||||||
|
return marketingActivityDao.softDelete(id, LocalDateTime.now()).then();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> updateStatus(Long id, String status) {
|
||||||
|
return marketingActivityDao.updateStatus(id, status, LocalDateTime.now()).then();
|
||||||
|
}
|
||||||
|
}
|
||||||
+31
@@ -0,0 +1,31 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.marketing.service;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageResponse;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.domain.MarketingActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.domain.MarketingActivityStatistics;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
public interface IMarketingActivityService {
|
||||||
|
|
||||||
|
Mono<MarketingActivity> findById(Long id);
|
||||||
|
|
||||||
|
Flux<MarketingActivity> findAll(boolean includeDeleted);
|
||||||
|
|
||||||
|
Flux<MarketingActivity> findByActivityTypeAndKeyword(String activityType, String keyword, String status);
|
||||||
|
|
||||||
|
Mono<PageResponse<MarketingActivity>> findByPage(PageRequest pageRequest, String activityType, String status);
|
||||||
|
|
||||||
|
Mono<MarketingActivity> create(MarketingActivity activity);
|
||||||
|
|
||||||
|
Mono<MarketingActivity> update(Long id, MarketingActivity activity);
|
||||||
|
|
||||||
|
Mono<Void> delete(Long id);
|
||||||
|
|
||||||
|
Mono<MarketingActivity> publish(Long id);
|
||||||
|
|
||||||
|
Mono<MarketingActivity> terminate(Long id);
|
||||||
|
|
||||||
|
Mono<MarketingActivityStatistics> getStatistics(Long id);
|
||||||
|
}
|
||||||
+192
@@ -0,0 +1,192 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.marketing.service.impl;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageRequest;
|
||||||
|
import cn.novalon.gym.manage.common.dto.PageResponse;
|
||||||
|
import cn.novalon.gym.manage.coupon.enums.ApplyScope;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.domain.MarketingActivity;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.domain.MarketingActivityStatistics;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.enums.MarketingActivityStatus;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.enums.MarketingActivityType;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.repository.IMarketingActivityRepository;
|
||||||
|
import cn.novalon.gym.manage.coupon.marketing.service.IMarketingActivityService;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class MarketingActivityService implements IMarketingActivityService {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger(MarketingActivityService.class);
|
||||||
|
|
||||||
|
private final IMarketingActivityRepository marketingActivityRepository;
|
||||||
|
|
||||||
|
public MarketingActivityService(IMarketingActivityRepository marketingActivityRepository) {
|
||||||
|
this.marketingActivityRepository = marketingActivityRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<MarketingActivity> findById(Long id) {
|
||||||
|
return marketingActivityRepository.findById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<MarketingActivity> findAll(boolean includeDeleted) {
|
||||||
|
return marketingActivityRepository.findAll(includeDeleted);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Flux<MarketingActivity> findByActivityTypeAndKeyword(String activityType, String keyword, String status) {
|
||||||
|
return marketingActivityRepository.findByActivityTypeAndKeyword(activityType, keyword, status);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<PageResponse<MarketingActivity>> findByPage(PageRequest pageRequest, String activityType, String status) {
|
||||||
|
int page = Math.max(pageRequest.getPage(), 0);
|
||||||
|
int size = pageRequest.getSize() <= 0 || pageRequest.getSize() > 100 ? 10 : pageRequest.getSize();
|
||||||
|
String keyword = pageRequest.getKeyword();
|
||||||
|
|
||||||
|
return marketingActivityRepository.findByActivityTypeAndKeyword(activityType, keyword, status)
|
||||||
|
.sort(Comparator.comparing(MarketingActivity::getCreatedAt,
|
||||||
|
Comparator.nullsLast(Comparator.reverseOrder())))
|
||||||
|
.collectList()
|
||||||
|
.map(list -> {
|
||||||
|
long total = list.size();
|
||||||
|
int fromIndex = Math.min(page * size, list.size());
|
||||||
|
int toIndex = Math.min(fromIndex + size, list.size());
|
||||||
|
List<MarketingActivity> content = list.subList(fromIndex, toIndex);
|
||||||
|
int totalPages = size == 0 ? 0 : (int) Math.ceil((double) total / size);
|
||||||
|
return new PageResponse<>(content, totalPages, total, page, size);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<MarketingActivity> create(MarketingActivity activity) {
|
||||||
|
return validateActivity(activity)
|
||||||
|
.flatMap(validated -> {
|
||||||
|
validated.generateId();
|
||||||
|
validated.setStatus(MarketingActivityStatus.DRAFT.name());
|
||||||
|
validated.setParticipantCount(0);
|
||||||
|
validated.setOrderCount(0);
|
||||||
|
validated.setTotalDiscountAmount(BigDecimal.ZERO);
|
||||||
|
applyDefaults(validated);
|
||||||
|
return marketingActivityRepository.save(validated);
|
||||||
|
})
|
||||||
|
.doOnSuccess(a -> logger.info("营销活动创建成功 - id={}, name={}", a.getId(), a.getName()))
|
||||||
|
.doOnError(error -> logger.error("营销活动创建失败 - error: {}", error.getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<MarketingActivity> update(Long id, MarketingActivity activity) {
|
||||||
|
return marketingActivityRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("营销活动不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
if (!MarketingActivityStatus.DRAFT.name().equals(existing.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("活动已发布,不可编辑"));
|
||||||
|
}
|
||||||
|
activity.setId(id);
|
||||||
|
return validateActivity(activity)
|
||||||
|
.flatMap(marketingActivityRepository::update);
|
||||||
|
})
|
||||||
|
.doOnSuccess(a -> logger.info("营销活动更新成功 - id={}", id))
|
||||||
|
.doOnError(error -> logger.error("营销活动更新失败 - id={}, error: {}", id, error.getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<Void> delete(Long id) {
|
||||||
|
return marketingActivityRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("营销活动不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
if (!MarketingActivityStatus.DRAFT.name().equals(existing.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("仅草稿状态的活动可删除"));
|
||||||
|
}
|
||||||
|
return marketingActivityRepository.deleteById(id);
|
||||||
|
})
|
||||||
|
.doOnSuccess(v -> logger.info("营销活动删除成功 - id={}", id))
|
||||||
|
.doOnError(error -> logger.error("营销活动删除失败 - id={}, error: {}", id, error.getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<MarketingActivity> publish(Long id) {
|
||||||
|
return marketingActivityRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("营销活动不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
if (!MarketingActivityStatus.DRAFT.name().equals(existing.getStatus())
|
||||||
|
&& !MarketingActivityStatus.TERMINATED.name().equals(existing.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("当前状态不允许发布"));
|
||||||
|
}
|
||||||
|
return validateActivity(existing)
|
||||||
|
.flatMap(validated -> marketingActivityRepository.updateStatus(id, MarketingActivityStatus.ACTIVE.name())
|
||||||
|
.then(marketingActivityRepository.findById(id)));
|
||||||
|
})
|
||||||
|
.doOnSuccess(a -> logger.info("营销活动发布成功 - id={}", id))
|
||||||
|
.doOnError(error -> logger.error("营销活动发布失败 - id={}, error: {}", id, error.getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<MarketingActivity> terminate(Long id) {
|
||||||
|
return marketingActivityRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("营销活动不存在")))
|
||||||
|
.flatMap(existing -> {
|
||||||
|
if (!MarketingActivityStatus.ACTIVE.name().equals(existing.getStatus())) {
|
||||||
|
return Mono.error(new RuntimeException("仅进行中的活动可终止"));
|
||||||
|
}
|
||||||
|
return marketingActivityRepository.updateStatus(id, MarketingActivityStatus.TERMINATED.name())
|
||||||
|
.then(marketingActivityRepository.findById(id));
|
||||||
|
})
|
||||||
|
.doOnSuccess(a -> logger.info("营销活动已终止 - id={}", id))
|
||||||
|
.doOnError(error -> logger.error("营销活动终止失败 - id={}, error: {}", id, error.getMessage()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mono<MarketingActivityStatistics> getStatistics(Long id) {
|
||||||
|
return marketingActivityRepository.findById(id)
|
||||||
|
.switchIfEmpty(Mono.error(new RuntimeException("营销活动不存在")))
|
||||||
|
.map(activity -> {
|
||||||
|
MarketingActivityStatistics stats = new MarketingActivityStatistics();
|
||||||
|
stats.setActivityId(id);
|
||||||
|
stats.setActivityName(activity.getName());
|
||||||
|
stats.setParticipantCount(activity.getParticipantCount() != null ? activity.getParticipantCount() : 0);
|
||||||
|
stats.setOrderCount(activity.getOrderCount() != null ? activity.getOrderCount() : 0);
|
||||||
|
stats.setTotalDiscountAmount(activity.getTotalDiscountAmount() != null
|
||||||
|
? activity.getTotalDiscountAmount() : BigDecimal.ZERO);
|
||||||
|
stats.setStatus(activity.getStatus());
|
||||||
|
return stats;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private Mono<MarketingActivity> validateActivity(MarketingActivity activity) {
|
||||||
|
if (activity.getName() == null || activity.getName().isBlank()) {
|
||||||
|
return Mono.error(new RuntimeException("活动名称不能为空"));
|
||||||
|
}
|
||||||
|
if (activity.getActivityType() == null || activity.getActivityType().isBlank()) {
|
||||||
|
return Mono.error(new RuntimeException("活动类型不能为空"));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
MarketingActivityType.valueOf(activity.getActivityType());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
return Mono.error(new RuntimeException("无效的活动类型"));
|
||||||
|
}
|
||||||
|
if (activity.getStartTime() == null || activity.getEndTime() == null) {
|
||||||
|
return Mono.error(new RuntimeException("活动开始和结束时间不能为空"));
|
||||||
|
}
|
||||||
|
if (activity.getEndTime().isBefore(activity.getStartTime())) {
|
||||||
|
return Mono.error(new RuntimeException("结束时间不能早于开始时间"));
|
||||||
|
}
|
||||||
|
return Mono.just(activity);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void applyDefaults(MarketingActivity activity) {
|
||||||
|
if (activity.getThresholdAmount() == null) {
|
||||||
|
activity.setThresholdAmount(BigDecimal.ZERO);
|
||||||
|
}
|
||||||
|
if (activity.getApplyScope() == null) {
|
||||||
|
activity.setApplyScope(ApplyScope.ALL.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
+102
@@ -0,0 +1,102 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.points.converter;
|
||||||
|
|
||||||
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import cn.novalon.gym.manage.coupon.points.domain.MemberPoints;
|
||||||
|
import cn.novalon.gym.manage.coupon.points.domain.PointsMallProduct;
|
||||||
|
import cn.novalon.gym.manage.coupon.points.domain.PointsRecord;
|
||||||
|
import cn.novalon.gym.manage.coupon.points.domain.PointsRule;
|
||||||
|
import cn.novalon.gym.manage.coupon.points.entity.MemberPointsEntity;
|
||||||
|
import cn.novalon.gym.manage.coupon.points.entity.PointsMallProductEntity;
|
||||||
|
import cn.novalon.gym.manage.coupon.points.entity.PointsRecordEntity;
|
||||||
|
import cn.novalon.gym.manage.coupon.points.entity.PointsRuleEntity;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
@Slf4j
|
||||||
|
public class PointsConverter {
|
||||||
|
|
||||||
|
public PointsRule toPointsRule(PointsRuleEntity entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
PointsRule domain = new PointsRule();
|
||||||
|
BeanUtil.copyProperties(entity, domain);
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointsRuleEntity toPointsRuleEntity(PointsRule domain) {
|
||||||
|
if (domain == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
PointsRuleEntity entity = new PointsRuleEntity();
|
||||||
|
BeanUtil.copyProperties(domain, entity);
|
||||||
|
if (domain.getId() != null) {
|
||||||
|
entity.markNotNew();
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointsMallProduct toPointsMallProduct(PointsMallProductEntity entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
PointsMallProduct domain = new PointsMallProduct();
|
||||||
|
BeanUtil.copyProperties(entity, domain);
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointsMallProductEntity toPointsMallProductEntity(PointsMallProduct domain) {
|
||||||
|
if (domain == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
PointsMallProductEntity entity = new PointsMallProductEntity();
|
||||||
|
BeanUtil.copyProperties(domain, entity);
|
||||||
|
if (domain.getId() != null) {
|
||||||
|
entity.markNotNew();
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MemberPoints toMemberPoints(MemberPointsEntity entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MemberPoints domain = new MemberPoints();
|
||||||
|
BeanUtil.copyProperties(entity, domain);
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public MemberPointsEntity toMemberPointsEntity(MemberPoints domain) {
|
||||||
|
if (domain == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
MemberPointsEntity entity = new MemberPointsEntity();
|
||||||
|
BeanUtil.copyProperties(domain, entity);
|
||||||
|
if (domain.getId() != null) {
|
||||||
|
entity.markNotNew();
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointsRecord toPointsRecord(PointsRecordEntity entity) {
|
||||||
|
if (entity == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
PointsRecord domain = new PointsRecord();
|
||||||
|
BeanUtil.copyProperties(entity, domain);
|
||||||
|
return domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
public PointsRecordEntity toPointsRecordEntity(PointsRecord domain) {
|
||||||
|
if (domain == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
PointsRecordEntity entity = new PointsRecordEntity();
|
||||||
|
BeanUtil.copyProperties(domain, entity);
|
||||||
|
if (domain.getId() != null) {
|
||||||
|
entity.markNotNew();
|
||||||
|
}
|
||||||
|
return entity;
|
||||||
|
}
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.points.dao;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.points.entity.MemberPointsEntity;
|
||||||
|
import org.springframework.data.r2dbc.repository.Modifying;
|
||||||
|
import org.springframework.data.r2dbc.repository.Query;
|
||||||
|
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface MemberPointsDao extends R2dbcRepository<MemberPointsEntity, Long> {
|
||||||
|
|
||||||
|
Mono<MemberPointsEntity> findByMemberIdAndDeletedAtIsNull(Long memberId);
|
||||||
|
|
||||||
|
Flux<MemberPointsEntity> findAllByDeletedAtIsNull();
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE member_points SET total_points = total_points + :points, available_points = available_points + :points, updated_at = :updatedAt WHERE member_id = :memberId AND deleted_at IS NULL")
|
||||||
|
Mono<Integer> addPoints(Long memberId, int points, LocalDateTime updatedAt);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE member_points SET available_points = available_points - :points, used_points = used_points + :points, updated_at = :updatedAt WHERE member_id = :memberId AND available_points >= :points AND deleted_at IS NULL")
|
||||||
|
Mono<Integer> deductPoints(Long memberId, int points, LocalDateTime updatedAt);
|
||||||
|
}
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.points.dao;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.points.entity.PointsMallProductEntity;
|
||||||
|
import org.springframework.data.r2dbc.repository.Modifying;
|
||||||
|
import org.springframework.data.r2dbc.repository.Query;
|
||||||
|
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface PointsMallProductDao extends R2dbcRepository<PointsMallProductEntity, Long> {
|
||||||
|
|
||||||
|
Mono<PointsMallProductEntity> findByIdIsAndDeletedAtIsNull(Long id);
|
||||||
|
|
||||||
|
Flux<PointsMallProductEntity> findAllByDeletedAtIsNull();
|
||||||
|
|
||||||
|
Flux<PointsMallProductEntity> findByProductNameContainingAndDeletedAtIsNull(String productName);
|
||||||
|
|
||||||
|
Flux<PointsMallProductEntity> findByStatusAndDeletedAtIsNull(String status);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE points_mall_product SET deleted_at = :deletedAt WHERE id = :id")
|
||||||
|
Mono<Integer> softDelete(Long id, LocalDateTime deletedAt);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE points_mall_product SET status = :status, updated_at = :updatedAt WHERE id = :id")
|
||||||
|
Mono<Integer> updateStatus(Long id, String status, LocalDateTime updatedAt);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE points_mall_product SET sold_count = sold_count + :count, stock = CASE WHEN stock = -1 THEN -1 ELSE stock - :count END, updated_at = :updatedAt WHERE id = :id AND (stock = -1 OR stock >= :count)")
|
||||||
|
Mono<Integer> decrementStockAndIncrementSold(Long id, int count, LocalDateTime updatedAt);
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.points.dao;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.points.entity.PointsRecordEntity;
|
||||||
|
import org.springframework.data.r2dbc.repository.Query;
|
||||||
|
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface PointsRecordDao extends R2dbcRepository<PointsRecordEntity, Long> {
|
||||||
|
|
||||||
|
Flux<PointsRecordEntity> findByMemberIdAndDeletedAtIsNullOrderByCreatedAtDesc(Long memberId);
|
||||||
|
|
||||||
|
@Query("SELECT COUNT(*) FROM points_record WHERE member_id = :memberId AND source = :source AND change_type = :changeType AND created_at >= :startOfDay AND deleted_at IS NULL")
|
||||||
|
Mono<Long> countTodayByMemberAndSource(Long memberId, String source, String changeType, LocalDateTime startOfDay);
|
||||||
|
|
||||||
|
@Query("SELECT COALESCE(SUM(points), 0) FROM points_record WHERE change_type = :changeType AND points > 0 AND deleted_at IS NULL")
|
||||||
|
Mono<Long> sumPositivePointsByChangeType(String changeType);
|
||||||
|
|
||||||
|
@Query("SELECT COALESCE(SUM(ABS(points)), 0) FROM points_record WHERE change_type IN ('SPEND', 'EXCHANGE') AND deleted_at IS NULL")
|
||||||
|
Mono<Long> sumSpentPoints();
|
||||||
|
|
||||||
|
Mono<Long> countByChangeTypeAndDeletedAtIsNull(String changeType);
|
||||||
|
}
|
||||||
+27
@@ -0,0 +1,27 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.points.dao;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.coupon.points.entity.PointsRuleEntity;
|
||||||
|
import org.springframework.data.r2dbc.repository.Modifying;
|
||||||
|
import org.springframework.data.r2dbc.repository.Query;
|
||||||
|
import org.springframework.data.r2dbc.repository.R2dbcRepository;
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
import reactor.core.publisher.Flux;
|
||||||
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Repository
|
||||||
|
public interface PointsRuleDao extends R2dbcRepository<PointsRuleEntity, Long> {
|
||||||
|
|
||||||
|
Mono<PointsRuleEntity> findByIdIsAndDeletedAtIsNull(Long id);
|
||||||
|
|
||||||
|
Flux<PointsRuleEntity> findAllByDeletedAtIsNull();
|
||||||
|
|
||||||
|
Flux<PointsRuleEntity> findByRuleTypeAndStatusAndDeletedAtIsNull(String ruleType, String status);
|
||||||
|
|
||||||
|
Mono<PointsRuleEntity> findFirstByRuleTypeAndStatusAndDeletedAtIsNull(String ruleType, String status);
|
||||||
|
|
||||||
|
@Modifying
|
||||||
|
@Query("UPDATE points_rule SET deleted_at = :deletedAt WHERE id = :id")
|
||||||
|
Mono<Integer> softDelete(Long id, LocalDateTime deletedAt);
|
||||||
|
}
|
||||||
+51
@@ -0,0 +1,51 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.points.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
@Schema(description = "积分获取请求")
|
||||||
|
public class EarnPointsRequest {
|
||||||
|
|
||||||
|
@Schema(description = "会员ID")
|
||||||
|
private Long memberId;
|
||||||
|
|
||||||
|
@Schema(description = "积分数量")
|
||||||
|
private Integer points;
|
||||||
|
|
||||||
|
@Schema(description = "来源")
|
||||||
|
private String source;
|
||||||
|
|
||||||
|
@Schema(description = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
public Long getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(Long memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPoints() {
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPoints(Integer points) {
|
||||||
|
this.points = points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSource(String source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemark() {
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemark(String remark) {
|
||||||
|
this.remark = remark;
|
||||||
|
}
|
||||||
|
}
|
||||||
+29
@@ -0,0 +1,29 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.points.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
@Schema(description = "积分兑换请求")
|
||||||
|
public class ExchangePointsRequest {
|
||||||
|
|
||||||
|
@Schema(description = "会员ID")
|
||||||
|
private Long memberId;
|
||||||
|
|
||||||
|
@Schema(description = "商品ID")
|
||||||
|
private Long productId;
|
||||||
|
|
||||||
|
public Long getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(Long memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getProductId() {
|
||||||
|
return productId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductId(Long productId) {
|
||||||
|
this.productId = productId;
|
||||||
|
}
|
||||||
|
}
|
||||||
+52
@@ -0,0 +1,52 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.points.domain;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
@Schema(description = "会员积分账户")
|
||||||
|
public class MemberPoints extends BaseDomain {
|
||||||
|
|
||||||
|
@Schema(description = "会员ID")
|
||||||
|
private Long memberId;
|
||||||
|
|
||||||
|
@Schema(description = "累计积分")
|
||||||
|
private Integer totalPoints;
|
||||||
|
|
||||||
|
@Schema(description = "可用积分")
|
||||||
|
private Integer availablePoints;
|
||||||
|
|
||||||
|
@Schema(description = "已使用积分")
|
||||||
|
private Integer usedPoints;
|
||||||
|
|
||||||
|
public Long getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(Long memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTotalPoints() {
|
||||||
|
return totalPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalPoints(Integer totalPoints) {
|
||||||
|
this.totalPoints = totalPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getAvailablePoints() {
|
||||||
|
return availablePoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAvailablePoints(Integer availablePoints) {
|
||||||
|
this.availablePoints = availablePoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getUsedPoints() {
|
||||||
|
return usedPoints;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUsedPoints(Integer usedPoints) {
|
||||||
|
this.usedPoints = usedPoints;
|
||||||
|
}
|
||||||
|
}
|
||||||
+107
@@ -0,0 +1,107 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.points.domain;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
@Schema(description = "积分商城商品")
|
||||||
|
public class PointsMallProduct extends BaseDomain {
|
||||||
|
|
||||||
|
@Schema(description = "商品名称")
|
||||||
|
private String productName;
|
||||||
|
|
||||||
|
@Schema(description = "商品描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "商品类型:COUPON/COURSE/GOODS/OTHER")
|
||||||
|
private String productType;
|
||||||
|
|
||||||
|
@Schema(description = "关联业务ID")
|
||||||
|
private Long relatedId;
|
||||||
|
|
||||||
|
@Schema(description = "兑换所需积分")
|
||||||
|
private Integer pointsCost;
|
||||||
|
|
||||||
|
@Schema(description = "库存,-1表示不限")
|
||||||
|
private Integer stock;
|
||||||
|
|
||||||
|
@Schema(description = "已兑换数量")
|
||||||
|
private Integer soldCount;
|
||||||
|
|
||||||
|
@Schema(description = "商品图片URL")
|
||||||
|
private String imageUrl;
|
||||||
|
|
||||||
|
@Schema(description = "状态:DRAFT/ACTIVE/OFFLINE")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
public String getProductName() {
|
||||||
|
return productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductName(String productName) {
|
||||||
|
this.productName = productName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getProductType() {
|
||||||
|
return productType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setProductType(String productType) {
|
||||||
|
this.productType = productType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getRelatedId() {
|
||||||
|
return relatedId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRelatedId(Long relatedId) {
|
||||||
|
this.relatedId = relatedId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPointsCost() {
|
||||||
|
return pointsCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPointsCost(Integer pointsCost) {
|
||||||
|
this.pointsCost = pointsCost;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getStock() {
|
||||||
|
return stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStock(Integer stock) {
|
||||||
|
this.stock = stock;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getSoldCount() {
|
||||||
|
return soldCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSoldCount(Integer soldCount) {
|
||||||
|
this.soldCount = soldCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getImageUrl() {
|
||||||
|
return imageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setImageUrl(String imageUrl) {
|
||||||
|
this.imageUrl = imageUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
+85
@@ -0,0 +1,85 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.points.domain;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
@Schema(description = "积分变动记录")
|
||||||
|
public class PointsRecord extends BaseDomain {
|
||||||
|
|
||||||
|
@Schema(description = "会员ID")
|
||||||
|
private Long memberId;
|
||||||
|
|
||||||
|
@Schema(description = "变动类型:EARN/SPEND/EXCHANGE")
|
||||||
|
private String changeType;
|
||||||
|
|
||||||
|
@Schema(description = "变动积分(正数为增加,负数为减少)")
|
||||||
|
private Integer points;
|
||||||
|
|
||||||
|
@Schema(description = "变动后余额")
|
||||||
|
private Integer balanceAfter;
|
||||||
|
|
||||||
|
@Schema(description = "来源")
|
||||||
|
private String source;
|
||||||
|
|
||||||
|
@Schema(description = "关联业务ID")
|
||||||
|
private Long relatedId;
|
||||||
|
|
||||||
|
@Schema(description = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
public Long getMemberId() {
|
||||||
|
return memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMemberId(Long memberId) {
|
||||||
|
this.memberId = memberId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getChangeType() {
|
||||||
|
return changeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setChangeType(String changeType) {
|
||||||
|
this.changeType = changeType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPoints() {
|
||||||
|
return points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPoints(Integer points) {
|
||||||
|
this.points = points;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getBalanceAfter() {
|
||||||
|
return balanceAfter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBalanceAfter(Integer balanceAfter) {
|
||||||
|
this.balanceAfter = balanceAfter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSource() {
|
||||||
|
return source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSource(String source) {
|
||||||
|
this.source = source;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getRelatedId() {
|
||||||
|
return relatedId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRelatedId(Long relatedId) {
|
||||||
|
this.relatedId = relatedId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRemark() {
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRemark(String remark) {
|
||||||
|
this.remark = remark;
|
||||||
|
}
|
||||||
|
}
|
||||||
+76
@@ -0,0 +1,76 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.points.domain;
|
||||||
|
|
||||||
|
import cn.novalon.gym.manage.sys.core.domain.BaseDomain;
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Schema(description = "积分规则")
|
||||||
|
public class PointsRule extends BaseDomain {
|
||||||
|
|
||||||
|
@Schema(description = "规则名称")
|
||||||
|
private String ruleName;
|
||||||
|
|
||||||
|
@Schema(description = "规则类型:SIGN_IN/CONSUME/REFERRAL/MANUAL")
|
||||||
|
private String ruleType;
|
||||||
|
|
||||||
|
@Schema(description = "积分值")
|
||||||
|
private Integer pointsValue;
|
||||||
|
|
||||||
|
@Schema(description = "消费积分比例")
|
||||||
|
private BigDecimal ratio;
|
||||||
|
|
||||||
|
@Schema(description = "规则描述")
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
@Schema(description = "状态:ACTIVE/INACTIVE")
|
||||||
|
private String status;
|
||||||
|
|
||||||
|
public String getRuleName() {
|
||||||
|
return ruleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRuleName(String ruleName) {
|
||||||
|
this.ruleName = ruleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRuleType() {
|
||||||
|
return ruleType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRuleType(String ruleType) {
|
||||||
|
this.ruleType = ruleType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getPointsValue() {
|
||||||
|
return pointsValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPointsValue(Integer pointsValue) {
|
||||||
|
this.pointsValue = pointsValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getRatio() {
|
||||||
|
return ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRatio(BigDecimal ratio) {
|
||||||
|
this.ratio = ratio;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDescription() {
|
||||||
|
return description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDescription(String description) {
|
||||||
|
this.description = description;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
this.status = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
+95
@@ -0,0 +1,95 @@
|
|||||||
|
package cn.novalon.gym.manage.coupon.points.domain;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
|
||||||
|
@Schema(description = "积分商城统计数据")
|
||||||
|
public class PointsStatistics {
|
||||||
|
|
||||||
|
@Schema(description = "积分规则总数")
|
||||||
|
private long totalRules;
|
||||||
|
|
||||||
|
@Schema(description = "启用规则数")
|
||||||
|
private long activeRules;
|
||||||
|
|
||||||
|
@Schema(description = "商品总数")
|
||||||
|
private long totalProducts;
|
||||||
|
|
||||||
|
@Schema(description = "上架商品数")
|
||||||
|
private long activeProducts;
|
||||||
|
|
||||||
|
@Schema(description = "会员积分账户总数")
|
||||||
|
private long totalMemberAccounts;
|
||||||
|
|
||||||
|
@Schema(description = "累计发放积分")
|
||||||
|
private long totalPointsIssued;
|
||||||
|
|
||||||
|
@Schema(description = "累计消耗积分")
|
||||||
|
private long totalPointsUsed;
|
||||||
|
|
||||||
|
@Schema(description = "累计兑换次数")
|
||||||
|
private long totalExchanges;
|
||||||
|
|
||||||
|
public long getTotalRules() {
|
||||||
|
return totalRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalRules(long totalRules) {
|
||||||
|
this.totalRules = totalRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getActiveRules() {
|
||||||
|
return activeRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActiveRules(long activeRules) {
|
||||||
|
this.activeRules = activeRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalProducts() {
|
||||||
|
return totalProducts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalProducts(long totalProducts) {
|
||||||
|
this.totalProducts = totalProducts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getActiveProducts() {
|
||||||
|
return activeProducts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActiveProducts(long activeProducts) {
|
||||||
|
this.activeProducts = activeProducts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalMemberAccounts() {
|
||||||
|
return totalMemberAccounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalMemberAccounts(long totalMemberAccounts) {
|
||||||
|
this.totalMemberAccounts = totalMemberAccounts;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalPointsIssued() {
|
||||||
|
return totalPointsIssued;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalPointsIssued(long totalPointsIssued) {
|
||||||
|
this.totalPointsIssued = totalPointsIssued;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalPointsUsed() {
|
||||||
|
return totalPointsUsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalPointsUsed(long totalPointsUsed) {
|
||||||
|
this.totalPointsUsed = totalPointsUsed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getTotalExchanges() {
|
||||||
|
return totalExchanges;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotalExchanges(long totalExchanges) {
|
||||||
|
this.totalExchanges = totalExchanges;
|
||||||
|
}
|
||||||
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user