feat: 3d模型
@@ -45,7 +45,16 @@
|
||||
"Bash(ren:*)",
|
||||
"Bash(move FireAlarmEventMessage.java DeviceStateEventMessage.java)",
|
||||
"Bash(del TourismDevices.tsx TourismDevices.less DeviceDetail.tsx DeviceDetail.less)",
|
||||
"Bash(find:*)"
|
||||
"Bash(find:*)",
|
||||
"Bash(cat:*)",
|
||||
"Bash(cd:*)",
|
||||
"Bash(xcopy:*)",
|
||||
"Bash(robocopy:*)",
|
||||
"Bash(powershell:*)",
|
||||
"Bash(curl:*)",
|
||||
"Bash(del \"F:\\project\\go-fly-platform-services\\zlt-business\\device-center\\src\\main\\java\\com\\central\\device\\service\\MinioModelUploadService.java\")",
|
||||
"Bash(cmd /c \"dir /s /b \"\"D:\\模型\\新建模型重建-2025-09-29 20_24_08 (UTC+08)\\model\\download\"\"\")",
|
||||
"Bash(cmd /c \"dir \"\"D:\\模型\\新建模型重建-2025-09-29 20_24_08 (UTC+08)\\model\\download\"\"\")"
|
||||
],
|
||||
"deny": [],
|
||||
"ask": []
|
||||
|
||||
@@ -0,0 +1,772 @@
|
||||
# 发明专利申请书
|
||||
|
||||
## 一、发明名称
|
||||
|
||||
**一种基于实体二维码的酒店优惠券发放与自动核销系统及方法**
|
||||
|
||||
---
|
||||
|
||||
## 二、技术领域
|
||||
|
||||
本发明涉及电子商务与旅游信息化技术领域,尤其涉及一种基于实体二维码的酒店优惠券发放与自动核销系统及方法。
|
||||
|
||||
---
|
||||
|
||||
## 三、背景技术
|
||||
|
||||
随着旅游行业的快速发展,景区与酒店的合作营销成为重要的获客渠道。酒店作为游客集中的场所,具有天然的流量优势,如何有效地将酒店住客引流至合作景区成为行业关注的重点。
|
||||
|
||||
然而,现有的酒店与景区合作营销方案存在以下技术问题:
|
||||
|
||||
1. **优惠券发放效率低**:传统纸质优惠券需要人工发放,容易遗失、伪造,且无法精准追踪发放和使用情况。
|
||||
|
||||
2. **优惠券核销流程繁琐**:用户使用优惠券时需要手动出示、人工核验,影响用户体验,增加景区运营成本。
|
||||
|
||||
3. **缺乏一码一用机制**:传统优惠券容易被复制传播,难以控制实际使用量,造成营销成本失控。
|
||||
|
||||
4. **数据追踪困难**:无法准确统计优惠券的发放、绑定、使用情况,难以评估合作效果和优化营销策略。
|
||||
|
||||
5. **系统对接复杂**:优惠券系统与订单系统分离,需要人工核对,容易出现核销遗漏或重复核销问题。
|
||||
|
||||
6. **有效期管理粗放**:无法支持灵活的有效期策略(如固定时间或绑定后N天有效),用户体验欠佳。
|
||||
|
||||
因此,亟需一种能够实现优惠券自动化发放、一码一用、自动核销的技术方案。
|
||||
|
||||
---
|
||||
|
||||
## 四、发明内容
|
||||
|
||||
### 4.1 发明目的
|
||||
|
||||
本发明的目的在于提供一种基于实体二维码的酒店优惠券发放与自动核销系统及方法,解决现有技术中优惠券发放效率低、核销流程繁琐、缺乏一码一用机制、数据追踪困难等技术问题。
|
||||
|
||||
### 4.2 技术方案
|
||||
|
||||
为实现上述目的,本发明提供以下技术方案:
|
||||
|
||||
#### 4.2.1 一种基于实体二维码的酒店优惠券发放与自动核销系统
|
||||
|
||||
所述系统包括:
|
||||
|
||||
**合作酒店管理模块**,用于管理与景区建立合作关系的酒店信息,包括:
|
||||
- 酒店基本信息(名称、地址、联系人等);
|
||||
- 合作有效期管理;
|
||||
- 酒店状态管理(启用/禁用);
|
||||
|
||||
**优惠券批量生成模块**,用于为指定酒店批量生成带有唯一标识码的优惠券,包括:
|
||||
- 生成唯一的批次号标识同一批次优惠券;
|
||||
- 为每张优惠券生成全局唯一的优惠券码;
|
||||
- 根据优惠券码生成对应的二维码图片;
|
||||
- 支持配置优惠券类型(免费体验券、折扣券、满减券);
|
||||
- 支持配置适用范围(指定景区、指定设备);
|
||||
- 支持配置有效期策略(固定时间或绑定后N天);
|
||||
|
||||
**二维码图片管理模块**,用于管理优惠券二维码图片,包括:
|
||||
- 将二维码图片上传至云存储服务;
|
||||
- 支持按批次或按条件批量下载二维码图片;
|
||||
- 将二维码打包为压缩文件供酒店打印制作实体二维码;
|
||||
|
||||
**用户扫码绑定模块**,用于处理用户扫描实体二维码后的绑定请求,包括:
|
||||
- 解析二维码获取优惠券码;
|
||||
- 校验优惠券状态(是否存在、是否已绑定、是否已过期、是否已作废);
|
||||
- 采用分布式锁机制确保一码只能被一个用户绑定;
|
||||
- 创建优惠券与用户的绑定关系;
|
||||
- 根据有效期策略计算优惠券的实际生效时间;
|
||||
- 更新优惠券状态为已绑定;
|
||||
|
||||
**用户优惠券查询模块**,用于为用户提供已绑定优惠券的查询功能,包括:
|
||||
- 展示用户所有已绑定的优惠券列表;
|
||||
- 支持按状态筛选(可用、已使用、已过期);
|
||||
- 展示优惠券详情和适用范围;
|
||||
|
||||
**可用优惠券检测模块**,用于在用户下单前检测是否有可用优惠券,包括:
|
||||
- 根据当前景区和设备信息查询用户的可用优惠券;
|
||||
- 校验优惠券是否在有效期内;
|
||||
- 校验优惠券是否适用于当前景区和设备;
|
||||
- 返回可用优惠券信息供下单使用;
|
||||
|
||||
**自动核销模块**,用于在订单创建时自动完成优惠券核销,包括:
|
||||
- 在订单创建流程中嵌入优惠券核销逻辑;
|
||||
- 根据优惠券类型计算优惠金额;
|
||||
- 创建零金额订单(免费体验券)或优惠后金额订单;
|
||||
- 更新优惠券状态和绑定记录状态为已使用;
|
||||
- 创建详细的核销记录用于数据追踪;
|
||||
|
||||
**订单类型标记模块**,用于在订单中标记优惠券使用信息,包括:
|
||||
- 订单类型标记(普通订单/优惠券订单);
|
||||
- 关联的优惠券标识;
|
||||
- 原始金额、优惠金额、实付金额;
|
||||
|
||||
**过期处理模块**,用于定时处理过期的优惠券,包括:
|
||||
- 定时扫描超过有效期的优惠券;
|
||||
- 更新未使用的过期优惠券状态;
|
||||
- 更新过期的绑定记录状态;
|
||||
|
||||
**数据统计模块**,用于统计优惠券的发放和使用情况,包括:
|
||||
- 按酒店统计优惠券发放数量;
|
||||
- 统计已绑定、已使用、已过期数量;
|
||||
- 支持按批次、按时间维度统计;
|
||||
|
||||
#### 4.2.2 一种基于实体二维码的酒店优惠券发放与自动核销方法
|
||||
|
||||
所述方法包括以下步骤:
|
||||
|
||||
**步骤S1:酒店合作关系建立**
|
||||
- S1.1:在系统中录入合作酒店基本信息;
|
||||
- S1.2:设置合作有效期;
|
||||
- S1.3:生成酒店唯一编码;
|
||||
|
||||
**步骤S2:优惠券批量生成**
|
||||
- S2.1:选择目标酒店,配置优惠券参数;
|
||||
- S2.2:系统生成批次号,格式为:B + 年月日 + 4位序号;
|
||||
- S2.3:循环生成指定数量的优惠券码,格式为:HC + 批次号 + 6位序号;
|
||||
- S2.4:为每个优惠券码生成二维码图片,二维码内容为小程序页面路径加优惠券码参数;
|
||||
- S2.5:将二维码图片上传至云存储;
|
||||
- S2.6:批量写入优惠券记录至数据库,初始状态为未绑定;
|
||||
|
||||
**步骤S3:实体二维码制作与投放**
|
||||
- S3.1:管理人员按批次下载二维码图片压缩包;
|
||||
- S3.2:将二维码图片打印制作成实体二维码卡片或海报;
|
||||
- S3.3:将实体二维码投放至合作酒店指定位置;
|
||||
|
||||
**步骤S4:用户扫码绑定**
|
||||
- S4.1:用户在酒店扫描实体二维码;
|
||||
- S4.2:小程序打开优惠券绑定页面,获取优惠券码参数;
|
||||
- S4.3:调用绑定接口,系统获取分布式锁防止并发绑定;
|
||||
- S4.4:校验优惠券状态,确保未被绑定、未过期、未作废;
|
||||
- S4.5:根据有效期策略计算优惠券的实际生效开始时间和结束时间;
|
||||
- S4.6:创建优惠券与用户的绑定记录;
|
||||
- S4.7:更新优惠券状态为已绑定;
|
||||
- S4.8:释放分布式锁,返回绑定成功信息;
|
||||
|
||||
**步骤S5:设备端下单检测**
|
||||
- S5.1:用户在景区设备端准备下单;
|
||||
- S5.2:系统调用可用优惠券检测接口;
|
||||
- S5.3:查询用户已绑定且状态为有效的优惠券;
|
||||
- S5.4:过滤出适用于当前景区和设备的优惠券;
|
||||
- S5.5:过滤出在有效期内的优惠券;
|
||||
- S5.6:若存在可用优惠券,前端展示免费体验或优惠信息;
|
||||
|
||||
**步骤S6:订单创建与自动核销**
|
||||
- S6.1:用户确认使用优惠券下单;
|
||||
- S6.2:创建订单,设置订单类型为优惠券订单;
|
||||
- S6.3:根据优惠券类型计算优惠金额:
|
||||
- 免费体验券:优惠金额等于订单原始金额,实付金额为0;
|
||||
- 折扣券:优惠金额等于原始金额乘以折扣率,实付金额为原始金额减优惠金额;
|
||||
- 满减券:满足最低消费条件时,优惠金额等于满减金额;
|
||||
- S6.4:在订单中记录优惠券标识和优惠金额;
|
||||
- S6.5:调用核销接口完成优惠券核销;
|
||||
- S6.6:更新优惠券状态为已使用;
|
||||
- S6.7:更新绑定记录状态为已使用;
|
||||
- S6.8:创建核销记录,记录核销详情;
|
||||
- S6.9:触发设备执行任务;
|
||||
|
||||
**步骤S7:过期优惠券处理**
|
||||
- S7.1:定时任务每日扫描所有优惠券;
|
||||
- S7.2:将超过有效期且状态仍为未绑定的优惠券状态更新为已过期;
|
||||
- S7.3:将超过有效期且状态仍为已绑定的绑定记录状态更新为已过期;
|
||||
|
||||
### 4.3 有益效果
|
||||
|
||||
本发明与现有技术相比,具有以下有益效果:
|
||||
|
||||
1. **一码一用防滥用**:每个优惠券码全局唯一,通过分布式锁确保同一时刻只有一个用户能成功绑定,有效防止优惠券被复制滥用。
|
||||
|
||||
2. **自动核销提效率**:优惠券核销与订单创建流程无缝集成,用户下单时自动完成核销,无需人工核验,提升用户体验和运营效率。
|
||||
|
||||
3. **实体二维码易投放**:将优惠券二维码制作成实体卡片或海报投放至酒店,无需酒店培训人员发放,降低合作门槛。
|
||||
|
||||
4. **灵活的有效期策略**:支持固定时间有效期和绑定后N天有效期两种策略,满足不同营销场景需求。
|
||||
|
||||
5. **精准的适用范围控制**:可配置优惠券仅适用于指定景区或指定设备,实现精细化营销。
|
||||
|
||||
6. **完整的数据追踪链路**:从发放、绑定、使用到过期,全链路数据可追溯,便于评估营销效果和优化策略。
|
||||
|
||||
7. **多类型优惠券支持**:支持免费体验券、折扣券、满减券等多种类型,可根据营销目标灵活配置。
|
||||
|
||||
8. **批量操作高效率**:支持批量生成优惠券、批量下载二维码,满足大规模投放需求。
|
||||
|
||||
---
|
||||
|
||||
## 五、附图说明
|
||||
|
||||
### 图1:系统整体架构图
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ 前端应用层 │
|
||||
├────────────────┬────────────────┬────────────────────────────────────┤
|
||||
│ 管理后台 │ 用户小程序 │ 设备端 │
|
||||
│ (优惠券管理) │ (扫码绑定) │ (自动核销) │
|
||||
└───────┬────────┴───────┬────────┴───────────────┬────────────────────┘
|
||||
│ │ │
|
||||
▼ ▼ ▼
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ 业务服务层 │
|
||||
├─────────────────────────────────────────────────────────────────────┤
|
||||
│ 合作酒店 优惠券生成 扫码绑定 可用检测 自动核销 过期处理 │
|
||||
│ 管理 模块 模块 模块 模块 模块 │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
│ │ │
|
||||
▼ ▼ ▼
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ 数据存储层 │
|
||||
├─────────────────────────────────────────────────────────────────────┤
|
||||
│ 合作酒店表 优惠券表 绑定记录表 核销记录表 订单表 │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ 基础设施层 │
|
||||
├─────────────────────────────────────────────────────────────────────┤
|
||||
│ 云存储(二维码图片) │ 分布式锁(Redis) │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 图2:优惠券生命周期状态图
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ 优惠券状态流转 │
|
||||
├─────────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ ┌───────────┐ │
|
||||
│ │ 生成优惠券 │ │
|
||||
│ └─────┬─────┘ │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ ┌───────────┐ │
|
||||
│ ┌─────────│ 未绑定(0) │─────────┐ │
|
||||
│ │ └─────┬─────┘ │ │
|
||||
│ │ │ │ │
|
||||
│ ▼ ▼ ▼ │
|
||||
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
|
||||
│ │ 已作废(4) │ │ 已绑定(1) │ │ 已过期(3) │ │
|
||||
│ └───────────┘ └─────┬─────┘ └───────────┘ │
|
||||
│ │ │
|
||||
│ ┌─────────┼─────────┐ │
|
||||
│ │ │ │ │
|
||||
│ ▼ ▼ ▼ │
|
||||
│ ┌───────────┐ ┌───────────┐ │
|
||||
│ │ 已过期(3) │ │ 已使用(2) │ │
|
||||
│ └───────────┘ └───────────┘ │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 图3:核心业务流程图
|
||||
|
||||
```
|
||||
┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐
|
||||
│ 创建合作酒店 │ ──> │ 生成优惠券码 │ ──> │ 用户扫码绑定 │ ──> │ 设备端核销 │
|
||||
└─────────────┘ └─────────────┘ └─────────────┘ └─────────────┘
|
||||
│ │ │ │
|
||||
▼ ▼ ▼ ▼
|
||||
酒店基本信息 批量生成二维码 一码一用 订单金额为0
|
||||
合作有效期 可批量下载 绑定用户ID 区分订单类型
|
||||
```
|
||||
|
||||
### 图4:用户扫码绑定流程图
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ 用户扫码绑定流程 │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ 1. 用户在酒店扫描实体二维码 │
|
||||
│ ↓ │
|
||||
│ 2. 小程序打开绑定页面,获取优惠券码 │
|
||||
│ ↓ │
|
||||
│ 3. 调用绑定接口,获取分布式锁 │
|
||||
│ ↓ │
|
||||
│ 4. 后端校验: │
|
||||
│ ├─ 优惠券是否存在 │
|
||||
│ ├─ 优惠券是否已被绑定 │
|
||||
│ ├─ 优惠券是否已过期 │
|
||||
│ └─ 优惠券是否已作废 │
|
||||
│ ↓ │
|
||||
│ 5. 创建绑定记录 │
|
||||
│ - 计算生效时间(固定时间或绑定后N天) │
|
||||
│ ↓ │
|
||||
│ 6. 更新优惠券状态为"已绑定" │
|
||||
│ ↓ │
|
||||
│ 7. 释放分布式锁,返回绑定成功信息 │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 图5:自动核销流程图
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ 优惠券核销流程 │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ 1. 用户在设备端扫码准备下单 │
|
||||
│ ↓ │
|
||||
│ 2. 前端调用检查可用优惠券接口 │
|
||||
│ ↓ │
|
||||
│ 3. 后端查询用户绑定的有效优惠券 │
|
||||
│ - 状态为有效 │
|
||||
│ - 在有效期内 │
|
||||
│ - 适用于当前景区/设备 │
|
||||
│ ↓ │
|
||||
│ 4. 如有可用优惠券,前端展示"免费体验" │
|
||||
│ ↓ │
|
||||
│ 5. 用户确认下单 │
|
||||
│ ↓ │
|
||||
│ 6. 创建订单 │
|
||||
│ - order_type = 2(优惠券订单) │
|
||||
│ - pay_type = 2(优惠券支付) │
|
||||
│ - order_amount = 0 │
|
||||
│ - coupon_id = 优惠券ID │
|
||||
│ ↓ │
|
||||
│ 7. 调用优惠券核销接口 │
|
||||
│ ↓ │
|
||||
│ 8. 更新优惠券状态和绑定记录状态为"已使用" │
|
||||
│ ↓ │
|
||||
│ 9. 创建核销记录 │
|
||||
│ ↓ │
|
||||
│ 10. 触发设备执行任务 │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 图6:数据表关系图
|
||||
|
||||
```
|
||||
┌──────────────────┐ ┌──────────────────┐ ┌──────────────────┐
|
||||
│ partner_hotel │ │ hotel_coupon │ │ coupon_binding │
|
||||
│ (合作酒店表) │ 1───n │ (优惠券表) │ 1───1 │ (绑定记录表) │
|
||||
├──────────────────┤ ├──────────────────┤ ├──────────────────┤
|
||||
│ id (PK) │ │ id (PK) │ │ id (PK) │
|
||||
│ hotel_code (UQ) │◄──────│ hotel_id (FK) │◄──────│ coupon_id (FK) │
|
||||
│ hotel_name │ │ coupon_code (UQ) │ │ coupon_code │
|
||||
│ contact_name │ │ batch_no │ │ user_id │
|
||||
│ cooperation_ │ │ coupon_type │ │ bind_time │
|
||||
│ start_date │ │ valid_start_time │ │ effective_ │
|
||||
│ cooperation_ │ │ valid_end_time │ │ start_time │
|
||||
│ end_date │ │ status │ │ effective_ │
|
||||
│ status │ │ qrcode_url │ │ end_time │
|
||||
│ ... │ │ ... │ │ status │
|
||||
└──────────────────┘ └──────────────────┘ └──────────────────┘
|
||||
│ │
|
||||
│ │
|
||||
▼ ▼
|
||||
┌──────────────────┐ ┌──────────────────┐
|
||||
│ coupon_usage │ │ orders │
|
||||
│ (核销记录表) │ │ (订单表) │
|
||||
├──────────────────┤ ├──────────────────┤
|
||||
│ id (PK) │ │ id (PK) │
|
||||
│ coupon_id │ │ order_no (UQ) │
|
||||
│ binding_id │ │ order_type │
|
||||
│ user_id │ │ coupon_id │
|
||||
│ order_id │───────│ coupon_code │
|
||||
│ order_no │ │ original_amount │
|
||||
│ original_amount │ │ discount_amount │
|
||||
│ discount_amount │ │ order_amount │
|
||||
│ actual_amount │ │ ... │
|
||||
│ usage_time │ └──────────────────┘
|
||||
│ ... │
|
||||
└──────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 六、具体实施方式
|
||||
|
||||
### 6.1 实施例一:优惠券批量生成
|
||||
|
||||
本实施例描述为合作酒店批量生成优惠券的过程:
|
||||
|
||||
**步骤1**:管理员在后台选择合作酒店"XX国际酒店"(ID=1),配置优惠券参数:
|
||||
- 优惠券名称:酒店住客免费体验券
|
||||
- 优惠券类型:免费体验券
|
||||
- 生成数量:1000张
|
||||
- 有效期类型:固定时间
|
||||
- 有效期:2024-11-25 至 2025-11-25
|
||||
- 适用景区:景区A、景区B
|
||||
|
||||
**步骤2**:系统生成批次号:
|
||||
```
|
||||
批次号 = "B" + "20241125" + "0001" = "B202411250001"
|
||||
```
|
||||
|
||||
**步骤3**:循环生成1000个优惠券码:
|
||||
```
|
||||
优惠券码1 = "HC" + "202411250001" + "000001" = "HC202411250001000001"
|
||||
优惠券码2 = "HC" + "202411250001" + "000002" = "HC202411250001000002"
|
||||
...
|
||||
优惠券码1000 = "HC" + "202411250001" + "001000" = "HC202411250001001000"
|
||||
```
|
||||
|
||||
**步骤4**:为每个优惠券码生成二维码,二维码内容:
|
||||
```
|
||||
pages/coupon/bind?code=HC202411250001000001
|
||||
```
|
||||
|
||||
**步骤5**:将二维码图片上传至云存储,保存访问URL。
|
||||
|
||||
**步骤6**:批量插入优惠券记录到数据库:
|
||||
```
|
||||
{
|
||||
coupon_code: "HC202411250001000001",
|
||||
hotel_id: 1,
|
||||
batch_no: "B202411250001",
|
||||
coupon_name: "酒店住客免费体验券",
|
||||
coupon_type: 1,
|
||||
valid_start_time: "2024-11-25 00:00:00",
|
||||
valid_end_time: "2025-11-25 23:59:59",
|
||||
status: 0, // 未绑定
|
||||
applicable_tourism_ids: "1,2",
|
||||
qrcode_url: "https://oss.xxx.com/coupon/HC202411250001000001.png"
|
||||
}
|
||||
```
|
||||
|
||||
### 6.2 实施例二:用户扫码绑定
|
||||
|
||||
本实施例描述用户在酒店扫描实体二维码绑定优惠券的过程:
|
||||
|
||||
**前置条件**:酒店已投放优惠券二维码海报,用户已登录小程序。
|
||||
|
||||
**步骤1**:用户张三(user_id=10001)在酒店前台扫描二维码海报。
|
||||
|
||||
**步骤2**:小程序解析二维码获取页面路径:
|
||||
```
|
||||
pages/coupon/bind?code=HC202411250001000001
|
||||
```
|
||||
|
||||
**步骤3**:小程序打开绑定页面,提取优惠券码,调用绑定接口:
|
||||
```
|
||||
POST /coupon/user/bind
|
||||
{
|
||||
"couponCode": "HC202411250001000001"
|
||||
}
|
||||
```
|
||||
|
||||
**步骤4**:后端获取分布式锁,锁键值:
|
||||
```
|
||||
coupon:bind:HC202411250001000001
|
||||
```
|
||||
|
||||
**步骤5**:后端查询优惠券信息并校验:
|
||||
- 优惠券存在 ✓
|
||||
- 状态为未绑定(0) ✓
|
||||
- 在有效期内 ✓
|
||||
- 未被作废 ✓
|
||||
|
||||
**步骤6**:创建绑定记录:
|
||||
```
|
||||
{
|
||||
coupon_id: 1,
|
||||
coupon_code: "HC202411250001000001",
|
||||
user_id: 10001,
|
||||
user_openid: "oXXXXX",
|
||||
bind_time: "2024-11-26 10:30:00",
|
||||
bind_source: 1, // 扫码绑定
|
||||
effective_start_time: "2024-11-25 00:00:00",
|
||||
effective_end_time: "2025-11-25 23:59:59",
|
||||
status: 1 // 有效
|
||||
}
|
||||
```
|
||||
|
||||
**步骤7**:更新优惠券状态为已绑定:
|
||||
```
|
||||
UPDATE hotel_coupon SET status = 1 WHERE id = 1
|
||||
```
|
||||
|
||||
**步骤8**:释放分布式锁,返回绑定成功:
|
||||
```
|
||||
{
|
||||
"code": 0,
|
||||
"msg": "绑定成功",
|
||||
"data": {
|
||||
"couponName": "酒店住客免费体验券",
|
||||
"effectiveEndTime": "2025-11-25 23:59:59",
|
||||
"applicableTourisms": ["景区A", "景区B"]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 6.3 实施例三:设备端自动核销
|
||||
|
||||
本实施例描述用户在景区设备端使用优惠券下单的自动核销过程:
|
||||
|
||||
**前置条件**:用户张三已绑定优惠券,现在景区A的设备DEVICE001前准备下单。
|
||||
|
||||
**步骤1**:用户扫描设备二维码进入下单页面。
|
||||
|
||||
**步骤2**:前端调用可用优惠券检测接口:
|
||||
```
|
||||
GET /coupon/user/check-available?tourismId=1&deviceSn=DEVICE001
|
||||
```
|
||||
|
||||
**步骤3**:后端查询用户可用优惠券:
|
||||
```sql
|
||||
SELECT cb.*, hc.* FROM coupon_binding cb
|
||||
JOIN hotel_coupon hc ON cb.coupon_id = hc.id
|
||||
WHERE cb.user_id = 10001
|
||||
AND cb.status = 1
|
||||
AND cb.effective_end_time > NOW()
|
||||
AND (hc.applicable_tourism_ids IS NULL
|
||||
OR FIND_IN_SET('1', hc.applicable_tourism_ids))
|
||||
```
|
||||
|
||||
**步骤4**:返回可用优惠券信息:
|
||||
```
|
||||
{
|
||||
"hasCoupon": true,
|
||||
"coupon": {
|
||||
"couponId": 1,
|
||||
"couponName": "酒店住客免费体验券",
|
||||
"couponType": 1,
|
||||
"discountValue": 0
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
**步骤5**:前端展示"您有可用的免费体验券",用户点击确认使用。
|
||||
|
||||
**步骤6**:创建订单,设置订单类型为优惠券订单:
|
||||
```
|
||||
{
|
||||
order_no: "ORD202411260001",
|
||||
order_type: 2, // 优惠券订单
|
||||
pay_type: 2, // 优惠券支付
|
||||
coupon_id: 1,
|
||||
coupon_code: "HC202411250001000001",
|
||||
original_amount: 99.00,
|
||||
discount_amount: 99.00,
|
||||
order_amount: 0.00, // 实付金额为0
|
||||
order_status: 2 // 已支付(无需支付)
|
||||
}
|
||||
```
|
||||
|
||||
**步骤7**:调用优惠券核销接口:
|
||||
```
|
||||
POST /coupon/internal/use
|
||||
{
|
||||
"userId": 10001,
|
||||
"couponId": 1,
|
||||
"orderId": 1,
|
||||
"orderNo": "ORD202411260001",
|
||||
"tourismId": 1,
|
||||
"tourismName": "景区A",
|
||||
"deviceSn": "DEVICE001",
|
||||
"originalAmount": 99.00
|
||||
}
|
||||
```
|
||||
|
||||
**步骤8**:更新优惠券和绑定记录状态为已使用:
|
||||
```sql
|
||||
UPDATE hotel_coupon SET status = 2 WHERE id = 1;
|
||||
UPDATE coupon_binding SET status = 2 WHERE coupon_id = 1;
|
||||
```
|
||||
|
||||
**步骤9**:创建核销记录:
|
||||
```
|
||||
{
|
||||
coupon_id: 1,
|
||||
coupon_code: "HC202411250001000001",
|
||||
binding_id: 1,
|
||||
user_id: 10001,
|
||||
order_id: 1,
|
||||
order_no: "ORD202411260001",
|
||||
tourism_id: 1,
|
||||
tourism_name: "景区A",
|
||||
device_sn: "DEVICE001",
|
||||
original_amount: 99.00,
|
||||
discount_amount: 99.00,
|
||||
actual_amount: 0.00,
|
||||
usage_time: "2024-11-26 14:30:00",
|
||||
usage_type: 1 // 自动核销
|
||||
}
|
||||
```
|
||||
|
||||
**步骤10**:触发设备执行任务,完成服务交付。
|
||||
|
||||
### 6.4 实施例四:绑定后N天有效期计算
|
||||
|
||||
本实施例描述"绑定后N天有效"类型优惠券的有效期计算:
|
||||
|
||||
**配置**:优惠券配置为"绑定后30天有效"。
|
||||
|
||||
**绑定时间**:2024-11-26 10:30:00
|
||||
|
||||
**有效期计算**:
|
||||
```
|
||||
effective_start_time = 绑定时间 = 2024-11-26 10:30:00
|
||||
effective_end_time = 绑定时间 + 30天 = 2024-12-26 10:30:00
|
||||
```
|
||||
|
||||
**存储的绑定记录**:
|
||||
```
|
||||
{
|
||||
bind_time: "2024-11-26 10:30:00",
|
||||
effective_start_time: "2024-11-26 10:30:00",
|
||||
effective_end_time: "2024-12-26 10:30:00"
|
||||
}
|
||||
```
|
||||
|
||||
### 6.5 实施例五:并发绑定控制
|
||||
|
||||
本实施例描述两个用户同时扫描同一优惠券二维码时的处理:
|
||||
|
||||
**场景**:用户A和用户B同时扫描优惠券码HC202411250001000001。
|
||||
|
||||
**时序**:
|
||||
```
|
||||
T1: 用户A调用绑定接口
|
||||
T2: 用户A尝试获取分布式锁,成功
|
||||
T3: 用户B调用绑定接口
|
||||
T4: 用户B尝试获取分布式锁,等待
|
||||
T5: 用户A完成绑定,释放锁
|
||||
T6: 用户B获取到锁
|
||||
T7: 用户B查询优惠券状态,发现已被绑定
|
||||
T8: 用户B返回错误:优惠券已被其他用户绑定
|
||||
T9: 用户B释放锁
|
||||
```
|
||||
|
||||
**结果**:只有用户A成功绑定优惠券,用户B收到"优惠券已被其他用户绑定"的提示。
|
||||
|
||||
---
|
||||
|
||||
## 七、权利要求书
|
||||
|
||||
### 权利要求1
|
||||
|
||||
一种基于实体二维码的酒店优惠券发放与自动核销系统,其特征在于,包括:
|
||||
|
||||
合作酒店管理模块,用于管理与景区建立合作关系的酒店信息;
|
||||
|
||||
优惠券批量生成模块,用于为指定酒店批量生成带有唯一标识码的优惠券,并为每张优惠券生成对应的二维码图片;
|
||||
|
||||
二维码图片管理模块,用于将二维码图片上传至云存储并支持批量下载,供酒店制作实体二维码投放;
|
||||
|
||||
用户扫码绑定模块,用于处理用户扫描实体二维码后的绑定请求,采用分布式锁机制确保一码只能被一个用户绑定;
|
||||
|
||||
可用优惠券检测模块,用于在用户下单前根据当前景区和设备信息检测是否有可用优惠券;
|
||||
|
||||
自动核销模块,用于在订单创建时自动完成优惠券核销,更新优惠券状态并创建核销记录。
|
||||
|
||||
### 权利要求2
|
||||
|
||||
根据权利要求1所述的系统,其特征在于,所述优惠券批量生成模块支持配置多种优惠券类型,包括免费体验券、折扣券和满减券,并支持配置适用范围包括指定景区和指定设备。
|
||||
|
||||
### 权利要求3
|
||||
|
||||
根据权利要求1所述的系统,其特征在于,所述优惠券批量生成模块支持两种有效期策略:固定时间有效期和绑定后N天有效期,所述用户扫码绑定模块根据有效期策略计算优惠券的实际生效时间。
|
||||
|
||||
### 权利要求4
|
||||
|
||||
根据权利要求1所述的系统,其特征在于,所述用户扫码绑定模块的具体处理过程为:
|
||||
|
||||
解析二维码获取优惠券码;
|
||||
|
||||
获取分布式锁;
|
||||
|
||||
校验优惠券状态,确保未被绑定、未过期、未作废;
|
||||
|
||||
根据有效期策略计算优惠券的实际生效开始时间和结束时间;
|
||||
|
||||
创建优惠券与用户的绑定记录;
|
||||
|
||||
更新优惠券状态为已绑定;
|
||||
|
||||
释放分布式锁。
|
||||
|
||||
### 权利要求5
|
||||
|
||||
根据权利要求1所述的系统,其特征在于,所述自动核销模块在订单创建流程中嵌入核销逻辑,根据优惠券类型计算优惠金额,创建标记为优惠券订单的订单记录,并在订单中记录优惠券标识和优惠金额。
|
||||
|
||||
### 权利要求6
|
||||
|
||||
根据权利要求1所述的系统,其特征在于,还包括:
|
||||
|
||||
过期处理模块,用于定时扫描超过有效期的优惠券,更新未使用的过期优惠券状态和过期的绑定记录状态;
|
||||
|
||||
数据统计模块,用于按酒店、按批次统计优惠券的发放、绑定、使用、过期数量。
|
||||
|
||||
### 权利要求7
|
||||
|
||||
一种基于实体二维码的酒店优惠券发放与自动核销方法,其特征在于,包括以下步骤:
|
||||
|
||||
S1:为合作酒店批量生成带有唯一标识码的优惠券,并为每张优惠券生成对应的二维码图片上传至云存储;
|
||||
|
||||
S2:将二维码图片批量下载并制作成实体二维码投放至酒店;
|
||||
|
||||
S3:用户扫描实体二维码后,系统获取分布式锁,校验优惠券状态后创建用户与优惠券的绑定关系;
|
||||
|
||||
S4:用户在景区设备端下单时,系统检测用户是否有适用于当前景区和设备的可用优惠券;
|
||||
|
||||
S5:若有可用优惠券,创建优惠券订单,根据优惠券类型计算优惠金额,自动完成优惠券核销。
|
||||
|
||||
### 权利要求8
|
||||
|
||||
根据权利要求7所述的方法,其特征在于,步骤S3中获取分布式锁的锁键值为优惠券码,确保同一优惠券在同一时刻只能被一个用户绑定。
|
||||
|
||||
### 权利要求9
|
||||
|
||||
根据权利要求7所述的方法,其特征在于,步骤S3中根据优惠券配置的有效期策略计算实际生效时间:若为固定时间策略,使用配置的有效期;若为绑定后N天策略,以绑定时间为起点计算有效期。
|
||||
|
||||
### 权利要求10
|
||||
|
||||
根据权利要求7所述的方法,其特征在于,步骤S5中自动核销的具体过程为:
|
||||
|
||||
在订单中设置订单类型为优惠券订单;
|
||||
|
||||
根据优惠券类型计算优惠金额和实付金额;
|
||||
|
||||
记录优惠券标识和优惠金额到订单;
|
||||
|
||||
更新优惠券状态和绑定记录状态为已使用;
|
||||
|
||||
创建包含核销详情的核销记录。
|
||||
|
||||
---
|
||||
|
||||
## 八、摘要
|
||||
|
||||
### 说明书摘要
|
||||
|
||||
本发明公开了一种基于实体二维码的酒店优惠券发放与自动核销系统及方法,涉及电子商务与旅游信息化技术领域。系统包括合作酒店管理模块、优惠券批量生成模块、二维码图片管理模块、用户扫码绑定模块、可用优惠券检测模块和自动核销模块。通过为每张优惠券生成唯一标识码和对应二维码,制作成实体二维码投放至酒店,用户扫码后完成绑定,在景区设备端下单时自动检测并核销优惠券。本发明采用分布式锁机制确保一码一用,支持多种优惠券类型和灵活的有效期策略,将核销逻辑嵌入订单创建流程实现自动核销,具有发放效率高、核销自动化、防滥用、数据可追溯等优点。
|
||||
|
||||
### 摘要附图
|
||||
|
||||
(选用图3:核心业务流程图)
|
||||
|
||||
---
|
||||
|
||||
## 九、附加说明
|
||||
|
||||
### 9.1 技术关键点
|
||||
|
||||
1. **一码一用机制**:每个优惠券码全局唯一,通过分布式锁防止并发绑定,确保一个优惠券只能被一个用户使用。
|
||||
|
||||
2. **实体二维码投放**:将数字优惠券转化为实体二维码,无需酒店人员培训,降低合作门槛。
|
||||
|
||||
3. **自动核销集成**:核销逻辑与订单创建流程无缝集成,用户无感知完成核销,提升体验。
|
||||
|
||||
4. **灵活有效期策略**:支持固定时间和绑定后N天两种策略,适应不同营销场景。
|
||||
|
||||
5. **精准适用范围**:可限定优惠券适用的景区和设备,实现精细化营销。
|
||||
|
||||
### 9.2 应用场景
|
||||
|
||||
- 酒店与景区合作营销
|
||||
- 酒店与游乐园合作营销
|
||||
- 民宿与周边景点合作营销
|
||||
- 其他需要线下发放、线上核销的优惠券场景
|
||||
|
||||
### 9.3 技术创新点
|
||||
|
||||
1. 首次提出将实体二维码与一码一用机制结合的酒店优惠券发放方案
|
||||
2. 首次实现优惠券核销与订单创建流程的无缝集成
|
||||
3. 首次提出支持"绑定后N天有效"的动态有效期计算机制
|
||||
4. 首次将分布式锁应用于优惠券绑定场景防止并发滥用
|
||||
|
||||
---
|
||||
|
||||
**申请人**:湖北高飞智航科技有限责任公司
|
||||
|
||||
**发明人**:杜志超
|
||||
|
||||
**申请日期**:2025年12月01日
|
||||
|
||||
**文档版本**:v1.0
|
||||
|
After Width: | Height: | Size: 35 KiB |
|
After Width: | Height: | Size: 3.2 MiB |
@@ -0,0 +1,101 @@
|
||||
-- =====================================================
|
||||
-- 3D模型文件管理表
|
||||
-- 用于存储大疆建图等工具生成的倾斜摄影、点云等3D模型
|
||||
-- =====================================================
|
||||
|
||||
-- 创建3D模型文件表
|
||||
CREATE TABLE IF NOT EXISTS `3d_model_file` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`model_name` VARCHAR(100) NOT NULL COMMENT '模型名称',
|
||||
`model_type` TINYINT NOT NULL DEFAULT 1 COMMENT '模型类型: 1-倾斜摄影 2-点云 3-BIM 4-其他',
|
||||
`model_format` VARCHAR(20) DEFAULT '3dtiles' COMMENT '模型格式: 3dtiles/osgb/obj/ply/las',
|
||||
`description` VARCHAR(500) DEFAULT NULL COMMENT '模型描述',
|
||||
|
||||
-- 文件存储信息
|
||||
`tileset_url` VARCHAR(500) NOT NULL COMMENT 'tileset.json的CDN访问URL',
|
||||
`tileset_path` VARCHAR(500) NOT NULL COMMENT 'tileset.json在MinIO的存储路径',
|
||||
`bucket_name` VARCHAR(50) NOT NULL DEFAULT 'goflymodel' COMMENT 'MinIO桶名称',
|
||||
`folder_path` VARCHAR(200) NOT NULL COMMENT '模型文件夹路径(相对于bucket)',
|
||||
`file_count` INT DEFAULT 0 COMMENT '模型文件总数',
|
||||
`total_size` BIGINT DEFAULT 0 COMMENT '模型文件总大小(bytes)',
|
||||
|
||||
-- 关联信息
|
||||
`tourism_id` BIGINT DEFAULT NULL COMMENT '关联景区ID(可为空)',
|
||||
`tourism_name` VARCHAR(100) DEFAULT NULL COMMENT '关联景区名称(冗余)',
|
||||
`workspace_id` VARCHAR(64) DEFAULT NULL COMMENT '工作空间ID',
|
||||
|
||||
-- 位置调整参数
|
||||
`offset_longitude` DECIMAL(12,9) DEFAULT 0 COMMENT '经度偏移(度)',
|
||||
`offset_latitude` DECIMAL(12,9) DEFAULT 0 COMMENT '纬度偏移(度)',
|
||||
`offset_height` DECIMAL(10,2) DEFAULT 0 COMMENT '高度偏移(米)',
|
||||
|
||||
-- 变换参数
|
||||
`scale` DECIMAL(8,4) DEFAULT 1.0000 COMMENT '缩放比例',
|
||||
`rotation_x` DECIMAL(8,4) DEFAULT 0 COMMENT 'X轴旋转(弧度)',
|
||||
`rotation_y` DECIMAL(8,4) DEFAULT 0 COMMENT 'Y轴旋转(弧度)',
|
||||
`rotation_z` DECIMAL(8,4) DEFAULT 0 COMMENT 'Z轴旋转(弧度)',
|
||||
|
||||
-- 渲染配置
|
||||
`max_screen_space_error` INT DEFAULT 16 COMMENT 'LOD精度控制(默认16)',
|
||||
`max_memory_usage` INT DEFAULT 512 COMMENT '最大内存使用(MB)',
|
||||
`skip_lod` TINYINT(1) DEFAULT 1 COMMENT '是否跳过LOD: 0-否 1-是',
|
||||
`prefer_leaves` TINYINT(1) DEFAULT 1 COMMENT '是否优先加载叶子节点: 0-否 1-是',
|
||||
|
||||
-- 元数据
|
||||
`source_type` VARCHAR(50) DEFAULT 'dji_terra' COMMENT '来源类型: dji_terra/cesium_ion/custom',
|
||||
`thumbnail_url` VARCHAR(500) DEFAULT NULL COMMENT '缩略图URL',
|
||||
`bounding_box` JSON DEFAULT NULL COMMENT '包围盒信息(JSON格式)',
|
||||
`center_point` JSON DEFAULT NULL COMMENT '模型中心点(JSON格式: {lng, lat, height})',
|
||||
|
||||
-- 状态与审计
|
||||
`status` TINYINT NOT NULL DEFAULT 1 COMMENT '状态: 0-禁用 1-启用 2-处理中',
|
||||
`upload_status` TINYINT NOT NULL DEFAULT 0 COMMENT '上传状态: 0-待上传 1-上传中 2-已完成 3-失败',
|
||||
`upload_progress` INT DEFAULT 0 COMMENT '上传进度(0-100)',
|
||||
`tenant_id` VARCHAR(32) DEFAULT NULL COMMENT '租户ID',
|
||||
`create_by` VARCHAR(64) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
`update_by` VARCHAR(64) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
`is_del` TINYINT(1) NOT NULL DEFAULT 0 COMMENT '是否删除: 0-否 1-是',
|
||||
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `idx_tourism_id` (`tourism_id`),
|
||||
INDEX `idx_model_type` (`model_type`),
|
||||
INDEX `idx_status` (`status`),
|
||||
INDEX `idx_tenant_id` (`tenant_id`),
|
||||
INDEX `idx_workspace_id` (`workspace_id`),
|
||||
INDEX `idx_create_time` (`create_time`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='3D模型文件管理表';
|
||||
|
||||
-- 创建模型类型枚举注释
|
||||
-- 1: 倾斜摄影(Oblique Photography) - 大疆Terra、ContextCapture等生成
|
||||
-- 2: 点云(Point Cloud) - LAS/LAZ/PLY格式
|
||||
-- 3: BIM模型(Building Information Modeling) - IFC/RVT转换
|
||||
-- 4: 其他(Other)
|
||||
|
||||
-- 创建模型文件详情表(用于存储单个模型包含的所有文件)
|
||||
CREATE TABLE IF NOT EXISTS `3d_model_file_detail` (
|
||||
`id` BIGINT NOT NULL AUTO_INCREMENT COMMENT '主键ID',
|
||||
`model_id` BIGINT NOT NULL COMMENT '关联的模型ID',
|
||||
`file_name` VARCHAR(200) NOT NULL COMMENT '文件名',
|
||||
`file_path` VARCHAR(500) NOT NULL COMMENT 'MinIO存储路径',
|
||||
`file_url` VARCHAR(500) DEFAULT NULL COMMENT 'CDN访问URL',
|
||||
`file_size` BIGINT DEFAULT 0 COMMENT '文件大小(bytes)',
|
||||
`file_type` VARCHAR(20) DEFAULT NULL COMMENT '文件类型: tileset/b3dm/i3dm/pnts/cmpt/json/texture',
|
||||
`lod_level` VARCHAR(20) DEFAULT NULL COMMENT 'LOD层级(如L14, L15等)',
|
||||
`upload_status` TINYINT NOT NULL DEFAULT 0 COMMENT '上传状态: 0-待上传 1-上传中 2-已完成 3-失败',
|
||||
`create_time` DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
|
||||
PRIMARY KEY (`id`),
|
||||
INDEX `idx_model_id` (`model_id`),
|
||||
INDEX `idx_file_type` (`file_type`),
|
||||
CONSTRAINT `fk_model_file_detail_model` FOREIGN KEY (`model_id`)
|
||||
REFERENCES `3d_model_file` (`id`) ON DELETE CASCADE
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='3D模型文件详情表';
|
||||
|
||||
-- 插入示例数据(可选)
|
||||
-- INSERT INTO `3d_model_file`
|
||||
-- (model_name, model_type, tileset_url, tileset_path, bucket_name, folder_path, tourism_id, status)
|
||||
-- VALUES
|
||||
-- ('黄山景区倾斜模型', 1, 'https://minicdn.goflytec.com/goflymodel/scenic_001/tileset.json',
|
||||
-- 'scenic_001/tileset.json', 'goflymodel', 'scenic_001', 101, 1);
|
||||
@@ -0,0 +1,178 @@
|
||||
package com.central.device.controller;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.model.dto.ThreeDModelFileDTO;
|
||||
import com.central.device.model.vo.ThreeDModelFileVO;
|
||||
import com.central.device.service.IThreeDModelFileService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 3D模型文件管理Controller
|
||||
*
|
||||
* @author claude
|
||||
* @date 2024-12-08
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/3d-model")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "3D模型文件管理")
|
||||
public class ThreeDModelFileController {
|
||||
|
||||
private final IThreeDModelFileService modelFileService;
|
||||
|
||||
/**
|
||||
* 分页查询模型列表
|
||||
*/
|
||||
@GetMapping
|
||||
@Operation(summary = "分页查询模型列表")
|
||||
public PageResult<ThreeDModelFileVO> list(@RequestParam Map<String, Object> params) {
|
||||
return modelFileService.findList(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模型详情
|
||||
*/
|
||||
@GetMapping("/{id}")
|
||||
@Operation(summary = "获取模型详情")
|
||||
public Result<ThreeDModelFileVO> getById(
|
||||
@Parameter(description = "模型ID") @PathVariable Long id) {
|
||||
ThreeDModelFileVO vo = modelFileService.getDetailById(id);
|
||||
return vo != null ? Result.succeed(vo) : Result.failed("模型不存在");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据景区ID获取模型列表
|
||||
*/
|
||||
@GetMapping("/tourism/{tourismId}")
|
||||
@Operation(summary = "根据景区ID获取模型列表")
|
||||
public Result<List<ThreeDModelFileVO>> getByTourismId(
|
||||
@Parameter(description = "景区ID") @PathVariable Long tourismId) {
|
||||
return Result.succeed(modelFileService.getByTourismId(tourismId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有可用模型(用于3D地图加载)
|
||||
*/
|
||||
@GetMapping("/available")
|
||||
@Operation(summary = "获取所有可用模型")
|
||||
public Result<List<ThreeDModelFileVO>> getAllAvailable() {
|
||||
return Result.succeed(modelFileService.getAllAvailableModels());
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建模型记录
|
||||
*/
|
||||
@PostMapping
|
||||
@Operation(summary = "创建模型记录")
|
||||
public Result<Long> create(@Valid @RequestBody ThreeDModelFileDTO dto) {
|
||||
Long id = modelFileService.create(dto);
|
||||
return Result.succeed(id, "创建成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新模型信息
|
||||
*/
|
||||
@PutMapping
|
||||
@Operation(summary = "更新模型信息")
|
||||
public Result<Void> update(@Valid @RequestBody ThreeDModelFileDTO dto) {
|
||||
boolean success = modelFileService.update(dto);
|
||||
return success ? Result.succeed("更新成功") : Result.failed("更新失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模型
|
||||
*/
|
||||
@DeleteMapping("/{id}")
|
||||
@Operation(summary = "删除模型")
|
||||
public Result<Void> delete(
|
||||
@Parameter(description = "模型ID") @PathVariable Long id) {
|
||||
boolean success = modelFileService.delete(id);
|
||||
return success ? Result.succeed("删除成功") : Result.failed("删除失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量上传模型文件
|
||||
*/
|
||||
@PostMapping("/{modelId}/upload")
|
||||
@Operation(summary = "批量上传模型文件")
|
||||
public Result<Map<String, Object>> uploadFiles(
|
||||
@Parameter(description = "模型ID") @PathVariable Long modelId,
|
||||
@Parameter(description = "文件列表") @RequestParam("files") MultipartFile[] files,
|
||||
@Parameter(description = "基础路径") @RequestParam(value = "basePath", required = false) String basePath) {
|
||||
Map<String, Object> result = modelFileService.uploadModelFiles(modelId, files, basePath);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传单个文件
|
||||
*/
|
||||
@PostMapping("/{modelId}/upload/single")
|
||||
@Operation(summary = "上传单个模型文件")
|
||||
public Result<String> uploadSingleFile(
|
||||
@Parameter(description = "模型ID") @PathVariable Long modelId,
|
||||
@Parameter(description = "文件") @RequestParam("file") MultipartFile file,
|
||||
@Parameter(description = "文件相对路径") @RequestParam("filePath") String filePath) {
|
||||
String url = modelFileService.uploadSingleFile(modelId, file, filePath);
|
||||
return Result.succeed(url, "上传成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成上传
|
||||
*/
|
||||
@PostMapping("/{modelId}/complete")
|
||||
@Operation(summary = "完成上传(更新状态)")
|
||||
public Result<Void> completeUpload(
|
||||
@Parameter(description = "模型ID") @PathVariable Long modelId) {
|
||||
boolean success = modelFileService.completeUpload(modelId);
|
||||
return success ? Result.succeed("完成") : Result.failed("操作失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新上传进度
|
||||
*/
|
||||
@PostMapping("/{modelId}/progress")
|
||||
@Operation(summary = "更新上传进度")
|
||||
public Result<Void> updateProgress(
|
||||
@Parameter(description = "模型ID") @PathVariable Long modelId,
|
||||
@Parameter(description = "进度(0-100)") @RequestParam Integer progress) {
|
||||
modelFileService.updateProgress(modelId, progress);
|
||||
return Result.succeed("上传完成");
|
||||
}
|
||||
|
||||
/**
|
||||
* 启用/禁用模型
|
||||
*/
|
||||
@PutMapping("/{id}/status")
|
||||
@Operation(summary = "启用/禁用模型")
|
||||
public Result<Void> updateStatus(
|
||||
@Parameter(description = "模型ID") @PathVariable Long id,
|
||||
@Parameter(description = "状态: 0-禁用 1-启用") @RequestParam Integer status) {
|
||||
boolean success = modelFileService.updateStatus(id, status);
|
||||
return success ? Result.succeed("操作成功") : Result.failed("操作失败");
|
||||
}
|
||||
|
||||
/**
|
||||
* 关联景区
|
||||
*/
|
||||
@PutMapping("/{id}/bindTourism")
|
||||
@Operation(summary = "关联景区")
|
||||
public Result<Void> bindTourism(
|
||||
@Parameter(description = "模型ID") @PathVariable Long id,
|
||||
@Parameter(description = "景区ID") @RequestParam Long tourismId,
|
||||
@Parameter(description = "景区名称") @RequestParam(required = false) String tourismName) {
|
||||
boolean success = modelFileService.bindTourism(id, tourismId, tourismName);
|
||||
return success ? Result.succeed("关联成功") : Result.failed("关联失败");
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,9 @@ import com.central.common.model.FileInfo;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.device.feign.fallback.FileCenterServiceFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -67,7 +69,56 @@ public interface FileCenterService {
|
||||
* @return 预热任务执行结果
|
||||
*/
|
||||
@PostMapping("/cdn/batch/prefetch")
|
||||
Result<Boolean> batchPrefetchFiles(@RequestBody List<String> urls,
|
||||
Result<Boolean> batchPrefetchFiles(@RequestBody List<String> urls,
|
||||
@RequestParam(value = "batchSize", defaultValue = "100") int batchSize,
|
||||
@RequestParam(value = "area", required = false) String area);
|
||||
|
||||
// ========== 3D模型文件上传相关接口 ==========
|
||||
|
||||
/**
|
||||
* 上传单个模型文件到MinIO(goflymodel桶)
|
||||
*
|
||||
* @param file 文件
|
||||
* @param folderPath 模型文件夹路径
|
||||
* @param filePath 文件相对路径
|
||||
* @return 上传结果
|
||||
*/
|
||||
@PostMapping(value = "/model-file/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
Result<Map<String, Object>> uploadModelFile(
|
||||
@RequestPart("file") MultipartFile file,
|
||||
@RequestParam("folderPath") String folderPath,
|
||||
@RequestParam("filePath") String filePath);
|
||||
|
||||
/**
|
||||
* 删除模型文件夹
|
||||
*
|
||||
* @param folderPath 文件夹路径
|
||||
* @return 操作结果
|
||||
*/
|
||||
@DeleteMapping("/model-file/folder")
|
||||
Result<Void> deleteModelFolder(@RequestParam("folderPath") String folderPath);
|
||||
|
||||
/**
|
||||
* 检查模型文件是否存在
|
||||
*
|
||||
* @param folderPath 文件夹路径
|
||||
* @param filePath 文件相对路径
|
||||
* @return 是否存在
|
||||
*/
|
||||
@GetMapping("/model-file/exists")
|
||||
Result<Boolean> checkModelFileExists(
|
||||
@RequestParam("folderPath") String folderPath,
|
||||
@RequestParam("filePath") String filePath);
|
||||
|
||||
/**
|
||||
* 获取模型文件CDN URL
|
||||
*
|
||||
* @param folderPath 文件夹路径
|
||||
* @param filePath 文件相对路径
|
||||
* @return CDN URL
|
||||
*/
|
||||
@GetMapping("/model-file/url")
|
||||
Result<String> getModelFileUrl(
|
||||
@RequestParam("folderPath") String folderPath,
|
||||
@RequestParam("filePath") String filePath);
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.central.device.feign.FileCenterService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.cloud.openfeign.FallbackFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -73,6 +74,32 @@ public class FileCenterServiceFallbackFactory implements FallbackFactory<FileCen
|
||||
return Result.failed("CDN批量预热文件失败: " + cause.getMessage());
|
||||
}
|
||||
|
||||
// ========== 3D模型文件上传相关接口 ==========
|
||||
|
||||
@Override
|
||||
public Result<Map<String, Object>> uploadModelFile(MultipartFile file, String folderPath, String filePath) {
|
||||
log.error("上传模型文件失败: folderPath={}, filePath={}", folderPath, filePath, cause);
|
||||
return Result.failed("上传模型文件失败: " + cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Void> deleteModelFolder(String folderPath) {
|
||||
log.error("删除模型文件夹失败: folderPath={}", folderPath, cause);
|
||||
return Result.failed("删除模型文件夹失败: " + cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<Boolean> checkModelFileExists(String folderPath, String filePath) {
|
||||
log.error("检查模型文件失败: folderPath={}, filePath={}", folderPath, filePath, cause);
|
||||
return Result.failed("检查模型文件失败: " + cause.getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Result<String> getModelFileUrl(String folderPath, String filePath) {
|
||||
log.error("获取模型文件URL失败: folderPath={}, filePath={}", folderPath, filePath, cause);
|
||||
return Result.failed("获取模型文件URL失败: " + cause.getMessage());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.central.device.mapper;
|
||||
|
||||
import com.central.db.mapper.SuperMapper;
|
||||
import com.central.device.model.ThreeDModelFileDetail;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 3D模型文件详情Mapper
|
||||
*
|
||||
* @author claude
|
||||
* @date 2024-12-08
|
||||
*/
|
||||
@Mapper
|
||||
public interface ThreeDModelFileDetailMapper extends SuperMapper<ThreeDModelFileDetail> {
|
||||
|
||||
/**
|
||||
* 根据模型ID查询文件详情列表
|
||||
*
|
||||
* @param modelId 模型ID
|
||||
* @return 文件列表
|
||||
*/
|
||||
@Select("SELECT * FROM 3d_model_file_detail WHERE model_id = #{modelId} ORDER BY file_type, lod_level")
|
||||
List<ThreeDModelFileDetail> findByModelId(@Param("modelId") Long modelId);
|
||||
|
||||
/**
|
||||
* 根据模型ID删除所有文件详情
|
||||
*
|
||||
* @param modelId 模型ID
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Delete("DELETE FROM 3d_model_file_detail WHERE model_id = #{modelId}")
|
||||
int deleteByModelId(@Param("modelId") Long modelId);
|
||||
|
||||
/**
|
||||
* 统计模型的文件数量和总大小
|
||||
*
|
||||
* @param modelId 模型ID
|
||||
* @return [文件数量, 总大小]
|
||||
*/
|
||||
@Select("SELECT COUNT(*) as count, COALESCE(SUM(file_size), 0) as totalSize FROM 3d_model_file_detail WHERE model_id = #{modelId}")
|
||||
java.util.Map<String, Object> countFileStats(@Param("modelId") Long modelId);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.central.device.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.db.mapper.SuperMapper;
|
||||
import com.central.device.model.ThreeDModelFile;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.apache.ibatis.annotations.Select;
|
||||
import org.apache.ibatis.annotations.Update;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 3D模型文件Mapper
|
||||
*
|
||||
* @author claude
|
||||
* @date 2024-12-08
|
||||
*/
|
||||
@Mapper
|
||||
public interface ThreeDModelFileMapper extends SuperMapper<ThreeDModelFile> {
|
||||
|
||||
/**
|
||||
* 分页查询
|
||||
*
|
||||
* @param page 分页参数
|
||||
* @param params 查询参数
|
||||
* @return 列表
|
||||
*/
|
||||
List<ThreeDModelFile> findList(Page<ThreeDModelFile> page, @Param("p") Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 根据景区ID查询模型列表
|
||||
*
|
||||
* @param tourismId 景区ID
|
||||
* @return 模型列表
|
||||
*/
|
||||
@Select("SELECT * FROM 3d_model_file WHERE tourism_id = #{tourismId} AND is_del = 0 AND status = 1 ORDER BY create_time DESC")
|
||||
List<ThreeDModelFile> findByTourismId(@Param("tourismId") Long tourismId);
|
||||
|
||||
/**
|
||||
* 根据工作空间ID查询模型列表
|
||||
*
|
||||
* @param workspaceId 工作空间ID
|
||||
* @return 模型列表
|
||||
*/
|
||||
@Select("SELECT * FROM 3d_model_file WHERE workspace_id = #{workspaceId} AND is_del = 0 ORDER BY create_time DESC")
|
||||
List<ThreeDModelFile> findByWorkspaceId(@Param("workspaceId") String workspaceId);
|
||||
|
||||
/**
|
||||
* 更新上传进度
|
||||
*
|
||||
* @param id 模型ID
|
||||
* @param uploadStatus 上传状态
|
||||
* @param progress 进度
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Update("UPDATE 3d_model_file SET upload_status = #{uploadStatus}, upload_progress = #{progress}, update_time = NOW() WHERE id = #{id}")
|
||||
int updateUploadProgress(@Param("id") Long id, @Param("uploadStatus") Integer uploadStatus, @Param("progress") Integer progress);
|
||||
|
||||
/**
|
||||
* 更新文件统计信息
|
||||
*
|
||||
* @param id 模型ID
|
||||
* @param fileCount 文件数量
|
||||
* @param totalSize 总大小
|
||||
* @return 影响行数
|
||||
*/
|
||||
@Update("UPDATE 3d_model_file SET file_count = #{fileCount}, total_size = #{totalSize}, update_time = NOW() WHERE id = #{id}")
|
||||
int updateFileStats(@Param("id") Long id, @Param("fileCount") Integer fileCount, @Param("totalSize") Long totalSize);
|
||||
|
||||
/**
|
||||
* 统计模型数量
|
||||
*
|
||||
* @param modelType 模型类型(可选)
|
||||
* @return 数量
|
||||
*/
|
||||
@Select("<script>" +
|
||||
"SELECT COUNT(*) FROM 3d_model_file WHERE is_del = 0 " +
|
||||
"<if test='modelType != null'> AND model_type = #{modelType}</if>" +
|
||||
"</script>")
|
||||
Long countByType(@Param("modelType") Integer modelType);
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
package com.central.device.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.central.common.model.SuperEntity;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 3D模型文件实体类
|
||||
* 用于存储大疆建图等工具生成的倾斜摄影、点云等3D模型
|
||||
*
|
||||
* 位置调整参数 (通常保持默认 0,模型会自动定位):
|
||||
* | 参数 | 说明 | 范围 | 使用场景 |
|
||||
* |------|-----------|-----------------|--------------|
|
||||
* | 经度偏移 | 正值向东,负值向西 | -180 ~ 180 度 | 模型偏离实际位置时调整 |
|
||||
* | 纬度偏移 | 正值向北,负值向南 | -90 ~ 90 度 | 模型偏离实际位置时调整 |
|
||||
* | 高度偏移 | 正值向上,负值向下 | -1000 ~ 10000 米 | 模型悬空或陷入地面时调整 |
|
||||
*
|
||||
* 变换参数 (通常保持默认,除非模型方向不正确):
|
||||
* | 参数 | 说明 | 范围 | 默认值 |
|
||||
* |------|-----------------|------------|-----|
|
||||
* | 缩放比例 | 1=原始大小,0.5=缩小一半 | 0.01 ~ 100 | 1 |
|
||||
* | X轴旋转 | 俯仰角(弧度) | -2π ~ 2π | 0 |
|
||||
* | Y轴旋转 | 翻滚角(弧度) | -2π ~ 2π | 0 |
|
||||
* | Z轴旋转 | 航向角(弧度) | -2π ~ 2π | 0 |
|
||||
*
|
||||
* 渲染配置 (核心清晰度设置):
|
||||
* | 参数 | 说明 | 推荐值 |
|
||||
* |--------|------------------------|--------------|
|
||||
* | LOD精度 | 核心参数!1-2=高清,8=中等,16=较低 | 1-4 (类似大疆司空) |
|
||||
* | 最大内存 | 越大越能加载高清瓦片 | 1024-2048 MB |
|
||||
* | 跳过LOD | 否=更清晰,是=更快 | 否 |
|
||||
* | 优先叶子节点 | 优先加载最精细瓦片 | 是 |
|
||||
* @author dzc
|
||||
* @date 2024-12-08
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@TableName("3d_model_file")
|
||||
@Schema(description = "3D模型文件")
|
||||
public class ThreeDModelFile extends SuperEntity {
|
||||
|
||||
@Schema(description = "模型名称")
|
||||
private String modelName;
|
||||
|
||||
@Schema(description = "模型类型: 1-倾斜摄影 2-点云 3-BIM 4-其他")
|
||||
private Integer modelType;
|
||||
|
||||
@Schema(description = "模型格式: 3dtiles/osgb/obj/ply/las")
|
||||
private String modelFormat;
|
||||
|
||||
@Schema(description = "模型描述")
|
||||
private String description;
|
||||
|
||||
// ========== 文件存储信息 ==========
|
||||
|
||||
@Schema(description = "tileset.json的CDN访问URL")
|
||||
private String tilesetUrl;
|
||||
|
||||
@Schema(description = "tileset.json在MinIO的存储路径")
|
||||
private String tilesetPath;
|
||||
|
||||
@Schema(description = "MinIO桶名称")
|
||||
private String bucketName;
|
||||
|
||||
@Schema(description = "模型文件夹路径(相对于bucket)")
|
||||
private String folderPath;
|
||||
|
||||
@Schema(description = "模型文件总数")
|
||||
private Integer fileCount;
|
||||
|
||||
@Schema(description = "模型文件总大小(bytes)")
|
||||
private Long totalSize;
|
||||
|
||||
// ========== 关联信息 ==========
|
||||
|
||||
@Schema(description = "关联景区ID")
|
||||
private Long tourismId;
|
||||
|
||||
@Schema(description = "关联景区名称")
|
||||
private String tourismName;
|
||||
|
||||
@Schema(description = "工作空间ID")
|
||||
private String workspaceId;
|
||||
|
||||
// ========== 位置调整参数 ==========
|
||||
|
||||
@Schema(description = "经度偏移(度)")
|
||||
private BigDecimal offsetLongitude;
|
||||
|
||||
@Schema(description = "纬度偏移(度)")
|
||||
private BigDecimal offsetLatitude;
|
||||
|
||||
@Schema(description = "高度偏移(米)")
|
||||
private BigDecimal offsetHeight;
|
||||
|
||||
// ========== 变换参数 ==========
|
||||
|
||||
@Schema(description = "缩放比例")
|
||||
private BigDecimal scale;
|
||||
|
||||
@Schema(description = "X轴旋转(弧度)")
|
||||
private BigDecimal rotationX;
|
||||
|
||||
@Schema(description = "Y轴旋转(弧度)")
|
||||
private BigDecimal rotationY;
|
||||
|
||||
@Schema(description = "Z轴旋转(弧度)")
|
||||
private BigDecimal rotationZ;
|
||||
|
||||
// ========== 渲染配置 ==========
|
||||
|
||||
@Schema(description = "LOD精度控制(默认16)")
|
||||
private Integer maxScreenSpaceError;
|
||||
|
||||
@Schema(description = "最大内存使用(MB)")
|
||||
private Integer maxMemoryUsage;
|
||||
|
||||
@Schema(description = "是否跳过LOD: 0-否 1-是")
|
||||
private Integer skipLod;
|
||||
|
||||
@Schema(description = "是否优先加载叶子节点: 0-否 1-是")
|
||||
private Integer preferLeaves;
|
||||
|
||||
// ========== 元数据 ==========
|
||||
|
||||
@Schema(description = "来源类型: dji_terra/cesium_ion/custom")
|
||||
private String sourceType;
|
||||
|
||||
@Schema(description = "缩略图URL")
|
||||
private String thumbnailUrl;
|
||||
|
||||
@Schema(description = "包围盒信息(JSON格式)")
|
||||
private String boundingBox;
|
||||
|
||||
@Schema(description = "模型中心点(JSON格式)")
|
||||
private String centerPoint;
|
||||
|
||||
// ========== 状态与审计 ==========
|
||||
|
||||
@Schema(description = "状态: 0-禁用 1-启用 2-处理中")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "上传状态: 0-待上传 1-上传中 2-已完成 3-失败")
|
||||
private Integer uploadStatus;
|
||||
|
||||
@Schema(description = "上传进度(0-100)")
|
||||
private Integer uploadProgress;
|
||||
|
||||
@Schema(description = "租户ID")
|
||||
private String tenantId;
|
||||
|
||||
@Schema(description = "创建人")
|
||||
private String createBy;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@Schema(description = "更新人")
|
||||
private String updateBy;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
@TableLogic
|
||||
@Schema(description = "是否删除: 0-否 1-是")
|
||||
private Integer isDel;
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.central.device.model;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 3D模型文件详情实体类
|
||||
* 用于存储单个模型包含的所有文件信息
|
||||
*
|
||||
* @author claude
|
||||
* @date 2024-12-08
|
||||
*/
|
||||
@Data
|
||||
@TableName("3d_model_file_detail")
|
||||
@Schema(description = "3D模型文件详情")
|
||||
public class ThreeDModelFileDetail {
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
@Schema(description = "主键ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "关联的模型ID")
|
||||
private Long modelId;
|
||||
|
||||
@Schema(description = "文件名")
|
||||
private String fileName;
|
||||
|
||||
@Schema(description = "MinIO存储路径")
|
||||
private String filePath;
|
||||
|
||||
@Schema(description = "CDN访问URL")
|
||||
private String fileUrl;
|
||||
|
||||
@Schema(description = "文件大小(bytes)")
|
||||
private Long fileSize;
|
||||
|
||||
@Schema(description = "文件类型: tileset/b3dm/i3dm/pnts/cmpt/json/texture")
|
||||
private String fileType;
|
||||
|
||||
@Schema(description = "LOD层级(如L14, L15等)")
|
||||
private String lodLevel;
|
||||
|
||||
@Schema(description = "上传状态: 0-待上传 1-上传中 2-已完成 3-失败")
|
||||
private Integer uploadStatus;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "创建时间")
|
||||
private Date createTime;
|
||||
}
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.central.device.model.dto;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 3D模型文件DTO - 用于创建/更新操作
|
||||
*
|
||||
* @author claude
|
||||
* @date 2024-12-08
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "3D模型文件DTO")
|
||||
public class ThreeDModelFileDTO {
|
||||
|
||||
@Schema(description = "ID(更新时必填)")
|
||||
private Long id;
|
||||
|
||||
@NotBlank(message = "模型名称不能为空")
|
||||
@Schema(description = "模型名称", required = true)
|
||||
private String modelName;
|
||||
|
||||
@Schema(description = "模型类型: 1-倾斜摄影 2-点云 3-BIM 4-其他", defaultValue = "1")
|
||||
private Integer modelType = 1;
|
||||
|
||||
@Schema(description = "模型格式: 3dtiles/osgb/obj/ply/las", defaultValue = "3dtiles")
|
||||
private String modelFormat = "3dtiles";
|
||||
|
||||
@Schema(description = "模型描述")
|
||||
private String description;
|
||||
|
||||
@Schema(description = "关联景区ID")
|
||||
private Long tourismId;
|
||||
|
||||
@Schema(description = "关联景区名称")
|
||||
private String tourismName;
|
||||
|
||||
@Schema(description = "工作空间ID")
|
||||
private String workspaceId;
|
||||
|
||||
// ========== 位置调整参数 ==========
|
||||
|
||||
@Schema(description = "经度偏移(度)", defaultValue = "0")
|
||||
private BigDecimal offsetLongitude = BigDecimal.ZERO;
|
||||
|
||||
@Schema(description = "纬度偏移(度)", defaultValue = "0")
|
||||
private BigDecimal offsetLatitude = BigDecimal.ZERO;
|
||||
|
||||
@Schema(description = "高度偏移(米)", defaultValue = "0")
|
||||
private BigDecimal offsetHeight = BigDecimal.ZERO;
|
||||
|
||||
// ========== 变换参数 ==========
|
||||
|
||||
@Schema(description = "缩放比例", defaultValue = "1.0")
|
||||
private BigDecimal scale = BigDecimal.ONE;
|
||||
|
||||
@Schema(description = "X轴旋转(弧度)", defaultValue = "0")
|
||||
private BigDecimal rotationX = BigDecimal.ZERO;
|
||||
|
||||
@Schema(description = "Y轴旋转(弧度)", defaultValue = "0")
|
||||
private BigDecimal rotationY = BigDecimal.ZERO;
|
||||
|
||||
@Schema(description = "Z轴旋转(弧度)", defaultValue = "0")
|
||||
private BigDecimal rotationZ = BigDecimal.ZERO;
|
||||
|
||||
// ========== 渲染配置 ==========
|
||||
|
||||
@Schema(description = "LOD精度控制(默认16)", defaultValue = "16")
|
||||
private Integer maxScreenSpaceError = 16;
|
||||
|
||||
@Schema(description = "最大内存使用(MB)", defaultValue = "512")
|
||||
private Integer maxMemoryUsage = 512;
|
||||
|
||||
@Schema(description = "是否跳过LOD: 0-否 1-是", defaultValue = "1")
|
||||
private Integer skipLod = 1;
|
||||
|
||||
@Schema(description = "是否优先加载叶子节点: 0-否 1-是", defaultValue = "1")
|
||||
private Integer preferLeaves = 1;
|
||||
|
||||
// ========== 元数据 ==========
|
||||
|
||||
@Schema(description = "来源类型: dji_terra/cesium_ion/custom", defaultValue = "dji_terra")
|
||||
private String sourceType = "dji_terra";
|
||||
|
||||
@Schema(description = "状态: 0-禁用 1-启用", defaultValue = "1")
|
||||
private Integer status = 1;
|
||||
|
||||
@Schema(description = "租户ID")
|
||||
private String tenantId;
|
||||
}
|
||||
@@ -0,0 +1,208 @@
|
||||
package com.central.device.model.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 3D模型文件VO - 用于前端展示
|
||||
*
|
||||
* @author claude
|
||||
* @date 2024-12-08
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "3D模型文件VO")
|
||||
public class ThreeDModelFileVO {
|
||||
|
||||
@Schema(description = "ID")
|
||||
private Long id;
|
||||
|
||||
@Schema(description = "模型名称")
|
||||
private String modelName;
|
||||
|
||||
@Schema(description = "模型类型: 1-倾斜摄影 2-点云 3-BIM 4-其他")
|
||||
private Integer modelType;
|
||||
|
||||
@Schema(description = "模型类型名称")
|
||||
private String modelTypeName;
|
||||
|
||||
@Schema(description = "模型格式")
|
||||
private String modelFormat;
|
||||
|
||||
@Schema(description = "模型描述")
|
||||
private String description;
|
||||
|
||||
// ========== 文件信息 ==========
|
||||
|
||||
@Schema(description = "tileset.json的CDN访问URL")
|
||||
private String tilesetUrl;
|
||||
|
||||
@Schema(description = "模型文件总数")
|
||||
private Integer fileCount;
|
||||
|
||||
@Schema(description = "模型文件总大小(bytes)")
|
||||
private Long totalSize;
|
||||
|
||||
@Schema(description = "格式化的文件大小")
|
||||
private String totalSizeFormat;
|
||||
|
||||
// ========== 关联信息 ==========
|
||||
|
||||
@Schema(description = "关联景区ID")
|
||||
private Long tourismId;
|
||||
|
||||
@Schema(description = "关联景区名称")
|
||||
private String tourismName;
|
||||
|
||||
// ========== 位置参数 ==========
|
||||
|
||||
@Schema(description = "位置配置")
|
||||
private PositionConfig position;
|
||||
|
||||
@Schema(description = "变换配置")
|
||||
private TransformConfig transform;
|
||||
|
||||
@Schema(description = "渲染样式配置")
|
||||
private StyleConfig style;
|
||||
|
||||
// ========== 状态信息 ==========
|
||||
|
||||
@Schema(description = "状态: 0-禁用 1-启用 2-处理中")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "状态名称")
|
||||
private String statusName;
|
||||
|
||||
@Schema(description = "上传状态: 0-待上传 1-上传中 2-已完成 3-失败")
|
||||
private Integer uploadStatus;
|
||||
|
||||
@Schema(description = "上传状态名称")
|
||||
private String uploadStatusName;
|
||||
|
||||
@Schema(description = "上传进度(0-100)")
|
||||
private Integer uploadProgress;
|
||||
|
||||
@Schema(description = "缩略图URL")
|
||||
private String thumbnailUrl;
|
||||
|
||||
@Schema(description = "来源类型")
|
||||
private String sourceType;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
private Date createTime;
|
||||
|
||||
@Schema(description = "更新时间")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 位置配置
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "位置配置")
|
||||
public static class PositionConfig {
|
||||
@Schema(description = "经度偏移")
|
||||
private BigDecimal longitude;
|
||||
|
||||
@Schema(description = "纬度偏移")
|
||||
private BigDecimal latitude;
|
||||
|
||||
@Schema(description = "高度偏移")
|
||||
private BigDecimal height;
|
||||
}
|
||||
|
||||
/**
|
||||
* 变换配置
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "变换配置")
|
||||
public static class TransformConfig {
|
||||
@Schema(description = "缩放比例")
|
||||
private BigDecimal scale;
|
||||
|
||||
@Schema(description = "X轴旋转")
|
||||
private BigDecimal rotationX;
|
||||
|
||||
@Schema(description = "Y轴旋转")
|
||||
private BigDecimal rotationY;
|
||||
|
||||
@Schema(description = "Z轴旋转")
|
||||
private BigDecimal rotationZ;
|
||||
}
|
||||
|
||||
/**
|
||||
* 渲染样式配置
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "渲染样式配置")
|
||||
public static class StyleConfig {
|
||||
@Schema(description = "LOD精度")
|
||||
private Integer maximumScreenSpaceError;
|
||||
|
||||
@Schema(description = "最大内存(MB)")
|
||||
private Integer maximumMemoryUsage;
|
||||
|
||||
@Schema(description = "跳过LOD")
|
||||
private Boolean skipLevelOfDetail;
|
||||
|
||||
@Schema(description = "优先叶子节点")
|
||||
private Boolean preferLeaves;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取模型类型名称
|
||||
*/
|
||||
public String getModelTypeName() {
|
||||
if (modelType == null) return "未知";
|
||||
switch (modelType) {
|
||||
case 1: return "倾斜摄影";
|
||||
case 2: return "点云";
|
||||
case 3: return "BIM";
|
||||
case 4: return "其他";
|
||||
default: return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取状态名称
|
||||
*/
|
||||
public String getStatusName() {
|
||||
if (status == null) return "未知";
|
||||
switch (status) {
|
||||
case 0: return "禁用";
|
||||
case 1: return "启用";
|
||||
case 2: return "处理中";
|
||||
default: return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取上传状态名称
|
||||
*/
|
||||
public String getUploadStatusName() {
|
||||
if (uploadStatus == null) return "未知";
|
||||
switch (uploadStatus) {
|
||||
case 0: return "待上传";
|
||||
case 1: return "上传中";
|
||||
case 2: return "已完成";
|
||||
case 3: return "失败";
|
||||
default: return "未知";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取格式化的文件大小
|
||||
*/
|
||||
public String getTotalSizeFormat() {
|
||||
if (totalSize == null || totalSize == 0) return "0 B";
|
||||
String[] units = {"B", "KB", "MB", "GB", "TB"};
|
||||
int unitIndex = 0;
|
||||
double size = totalSize;
|
||||
while (size >= 1024 && unitIndex < units.length - 1) {
|
||||
size /= 1024;
|
||||
unitIndex++;
|
||||
}
|
||||
return String.format("%.2f %s", size, units[unitIndex]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package com.central.device.service;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.service.ISuperService;
|
||||
import com.central.device.model.ThreeDModelFile;
|
||||
import com.central.device.model.dto.ThreeDModelFileDTO;
|
||||
import com.central.device.model.vo.ThreeDModelFileVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 3D模型文件服务接口
|
||||
*
|
||||
* @author claude
|
||||
* @date 2024-12-08
|
||||
*/
|
||||
public interface IThreeDModelFileService extends ISuperService<ThreeDModelFile> {
|
||||
|
||||
/**
|
||||
* 分页查询模型列表
|
||||
*
|
||||
* @param params 查询参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResult<ThreeDModelFileVO> findList(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 根据ID获取模型详情
|
||||
*
|
||||
* @param id 模型ID
|
||||
* @return 模型VO
|
||||
*/
|
||||
ThreeDModelFileVO getDetailById(Long id);
|
||||
|
||||
/**
|
||||
* 根据景区ID获取模型列表(用于前端加载)
|
||||
*
|
||||
* @param tourismId 景区ID
|
||||
* @return 模型列表
|
||||
*/
|
||||
List<ThreeDModelFileVO> getByTourismId(Long tourismId);
|
||||
|
||||
/**
|
||||
* 获取所有可用模型列表(用于前端3D地图加载)
|
||||
*
|
||||
* @return 模型列表
|
||||
*/
|
||||
List<ThreeDModelFileVO> getAllAvailableModels();
|
||||
|
||||
/**
|
||||
* 创建模型记录(不含文件上传)
|
||||
*
|
||||
* @param dto 模型信息
|
||||
* @return 模型ID
|
||||
*/
|
||||
Long create(ThreeDModelFileDTO dto);
|
||||
|
||||
/**
|
||||
* 更新模型信息
|
||||
*
|
||||
* @param dto 模型信息
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean update(ThreeDModelFileDTO dto);
|
||||
|
||||
/**
|
||||
* 删除模型(逻辑删除)
|
||||
*
|
||||
* @param id 模型ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean delete(Long id);
|
||||
|
||||
/**
|
||||
* 上传模型文件夹(批量上传所有文件)
|
||||
*
|
||||
* @param modelId 模型ID
|
||||
* @param files 文件列表
|
||||
* @param basePath 基础路径(文件夹结构)
|
||||
* @return 上传结果
|
||||
*/
|
||||
Map<String, Object> uploadModelFiles(Long modelId, MultipartFile[] files, String basePath);
|
||||
|
||||
/**
|
||||
* 上传单个模型文件
|
||||
*
|
||||
* @param modelId 模型ID
|
||||
* @param file 文件
|
||||
* @param filePath 文件相对路径
|
||||
* @return 文件CDN URL
|
||||
*/
|
||||
String uploadSingleFile(Long modelId, MultipartFile file, String filePath);
|
||||
|
||||
/**
|
||||
* 完成上传(更新状态和统计信息)
|
||||
*
|
||||
* @param modelId 模型ID
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean completeUpload(Long modelId);
|
||||
|
||||
/**
|
||||
* 更新上传进度
|
||||
*
|
||||
* @param modelId 模型ID
|
||||
* @param progress 进度(0-100)
|
||||
*/
|
||||
void updateProgress(Long modelId, Integer progress);
|
||||
|
||||
/**
|
||||
* 启用/禁用模型
|
||||
*
|
||||
* @param id 模型ID
|
||||
* @param status 状态
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean updateStatus(Long id, Integer status);
|
||||
|
||||
/**
|
||||
* 关联景区
|
||||
*
|
||||
* @param id 模型ID
|
||||
* @param tourismId 景区ID
|
||||
* @param tourismName 景区名称
|
||||
* @return 是否成功
|
||||
*/
|
||||
boolean bindTourism(Long id, Long tourismId, String tourismName);
|
||||
}
|
||||
@@ -0,0 +1,434 @@
|
||||
package com.central.device.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.common.service.impl.SuperServiceImpl;
|
||||
import com.central.device.feign.FileCenterService;
|
||||
import com.central.device.mapper.ThreeDModelFileDetailMapper;
|
||||
import com.central.device.mapper.ThreeDModelFileMapper;
|
||||
import com.central.device.model.ThreeDModelFile;
|
||||
import com.central.device.model.ThreeDModelFileDetail;
|
||||
import com.central.device.model.dto.ThreeDModelFileDTO;
|
||||
import com.central.device.model.vo.ThreeDModelFileVO;
|
||||
import com.central.device.service.IThreeDModelFileService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 3D模型文件服务实现类
|
||||
*
|
||||
* @author claude
|
||||
* @date 2024-12-08
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class ThreeDModelFileServiceImpl extends SuperServiceImpl<ThreeDModelFileMapper, ThreeDModelFile>
|
||||
implements IThreeDModelFileService {
|
||||
|
||||
private final ThreeDModelFileDetailMapper detailMapper;
|
||||
private final FileCenterService fileCenterService;
|
||||
|
||||
@Override
|
||||
public PageResult<ThreeDModelFileVO> findList(Map<String, Object> params) {
|
||||
Page<ThreeDModelFile> page = new Page<>(
|
||||
MapUtils.getInteger(params, "page", 1),
|
||||
MapUtils.getInteger(params, "limit", 10)
|
||||
);
|
||||
List<ThreeDModelFile> list = baseMapper.findList(page, params);
|
||||
List<ThreeDModelFileVO> voList = list.stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return PageResult.<ThreeDModelFileVO>builder()
|
||||
.data(voList)
|
||||
.resp_code(0)
|
||||
.count(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThreeDModelFileVO getDetailById(Long id) {
|
||||
ThreeDModelFile model = getById(id);
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
return convertToVO(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ThreeDModelFileVO> getByTourismId(Long tourismId) {
|
||||
List<ThreeDModelFile> list = baseMapper.findByTourismId(tourismId);
|
||||
return list.stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ThreeDModelFileVO> getAllAvailableModels() {
|
||||
Map<String, Object> params = new HashMap<>();
|
||||
params.put("status", 1);
|
||||
params.put("uploadStatus", 2); // 已完成上传
|
||||
params.put("page", 1);
|
||||
params.put("limit", 1000);
|
||||
|
||||
Page<ThreeDModelFile> page = new Page<>(1, 1000);
|
||||
List<ThreeDModelFile> list = baseMapper.findList(page, params);
|
||||
return list.stream()
|
||||
.map(this::convertToVO)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long create(ThreeDModelFileDTO dto) {
|
||||
ThreeDModelFile model = new ThreeDModelFile();
|
||||
BeanUtil.copyProperties(dto, model);
|
||||
|
||||
// 设置默认值
|
||||
model.setBucketName("goflymodel");
|
||||
model.setUploadStatus(0); // 待上传
|
||||
model.setUploadProgress(0);
|
||||
model.setFileCount(0);
|
||||
model.setTotalSize(0L);
|
||||
model.setTilesetUrl("");
|
||||
model.setTilesetPath("");
|
||||
model.setStatus(0); // 默认禁用,上传完成后启用
|
||||
|
||||
// 生成文件夹路径
|
||||
String folderPath = generateFolderPath(dto.getModelName());
|
||||
model.setFolderPath(folderPath);
|
||||
|
||||
save(model);
|
||||
return model.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean update(ThreeDModelFileDTO dto) {
|
||||
if (dto.getId() == null) {
|
||||
throw new IllegalArgumentException("ID不能为空");
|
||||
}
|
||||
ThreeDModelFile model = getById(dto.getId());
|
||||
if (model == null) {
|
||||
throw new IllegalArgumentException("模型不存在");
|
||||
}
|
||||
|
||||
// 更新字段
|
||||
if (StrUtil.isNotBlank(dto.getModelName())) {
|
||||
model.setModelName(dto.getModelName());
|
||||
}
|
||||
if (dto.getModelType() != null) {
|
||||
model.setModelType(dto.getModelType());
|
||||
}
|
||||
if (StrUtil.isNotBlank(dto.getDescription())) {
|
||||
model.setDescription(dto.getDescription());
|
||||
}
|
||||
if (dto.getTourismId() != null) {
|
||||
model.setTourismId(dto.getTourismId());
|
||||
model.setTourismName(dto.getTourismName());
|
||||
}
|
||||
|
||||
// 更新位置参数
|
||||
if (dto.getOffsetLongitude() != null) {
|
||||
model.setOffsetLongitude(dto.getOffsetLongitude());
|
||||
}
|
||||
if (dto.getOffsetLatitude() != null) {
|
||||
model.setOffsetLatitude(dto.getOffsetLatitude());
|
||||
}
|
||||
if (dto.getOffsetHeight() != null) {
|
||||
model.setOffsetHeight(dto.getOffsetHeight());
|
||||
}
|
||||
|
||||
// 更新变换参数
|
||||
if (dto.getScale() != null) {
|
||||
model.setScale(dto.getScale());
|
||||
}
|
||||
if (dto.getRotationX() != null) {
|
||||
model.setRotationX(dto.getRotationX());
|
||||
}
|
||||
if (dto.getRotationY() != null) {
|
||||
model.setRotationY(dto.getRotationY());
|
||||
}
|
||||
if (dto.getRotationZ() != null) {
|
||||
model.setRotationZ(dto.getRotationZ());
|
||||
}
|
||||
|
||||
// 更新渲染配置
|
||||
if (dto.getMaxScreenSpaceError() != null) {
|
||||
model.setMaxScreenSpaceError(dto.getMaxScreenSpaceError());
|
||||
}
|
||||
if (dto.getMaxMemoryUsage() != null) {
|
||||
model.setMaxMemoryUsage(dto.getMaxMemoryUsage());
|
||||
}
|
||||
if (dto.getSkipLod() != null) {
|
||||
model.setSkipLod(dto.getSkipLod());
|
||||
}
|
||||
if (dto.getPreferLeaves() != null) {
|
||||
model.setPreferLeaves(dto.getPreferLeaves());
|
||||
}
|
||||
|
||||
if (dto.getStatus() != null) {
|
||||
model.setStatus(dto.getStatus());
|
||||
}
|
||||
|
||||
return updateById(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean delete(Long id) {
|
||||
ThreeDModelFile model = getById(id);
|
||||
if (model == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 删除MinIO中的文件(可选,也可以保留)
|
||||
// minioUploadService.deleteFolder(model.getBucketName(), model.getFolderPath());
|
||||
|
||||
// 删除文件详情
|
||||
detailMapper.deleteByModelId(id);
|
||||
|
||||
// 逻辑删除模型
|
||||
model.setIsDel(1);
|
||||
return updateById(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Map<String, Object> uploadModelFiles(Long modelId, MultipartFile[] files, String basePath) {
|
||||
ThreeDModelFile model = getById(modelId);
|
||||
if (model == null) {
|
||||
throw new IllegalArgumentException("模型不存在");
|
||||
}
|
||||
|
||||
// 更新上传状态
|
||||
model.setUploadStatus(1); // 上传中
|
||||
updateById(model);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
List<String> successFiles = new ArrayList<>();
|
||||
List<String> failedFiles = new ArrayList<>();
|
||||
long totalSize = 0;
|
||||
|
||||
try {
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
MultipartFile file = files[i];
|
||||
String relativePath = StrUtil.isNotBlank(basePath) ?
|
||||
basePath + "/" + file.getOriginalFilename() :
|
||||
file.getOriginalFilename();
|
||||
|
||||
try {
|
||||
String fileUrl = uploadSingleFile(modelId, file, relativePath);
|
||||
successFiles.add(relativePath);
|
||||
totalSize += file.getSize();
|
||||
|
||||
// 更新进度
|
||||
int progress = (int) ((i + 1) * 100.0 / files.length);
|
||||
updateProgress(modelId, progress);
|
||||
} catch (Exception e) {
|
||||
log.error("上传文件失败: {}", relativePath, e);
|
||||
failedFiles.add(relativePath);
|
||||
}
|
||||
}
|
||||
|
||||
// 完成上传
|
||||
if (failedFiles.isEmpty()) {
|
||||
completeUpload(modelId);
|
||||
} else {
|
||||
model.setUploadStatus(3); // 部分失败
|
||||
updateById(model);
|
||||
}
|
||||
|
||||
result.put("success", true);
|
||||
result.put("successFiles", successFiles);
|
||||
result.put("failedFiles", failedFiles);
|
||||
result.put("totalSize", totalSize);
|
||||
result.put("tilesetUrl", model.getTilesetUrl());
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("批量上传文件失败", e);
|
||||
model.setUploadStatus(3); // 失败
|
||||
updateById(model);
|
||||
result.put("success", false);
|
||||
result.put("error", e.getMessage());
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String uploadSingleFile(Long modelId, MultipartFile file, String filePath) {
|
||||
ThreeDModelFile model = getById(modelId);
|
||||
if (model == null) {
|
||||
throw new IllegalArgumentException("模型不存在");
|
||||
}
|
||||
|
||||
String folderPath = model.getFolderPath();
|
||||
|
||||
// 通过Feign调用file-center上传到MinIO
|
||||
Result<Map<String, Object>> uploadResult = fileCenterService.uploadModelFile(file, folderPath, filePath);
|
||||
if (uploadResult == null || uploadResult.getResp_code() != 0) {
|
||||
String errorMsg = uploadResult != null ? uploadResult.getResp_msg() : "上传失败";
|
||||
throw new RuntimeException("上传文件失败: " + errorMsg);
|
||||
}
|
||||
|
||||
Map<String, Object> resultData = uploadResult.getData();
|
||||
String fileUrl = (String) resultData.get("cdnUrl");
|
||||
String objectKey = (String) resultData.get("objectKey");
|
||||
|
||||
// 保存文件详情
|
||||
ThreeDModelFileDetail detail = new ThreeDModelFileDetail();
|
||||
detail.setModelId(modelId);
|
||||
detail.setFileName(file.getOriginalFilename());
|
||||
detail.setFilePath(objectKey);
|
||||
detail.setFileUrl(fileUrl);
|
||||
detail.setFileSize(file.getSize());
|
||||
detail.setFileType(getFileType(file.getOriginalFilename()));
|
||||
detail.setLodLevel(extractLodLevel(file.getOriginalFilename()));
|
||||
detail.setUploadStatus(2); // 已完成
|
||||
detailMapper.insert(detail);
|
||||
|
||||
// 如果是tileset.json,更新主记录
|
||||
if (filePath.endsWith("tileset.json") && !filePath.contains("/Block/")) {
|
||||
model.setTilesetPath(objectKey);
|
||||
model.setTilesetUrl(fileUrl);
|
||||
updateById(model);
|
||||
}
|
||||
|
||||
return fileUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean completeUpload(Long modelId) {
|
||||
ThreeDModelFile model = getById(modelId);
|
||||
if (model == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 统计文件信息
|
||||
Map<String, Object> stats = detailMapper.countFileStats(modelId);
|
||||
int fileCount = ((Number) stats.get("count")).intValue();
|
||||
long totalSize = ((Number) stats.get("totalSize")).longValue();
|
||||
|
||||
model.setFileCount(fileCount);
|
||||
model.setTotalSize(totalSize);
|
||||
model.setUploadStatus(2); // 已完成
|
||||
model.setUploadProgress(100);
|
||||
model.setStatus(1); // 启用
|
||||
|
||||
return updateById(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgress(Long modelId, Integer progress) {
|
||||
baseMapper.updateUploadProgress(modelId, 1, progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateStatus(Long id, Integer status) {
|
||||
ThreeDModelFile model = getById(id);
|
||||
if (model == null) {
|
||||
return false;
|
||||
}
|
||||
model.setStatus(status);
|
||||
return updateById(model);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean bindTourism(Long id, Long tourismId, String tourismName) {
|
||||
ThreeDModelFile model = getById(id);
|
||||
if (model == null) {
|
||||
return false;
|
||||
}
|
||||
model.setTourismId(tourismId);
|
||||
model.setTourismName(tourismName);
|
||||
return updateById(model);
|
||||
}
|
||||
|
||||
/**
|
||||
* 转换为VO
|
||||
*/
|
||||
private ThreeDModelFileVO convertToVO(ThreeDModelFile model) {
|
||||
ThreeDModelFileVO vo = new ThreeDModelFileVO();
|
||||
BeanUtil.copyProperties(model, vo);
|
||||
|
||||
// 设置位置配置
|
||||
ThreeDModelFileVO.PositionConfig position = new ThreeDModelFileVO.PositionConfig();
|
||||
position.setLongitude(model.getOffsetLongitude());
|
||||
position.setLatitude(model.getOffsetLatitude());
|
||||
position.setHeight(model.getOffsetHeight());
|
||||
vo.setPosition(position);
|
||||
|
||||
// 设置变换配置
|
||||
ThreeDModelFileVO.TransformConfig transform = new ThreeDModelFileVO.TransformConfig();
|
||||
transform.setScale(model.getScale());
|
||||
transform.setRotationX(model.getRotationX());
|
||||
transform.setRotationY(model.getRotationY());
|
||||
transform.setRotationZ(model.getRotationZ());
|
||||
vo.setTransform(transform);
|
||||
|
||||
// 设置样式配置
|
||||
ThreeDModelFileVO.StyleConfig style = new ThreeDModelFileVO.StyleConfig();
|
||||
style.setMaximumScreenSpaceError(model.getMaxScreenSpaceError());
|
||||
style.setMaximumMemoryUsage(model.getMaxMemoryUsage());
|
||||
style.setSkipLevelOfDetail(model.getSkipLod() != null && model.getSkipLod() == 1);
|
||||
style.setPreferLeaves(model.getPreferLeaves() != null && model.getPreferLeaves() == 1);
|
||||
vo.setStyle(style);
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成文件夹路径
|
||||
*/
|
||||
private String generateFolderPath(String modelName) {
|
||||
String timestamp = String.valueOf(System.currentTimeMillis());
|
||||
String safeName = modelName.replaceAll("[^a-zA-Z0-9\\u4e00-\\u9fa5]", "_");
|
||||
return "model_" + timestamp + "_" + safeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件类型
|
||||
*/
|
||||
private String getFileType(String fileName) {
|
||||
if (fileName == null) return "other";
|
||||
String lower = fileName.toLowerCase();
|
||||
if (lower.endsWith(".json")) return "json";
|
||||
if (lower.endsWith(".b3dm")) return "b3dm";
|
||||
if (lower.endsWith(".i3dm")) return "i3dm";
|
||||
if (lower.endsWith(".pnts")) return "pnts";
|
||||
if (lower.endsWith(".cmpt")) return "cmpt";
|
||||
if (lower.endsWith(".glb") || lower.endsWith(".gltf")) return "gltf";
|
||||
if (lower.endsWith(".jpg") || lower.endsWith(".jpeg") || lower.endsWith(".png")) return "texture";
|
||||
return "other";
|
||||
}
|
||||
|
||||
/**
|
||||
* 提取LOD层级
|
||||
*/
|
||||
private String extractLodLevel(String fileName) {
|
||||
if (fileName == null) return null;
|
||||
// 匹配 L14, L15 等模式
|
||||
java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("L(\\d+)");
|
||||
java.util.regex.Matcher matcher = pattern.matcher(fileName);
|
||||
if (matcher.find()) {
|
||||
return "L" + matcher.group(1);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.central.device.mapper.ThreeDModelFileMapper">
|
||||
|
||||
<!-- 分页查询 -->
|
||||
<select id="findList" resultType="com.central.device.model.ThreeDModelFile">
|
||||
SELECT * FROM 3d_model_file t
|
||||
WHERE t.is_del = 0
|
||||
<if test="p.modelName != null and p.modelName != ''">
|
||||
AND t.model_name LIKE CONCAT('%', #{p.modelName}, '%')
|
||||
</if>
|
||||
<if test="p.modelType != null">
|
||||
AND t.model_type = #{p.modelType}
|
||||
</if>
|
||||
<if test="p.tourismId != null">
|
||||
AND t.tourism_id = #{p.tourismId}
|
||||
</if>
|
||||
<if test="p.tourismName != null and p.tourismName != ''">
|
||||
AND t.tourism_name LIKE CONCAT('%', #{p.tourismName}, '%')
|
||||
</if>
|
||||
<if test="p.workspaceId != null and p.workspaceId != ''">
|
||||
AND t.workspace_id = #{p.workspaceId}
|
||||
</if>
|
||||
<if test="p.status != null">
|
||||
AND t.status = #{p.status}
|
||||
</if>
|
||||
<if test="p.uploadStatus != null">
|
||||
AND t.upload_status = #{p.uploadStatus}
|
||||
</if>
|
||||
<if test="p.tenantId != null and p.tenantId != ''">
|
||||
AND t.tenant_id = #{p.tenantId}
|
||||
</if>
|
||||
<if test="p.sourceType != null and p.sourceType != ''">
|
||||
AND t.source_type = #{p.sourceType}
|
||||
</if>
|
||||
<if test="p.startTime != null">
|
||||
AND t.create_time >= #{p.startTime}
|
||||
</if>
|
||||
<if test="p.endTime != null">
|
||||
AND t.create_time <= #{p.endTime}
|
||||
</if>
|
||||
ORDER BY t.create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,129 @@
|
||||
package com.central.file.controller;
|
||||
|
||||
import com.central.common.model.Result;
|
||||
import com.central.file.service.ModelFileUploadService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 3D模型文件上传Controller
|
||||
* 专用于上传到MinIO的goflymodel桶
|
||||
*
|
||||
* @author claude
|
||||
* @date 2024-12-08
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/model-file")
|
||||
@RequiredArgsConstructor
|
||||
@Tag(name = "3D模型文件上传")
|
||||
public class ModelFileController {
|
||||
|
||||
private final ModelFileUploadService modelFileUploadService;
|
||||
|
||||
/**
|
||||
* 上传单个模型文件
|
||||
*
|
||||
* @param file 文件
|
||||
* @param folderPath 文件夹路径(模型文件夹名称)
|
||||
* @param filePath 文件相对路径(相对于文件夹)
|
||||
* @return CDN访问URL
|
||||
*/
|
||||
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
@Operation(summary = "上传单个模型文件")
|
||||
public Result<Map<String, Object>> uploadFile(
|
||||
@Parameter(description = "文件") @RequestParam("file") MultipartFile file,
|
||||
@Parameter(description = "模型文件夹路径") @RequestParam("folderPath") String folderPath,
|
||||
@Parameter(description = "文件相对路径") @RequestParam("filePath") String filePath) {
|
||||
try {
|
||||
Map<String, Object> result = modelFileUploadService.uploadFile(folderPath, filePath, file);
|
||||
return Result.succeed(result, "上传成功");
|
||||
} catch (Exception e) {
|
||||
log.error("上传模型文件失败: folderPath={}, filePath={}", folderPath, filePath, e);
|
||||
return Result.failed("上传失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量上传模型文件
|
||||
*
|
||||
* @param files 文件列表
|
||||
* @param folderPath 文件夹路径
|
||||
* @param filePaths 文件相对路径列表(与files一一对应)
|
||||
* @return 上传结果
|
||||
*/
|
||||
@PostMapping(value = "/upload/batch", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||||
@Operation(summary = "批量上传模型文件")
|
||||
public Result<Map<String, Object>> uploadFiles(
|
||||
@Parameter(description = "文件列表") @RequestParam("files") MultipartFile[] files,
|
||||
@Parameter(description = "模型文件夹路径") @RequestParam("folderPath") String folderPath,
|
||||
@Parameter(description = "文件相对路径列表") @RequestParam("filePaths") List<String> filePaths) {
|
||||
try {
|
||||
Map<String, Object> result = modelFileUploadService.uploadFiles(folderPath, files, filePaths);
|
||||
return Result.succeed(result);
|
||||
} catch (Exception e) {
|
||||
log.error("批量上传模型文件失败: folderPath={}", folderPath, e);
|
||||
return Result.failed("上传失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除模型文件夹(所有文件)
|
||||
*
|
||||
* @param folderPath 文件夹路径
|
||||
* @return 操作结果
|
||||
*/
|
||||
@DeleteMapping("/folder")
|
||||
@Operation(summary = "删除模型文件夹")
|
||||
public Result<Void> deleteFolder(
|
||||
@Parameter(description = "文件夹路径") @RequestParam("folderPath") String folderPath) {
|
||||
try {
|
||||
modelFileUploadService.deleteFolder(folderPath);
|
||||
return Result.succeed("删除成功");
|
||||
} catch (Exception e) {
|
||||
log.error("删除模型文件夹失败: folderPath={}", folderPath, e);
|
||||
return Result.failed("删除失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查文件是否存在
|
||||
*
|
||||
* @param folderPath 文件夹路径
|
||||
* @param filePath 文件相对路径
|
||||
* @return 是否存在
|
||||
*/
|
||||
@GetMapping("/exists")
|
||||
@Operation(summary = "检查文件是否存在")
|
||||
public Result<Boolean> checkFileExists(
|
||||
@Parameter(description = "文件夹路径") @RequestParam("folderPath") String folderPath,
|
||||
@Parameter(description = "文件相对路径") @RequestParam("filePath") String filePath) {
|
||||
boolean exists = modelFileUploadService.fileExists(folderPath, filePath);
|
||||
return Result.succeed(exists);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件CDN访问URL
|
||||
*
|
||||
* @param folderPath 文件夹路径
|
||||
* @param filePath 文件相对路径
|
||||
* @return CDN URL
|
||||
*/
|
||||
@GetMapping("/url")
|
||||
@Operation(summary = "获取文件CDN URL")
|
||||
public Result<String> getFileUrl(
|
||||
@Parameter(description = "文件夹路径") @RequestParam("folderPath") String folderPath,
|
||||
@Parameter(description = "文件相对路径") @RequestParam("filePath") String filePath) {
|
||||
String url = modelFileUploadService.getFileUrl(folderPath, filePath);
|
||||
return Result.succeed(url);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,278 @@
|
||||
package com.central.file.service;
|
||||
|
||||
import com.amazonaws.services.s3.AmazonS3;
|
||||
import com.amazonaws.services.s3.model.*;
|
||||
import com.central.oss.template.S3Template;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 3D模型文件上传服务
|
||||
* 专用于上传到MinIO的goflymodel桶
|
||||
*
|
||||
* @author claude
|
||||
* @date 2024-12-08
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
public class ModelFileUploadService {
|
||||
|
||||
private static final String MODEL_BUCKET = "goflymodel";
|
||||
|
||||
@Autowired(required = false)
|
||||
private S3Template s3Template;
|
||||
|
||||
@Value("${zlt.file-server.s3.endpoint:}")
|
||||
private String endpoint;
|
||||
|
||||
@Value("${cdn.s3.domain:minicdn.goflytec.com}")
|
||||
private String cdnDomain;
|
||||
|
||||
@Value("${cdn.s3.enabled:true}")
|
||||
private boolean cdnEnabled;
|
||||
|
||||
private AmazonS3 amazonS3;
|
||||
|
||||
@PostConstruct
|
||||
public void init() {
|
||||
if (s3Template != null) {
|
||||
this.amazonS3 = s3Template.getAmazonS3();
|
||||
ensureBucketExists();
|
||||
} else {
|
||||
log.warn("S3Template未配置,3D模型上传服务不可用");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 确保bucket存在
|
||||
*/
|
||||
private void ensureBucketExists() {
|
||||
if (amazonS3 == null) return;
|
||||
try {
|
||||
if (!amazonS3.doesBucketExistV2(MODEL_BUCKET)) {
|
||||
amazonS3.createBucket(MODEL_BUCKET);
|
||||
log.info("创建bucket成功: {}", MODEL_BUCKET);
|
||||
|
||||
// 设置bucket为公共读取
|
||||
amazonS3.setBucketPolicy(MODEL_BUCKET, getPublicReadPolicy());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.warn("检查/创建bucket失败: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取公共读取策略
|
||||
*/
|
||||
private String getPublicReadPolicy() {
|
||||
return "{\n" +
|
||||
" \"Version\": \"2012-10-17\",\n" +
|
||||
" \"Statement\": [\n" +
|
||||
" {\n" +
|
||||
" \"Effect\": \"Allow\",\n" +
|
||||
" \"Principal\": \"*\",\n" +
|
||||
" \"Action\": [\"s3:GetObject\"],\n" +
|
||||
" \"Resource\": [\"arn:aws:s3:::" + MODEL_BUCKET + "/*\"]\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
"}";
|
||||
}
|
||||
|
||||
/**
|
||||
* 上传单个文件
|
||||
*
|
||||
* @param folderPath 文件夹路径
|
||||
* @param filePath 文件相对路径
|
||||
* @param file 文件
|
||||
* @return 上传结果 {objectKey, cdnUrl, directUrl, fileSize}
|
||||
*/
|
||||
public Map<String, Object> uploadFile(String folderPath, String filePath, MultipartFile file) {
|
||||
if (amazonS3 == null) {
|
||||
throw new RuntimeException("S3服务未初始化");
|
||||
}
|
||||
|
||||
String objectKey = folderPath + "/" + filePath;
|
||||
|
||||
try (InputStream inputStream = file.getInputStream()) {
|
||||
ObjectMetadata metadata = new ObjectMetadata();
|
||||
metadata.setContentLength(file.getSize());
|
||||
metadata.setContentType(getContentType(file.getOriginalFilename()));
|
||||
|
||||
PutObjectRequest request = new PutObjectRequest(MODEL_BUCKET, objectKey, inputStream, metadata);
|
||||
request.getRequestClientOptions().setReadLimit((int) file.getSize() + 1);
|
||||
|
||||
amazonS3.putObject(request);
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("objectKey", objectKey);
|
||||
result.put("cdnUrl", buildCdnUrl(objectKey));
|
||||
result.put("directUrl", buildDirectUrl(objectKey));
|
||||
result.put("fileSize", file.getSize());
|
||||
|
||||
log.debug("上传文件成功: {}", objectKey);
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
log.error("上传文件到MinIO失败: bucket={}, key={}", MODEL_BUCKET, objectKey, e);
|
||||
throw new RuntimeException("文件上传失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量上传文件
|
||||
*
|
||||
* @param folderPath 文件夹路径
|
||||
* @param files 文件数组
|
||||
* @param filePaths 对应的文件路径列表
|
||||
* @return 上传结果
|
||||
*/
|
||||
public Map<String, Object> uploadFiles(String folderPath, MultipartFile[] files, List<String> filePaths) {
|
||||
if (files.length != filePaths.size()) {
|
||||
throw new IllegalArgumentException("文件数量与路径数量不匹配");
|
||||
}
|
||||
|
||||
List<Map<String, Object>> successList = new ArrayList<>();
|
||||
List<Map<String, Object>> failedList = new ArrayList<>();
|
||||
long totalSize = 0;
|
||||
|
||||
for (int i = 0; i < files.length; i++) {
|
||||
MultipartFile file = files[i];
|
||||
String filePath = filePaths.get(i);
|
||||
|
||||
try {
|
||||
Map<String, Object> result = uploadFile(folderPath, filePath, file);
|
||||
successList.add(result);
|
||||
totalSize += file.getSize();
|
||||
} catch (Exception e) {
|
||||
Map<String, Object> failed = new HashMap<>();
|
||||
failed.put("filePath", filePath);
|
||||
failed.put("error", e.getMessage());
|
||||
failedList.add(failed);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> result = new HashMap<>();
|
||||
result.put("success", failedList.isEmpty());
|
||||
result.put("successCount", successList.size());
|
||||
result.put("failedCount", failedList.size());
|
||||
result.put("successFiles", successList);
|
||||
result.put("failedFiles", failedList);
|
||||
result.put("totalSize", totalSize);
|
||||
|
||||
// 如果有tileset.json,返回其URL
|
||||
for (Map<String, Object> item : successList) {
|
||||
String key = (String) item.get("objectKey");
|
||||
if (key != null && key.endsWith("tileset.json") && !key.contains("/Block/")) {
|
||||
result.put("tilesetUrl", item.get("cdnUrl"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除文件夹(批量删除)
|
||||
*
|
||||
* @param folderPath 文件夹路径
|
||||
*/
|
||||
public void deleteFolder(String folderPath) {
|
||||
if (amazonS3 == null) {
|
||||
throw new RuntimeException("S3服务未初始化");
|
||||
}
|
||||
|
||||
try {
|
||||
ListObjectsV2Request listRequest = new ListObjectsV2Request()
|
||||
.withBucketName(MODEL_BUCKET)
|
||||
.withPrefix(folderPath);
|
||||
|
||||
ListObjectsV2Result result;
|
||||
List<DeleteObjectsRequest.KeyVersion> keysToDelete = new ArrayList<>();
|
||||
|
||||
do {
|
||||
result = amazonS3.listObjectsV2(listRequest);
|
||||
for (S3ObjectSummary summary : result.getObjectSummaries()) {
|
||||
keysToDelete.add(new DeleteObjectsRequest.KeyVersion(summary.getKey()));
|
||||
}
|
||||
listRequest.setContinuationToken(result.getNextContinuationToken());
|
||||
} while (result.isTruncated());
|
||||
|
||||
if (!keysToDelete.isEmpty()) {
|
||||
DeleteObjectsRequest deleteRequest = new DeleteObjectsRequest(MODEL_BUCKET)
|
||||
.withKeys(keysToDelete);
|
||||
amazonS3.deleteObjects(deleteRequest);
|
||||
log.info("批量删除文件成功: {}/{}, 共{}个文件", MODEL_BUCKET, folderPath, keysToDelete.size());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("删除文件夹失败: {}/{}", MODEL_BUCKET, folderPath, e);
|
||||
throw new RuntimeException("删除失败: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查文件是否存在
|
||||
*/
|
||||
public boolean fileExists(String folderPath, String filePath) {
|
||||
if (amazonS3 == null) return false;
|
||||
String objectKey = folderPath + "/" + filePath;
|
||||
try {
|
||||
amazonS3.getObjectMetadata(MODEL_BUCKET, objectKey);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件CDN URL
|
||||
*/
|
||||
public String getFileUrl(String folderPath, String filePath) {
|
||||
String objectKey = folderPath + "/" + filePath;
|
||||
return buildCdnUrl(objectKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建CDN URL
|
||||
*/
|
||||
private String buildCdnUrl(String objectKey) {
|
||||
if (cdnEnabled && cdnDomain != null && !cdnDomain.isEmpty()) {
|
||||
return "https://" + cdnDomain + "/" + MODEL_BUCKET + "/" + objectKey;
|
||||
} else {
|
||||
return buildDirectUrl(objectKey);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建直接访问URL
|
||||
*/
|
||||
private String buildDirectUrl(String objectKey) {
|
||||
return endpoint + "/" + MODEL_BUCKET + "/" + objectKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据文件名获取ContentType
|
||||
*/
|
||||
private String getContentType(String fileName) {
|
||||
if (fileName == null) return "application/octet-stream";
|
||||
String lower = fileName.toLowerCase();
|
||||
|
||||
if (lower.endsWith(".json")) return "application/json";
|
||||
if (lower.endsWith(".b3dm")) return "application/octet-stream";
|
||||
if (lower.endsWith(".i3dm")) return "application/octet-stream";
|
||||
if (lower.endsWith(".pnts")) return "application/octet-stream";
|
||||
if (lower.endsWith(".cmpt")) return "application/octet-stream";
|
||||
if (lower.endsWith(".glb")) return "model/gltf-binary";
|
||||
if (lower.endsWith(".gltf")) return "model/gltf+json";
|
||||
if (lower.endsWith(".jpg") || lower.endsWith(".jpeg")) return "image/jpeg";
|
||||
if (lower.endsWith(".png")) return "image/png";
|
||||
if (lower.endsWith(".ktx2")) return "image/ktx2";
|
||||
|
||||
return "application/octet-stream";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,668 @@
|
||||
# 发明专利申请书
|
||||
|
||||
## 一、发明名称
|
||||
|
||||
**一种基于多租户架构的旅游导游佣金分成管理系统及方法**
|
||||
|
||||
---
|
||||
|
||||
## 二、技术领域
|
||||
|
||||
本发明涉及旅游信息化管理技术领域,尤其涉及一种基于多租户架构的旅游导游佣金分成管理系统及方法。
|
||||
|
||||
---
|
||||
|
||||
## 三、背景技术
|
||||
|
||||
随着旅游行业的快速发展,景区二维码扫码购票已成为主流购票方式。游客通过扫描景区二维码完成门票购买,实现了无接触、便捷化的购票体验。
|
||||
|
||||
然而,在传统的景区二维码业务模式中,存在以下技术问题:
|
||||
|
||||
1. **导游拉客缺乏激励机制**:导游作为景区重要的客源渠道,在引导游客购票过程中无法获得合理的佣金分成,降低了导游推广景区的积极性。
|
||||
|
||||
2. **数据隔离困难**:现有系统难以在同一平台上实现景区数据与导游数据的有效隔离,导致数据管理混乱,存在信息泄露风险。
|
||||
|
||||
3. **系统改造成本高**:若要为导游增加佣金功能,传统方案需要大量修改现有的二维码系统、订单系统等核心模块,开发成本高、风险大。
|
||||
|
||||
4. **佣金结算不透明**:缺乏完善的佣金计算、结算和提现机制,导游无法实时查看收益,容易产生信任问题。
|
||||
|
||||
5. **多角色管理复杂**:平台运营商、景区、导游等多角色在同一系统中的权限划分和数据可见性控制实现复杂。
|
||||
|
||||
因此,亟需一种能够在现有景区二维码系统基础上,以最小改动实现导游佣金分成功能的技术方案。
|
||||
|
||||
---
|
||||
|
||||
## 四、发明内容
|
||||
|
||||
### 4.1 发明目的
|
||||
|
||||
本发明的目的在于提供一种基于多租户架构的旅游导游佣金分成管理系统及方法,解决现有技术中导游拉客激励机制缺失、系统改造成本高、数据隔离困难等技术问题。
|
||||
|
||||
### 4.2 技术方案
|
||||
|
||||
为实现上述目的,本发明提供以下技术方案:
|
||||
|
||||
#### 4.2.1 一种基于多租户架构的旅游导游佣金分成管理系统
|
||||
|
||||
所述系统包括:
|
||||
|
||||
**租户管理模块**,用于管理多级租户层级结构,其中:
|
||||
- 父租户为平台运营商;
|
||||
- 子租户包括景区租户和导游租户,二者在租户层级中处于平级关系;
|
||||
- 每个租户拥有独立的租户标识(tenant_id);
|
||||
|
||||
**统一主体管理模块**,用于在同一数据表中存储景区和导游信息,其中:
|
||||
- 通过主体类型字段(tourism_type)区分景区(值为1)和导游(值为2);
|
||||
- 景区和导游共用相同的数据结构,仅通过类型字段区分;
|
||||
- 每个主体关联对应的租户标识;
|
||||
|
||||
**二维码管理模块**,用于为景区和导游创建专属二维码,其中:
|
||||
- 导游二维码与景区二维码采用完全相同的创建逻辑;
|
||||
- 二维码关联对应的主体标识(tourism_id);
|
||||
- 游客扫描任意二维码后的购票流程完全一致;
|
||||
|
||||
**订单管理模块**,用于处理游客扫码购票产生的订单,其中:
|
||||
- 订单记录关联的主体标识和租户标识;
|
||||
- 订单创建流程对景区订单和导游订单完全相同;
|
||||
- 通过租户标识实现订单数据的自动隔离;
|
||||
|
||||
**导游扩展信息模块**,用于存储导游特有的扩展信息,包括:
|
||||
- 导游编号、身份证号、提现账户信息;
|
||||
- 佣金比例配置;
|
||||
- 累计佣金、可提现佣金、冻结佣金、已提现佣金余额;
|
||||
- 导游审核状态;
|
||||
|
||||
**佣金计算模块**,用于在订单支付成功后自动计算导游佣金,其中:
|
||||
- 根据订单关联的主体标识查询主体类型;
|
||||
- 若主体类型为导游,则根据佣金比例计算佣金金额;
|
||||
- 创建佣金明细记录,状态为待结算;
|
||||
- 更新导游累计佣金余额;
|
||||
|
||||
**佣金结算模块**,用于定时将待结算佣金转为可提现佣金,其中:
|
||||
- 设置结算周期(如T+7天)确保订单稳定后再结算;
|
||||
- 检查订单状态确认无退款后执行结算;
|
||||
- 更新佣金状态为已结算,同步更新可提现余额;
|
||||
|
||||
**提现管理模块**,用于处理导游的佣金提现申请,包括:
|
||||
- 导游端提交提现申请,冻结对应金额;
|
||||
- 后台人工审核提现申请;
|
||||
- 审核通过后调用支付接口执行打款;
|
||||
- 更新提现状态和导游余额;
|
||||
|
||||
**数据隔离模块**,用于基于租户层级实现数据访问控制,其中:
|
||||
- 父租户可查看所有子租户(景区+导游)的数据;
|
||||
- 景区租户仅能查看自身数据;
|
||||
- 导游租户仅能查看自身数据;
|
||||
- 利用现有租户过滤机制,无需额外开发隔离逻辑;
|
||||
|
||||
#### 4.2.2 一种基于多租户架构的旅游导游佣金分成管理方法
|
||||
|
||||
所述方法包括以下步骤:
|
||||
|
||||
**步骤S1:导游注册与审核**
|
||||
- S1.1:为导游创建独立的子租户;
|
||||
- S1.2:在统一主体表中创建导游记录,设置主体类型为导游(tourism_type=2);
|
||||
- S1.3:创建导游扩展信息记录,包含佣金比例等配置;
|
||||
- S1.4:后台管理员审核导游资质,审核通过后导游状态变为正常;
|
||||
|
||||
**步骤S2:导游二维码创建**
|
||||
- S2.1:选择已审核通过的导游主体;
|
||||
- S2.2:调用与景区二维码相同的创建接口;
|
||||
- S2.3:生成导游专属二维码,关联导游的主体标识;
|
||||
|
||||
**步骤S3:游客扫码下单**
|
||||
- S3.1:游客扫描导游二维码;
|
||||
- S3.2:系统解析二维码获取主体标识;
|
||||
- S3.3:按照标准订单流程创建订单,记录主体标识和租户标识;
|
||||
- S3.4:游客完成支付;
|
||||
|
||||
**步骤S4:佣金自动计算**
|
||||
- S4.1:支付成功回调触发佣金计算逻辑;
|
||||
- S4.2:根据订单的主体标识查询主体类型;
|
||||
- S4.3:判断主体类型是否为导游(tourism_type=2);
|
||||
- S4.4:若为导游,查询导游扩展信息获取佣金比例;
|
||||
- S4.5:计算佣金金额 = 订单金额 × 佣金比例;
|
||||
- S4.6:创建佣金明细记录,状态设为待结算;
|
||||
- S4.7:累加导游累计佣金余额;
|
||||
|
||||
**步骤S5:佣金定时结算**
|
||||
- S5.1:定时任务扫描超过结算周期的待结算佣金;
|
||||
- S5.2:检查关联订单状态,确认已完成且无退款;
|
||||
- S5.3:更新佣金状态为已结算;
|
||||
- S5.4:将佣金金额从待结算转入可提现余额;
|
||||
|
||||
**步骤S6:导游提现**
|
||||
- S6.1:导游在小程序端申请提现,指定提现金额;
|
||||
- S6.2:系统校验可提现余额是否充足;
|
||||
- S6.3:冻结提现金额,创建提现申请记录;
|
||||
- S6.4:后台管理员审核提现申请;
|
||||
- S6.5:审核通过后,调用微信企业付款接口执行打款;
|
||||
- S6.6:打款成功后更新提现状态为已到账;
|
||||
- S6.7:扣减冻结余额,累加已提现余额;
|
||||
|
||||
**步骤S7:数据查询与统计**
|
||||
- S7.1:用户登录时获取其租户标识;
|
||||
- S7.2:递归获取该租户及其所有子租户的标识列表;
|
||||
- S7.3:查询这些租户下的所有主体标识;
|
||||
- S7.4:使用主体标识列表过滤订单、二维码等业务数据;
|
||||
- S7.5:实现父租户看全部、子租户看自己的数据隔离效果;
|
||||
|
||||
### 4.3 有益效果
|
||||
|
||||
本发明与现有技术相比,具有以下有益效果:
|
||||
|
||||
1. **最小化系统改造**:仅需在现有主体表新增一个类型字段,二维码表、订单表等核心表结构完全不变,大幅降低开发成本和风险。
|
||||
|
||||
2. **完全复用现有逻辑**:导游二维码创建、订单生成、数据查询等流程100%复用现有景区业务逻辑,无需重复开发。
|
||||
|
||||
3. **优雅的数据隔离**:利用多租户层级体系自动实现数据隔离,景区账号登录后看不到导游数据,导游账号也看不到景区数据,无需额外开发权限控制。
|
||||
|
||||
4. **灵活的佣金配置**:支持为每个导游独立配置佣金比例,满足差异化激励需求。
|
||||
|
||||
5. **安全的资金管理**:通过待结算、已结算、冻结等多状态管理,配合T+7结算周期,有效防范退款导致的资金风险。
|
||||
|
||||
6. **透明的收益追踪**:导游可实时查看佣金明细、订单来源,提升合作信任度。
|
||||
|
||||
7. **可扩展的架构设计**:基于统一主体模型,未来可轻松扩展其他角色类型(如代理商、分销商等)。
|
||||
|
||||
---
|
||||
|
||||
## 五、附图说明
|
||||
|
||||
### 图1:系统整体架构图
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ 前端应用层 │
|
||||
├─────────────────┬─────────────────┬─────────────────────────────────┤
|
||||
│ 游客小程序 │ 导游端小程序 │ 管理后台 │
|
||||
└────────┬────────┴────────┬────────┴─────────────┬───────────────────┘
|
||||
│ │ │
|
||||
▼ ▼ ▼
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ 业务服务层 │
|
||||
├─────────────────────────────────────────────────────────────────────┤
|
||||
│ 统一主体服务 │ 二维码服务 │ 订单服务 │ 佣金服务 │ 提现服务 │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
│ │ │
|
||||
▼ ▼ ▼
|
||||
┌─────────────────────────────────────────────────────────────────────┐
|
||||
│ 数据存储层 │
|
||||
├─────────────────────────────────────────────────────────────────────┤
|
||||
│ 主体表(tourisms) │ 二维码表 │ 订单表 │ 导游扩展表 │ 佣金表 │
|
||||
└─────────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 图2:租户层级结构图
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ 租户层级体系 │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ 父租户A (平台运营商) │
|
||||
│ │ │
|
||||
│ ├── 子租户B (景区) │
|
||||
│ │ └── 主体记录 (tourism_type=1, tenant_id=B) │
|
||||
│ │ └── 二维码 (tourism_id=景区id) │
|
||||
│ │ └── 订单 (tourism_id=景区id, tenant_id=B) │
|
||||
│ │ │
|
||||
│ ├── 子租户C (导游) │
|
||||
│ │ └── 主体记录 (tourism_type=2, tenant_id=C) │
|
||||
│ │ └── 导游扩展信息 (tourism_id=导游id) │
|
||||
│ │ └── 二维码 (tourism_id=导游id) │
|
||||
│ │ └── 订单 (tourism_id=导游id, tenant_id=C) │
|
||||
│ │ │
|
||||
│ └── 子租户D (导游) │
|
||||
│ └── 主体记录 (tourism_type=2, tenant_id=D) │
|
||||
│ └── 导游扩展信息 (tourism_id=导游id) │
|
||||
│ └── 二维码 (tourism_id=导游id) │
|
||||
│ └── 订单 (tourism_id=导游id, tenant_id=D) │
|
||||
│ │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 图3:订单与佣金流转流程图
|
||||
|
||||
```
|
||||
┌──────────────────────────────────────────────────────────────────┐
|
||||
│ 订单与佣金流转流程 │
|
||||
├──────────────────────────────────────────────────────────────────┤
|
||||
│ │
|
||||
│ 1. 游客扫描二维码 (code_id) │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ 2. 查询二维码信息,获取 tourism_id │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ 3. 创建订单 (复用现有逻辑) │
|
||||
│ orders.tourism_id = 二维码的tourism_id │
|
||||
│ orders.tenant_id = 主体的tenant_id │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ 4. 支付成功回调 │
|
||||
│ │ │
|
||||
│ ▼ │
|
||||
│ 5. 查询主体类型 (tourism_type) │
|
||||
│ │ │
|
||||
│ ┌────────┴────────┐ │
|
||||
│ │ │ │
|
||||
│ ▼ ▼ │
|
||||
│ type=2 (导游) type=1 (景区) │
|
||||
│ │ │ │
|
||||
│ ▼ ▼ │
|
||||
│ 计算并创建佣金 无佣金逻辑 │
|
||||
│ │
|
||||
└──────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
### 图4:佣金结算与提现流程图
|
||||
|
||||
```
|
||||
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
|
||||
│ 支付成功 │───▶│ 创建佣金 │───▶│ 订单完成 │───▶│ 佣金结算 │
|
||||
│ 回调 │ │ 明细记录 │ │ 无退款 │ │ (T+7) │
|
||||
└──────────┘ └──────────┘ └──────────┘ └──────────┘
|
||||
│ │ │ │
|
||||
▼ ▼ ▼ ▼
|
||||
判断主体 status=0 检查订单 status=1
|
||||
类型=导游 待结算 状态 已结算
|
||||
更新可提现余额
|
||||
│
|
||||
▼
|
||||
┌──────────┐ ┌──────────┐ ┌──────────┐ ┌──────────┐
|
||||
│ 导游申请 │───▶│ 后台审核 │───▶│ 执行打款 │───▶│ 完成提现 │
|
||||
│ 提现 │ │ (人工) │ │ (微信API) │ │ │
|
||||
└──────────┘ └──────────┘ └──────────┘ └──────────┘
|
||||
│ │ │ │
|
||||
▼ ▼ ▼ ▼
|
||||
冻结余额 审核通过 调用微信 更新余额
|
||||
status=0 status=1 企业付款 status=4
|
||||
```
|
||||
|
||||
### 图5:数据表关系图
|
||||
|
||||
```
|
||||
┌──────────────────┐ ┌──────────────────┐
|
||||
│ tourisms │ │ qrcodes │
|
||||
│ (主体表) │ │ (二维码表) │
|
||||
│ 【扩展1字段】 │ │ 【不修改】 │
|
||||
├──────────────────┤ ├──────────────────┤
|
||||
│ id (PK) │ 1:N │ id │
|
||||
│ tourism_name │◄───────────────────│ tourism_id (FK) │
|
||||
│ tourism_type │ ← 新增字段 │ code_id (UQ) │
|
||||
│ tenant_id │ │ price │
|
||||
│ ... │ │ ... │
|
||||
└──────────────────┘ └──────────────────┘
|
||||
│ │
|
||||
│ 1:1 (仅导游) │ 1:N
|
||||
▼ ▼
|
||||
┌──────────────────┐ ┌──────────────────┐
|
||||
│ guide_profiles │ │ orders │
|
||||
│ (导游扩展信息) │ │ (订单表) │
|
||||
│ 【新增表】 │ │ 【不修改】 │
|
||||
├──────────────────┤ ├──────────────────┤
|
||||
│ id (PK) │ │ id │
|
||||
│ tourism_id (FK) │ │ order_no (UQ) │
|
||||
│ guide_no │ │ tourism_id (FK) │
|
||||
│ commission_rate │ │ code_id │
|
||||
│ total_commission │ │ tenant_id │
|
||||
│ available_commission│ │ ... │
|
||||
│ ... │ └──────────────────┘
|
||||
└──────────────────┘
|
||||
│
|
||||
│ 1:N
|
||||
▼
|
||||
┌──────────────────┐ ┌──────────────────┐
|
||||
│guide_commissions │ │guide_withdrawals │
|
||||
│ (佣金明细表) │ │ (提现申请表) │
|
||||
│ 【新增表】 │ │ 【新增表】 │
|
||||
├──────────────────┤ ├──────────────────┤
|
||||
│ id (PK) │ │ id (PK) │
|
||||
│ guide_id (FK) │ │ guide_id (FK) │
|
||||
│ order_no │ │ withdraw_no │
|
||||
│ commission_amount│ │ amount │
|
||||
│ status │ │ status │
|
||||
│ ... │ │ ... │
|
||||
└──────────────────┘ └──────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 六、具体实施方式
|
||||
|
||||
### 6.1 实施例一:导游注册与审核
|
||||
|
||||
本实施例描述导游从注册到审核通过的完整流程:
|
||||
|
||||
**步骤1**:平台管理员在管理后台为导游创建独立的子租户,获得租户标识tenant_id=C。
|
||||
|
||||
**步骤2**:调用导游创建接口,在主体表(tourisms)中插入一条记录:
|
||||
```
|
||||
{
|
||||
id: 1001,
|
||||
tourism_name: "张三",
|
||||
tourism_type: 2, // 导游类型
|
||||
tenant_id: "C",
|
||||
tourism_phone: "13800138000",
|
||||
status: 0 // 待审核
|
||||
}
|
||||
```
|
||||
|
||||
**步骤3**:同时在导游扩展信息表(guide_profiles)中插入关联记录:
|
||||
```
|
||||
{
|
||||
id: 1,
|
||||
tourism_id: 1001, // 关联主体表
|
||||
guide_no: "G202401001",
|
||||
id_card: "330102****1234",
|
||||
commission_rate: 10.00, // 佣金比例10%
|
||||
status: 0, // 待审核
|
||||
total_commission: 0,
|
||||
available_commission: 0,
|
||||
frozen_commission: 0,
|
||||
withdrawn_commission: 0
|
||||
}
|
||||
```
|
||||
|
||||
**步骤4**:管理员审核导游资质,审核通过后更新两张表的status字段为1(正常)。
|
||||
|
||||
### 6.2 实施例二:游客扫描导游二维码下单
|
||||
|
||||
本实施例描述游客通过导游二维码完成购票的流程:
|
||||
|
||||
**步骤1**:导游向游客展示其专属二维码,二维码包含code_id="QR20240101001"。
|
||||
|
||||
**步骤2**:游客使用微信扫描二维码,小程序解析获得code_id。
|
||||
|
||||
**步骤3**:小程序调用二维码查询接口,根据code_id获取二维码详情:
|
||||
```
|
||||
{
|
||||
code_id: "QR20240101001",
|
||||
tourism_id: 1001, // 导游的主体ID
|
||||
price: 9900, // 票价99元
|
||||
...
|
||||
}
|
||||
```
|
||||
|
||||
**步骤4**:游客确认购票后,系统创建订单(与景区订单完全相同的逻辑):
|
||||
```
|
||||
{
|
||||
order_no: "ORD20240101000001",
|
||||
tourism_id: 1001, // 导游的主体ID
|
||||
code_id: "QR20240101001",
|
||||
tenant_id: "C", // 导游的租户ID
|
||||
order_amount: 9900,
|
||||
order_status: 0 // 待支付
|
||||
}
|
||||
```
|
||||
|
||||
**步骤5**:游客完成微信支付,触发支付成功回调。
|
||||
|
||||
### 6.3 实施例三:佣金自动计算
|
||||
|
||||
本实施例描述支付成功后的佣金自动计算过程:
|
||||
|
||||
**步骤1**:支付回调处理程序接收到订单支付成功通知。
|
||||
|
||||
**步骤2**:根据订单的tourism_id查询主体表:
|
||||
```sql
|
||||
SELECT tourism_type FROM tourisms WHERE id = 1001
|
||||
```
|
||||
结果:tourism_type = 2(导游)
|
||||
|
||||
**步骤3**:确认为导游订单,查询导游扩展信息获取佣金比例:
|
||||
```sql
|
||||
SELECT commission_rate FROM guide_profiles WHERE tourism_id = 1001
|
||||
```
|
||||
结果:commission_rate = 10.00
|
||||
|
||||
**步骤4**:计算佣金金额:
|
||||
```
|
||||
佣金金额 = 订单金额 × 佣金比例 / 100
|
||||
= 9900 × 10.00 / 100
|
||||
= 990 (分,即9.9元)
|
||||
```
|
||||
|
||||
**步骤5**:创建佣金明细记录:
|
||||
```
|
||||
{
|
||||
commission_no: "CM20240101000001",
|
||||
guide_id: 1001,
|
||||
order_no: "ORD20240101000001",
|
||||
order_amount: 9900,
|
||||
commission_rate: 10.00,
|
||||
commission_amount: 990,
|
||||
status: 0, // 待结算
|
||||
tenant_id: "C"
|
||||
}
|
||||
```
|
||||
|
||||
**步骤6**:更新导游累计佣金:
|
||||
```sql
|
||||
UPDATE guide_profiles
|
||||
SET total_commission = total_commission + 990
|
||||
WHERE tourism_id = 1001
|
||||
```
|
||||
|
||||
### 6.4 实施例四:数据隔离效果
|
||||
|
||||
本实施例描述不同角色登录后的数据可见性:
|
||||
|
||||
**场景1**:父租户A(平台运营商)登录
|
||||
- 获取租户列表:[A, B, C, D](包含所有子租户)
|
||||
- 查询主体列表:能看到景区B + 导游C + 导游D的所有主体
|
||||
- 查询订单列表:能看到所有子租户的订单
|
||||
- 查询统计数据:汇总所有子租户的营收数据
|
||||
|
||||
**场景2**:子租户B(景区)登录
|
||||
- 获取租户列表:[B](仅自己)
|
||||
- 查询主体列表:只能看到自己的景区信息
|
||||
- 查询订单列表:只能看到景区B的订单
|
||||
- **看不到任何导游的数据**
|
||||
|
||||
**场景3**:子租户C(导游张三)登录
|
||||
- 获取租户列表:[C](仅自己)
|
||||
- 查询主体列表:只能看到自己的导游信息
|
||||
- 查询订单列表:只能看到通过自己二维码产生的订单
|
||||
- 查询佣金明细:只能看到自己的佣金记录
|
||||
- **看不到景区和其他导游的数据**
|
||||
|
||||
### 6.5 实施例五:导游提现
|
||||
|
||||
本实施例描述导游申请提现的完整流程:
|
||||
|
||||
**前置条件**:导游张三可提现余额为10000分(100元)
|
||||
|
||||
**步骤1**:导游在小程序端申请提现5000分(50元)。
|
||||
|
||||
**步骤2**:系统校验可提现余额充足,创建提现申请:
|
||||
```
|
||||
{
|
||||
withdraw_no: "W202401010001",
|
||||
guide_id: 1001,
|
||||
amount: 5000,
|
||||
withdraw_type: 1, // 微信零钱
|
||||
status: 0, // 待审核
|
||||
tenant_id: "C"
|
||||
}
|
||||
```
|
||||
|
||||
**步骤3**:冻结提现金额:
|
||||
```sql
|
||||
UPDATE guide_profiles SET
|
||||
available_commission = available_commission - 5000,
|
||||
frozen_commission = frozen_commission + 5000
|
||||
WHERE tourism_id = 1001
|
||||
```
|
||||
|
||||
**步骤4**:管理员审核提现申请,确认无误后点击"审核通过"。
|
||||
|
||||
**步骤5**:系统调用微信企业付款API,向导游openid转账5000分。
|
||||
|
||||
**步骤6**:转账成功后更新提现状态和余额:
|
||||
```sql
|
||||
-- 更新提现状态
|
||||
UPDATE guide_withdrawals SET
|
||||
status = 4, // 已到账
|
||||
transfer_time = NOW(),
|
||||
transfer_no = "WX123456789"
|
||||
WHERE withdraw_no = "W202401010001"
|
||||
|
||||
-- 更新导游余额
|
||||
UPDATE guide_profiles SET
|
||||
frozen_commission = frozen_commission - 5000,
|
||||
withdrawn_commission = withdrawn_commission + 5000
|
||||
WHERE tourism_id = 1001
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 七、权利要求书
|
||||
|
||||
### 权利要求1
|
||||
|
||||
一种基于多租户架构的旅游导游佣金分成管理系统,其特征在于,包括:
|
||||
|
||||
租户管理模块,用于管理多级租户层级结构,父租户为平台运营商,子租户包括处于平级关系的景区租户和导游租户;
|
||||
|
||||
统一主体管理模块,用于在同一数据表中存储景区和导游信息,通过主体类型字段区分景区和导游;
|
||||
|
||||
二维码管理模块,用于为景区和导游创建采用相同创建逻辑的专属二维码;
|
||||
|
||||
订单管理模块,用于以相同流程处理景区订单和导游订单;
|
||||
|
||||
佣金计算模块,用于在订单支付成功后根据主体类型判断是否为导游订单,若是则自动计算并记录佣金;
|
||||
|
||||
数据隔离模块,用于基于租户层级实现父租户可查看所有子租户数据、子租户仅可查看自身数据的访问控制。
|
||||
|
||||
### 权利要求2
|
||||
|
||||
根据权利要求1所述的系统,其特征在于,还包括:
|
||||
|
||||
导游扩展信息模块,用于存储导游特有的佣金比例、余额信息和提现账户信息;
|
||||
|
||||
佣金结算模块,用于在设定的结算周期后将待结算佣金转为可提现佣金;
|
||||
|
||||
提现管理模块,用于处理导游的佣金提现申请,包括申请、审核、打款流程。
|
||||
|
||||
### 权利要求3
|
||||
|
||||
根据权利要求1所述的系统,其特征在于,所述统一主体管理模块中,主体类型字段的值为1表示景区,值为2表示导游,景区和导游在数据表中采用相同的数据结构。
|
||||
|
||||
### 权利要求4
|
||||
|
||||
根据权利要求1所述的系统,其特征在于,所述佣金计算模块的具体处理过程为:
|
||||
|
||||
接收订单支付成功通知;
|
||||
|
||||
根据订单关联的主体标识查询主体类型;
|
||||
|
||||
判断主体类型是否为导游;
|
||||
|
||||
若为导游,查询导游扩展信息获取佣金比例;
|
||||
|
||||
根据订单金额和佣金比例计算佣金金额;
|
||||
|
||||
创建佣金明细记录并更新导游累计佣金余额。
|
||||
|
||||
### 权利要求5
|
||||
|
||||
根据权利要求2所述的系统,其特征在于,所述佣金结算模块采用T+N天的结算周期,在结算前检查订单状态确认已完成且无退款后执行结算。
|
||||
|
||||
### 权利要求6
|
||||
|
||||
根据权利要求2所述的系统,其特征在于,所述提现管理模块在导游申请提现时冻结对应金额,审核通过后调用第三方支付接口执行打款,打款成功后更新余额状态。
|
||||
|
||||
### 权利要求7
|
||||
|
||||
一种基于多租户架构的旅游导游佣金分成管理方法,其特征在于,包括以下步骤:
|
||||
|
||||
S1:为导游创建独立的子租户,在统一主体表中创建导游记录并设置主体类型为导游,同时创建导游扩展信息记录;
|
||||
|
||||
S2:为导游创建专属二维码,采用与景区二维码相同的创建逻辑;
|
||||
|
||||
S3:游客扫描导游二维码后,按照标准订单流程创建订单并完成支付;
|
||||
|
||||
S4:支付成功后根据订单关联的主体类型判断是否为导游订单,若是则根据佣金比例计算并记录佣金;
|
||||
|
||||
S5:定时任务在结算周期后将待结算佣金转为可提现佣金;
|
||||
|
||||
S6:导游申请提现后经审核通过执行打款,完成佣金提取。
|
||||
|
||||
### 权利要求8
|
||||
|
||||
根据权利要求7所述的方法,其特征在于,步骤S4中判断是否为导游订单的方式为:查询主体表中该订单关联主体的类型字段值是否为导游类型值。
|
||||
|
||||
### 权利要求9
|
||||
|
||||
根据权利要求7所述的方法,其特征在于,还包括数据隔离步骤:
|
||||
|
||||
获取当前用户的租户标识;
|
||||
|
||||
递归获取该租户及其所有子租户的标识列表;
|
||||
|
||||
查询这些租户下的所有主体标识;
|
||||
|
||||
使用主体标识列表过滤业务数据,实现父租户可查看所有子租户数据、子租户仅可查看自身数据。
|
||||
|
||||
### 权利要求10
|
||||
|
||||
根据权利要求7所述的方法,其特征在于,步骤S6中提现流程包括:
|
||||
|
||||
导游提交提现申请并冻结对应金额;
|
||||
|
||||
后台管理员审核提现申请;
|
||||
|
||||
审核通过后调用第三方支付接口执行打款;
|
||||
|
||||
打款成功后扣减冻结余额并累加已提现余额。
|
||||
|
||||
---
|
||||
|
||||
## 八、摘要
|
||||
|
||||
### 说明书摘要
|
||||
|
||||
本发明公开了一种基于多租户架构的旅游导游佣金分成管理系统及方法,涉及旅游信息化管理技术领域。系统包括租户管理模块、统一主体管理模块、二维码管理模块、订单管理模块、佣金计算模块和数据隔离模块。通过在统一主体表中用类型字段区分景区和导游,实现导游与景区共用相同的二维码创建和订单处理逻辑;通过多租户层级结构实现数据自动隔离;在支付回调中根据主体类型自动计算导游佣金。本发明仅需对现有系统进行最小改动(新增1个字段+3张表),即可完整实现导游佣金分成功能,具有改造成本低、完全复用现有逻辑、数据隔离优雅、佣金管理透明等优点。
|
||||
|
||||
### 摘要附图
|
||||
|
||||
(选用图3:订单与佣金流转流程图)
|
||||
|
||||
---
|
||||
|
||||
## 九、附加说明
|
||||
|
||||
### 9.1 技术关键点
|
||||
|
||||
1. **统一主体模型**:景区和导游存储在同一张表,通过类型字段区分,是本发明实现最小化改动的核心设计。
|
||||
|
||||
2. **租户层级隔离**:利用多租户架构的层级关系自动实现数据隔离,无需额外开发权限逻辑。
|
||||
|
||||
3. **佣金状态机**:待结算→已结算→可提现→冻结→已提现,完整的状态流转确保资金安全。
|
||||
|
||||
4. **逻辑复用**:二维码创建、订单创建、数据查询等核心逻辑100%复用,仅在支付回调中新增佣金判断。
|
||||
|
||||
### 9.2 应用场景
|
||||
|
||||
- 旅游景区导游分销系统
|
||||
- 酒店民宿渠道分销系统
|
||||
- 餐饮团购渠道分成系统
|
||||
- 其他需要渠道佣金分成的O2O业务场景
|
||||
|
||||
### 9.3 技术创新点
|
||||
|
||||
1. 首次提出将导游与景区作为平级租户、统一主体的设计理念
|
||||
2. 首次实现在不修改核心业务表的前提下扩展佣金分成功能
|
||||
3. 首次将多租户数据隔离机制应用于导游佣金管理场景
|
||||
|
||||
---
|
||||
|
||||
**申请人**:湖北高飞智航科技有限责任公司
|
||||
|
||||
**发明人**:杜志超
|
||||
|
||||
**申请日期**:2025年12月01日
|
||||
|
||||
**文档版本**:v1.0
|
||||
@@ -0,0 +1,104 @@
|
||||
-- ============================================
|
||||
-- 导游佣金系统数据库迁移脚本
|
||||
-- 创建日期: 2024-12-01
|
||||
-- 作者: dzc
|
||||
-- ============================================
|
||||
|
||||
-- 1. 为 tourisms 表添加 tourism_type 字段
|
||||
ALTER TABLE tourisms
|
||||
ADD COLUMN tourism_type TINYINT(1) DEFAULT 1 COMMENT '景区类型(1:景区,2:导游)';
|
||||
|
||||
-- 为现有数据设置默认值(所有现有记录默认为景区类型)
|
||||
UPDATE tourisms SET tourism_type = 1 WHERE tourism_type IS NULL;
|
||||
|
||||
-- 添加索引以提高查询性能
|
||||
CREATE INDEX idx_tourism_type ON tourisms(tourism_type);
|
||||
|
||||
-- ============================================
|
||||
-- 2. 创建导游扩展信息表
|
||||
-- ============================================
|
||||
CREATE TABLE IF NOT EXISTS guide_profile (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '主键ID',
|
||||
tourism_id BIGINT NOT NULL COMMENT '关联tourisms表ID',
|
||||
id_card VARCHAR(18) COMMENT '身份证号',
|
||||
guide_license VARCHAR(50) COMMENT '导游证号',
|
||||
license_image VARCHAR(500) COMMENT '导游证照片URL',
|
||||
status TINYINT DEFAULT 0 COMMENT '状态:0-待审核 1-正常 2-禁用 3-审核拒绝',
|
||||
commission_rate DECIMAL(5,2) DEFAULT 10.00 COMMENT '佣金比例(%)',
|
||||
total_commission BIGINT DEFAULT 0 COMMENT '累计佣金(分)',
|
||||
available_commission BIGINT DEFAULT 0 COMMENT '可提现佣金(分)',
|
||||
frozen_commission BIGINT DEFAULT 0 COMMENT '冻结中佣金(分)',
|
||||
withdrawn_commission BIGINT DEFAULT 0 COMMENT '已提现佣金(分)',
|
||||
audit_user_id BIGINT COMMENT '审核人ID',
|
||||
audit_time DATETIME COMMENT '审核时间',
|
||||
audit_remark VARCHAR(500) COMMENT '审核备注',
|
||||
tenant_id VARCHAR(32) COMMENT '租户ID',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
UNIQUE KEY uk_tourism_id (tourism_id),
|
||||
KEY idx_status (status),
|
||||
KEY idx_tenant_id (tenant_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='导游扩展信息表';
|
||||
|
||||
-- ============================================
|
||||
-- 3. 创建导游佣金明细表
|
||||
-- ============================================
|
||||
CREATE TABLE IF NOT EXISTS guide_commission (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '主键ID',
|
||||
commission_no VARCHAR(32) NOT NULL COMMENT '佣金单号',
|
||||
guide_id BIGINT NOT NULL COMMENT '导游ID(tourisms表ID)',
|
||||
order_no VARCHAR(32) NOT NULL COMMENT '订单号',
|
||||
order_amount BIGINT NOT NULL COMMENT '订单金额(分)',
|
||||
commission_rate DECIMAL(5,2) NOT NULL COMMENT '佣金比例(%)',
|
||||
commission_amount BIGINT NOT NULL COMMENT '佣金金额(分)',
|
||||
status TINYINT DEFAULT 0 COMMENT '状态:0-待结算 1-已结算 2-已退款 3-结算失败',
|
||||
settle_time DATETIME COMMENT '结算时间',
|
||||
remark VARCHAR(500) COMMENT '备注',
|
||||
tenant_id VARCHAR(32) COMMENT '租户ID',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
UNIQUE KEY uk_commission_no (commission_no),
|
||||
UNIQUE KEY uk_order_no (order_no),
|
||||
KEY idx_guide_id (guide_id),
|
||||
KEY idx_status (status),
|
||||
KEY idx_create_time (create_time),
|
||||
KEY idx_tenant_id (tenant_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='导游佣金明细表';
|
||||
|
||||
-- ============================================
|
||||
-- 4. 创建导游提现记录表
|
||||
-- ============================================
|
||||
CREATE TABLE IF NOT EXISTS guide_withdrawal (
|
||||
id BIGINT PRIMARY KEY AUTO_INCREMENT COMMENT '主键ID',
|
||||
withdraw_no VARCHAR(32) NOT NULL COMMENT '提现单号',
|
||||
guide_id BIGINT NOT NULL COMMENT '导游ID(tourisms表ID)',
|
||||
amount BIGINT NOT NULL COMMENT '提现金额(分)',
|
||||
actual_amount BIGINT NOT NULL COMMENT '实际到账金额(分)',
|
||||
fee BIGINT DEFAULT 0 COMMENT '手续费(分)',
|
||||
withdraw_type TINYINT DEFAULT 1 COMMENT '提现方式:1-微信 2-支付宝 3-银行卡',
|
||||
account_info VARCHAR(500) COMMENT '收款账户信息(JSON)',
|
||||
status TINYINT DEFAULT 0 COMMENT '状态:0-待审核 1-审核通过 2-审核拒绝 3-打款中 4-已到账 5-打款失败',
|
||||
apply_time DATETIME COMMENT '申请时间',
|
||||
audit_user_id BIGINT COMMENT '审核人ID',
|
||||
audit_time DATETIME COMMENT '审核时间',
|
||||
audit_remark VARCHAR(500) COMMENT '审核备注',
|
||||
transfer_time DATETIME COMMENT '转账时间',
|
||||
transfer_no VARCHAR(64) COMMENT '转账流水号',
|
||||
fail_reason VARCHAR(500) COMMENT '失败原因',
|
||||
tenant_id VARCHAR(32) COMMENT '租户ID',
|
||||
create_time DATETIME DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
||||
update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
||||
UNIQUE KEY uk_withdraw_no (withdraw_no),
|
||||
KEY idx_guide_id (guide_id),
|
||||
KEY idx_status (status),
|
||||
KEY idx_apply_time (apply_time),
|
||||
KEY idx_tenant_id (tenant_id)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='导游提现记录表';
|
||||
|
||||
-- ============================================
|
||||
-- 验证表创建成功
|
||||
-- ============================================
|
||||
DESCRIBE tourisms;
|
||||
DESCRIBE guide_profile;
|
||||
DESCRIBE guide_commission;
|
||||
DESCRIBE guide_withdrawal;
|
||||
@@ -107,4 +107,17 @@ public class TourismFileController {
|
||||
}
|
||||
return Result.succeed(list, "操作成功");
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据素材ID列表获取素材详情
|
||||
*/
|
||||
@Operation(summary = "根据素材ID列表获取素材详情")
|
||||
@GetMapping("/byIds")
|
||||
public Result<java.util.List<TourismFile>> listByIds(@RequestParam("ids") java.util.List<Long> ids) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return Result.succeed(java.util.Collections.emptyList(), "操作成功");
|
||||
}
|
||||
java.util.List<TourismFile> list = tourismFileService.findByIds(ids);
|
||||
return Result.succeed(list, "操作成功");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.central.order.controller.guide;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.model.guide.GuideCommission;
|
||||
import com.central.order.model.vo.guide.CommissionOverviewVO;
|
||||
import com.central.order.service.guide.IGuideCommissionService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游佣金管理控制器
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Tag(name = "导游佣金管理")
|
||||
@RestController
|
||||
@RequestMapping("/guide/commission")
|
||||
@RequiredArgsConstructor
|
||||
public class GuideCommissionController {
|
||||
|
||||
private final IGuideCommissionService guideCommissionService;
|
||||
|
||||
@Operation(summary = "获取佣金概览")
|
||||
@GetMapping("/overview")
|
||||
public Result<CommissionOverviewVO> getOverview(
|
||||
@Parameter(description = "导游ID") @RequestParam Long guideId) {
|
||||
CommissionOverviewVO overview = guideCommissionService.getCommissionOverview(guideId);
|
||||
if (overview == null) {
|
||||
return Result.failed("导游不存在");
|
||||
}
|
||||
return Result.succeed(overview);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询佣金明细")
|
||||
@GetMapping("/list")
|
||||
public Result<PageResult<GuideCommission>> list(@RequestParam Map<String, Object> params) {
|
||||
PageResult<GuideCommission> result = guideCommissionService.findList(params);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取佣金详情")
|
||||
@GetMapping("/{id}")
|
||||
public Result<GuideCommission> getById(@PathVariable("id") Long commissionId) {
|
||||
GuideCommission commission = guideCommissionService.getById(commissionId);
|
||||
if (commission == null) {
|
||||
return Result.failed("佣金记录不存在");
|
||||
}
|
||||
return Result.succeed(commission);
|
||||
}
|
||||
|
||||
@Operation(summary = "手动结算佣金")
|
||||
@PostMapping("/{id}/settle")
|
||||
public Result<Void> settleCommission(@PathVariable("id") Long commissionId) {
|
||||
guideCommissionService.settleCommission(commissionId);
|
||||
return Result.succeed(null, "结算成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "批量结算佣金")
|
||||
@PostMapping("/batch-settle")
|
||||
public Result<Integer> batchSettle(
|
||||
@Parameter(description = "结算周期(天),默认7") @RequestParam(defaultValue = "7") Integer days) {
|
||||
int count = guideCommissionService.batchSettleCommissions(days);
|
||||
return Result.succeed(count, "批量结算完成");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.central.order.controller.guide;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.model.dto.guide.GuideAuditDTO;
|
||||
import com.central.order.model.dto.guide.GuideCreateDTO;
|
||||
import com.central.order.model.guide.GuideProfile;
|
||||
import com.central.order.model.vo.guide.GuideInfoVO;
|
||||
import com.central.order.service.guide.IGuideService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游管理控制器
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Tag(name = "导游管理")
|
||||
@RestController
|
||||
@RequestMapping("/guide")
|
||||
@RequiredArgsConstructor
|
||||
public class GuideController {
|
||||
|
||||
private final IGuideService guideService;
|
||||
|
||||
@Operation(summary = "创建导游")
|
||||
@PostMapping
|
||||
public Result<Long> createGuide(@Valid @RequestBody GuideCreateDTO dto) {
|
||||
Long guideId = guideService.createGuide(dto);
|
||||
return Result.succeed(guideId, "创建成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "获取导游信息")
|
||||
@GetMapping("/{id}")
|
||||
public Result<GuideInfoVO> getGuideInfo(@PathVariable("id") Long guideId) {
|
||||
GuideInfoVO info = guideService.getGuideInfo(guideId);
|
||||
if (info == null) {
|
||||
return Result.failed("导游不存在");
|
||||
}
|
||||
return Result.succeed(info);
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询导游列表")
|
||||
@GetMapping("/list")
|
||||
public Result<PageResult<GuideProfile>> list(@RequestParam Map<String, Object> params) {
|
||||
PageResult<GuideProfile> result = guideService.findList(params);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "审核导游")
|
||||
@PutMapping("/{id}/audit")
|
||||
public Result<Void> auditGuide(
|
||||
@PathVariable("id") Long guideId,
|
||||
@Valid @RequestBody GuideAuditDTO dto) {
|
||||
guideService.auditGuide(guideId, dto);
|
||||
return Result.succeed(null, "审核完成");
|
||||
}
|
||||
|
||||
@Operation(summary = "更新导游状态")
|
||||
@PutMapping("/{id}/status")
|
||||
public Result<Void> updateStatus(
|
||||
@PathVariable("id") Long guideId,
|
||||
@Parameter(description = "状态: 1-正常 2-禁用") @RequestParam Integer status) {
|
||||
guideService.updateStatus(guideId, status);
|
||||
return Result.succeed(null, "状态更新成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "设置佣金比例")
|
||||
@PutMapping("/{id}/commission-rate")
|
||||
public Result<Void> setCommissionRate(
|
||||
@PathVariable("id") Long guideId,
|
||||
@Parameter(description = "佣金比例(%)") @RequestParam BigDecimal commissionRate) {
|
||||
guideService.setCommissionRate(guideId, commissionRate);
|
||||
return Result.succeed(null, "设置成功");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.central.order.controller.guide;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.common.model.Result;
|
||||
import com.central.order.model.dto.guide.WithdrawalApplyDTO;
|
||||
import com.central.order.model.dto.guide.WithdrawalAuditDTO;
|
||||
import com.central.order.model.guide.GuideWithdrawal;
|
||||
import com.central.order.service.guide.IGuideWithdrawalService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.Parameter;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游提现管理控制器
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Tag(name = "导游提现管理")
|
||||
@RestController
|
||||
@RequestMapping("/guide/withdrawal")
|
||||
@RequiredArgsConstructor
|
||||
public class GuideWithdrawalController {
|
||||
|
||||
private final IGuideWithdrawalService guideWithdrawalService;
|
||||
|
||||
@Operation(summary = "申请提现")
|
||||
@PostMapping("/apply")
|
||||
public Result<String> applyWithdrawal(
|
||||
@Parameter(description = "导游ID") @RequestParam Long guideId,
|
||||
@Valid @RequestBody WithdrawalApplyDTO dto) {
|
||||
String withdrawNo = guideWithdrawalService.applyWithdrawal(guideId, dto);
|
||||
return Result.succeed(withdrawNo, "申请成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询提现记录")
|
||||
@GetMapping("/list")
|
||||
public Result<PageResult<GuideWithdrawal>> list(@RequestParam Map<String, Object> params) {
|
||||
PageResult<GuideWithdrawal> result = guideWithdrawalService.findList(params);
|
||||
return Result.succeed(result);
|
||||
}
|
||||
|
||||
@Operation(summary = "获取提现详情")
|
||||
@GetMapping("/{id}")
|
||||
public Result<GuideWithdrawal> getById(@PathVariable("id") Long withdrawalId) {
|
||||
GuideWithdrawal withdrawal = guideWithdrawalService.getById(withdrawalId);
|
||||
if (withdrawal == null) {
|
||||
return Result.failed("提现记录不存在");
|
||||
}
|
||||
return Result.succeed(withdrawal);
|
||||
}
|
||||
|
||||
@Operation(summary = "根据提现单号查询")
|
||||
@GetMapping("/no/{withdrawNo}")
|
||||
public Result<GuideWithdrawal> getByWithdrawNo(@PathVariable("withdrawNo") String withdrawNo) {
|
||||
GuideWithdrawal withdrawal = guideWithdrawalService.getByWithdrawNo(withdrawNo);
|
||||
if (withdrawal == null) {
|
||||
return Result.failed("提现记录不存在");
|
||||
}
|
||||
return Result.succeed(withdrawal);
|
||||
}
|
||||
|
||||
@Operation(summary = "审核提现")
|
||||
@PutMapping("/{id}/audit")
|
||||
public Result<Void> auditWithdrawal(
|
||||
@PathVariable("id") Long withdrawalId,
|
||||
@Parameter(description = "审核人ID") @RequestParam Long auditUserId,
|
||||
@Valid @RequestBody WithdrawalAuditDTO dto) {
|
||||
guideWithdrawalService.auditWithdrawal(withdrawalId, dto, auditUserId);
|
||||
return Result.succeed(null, "审核完成");
|
||||
}
|
||||
|
||||
@Operation(summary = "确认打款完成")
|
||||
@PutMapping("/{id}/transfer")
|
||||
public Result<Void> confirmTransfer(
|
||||
@PathVariable("id") Long withdrawalId,
|
||||
@Parameter(description = "转账单号") @RequestParam String transferNo) {
|
||||
guideWithdrawalService.confirmTransfer(withdrawalId, transferNo);
|
||||
return Result.succeed(null, "打款确认成功");
|
||||
}
|
||||
|
||||
@Operation(summary = "打款失败")
|
||||
@PutMapping("/{id}/transfer-failed")
|
||||
public Result<Void> transferFailed(
|
||||
@PathVariable("id") Long withdrawalId,
|
||||
@Parameter(description = "失败原因") @RequestParam String failReason) {
|
||||
guideWithdrawalService.transferFailed(withdrawalId, failReason);
|
||||
return Result.succeed(null, "已记录失败");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.central.order.enums.guide;
|
||||
|
||||
import com.central.common.enums.ZltEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 佣金状态枚举
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Getter
|
||||
public enum CommissionStatusEnum implements ZltEnum {
|
||||
PENDING(0, "待结算"),
|
||||
SETTLED(1, "已结算"),
|
||||
REFUNDED(2, "已退款"),
|
||||
FAILED(3, "结算失败");
|
||||
|
||||
private final Integer id;
|
||||
private final String content;
|
||||
|
||||
CommissionStatusEnum(Integer id, String content) {
|
||||
this.id = id;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public static CommissionStatusEnum getById(Integer id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
for (CommissionStatusEnum status : values()) {
|
||||
if (status.getId().equals(id)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.central.order.enums.guide;
|
||||
|
||||
import com.central.common.enums.ZltEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 导游状态枚举
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Getter
|
||||
public enum GuideStatusEnum implements ZltEnum {
|
||||
PENDING(0, "待审核"),
|
||||
NORMAL(1, "正常"),
|
||||
DISABLED(2, "禁用"),
|
||||
REJECTED(3, "审核拒绝");
|
||||
|
||||
private final Integer id;
|
||||
private final String content;
|
||||
|
||||
GuideStatusEnum(Integer id, String content) {
|
||||
this.id = id;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public static GuideStatusEnum getById(Integer id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
for (GuideStatusEnum status : values()) {
|
||||
if (status.getId().equals(id)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.central.order.enums.guide;
|
||||
|
||||
import com.central.common.enums.ZltEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 景区/导游类型枚举
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Getter
|
||||
public enum TourismTypeEnum implements ZltEnum {
|
||||
SCENIC(1, "景区"),
|
||||
GUIDE(2, "导游");
|
||||
|
||||
private final Integer id;
|
||||
private final String content;
|
||||
|
||||
TourismTypeEnum(Integer id, String content) {
|
||||
this.id = id;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public static TourismTypeEnum getById(Integer id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
for (TourismTypeEnum type : values()) {
|
||||
if (type.getId().equals(id)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.central.order.enums.guide;
|
||||
|
||||
import com.central.common.enums.ZltEnum;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 提现状态枚举
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Getter
|
||||
public enum WithdrawalStatusEnum implements ZltEnum {
|
||||
PENDING(0, "待审核"),
|
||||
APPROVED(1, "审核通过"),
|
||||
REJECTED(2, "审核拒绝"),
|
||||
TRANSFERRING(3, "打款中"),
|
||||
COMPLETED(4, "已到账"),
|
||||
FAILED(5, "打款失败");
|
||||
|
||||
private final Integer id;
|
||||
private final String content;
|
||||
|
||||
WithdrawalStatusEnum(Integer id, String content) {
|
||||
this.id = id;
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public static WithdrawalStatusEnum getById(Integer id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
for (WithdrawalStatusEnum status : values()) {
|
||||
if (status.getId().equals(id)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -29,4 +29,9 @@ public interface TourismFileMapper extends SuperMapper<TourismFile> {
|
||||
@Param("type") Integer type,
|
||||
@Param("status") Integer status,
|
||||
@Param("description") String description);
|
||||
|
||||
/**
|
||||
* 根据素材ID列表查询
|
||||
*/
|
||||
List<TourismFile> findByIds(@Param("ids") List<Long> ids);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.central.order.mapper.guide;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.order.model.guide.GuideCommission;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游佣金明细Mapper
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Mapper
|
||||
public interface GuideCommissionMapper extends BaseMapper<GuideCommission> {
|
||||
|
||||
/**
|
||||
* 根据订单号查询佣金记录
|
||||
*/
|
||||
GuideCommission selectByOrderNo(@Param("orderNo") String orderNo);
|
||||
|
||||
/**
|
||||
* 根据佣金单号查询
|
||||
*/
|
||||
GuideCommission selectByCommissionNo(@Param("commissionNo") String commissionNo);
|
||||
|
||||
/**
|
||||
* 分页查询佣金列表
|
||||
*/
|
||||
List<GuideCommission> findList(Page<GuideCommission> page, @Param("p") Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 查询待结算的佣金列表(创建时间早于指定时间)
|
||||
*/
|
||||
List<GuideCommission> selectPendingSettleList(@Param("beforeTime") LocalDateTime beforeTime, @Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* 统计导游今日佣金
|
||||
*/
|
||||
Long sumTodayCommission(@Param("guideId") Long guideId);
|
||||
|
||||
/**
|
||||
* 统计导游本月佣金
|
||||
*/
|
||||
Long sumMonthCommission(@Param("guideId") Long guideId);
|
||||
|
||||
/**
|
||||
* 统计导游待结算笔数
|
||||
*/
|
||||
Integer countPendingSettle(@Param("guideId") Long guideId);
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package com.central.order.mapper.guide;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.order.model.guide.GuideProfile;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游扩展信息Mapper
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Mapper
|
||||
public interface GuideProfileMapper extends BaseMapper<GuideProfile> {
|
||||
|
||||
/**
|
||||
* 根据tourism_id查询导游信息
|
||||
*/
|
||||
GuideProfile selectByTourismId(@Param("tourismId") Long tourismId);
|
||||
|
||||
/**
|
||||
* 根据用户ID查询导游信息
|
||||
*/
|
||||
GuideProfile selectByUserId(@Param("userId") Long userId);
|
||||
|
||||
/**
|
||||
* 根据导游编号查询
|
||||
*/
|
||||
GuideProfile selectByGuideNo(@Param("guideNo") String guideNo);
|
||||
|
||||
/**
|
||||
* 分页查询导游列表
|
||||
*/
|
||||
List<GuideProfile> findList(Page<GuideProfile> page, @Param("p") Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 增加累计佣金
|
||||
*/
|
||||
int addTotalCommission(@Param("id") Long id, @Param("amount") Long amount);
|
||||
|
||||
/**
|
||||
* 增加可提现佣金
|
||||
*/
|
||||
int addAvailableCommission(@Param("id") Long id, @Param("amount") Long amount);
|
||||
|
||||
/**
|
||||
* 冻结佣金(从可提现转到冻结)
|
||||
*/
|
||||
int freezeCommission(@Param("id") Long id, @Param("amount") Long amount);
|
||||
|
||||
/**
|
||||
* 解冻佣金(从冻结转回可提现)
|
||||
*/
|
||||
int unfreezeCommission(@Param("id") Long id, @Param("amount") Long amount);
|
||||
|
||||
/**
|
||||
* 完成提现(从冻结转到已提现)
|
||||
*/
|
||||
int completeWithdrawal(@Param("id") Long id, @Param("amount") Long amount);
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.central.order.mapper.guide;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.order.model.guide.GuideWithdrawal;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游提现申请Mapper
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Mapper
|
||||
public interface GuideWithdrawalMapper extends BaseMapper<GuideWithdrawal> {
|
||||
|
||||
/**
|
||||
* 根据提现单号查询
|
||||
*/
|
||||
GuideWithdrawal selectByWithdrawNo(@Param("withdrawNo") String withdrawNo);
|
||||
|
||||
/**
|
||||
* 分页查询提现列表
|
||||
*/
|
||||
List<GuideWithdrawal> findList(Page<GuideWithdrawal> page, @Param("p") Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 查询审核通过待打款的列表
|
||||
*/
|
||||
List<GuideWithdrawal> selectApprovedList(@Param("limit") Integer limit);
|
||||
|
||||
/**
|
||||
* 统计导游今日提现次数
|
||||
*/
|
||||
Integer countTodayWithdrawal(@Param("guideId") Long guideId);
|
||||
}
|
||||
@@ -59,4 +59,10 @@ public class Tourism extends SuperEntity {
|
||||
* 是否在首页显示(0:不显示,1:显示)
|
||||
*/
|
||||
private Integer showInHomepage;
|
||||
|
||||
/**
|
||||
* 景区类型(1:景区,2:导游)
|
||||
* @see com.central.order.enums.guide.TourismTypeEnum
|
||||
*/
|
||||
private Integer tourismType;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.central.order.model.dto.guide;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 导游审核请求DTO
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "导游审核请求")
|
||||
public class GuideAuditDTO {
|
||||
|
||||
@NotNull(message = "审核结果不能为空")
|
||||
@Schema(description = "审核结果: true-通过 false-拒绝")
|
||||
private Boolean approved;
|
||||
|
||||
@Schema(description = "审核备注")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.central.order.model.dto.guide;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.NotBlank;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 创建导游请求DTO
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "创建导游请求")
|
||||
public class GuideCreateDTO {
|
||||
|
||||
@NotBlank(message = "导游姓名不能为空")
|
||||
@Schema(description = "导游姓名")
|
||||
private String name;
|
||||
|
||||
@NotBlank(message = "手机号不能为空")
|
||||
@Schema(description = "手机号")
|
||||
private String phone;
|
||||
|
||||
@Schema(description = "身份证号")
|
||||
private String idCard;
|
||||
|
||||
@NotBlank(message = "租户ID不能为空")
|
||||
@Schema(description = "租户ID")
|
||||
private String tenantId;
|
||||
|
||||
@Schema(description = "用户ID")
|
||||
private Long userId;
|
||||
|
||||
@Schema(description = "微信openid")
|
||||
private String openid;
|
||||
|
||||
@Schema(description = "头像URL")
|
||||
private String avatar;
|
||||
|
||||
@Schema(description = "佣金比例(%)")
|
||||
private BigDecimal commissionRate;
|
||||
|
||||
@Schema(description = "银行账户")
|
||||
private String bankAccount;
|
||||
|
||||
@Schema(description = "开户行")
|
||||
private String bankName;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.central.order.model.dto.guide;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 提现申请请求DTO
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "提现申请请求")
|
||||
public class WithdrawalApplyDTO {
|
||||
|
||||
@NotNull(message = "提现金额不能为空")
|
||||
@Min(value = 1, message = "提现金额必须大于0")
|
||||
@Schema(description = "提现金额(分)")
|
||||
private Long amount;
|
||||
|
||||
@NotNull(message = "提现方式不能为空")
|
||||
@Schema(description = "提现方式: 1-微信零钱 2-银行卡")
|
||||
private Integer withdrawType;
|
||||
|
||||
@Schema(description = "收款账户信息(JSON)")
|
||||
private String accountInfo;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.central.order.model.dto.guide;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotNull;
|
||||
|
||||
/**
|
||||
* 提现审核请求DTO
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "提现审核请求")
|
||||
public class WithdrawalAuditDTO {
|
||||
|
||||
@NotNull(message = "审核结果不能为空")
|
||||
@Schema(description = "审核结果: true-通过 false-拒绝")
|
||||
private Boolean approved;
|
||||
|
||||
@Schema(description = "审核备注")
|
||||
private String remark;
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.central.order.model.guide;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 导游佣金明细表
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@TableName("guide_commissions")
|
||||
public class GuideCommission implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 佣金单号
|
||||
*/
|
||||
private String commissionNo;
|
||||
|
||||
/**
|
||||
* 导游ID (tourisms.id)
|
||||
*/
|
||||
private Long guideId;
|
||||
|
||||
/**
|
||||
* 订单编号
|
||||
*/
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 订单金额(分)
|
||||
*/
|
||||
private Long orderAmount;
|
||||
|
||||
/**
|
||||
* 佣金比例(%)
|
||||
*/
|
||||
private BigDecimal commissionRate;
|
||||
|
||||
/**
|
||||
* 佣金金额(分)
|
||||
*/
|
||||
private Long commissionAmount;
|
||||
|
||||
/**
|
||||
* 状态: 0-待结算 1-已结算 2-已退款 3-结算失败
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 结算时间
|
||||
*/
|
||||
private LocalDateTime settleTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 导游姓名 (关联查询)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String guideName;
|
||||
|
||||
/**
|
||||
* 导游编号 (关联查询)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String guideNo;
|
||||
}
|
||||
@@ -0,0 +1,117 @@
|
||||
package com.central.order.model.guide;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 导游扩展信息表
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@TableName("guide_profiles")
|
||||
public class GuideProfile implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 关联tourisms表ID (tourism_type=2)
|
||||
*/
|
||||
private Long tourismId;
|
||||
|
||||
/**
|
||||
* 关联用户ID (sys_user)
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 导游编号
|
||||
*/
|
||||
private String guideNo;
|
||||
|
||||
/**
|
||||
* 身份证号
|
||||
*/
|
||||
private String idCard;
|
||||
|
||||
/**
|
||||
* 微信openid (用于提现)
|
||||
*/
|
||||
private String openid;
|
||||
|
||||
/**
|
||||
* 银行账户
|
||||
*/
|
||||
private String bankAccount;
|
||||
|
||||
/**
|
||||
* 开户行
|
||||
*/
|
||||
private String bankName;
|
||||
|
||||
/**
|
||||
* 状态: 0-待审核 1-正常 2-禁用 3-审核拒绝
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 审核备注
|
||||
*/
|
||||
private String auditRemark;
|
||||
|
||||
/**
|
||||
* 默认佣金比例(%)
|
||||
*/
|
||||
private BigDecimal commissionRate;
|
||||
|
||||
/**
|
||||
* 累计佣金(分)
|
||||
*/
|
||||
private Long totalCommission;
|
||||
|
||||
/**
|
||||
* 可提现佣金(分)
|
||||
*/
|
||||
private Long availableCommission;
|
||||
|
||||
/**
|
||||
* 冻结佣金(分)
|
||||
*/
|
||||
private Long frozenCommission;
|
||||
|
||||
/**
|
||||
* 已提现佣金(分)
|
||||
*/
|
||||
private Long withdrawnCommission;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 导游姓名 (关联查询)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String guideName;
|
||||
|
||||
/**
|
||||
* 导游手机 (关联查询)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String guidePhone;
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
package com.central.order.model.guide;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 导游提现申请表
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@TableName("guide_withdrawals")
|
||||
public class GuideWithdrawal implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 提现单号
|
||||
*/
|
||||
private String withdrawNo;
|
||||
|
||||
/**
|
||||
* 导游ID (tourisms.id)
|
||||
*/
|
||||
private Long guideId;
|
||||
|
||||
/**
|
||||
* 提现金额(分)
|
||||
*/
|
||||
private Long amount;
|
||||
|
||||
/**
|
||||
* 实际到账金额(分)
|
||||
*/
|
||||
private Long actualAmount;
|
||||
|
||||
/**
|
||||
* 手续费(分)
|
||||
*/
|
||||
private Long fee;
|
||||
|
||||
/**
|
||||
* 提现方式: 1-微信零钱 2-银行卡
|
||||
*/
|
||||
private Integer withdrawType;
|
||||
|
||||
/**
|
||||
* 收款账户信息(JSON)
|
||||
*/
|
||||
private String accountInfo;
|
||||
|
||||
/**
|
||||
* 状态: 0-待审核 1-审核通过 2-审核拒绝 3-打款中 4-已到账 5-打款失败
|
||||
*/
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 申请时间
|
||||
*/
|
||||
private LocalDateTime applyTime;
|
||||
|
||||
/**
|
||||
* 审核人ID
|
||||
*/
|
||||
private Long auditUserId;
|
||||
|
||||
/**
|
||||
* 审核时间
|
||||
*/
|
||||
private LocalDateTime auditTime;
|
||||
|
||||
/**
|
||||
* 审核备注
|
||||
*/
|
||||
private String auditRemark;
|
||||
|
||||
/**
|
||||
* 打款时间
|
||||
*/
|
||||
private LocalDateTime transferTime;
|
||||
|
||||
/**
|
||||
* 微信/银行转账单号
|
||||
*/
|
||||
private String transferNo;
|
||||
|
||||
/**
|
||||
* 失败原因
|
||||
*/
|
||||
private String failReason;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
private String tenantId;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 导游姓名 (关联查询)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String guideName;
|
||||
|
||||
/**
|
||||
* 导游编号 (关联查询)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String guideNo;
|
||||
|
||||
/**
|
||||
* 导游手机 (关联查询)
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String guidePhone;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.central.order.model.vo.guide;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 佣金概览VO
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "佣金概览")
|
||||
public class CommissionOverviewVO {
|
||||
|
||||
@Schema(description = "累计佣金(分)")
|
||||
private Long totalCommission;
|
||||
|
||||
@Schema(description = "可提现佣金(分)")
|
||||
private Long availableCommission;
|
||||
|
||||
@Schema(description = "冻结佣金(分)")
|
||||
private Long frozenCommission;
|
||||
|
||||
@Schema(description = "已提现佣金(分)")
|
||||
private Long withdrawnCommission;
|
||||
|
||||
@Schema(description = "今日佣金(分)")
|
||||
private Long todayCommission;
|
||||
|
||||
@Schema(description = "本月佣金(分)")
|
||||
private Long monthCommission;
|
||||
|
||||
@Schema(description = "待结算笔数")
|
||||
private Integer pendingSettleCount;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.central.order.model.vo.guide;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 导游信息VO
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "导游信息")
|
||||
public class GuideInfoVO {
|
||||
|
||||
@Schema(description = "导游ID (tourisms.id)")
|
||||
private Long guideId;
|
||||
|
||||
@Schema(description = "导游编号")
|
||||
private String guideNo;
|
||||
|
||||
@Schema(description = "导游姓名")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "手机号")
|
||||
private String phone;
|
||||
|
||||
@Schema(description = "状态: 0-待审核 1-正常 2-禁用 3-审核拒绝")
|
||||
private Integer status;
|
||||
|
||||
@Schema(description = "状态描述")
|
||||
private String statusDesc;
|
||||
|
||||
@Schema(description = "佣金比例(%)")
|
||||
private BigDecimal commissionRate;
|
||||
|
||||
@Schema(description = "累计佣金(分)")
|
||||
private Long totalCommission;
|
||||
|
||||
@Schema(description = "可提现佣金(分)")
|
||||
private Long availableCommission;
|
||||
|
||||
@Schema(description = "租户ID")
|
||||
private String tenantId;
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.central.order.scheduler;
|
||||
|
||||
import com.central.common.context.TenantContextHolder;
|
||||
import com.central.order.service.guide.IGuideCommissionService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 导游佣金结算定时任务
|
||||
* 每天凌晨2点执行,结算T+N天前的待结算佣金
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class CommissionSettleScheduler {
|
||||
|
||||
private final IGuideCommissionService guideCommissionService;
|
||||
|
||||
/**
|
||||
* 结算周期(天),默认7天
|
||||
*/
|
||||
@Value("${guide.commission.settle-days:7}")
|
||||
private Integer settleDays;
|
||||
|
||||
/**
|
||||
* 是否启用自动结算
|
||||
*/
|
||||
@Value("${guide.commission.auto-settle:true}")
|
||||
private Boolean autoSettle;
|
||||
|
||||
/**
|
||||
* 每天凌晨2点执行佣金结算
|
||||
* cron表达式: 秒 分 时 日 月 周
|
||||
*/
|
||||
@Scheduled(cron = "${guide.commission.settle-cron:0 0 2 * * ?}")
|
||||
public void settleCommission() {
|
||||
if (!autoSettle) {
|
||||
log.debug("佣金自动结算已禁用,跳过执行");
|
||||
return;
|
||||
}
|
||||
|
||||
log.info("开始执行佣金结算定时任务, settleDays={}", settleDays);
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
TenantContextHolder.setTenant("webApp");
|
||||
int settledCount = guideCommissionService.batchSettleCommissions(settleDays);
|
||||
long costTime = System.currentTimeMillis() - startTime;
|
||||
log.info("佣金结算定时任务执行完成, 结算数量={}, 耗时={}ms", settledCount, costTime);
|
||||
} catch (Exception e) {
|
||||
log.error("佣金结算定时任务执行失败", e);
|
||||
} finally {
|
||||
TenantContextHolder.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -23,5 +23,10 @@ public interface ITourismFileService extends ISuperService<TourismFile> {
|
||||
|
||||
|
||||
PageResult<TourismFileGroupVO> findFilesGroupedByTenant(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 根据素材ID列表查询
|
||||
*/
|
||||
List<TourismFile> findByIds(List<Long> ids);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.central.order.service.guide;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.order.model.Order;
|
||||
import com.central.order.model.guide.GuideCommission;
|
||||
import com.central.order.model.vo.guide.CommissionOverviewVO;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游佣金服务接口
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
public interface IGuideCommissionService {
|
||||
|
||||
/**
|
||||
* 支付成功后检查并创建佣金明细
|
||||
* 在支付回调中调用此方法
|
||||
*
|
||||
* @param order 订单
|
||||
*/
|
||||
void createCommissionIfGuideOrder(Order order);
|
||||
|
||||
/**
|
||||
* 获取佣金概览
|
||||
*
|
||||
* @param guideId 导游ID
|
||||
* @return 佣金概览
|
||||
*/
|
||||
CommissionOverviewVO getCommissionOverview(Long guideId);
|
||||
|
||||
/**
|
||||
* 分页查询佣金明细
|
||||
*
|
||||
* @param params 查询参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResult<GuideCommission> findList(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 获取佣金详情
|
||||
*
|
||||
* @param commissionId 佣金ID
|
||||
* @return 佣金详情
|
||||
*/
|
||||
GuideCommission getById(Long commissionId);
|
||||
|
||||
/**
|
||||
* 结算佣金
|
||||
*
|
||||
* @param commissionId 佣金ID
|
||||
*/
|
||||
void settleCommission(Long commissionId);
|
||||
|
||||
/**
|
||||
* 批量结算待结算的佣金
|
||||
*
|
||||
* @param days 结算周期(天数)
|
||||
* @return 结算数量
|
||||
*/
|
||||
int batchSettleCommissions(int days);
|
||||
|
||||
/**
|
||||
* 退款时更新佣金状态
|
||||
*
|
||||
* @param orderNo 订单号
|
||||
*/
|
||||
void refundCommission(String orderNo);
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package com.central.order.service.guide;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.order.model.dto.guide.GuideAuditDTO;
|
||||
import com.central.order.model.dto.guide.GuideCreateDTO;
|
||||
import com.central.order.model.guide.GuideProfile;
|
||||
import com.central.order.model.vo.guide.GuideInfoVO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游服务接口
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
public interface IGuideService {
|
||||
|
||||
/**
|
||||
* 创建导游
|
||||
*
|
||||
* @param dto 创建请求
|
||||
* @return 导游ID (tourisms.id)
|
||||
*/
|
||||
Long createGuide(GuideCreateDTO dto);
|
||||
|
||||
/**
|
||||
* 获取导游信息
|
||||
*
|
||||
* @param guideId 导游ID (tourisms.id)
|
||||
* @return 导游信息
|
||||
*/
|
||||
GuideInfoVO getGuideInfo(Long guideId);
|
||||
|
||||
/**
|
||||
* 根据用户ID获取导游信息
|
||||
*
|
||||
* @param userId 用户ID
|
||||
* @return 导游信息
|
||||
*/
|
||||
GuideInfoVO getGuideInfoByUserId(Long userId);
|
||||
|
||||
/**
|
||||
* 获取导游扩展信息
|
||||
*
|
||||
* @param guideId 导游ID (tourisms.id)
|
||||
* @return 导游扩展信息
|
||||
*/
|
||||
GuideProfile getGuideProfile(Long guideId);
|
||||
|
||||
/**
|
||||
* 分页查询导游列表
|
||||
*
|
||||
* @param params 查询参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResult<GuideProfile> findList(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 审核导游
|
||||
*
|
||||
* @param guideId 导游ID
|
||||
* @param dto 审核请求
|
||||
*/
|
||||
void auditGuide(Long guideId, GuideAuditDTO dto);
|
||||
|
||||
/**
|
||||
* 更新导游状态
|
||||
*
|
||||
* @param guideId 导游ID
|
||||
* @param status 状态
|
||||
*/
|
||||
void updateStatus(Long guideId, Integer status);
|
||||
|
||||
/**
|
||||
* 设置佣金比例
|
||||
*
|
||||
* @param guideId 导游ID
|
||||
* @param commissionRate 佣金比例
|
||||
*/
|
||||
void setCommissionRate(Long guideId, BigDecimal commissionRate);
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package com.central.order.service.guide;
|
||||
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.order.model.dto.guide.WithdrawalApplyDTO;
|
||||
import com.central.order.model.dto.guide.WithdrawalAuditDTO;
|
||||
import com.central.order.model.guide.GuideWithdrawal;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 导游提现服务接口
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
public interface IGuideWithdrawalService {
|
||||
|
||||
/**
|
||||
* 申请提现
|
||||
*
|
||||
* @param guideId 导游ID
|
||||
* @param dto 申请请求
|
||||
* @return 提现单号
|
||||
*/
|
||||
String applyWithdrawal(Long guideId, WithdrawalApplyDTO dto);
|
||||
|
||||
/**
|
||||
* 分页查询提现记录
|
||||
*
|
||||
* @param params 查询参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
PageResult<GuideWithdrawal> findList(Map<String, Object> params);
|
||||
|
||||
/**
|
||||
* 获取提现详情
|
||||
*
|
||||
* @param withdrawalId 提现ID
|
||||
* @return 提现详情
|
||||
*/
|
||||
GuideWithdrawal getById(Long withdrawalId);
|
||||
|
||||
/**
|
||||
* 根据提现单号获取详情
|
||||
*
|
||||
* @param withdrawNo 提现单号
|
||||
* @return 提现详情
|
||||
*/
|
||||
GuideWithdrawal getByWithdrawNo(String withdrawNo);
|
||||
|
||||
/**
|
||||
* 审核提现
|
||||
*
|
||||
* @param withdrawalId 提现ID
|
||||
* @param dto 审核请求
|
||||
* @param auditUserId 审核人ID
|
||||
*/
|
||||
void auditWithdrawal(Long withdrawalId, WithdrawalAuditDTO dto, Long auditUserId);
|
||||
|
||||
/**
|
||||
* 执行打款
|
||||
*
|
||||
* @param withdrawalId 提现ID
|
||||
*/
|
||||
void executeTransfer(Long withdrawalId);
|
||||
|
||||
/**
|
||||
* 确认打款完成
|
||||
*
|
||||
* @param withdrawalId 提现ID
|
||||
* @param transferNo 转账单号
|
||||
*/
|
||||
void confirmTransfer(Long withdrawalId, String transferNo);
|
||||
|
||||
/**
|
||||
* 打款失败
|
||||
*
|
||||
* @param withdrawalId 提现ID
|
||||
* @param failReason 失败原因
|
||||
*/
|
||||
void transferFailed(Long withdrawalId, String failReason);
|
||||
}
|
||||
@@ -0,0 +1,230 @@
|
||||
package com.central.order.service.guide.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.order.enums.guide.CommissionStatusEnum;
|
||||
import com.central.order.enums.guide.GuideStatusEnum;
|
||||
import com.central.order.enums.guide.TourismTypeEnum;
|
||||
import com.central.order.mapper.TourismMapper;
|
||||
import com.central.order.mapper.guide.GuideCommissionMapper;
|
||||
import com.central.order.mapper.guide.GuideProfileMapper;
|
||||
import com.central.order.model.Order;
|
||||
import com.central.order.model.Tourism;
|
||||
import com.central.order.model.guide.GuideCommission;
|
||||
import com.central.order.model.guide.GuideProfile;
|
||||
import com.central.order.model.vo.guide.CommissionOverviewVO;
|
||||
import com.central.order.service.guide.IGuideCommissionService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 导游佣金服务实现
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GuideCommissionServiceImpl implements IGuideCommissionService {
|
||||
|
||||
private final TourismMapper tourismMapper;
|
||||
private final GuideProfileMapper guideProfileMapper;
|
||||
private final GuideCommissionMapper guideCommissionMapper;
|
||||
|
||||
private static final AtomicInteger COMMISSION_NO_COUNTER = new AtomicInteger(0);
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void createCommissionIfGuideOrder(Order order) {
|
||||
// 1. 查询订单关联的tourism
|
||||
Tourism tourism = tourismMapper.selectById(order.getTourismId());
|
||||
if (tourism == null) {
|
||||
log.debug("订单关联的tourism不存在: tourismId={}", order.getTourismId());
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. 判断是否为导游类型
|
||||
if (tourism.getTourismType() == null ||
|
||||
!tourism.getTourismType().equals(TourismTypeEnum.GUIDE.getId())) {
|
||||
// 不是导游订单,跳过
|
||||
log.debug("非导游订单,跳过佣金计算: tourismId={}, type={}",
|
||||
order.getTourismId(), tourism.getTourismType());
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. 检查是否已存在佣金记录(防止重复创建)
|
||||
GuideCommission existingCommission = guideCommissionMapper.selectByOrderNo(order.getOrderNo());
|
||||
if (existingCommission != null) {
|
||||
log.warn("佣金记录已存在,跳过: orderNo={}", order.getOrderNo());
|
||||
return;
|
||||
}
|
||||
|
||||
// 4. 查询导游扩展信息
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(tourism.getId());
|
||||
if (profile == null) {
|
||||
log.warn("导游扩展信息不存在: tourismId={}", tourism.getId());
|
||||
return;
|
||||
}
|
||||
if (!GuideStatusEnum.NORMAL.getId().equals(profile.getStatus())) {
|
||||
log.warn("导游状态异常,跳过佣金计算: tourismId={}, status={}", tourism.getId(), profile.getStatus());
|
||||
return;
|
||||
}
|
||||
|
||||
// 5. 计算佣金
|
||||
Long orderAmount = Long.parseLong(order.getOrderAmount());
|
||||
BigDecimal rate = profile.getCommissionRate();
|
||||
Long commissionAmount = new BigDecimal(orderAmount)
|
||||
.multiply(rate)
|
||||
.divide(new BigDecimal("100"), 0, RoundingMode.DOWN)
|
||||
.longValue();
|
||||
|
||||
// 6. 创建佣金记录
|
||||
GuideCommission commission = new GuideCommission();
|
||||
commission.setCommissionNo(generateCommissionNo());
|
||||
commission.setGuideId(tourism.getId());
|
||||
commission.setOrderNo(order.getOrderNo());
|
||||
commission.setOrderAmount(orderAmount);
|
||||
commission.setCommissionRate(rate);
|
||||
commission.setCommissionAmount(commissionAmount);
|
||||
commission.setStatus(CommissionStatusEnum.PENDING.getId());
|
||||
commission.setTenantId(order.getTenantId());
|
||||
|
||||
guideCommissionMapper.insert(commission);
|
||||
|
||||
// 7. 更新导游累计佣金
|
||||
guideProfileMapper.addTotalCommission(profile.getId(), commissionAmount);
|
||||
|
||||
log.info("创建导游佣金记录: guideId={}, orderNo={}, amount={}",
|
||||
tourism.getId(), order.getOrderNo(), commissionAmount);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommissionOverviewVO getCommissionOverview(Long guideId) {
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(guideId);
|
||||
if (profile == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
CommissionOverviewVO vo = new CommissionOverviewVO();
|
||||
vo.setTotalCommission(profile.getTotalCommission());
|
||||
vo.setAvailableCommission(profile.getAvailableCommission());
|
||||
vo.setFrozenCommission(profile.getFrozenCommission());
|
||||
vo.setWithdrawnCommission(profile.getWithdrawnCommission());
|
||||
vo.setTodayCommission(guideCommissionMapper.sumTodayCommission(guideId));
|
||||
vo.setMonthCommission(guideCommissionMapper.sumMonthCommission(guideId));
|
||||
vo.setPendingSettleCount(guideCommissionMapper.countPendingSettle(guideId));
|
||||
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<GuideCommission> findList(Map<String, Object> params) {
|
||||
Page<GuideCommission> page = new Page<>(
|
||||
Integer.parseInt(params.getOrDefault("page", "1").toString()),
|
||||
Integer.parseInt(params.getOrDefault("limit", "10").toString())
|
||||
);
|
||||
List<GuideCommission> list = guideCommissionMapper.findList(page, params);
|
||||
return PageResult.<GuideCommission>builder()
|
||||
.data(list)
|
||||
.count(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuideCommission getById(Long commissionId) {
|
||||
return guideCommissionMapper.selectById(commissionId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void settleCommission(Long commissionId) {
|
||||
GuideCommission commission = guideCommissionMapper.selectById(commissionId);
|
||||
if (commission == null) {
|
||||
log.warn("佣金记录不存在: commissionId={}", commissionId);
|
||||
return;
|
||||
}
|
||||
if (!CommissionStatusEnum.PENDING.getId().equals(commission.getStatus())) {
|
||||
log.warn("佣金状态非待结算,跳过: commissionId={}, status={}", commissionId, commission.getStatus());
|
||||
return;
|
||||
}
|
||||
|
||||
// 更新佣金状态为已结算
|
||||
commission.setStatus(CommissionStatusEnum.SETTLED.getId());
|
||||
commission.setSettleTime(LocalDateTime.now());
|
||||
guideCommissionMapper.updateById(commission);
|
||||
|
||||
// 更新导游可提现余额
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(commission.getGuideId());
|
||||
if (profile != null) {
|
||||
guideProfileMapper.addAvailableCommission(profile.getId(), commission.getCommissionAmount());
|
||||
}
|
||||
|
||||
log.info("佣金结算成功: commissionId={}, amount={}", commissionId, commission.getCommissionAmount());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int batchSettleCommissions(int days) {
|
||||
LocalDateTime beforeTime = LocalDateTime.now().minusDays(days);
|
||||
List<GuideCommission> pendingList = guideCommissionMapper.selectPendingSettleList(beforeTime, 500);
|
||||
|
||||
int successCount = 0;
|
||||
for (GuideCommission commission : pendingList) {
|
||||
try {
|
||||
settleCommission(commission.getId());
|
||||
successCount++;
|
||||
} catch (Exception e) {
|
||||
log.error("佣金结算失败: commissionId={}", commission.getId(), e);
|
||||
}
|
||||
}
|
||||
|
||||
log.info("批量佣金结算完成: total={}, success={}", pendingList.size(), successCount);
|
||||
return successCount;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void refundCommission(String orderNo) {
|
||||
GuideCommission commission = guideCommissionMapper.selectByOrderNo(orderNo);
|
||||
if (commission == null) {
|
||||
log.debug("未找到订单对应的佣金记录: orderNo={}", orderNo);
|
||||
return;
|
||||
}
|
||||
|
||||
Integer oldStatus = commission.getStatus();
|
||||
commission.setStatus(CommissionStatusEnum.REFUNDED.getId());
|
||||
commission.setRemark("订单退款");
|
||||
guideCommissionMapper.updateById(commission);
|
||||
|
||||
// 如果是已结算的佣金,需要扣减可提现余额
|
||||
if (CommissionStatusEnum.SETTLED.getId().equals(oldStatus)) {
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(commission.getGuideId());
|
||||
if (profile != null && profile.getAvailableCommission() >= commission.getCommissionAmount()) {
|
||||
guideProfileMapper.addAvailableCommission(profile.getId(), -commission.getCommissionAmount());
|
||||
}
|
||||
}
|
||||
|
||||
log.info("佣金已退款: orderNo={}, commissionId={}", orderNo, commission.getId());
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成佣金单号
|
||||
*/
|
||||
private String generateCommissionNo() {
|
||||
String dateStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
int seq = COMMISSION_NO_COUNTER.incrementAndGet() % 1000000;
|
||||
return String.format("CM%s%06d", dateStr, seq);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,207 @@
|
||||
package com.central.order.service.guide.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.order.enums.guide.GuideStatusEnum;
|
||||
import com.central.order.enums.guide.TourismTypeEnum;
|
||||
import com.central.order.mapper.TourismMapper;
|
||||
import com.central.order.mapper.guide.GuideProfileMapper;
|
||||
import com.central.order.model.Tourism;
|
||||
import com.central.order.model.dto.guide.GuideAuditDTO;
|
||||
import com.central.order.model.dto.guide.GuideCreateDTO;
|
||||
import com.central.order.model.guide.GuideProfile;
|
||||
import com.central.order.model.vo.guide.GuideInfoVO;
|
||||
import com.central.order.service.guide.IGuideService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 导游服务实现
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GuideServiceImpl implements IGuideService {
|
||||
|
||||
private final TourismMapper tourismMapper;
|
||||
private final GuideProfileMapper guideProfileMapper;
|
||||
|
||||
private static final AtomicInteger GUIDE_NO_COUNTER = new AtomicInteger(0);
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Long createGuide(GuideCreateDTO dto) {
|
||||
// 1. 在tourisms表创建导游记录
|
||||
Tourism guide = new Tourism();
|
||||
guide.setTourismName(dto.getName());
|
||||
guide.setTourismType(TourismTypeEnum.GUIDE.getId());
|
||||
guide.setTenantId(dto.getTenantId());
|
||||
guide.setTourismPhone(dto.getPhone());
|
||||
guide.setStatus(GuideStatusEnum.PENDING.getId());
|
||||
guide.setIsDel(0);
|
||||
tourismMapper.insert(guide);
|
||||
|
||||
// 2. 创建导游扩展信息
|
||||
GuideProfile profile = new GuideProfile();
|
||||
profile.setTourismId(guide.getId());
|
||||
profile.setUserId(dto.getUserId());
|
||||
profile.setGuideNo(generateGuideNo());
|
||||
profile.setIdCard(dto.getIdCard());
|
||||
profile.setOpenid(dto.getOpenid());
|
||||
profile.setBankAccount(dto.getBankAccount());
|
||||
profile.setBankName(dto.getBankName());
|
||||
profile.setCommissionRate(dto.getCommissionRate() != null ?
|
||||
dto.getCommissionRate() : new BigDecimal("10.00"));
|
||||
profile.setStatus(GuideStatusEnum.PENDING.getId());
|
||||
profile.setTotalCommission(0L);
|
||||
profile.setAvailableCommission(0L);
|
||||
profile.setFrozenCommission(0L);
|
||||
profile.setWithdrawnCommission(0L);
|
||||
profile.setTenantId(dto.getTenantId());
|
||||
guideProfileMapper.insert(profile);
|
||||
|
||||
log.info("创建导游成功: guideId={}, guideNo={}", guide.getId(), profile.getGuideNo());
|
||||
return guide.getId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuideInfoVO getGuideInfo(Long guideId) {
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(guideId);
|
||||
if (profile == null) {
|
||||
return null;
|
||||
}
|
||||
return buildGuideInfoVO(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuideInfoVO getGuideInfoByUserId(Long userId) {
|
||||
GuideProfile profile = guideProfileMapper.selectByUserId(userId);
|
||||
if (profile == null) {
|
||||
return null;
|
||||
}
|
||||
return buildGuideInfoVO(profile);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuideProfile getGuideProfile(Long guideId) {
|
||||
return guideProfileMapper.selectByTourismId(guideId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<GuideProfile> findList(Map<String, Object> params) {
|
||||
Page<GuideProfile> page = new Page<>(
|
||||
Integer.parseInt(params.getOrDefault("page", "1").toString()),
|
||||
Integer.parseInt(params.getOrDefault("limit", "10").toString())
|
||||
);
|
||||
List<GuideProfile> list = guideProfileMapper.findList(page, params);
|
||||
return PageResult.<GuideProfile>builder()
|
||||
.data(list)
|
||||
.count(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void auditGuide(Long guideId, GuideAuditDTO dto) {
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(guideId);
|
||||
if (profile == null) {
|
||||
throw new RuntimeException("导游不存在");
|
||||
}
|
||||
|
||||
Integer newStatus = dto.getApproved() ?
|
||||
GuideStatusEnum.NORMAL.getId() : GuideStatusEnum.REJECTED.getId();
|
||||
|
||||
// 更新导游扩展信息状态
|
||||
profile.setStatus(newStatus);
|
||||
profile.setAuditRemark(dto.getRemark());
|
||||
profile.setUpdateTime(LocalDateTime.now());
|
||||
guideProfileMapper.updateById(profile);
|
||||
|
||||
// 更新tourisms表状态
|
||||
Tourism tourism = tourismMapper.selectById(guideId);
|
||||
if (tourism != null) {
|
||||
tourism.setStatus(newStatus);
|
||||
tourismMapper.updateById(tourism);
|
||||
}
|
||||
|
||||
log.info("审核导游: guideId={}, approved={}, status={}", guideId, dto.getApproved(), newStatus);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateStatus(Long guideId, Integer status) {
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(guideId);
|
||||
if (profile == null) {
|
||||
throw new RuntimeException("导游不存在");
|
||||
}
|
||||
|
||||
profile.setStatus(status);
|
||||
profile.setUpdateTime(LocalDateTime.now());
|
||||
guideProfileMapper.updateById(profile);
|
||||
|
||||
// 同步更新tourisms表状态
|
||||
Tourism tourism = tourismMapper.selectById(guideId);
|
||||
if (tourism != null) {
|
||||
tourism.setStatus(status);
|
||||
tourismMapper.updateById(tourism);
|
||||
}
|
||||
|
||||
log.info("更新导游状态: guideId={}, status={}", guideId, status);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCommissionRate(Long guideId, BigDecimal commissionRate) {
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(guideId);
|
||||
if (profile == null) {
|
||||
throw new RuntimeException("导游不存在");
|
||||
}
|
||||
|
||||
profile.setCommissionRate(commissionRate);
|
||||
profile.setUpdateTime(LocalDateTime.now());
|
||||
guideProfileMapper.updateById(profile);
|
||||
|
||||
log.info("设置佣金比例: guideId={}, rate={}", guideId, commissionRate);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成导游编号
|
||||
*/
|
||||
private String generateGuideNo() {
|
||||
String dateStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
int seq = GUIDE_NO_COUNTER.incrementAndGet() % 10000;
|
||||
return String.format("G%s%04d", dateStr, seq);
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建导游信息VO
|
||||
*/
|
||||
private GuideInfoVO buildGuideInfoVO(GuideProfile profile) {
|
||||
GuideInfoVO vo = new GuideInfoVO();
|
||||
vo.setGuideId(profile.getTourismId());
|
||||
vo.setGuideNo(profile.getGuideNo());
|
||||
vo.setName(profile.getGuideName());
|
||||
vo.setPhone(profile.getGuidePhone());
|
||||
vo.setStatus(profile.getStatus());
|
||||
vo.setStatusDesc(GuideStatusEnum.getById(profile.getStatus()) != null ?
|
||||
GuideStatusEnum.getById(profile.getStatus()).getContent() : "未知");
|
||||
vo.setCommissionRate(profile.getCommissionRate());
|
||||
vo.setTotalCommission(profile.getTotalCommission());
|
||||
vo.setAvailableCommission(profile.getAvailableCommission());
|
||||
vo.setTenantId(profile.getTenantId());
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,247 @@
|
||||
package com.central.order.service.guide.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.central.common.model.PageResult;
|
||||
import com.central.order.enums.guide.GuideStatusEnum;
|
||||
import com.central.order.enums.guide.WithdrawalStatusEnum;
|
||||
import com.central.order.mapper.guide.GuideProfileMapper;
|
||||
import com.central.order.mapper.guide.GuideWithdrawalMapper;
|
||||
import com.central.order.model.dto.guide.WithdrawalApplyDTO;
|
||||
import com.central.order.model.dto.guide.WithdrawalAuditDTO;
|
||||
import com.central.order.model.guide.GuideProfile;
|
||||
import com.central.order.model.guide.GuideWithdrawal;
|
||||
import com.central.order.service.guide.IGuideWithdrawalService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
/**
|
||||
* 导游提现服务实现
|
||||
*
|
||||
* @author dzc
|
||||
* @date 2024-12-01
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class GuideWithdrawalServiceImpl implements IGuideWithdrawalService {
|
||||
|
||||
private final GuideProfileMapper guideProfileMapper;
|
||||
private final GuideWithdrawalMapper guideWithdrawalMapper;
|
||||
|
||||
private static final AtomicInteger WITHDRAW_NO_COUNTER = new AtomicInteger(0);
|
||||
|
||||
@Value("${guide.withdrawal.min-amount:10000}")
|
||||
private Long minWithdrawAmount;
|
||||
|
||||
@Value("${guide.withdrawal.max-amount:500000}")
|
||||
private Long maxWithdrawAmount;
|
||||
|
||||
@Value("${guide.withdrawal.max-daily-count:3}")
|
||||
private Integer maxDailyCount;
|
||||
|
||||
@Value("${guide.withdrawal.fee-rate:0}")
|
||||
private Double feeRate;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public String applyWithdrawal(Long guideId, WithdrawalApplyDTO dto) {
|
||||
// 1. 查询导游信息
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(guideId);
|
||||
if (profile == null) {
|
||||
throw new RuntimeException("导游不存在");
|
||||
}
|
||||
if (!GuideStatusEnum.NORMAL.getId().equals(profile.getStatus())) {
|
||||
throw new RuntimeException("导游状态异常,无法提现");
|
||||
}
|
||||
|
||||
// 2. 校验提现金额
|
||||
Long amount = dto.getAmount();
|
||||
if (amount < minWithdrawAmount) {
|
||||
throw new RuntimeException("提现金额不能低于" + (minWithdrawAmount / 100) + "元");
|
||||
}
|
||||
if (amount > maxWithdrawAmount) {
|
||||
throw new RuntimeException("单次提现金额不能超过" + (maxWithdrawAmount / 100) + "元");
|
||||
}
|
||||
if (amount > profile.getAvailableCommission()) {
|
||||
throw new RuntimeException("可提现余额不足");
|
||||
}
|
||||
|
||||
// 3. 校验每日提现次数
|
||||
Integer todayCount = guideWithdrawalMapper.countTodayWithdrawal(guideId);
|
||||
if (todayCount >= maxDailyCount) {
|
||||
throw new RuntimeException("今日提现次数已达上限");
|
||||
}
|
||||
|
||||
// 4. 冻结提现金额
|
||||
int rows = guideProfileMapper.freezeCommission(profile.getId(), amount);
|
||||
if (rows == 0) {
|
||||
throw new RuntimeException("冻结余额失败,可能余额不足");
|
||||
}
|
||||
|
||||
// 5. 计算手续费
|
||||
Long fee = BigDecimal.valueOf(feeRate)
|
||||
.multiply(BigDecimal.valueOf(amount))
|
||||
.divide(BigDecimal.valueOf(100), 0, RoundingMode.UP)
|
||||
.longValue();
|
||||
Long actualAmount = amount - fee;
|
||||
|
||||
// 6. 创建提现申请
|
||||
GuideWithdrawal withdrawal = new GuideWithdrawal();
|
||||
withdrawal.setWithdrawNo(generateWithdrawNo());
|
||||
withdrawal.setGuideId(guideId);
|
||||
withdrawal.setAmount(amount);
|
||||
withdrawal.setActualAmount(actualAmount);
|
||||
withdrawal.setFee(fee);
|
||||
withdrawal.setWithdrawType(dto.getWithdrawType());
|
||||
withdrawal.setAccountInfo(dto.getAccountInfo());
|
||||
withdrawal.setStatus(WithdrawalStatusEnum.PENDING.getId());
|
||||
withdrawal.setApplyTime(LocalDateTime.now());
|
||||
withdrawal.setTenantId(profile.getTenantId());
|
||||
|
||||
guideWithdrawalMapper.insert(withdrawal);
|
||||
|
||||
log.info("提现申请已提交: guideId={}, withdrawNo={}, amount={}", guideId, withdrawal.getWithdrawNo(), amount);
|
||||
return withdrawal.getWithdrawNo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PageResult<GuideWithdrawal> findList(Map<String, Object> params) {
|
||||
Page<GuideWithdrawal> page = new Page<>(
|
||||
Integer.parseInt(params.getOrDefault("page", "1").toString()),
|
||||
Integer.parseInt(params.getOrDefault("limit", "10").toString())
|
||||
);
|
||||
List<GuideWithdrawal> list = guideWithdrawalMapper.findList(page, params);
|
||||
return PageResult.<GuideWithdrawal>builder()
|
||||
.data(list)
|
||||
.count(page.getTotal())
|
||||
.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuideWithdrawal getById(Long withdrawalId) {
|
||||
return guideWithdrawalMapper.selectById(withdrawalId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GuideWithdrawal getByWithdrawNo(String withdrawNo) {
|
||||
return guideWithdrawalMapper.selectByWithdrawNo(withdrawNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void auditWithdrawal(Long withdrawalId, WithdrawalAuditDTO dto, Long auditUserId) {
|
||||
GuideWithdrawal withdrawal = guideWithdrawalMapper.selectById(withdrawalId);
|
||||
if (withdrawal == null) {
|
||||
throw new RuntimeException("提现申请不存在");
|
||||
}
|
||||
if (!WithdrawalStatusEnum.PENDING.getId().equals(withdrawal.getStatus())) {
|
||||
throw new RuntimeException("提现申请状态不允许审核");
|
||||
}
|
||||
|
||||
if (dto.getApproved()) {
|
||||
// 审核通过
|
||||
withdrawal.setStatus(WithdrawalStatusEnum.APPROVED.getId());
|
||||
} else {
|
||||
// 审核拒绝,解冻金额
|
||||
withdrawal.setStatus(WithdrawalStatusEnum.REJECTED.getId());
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(withdrawal.getGuideId());
|
||||
if (profile != null) {
|
||||
guideProfileMapper.unfreezeCommission(profile.getId(), withdrawal.getAmount());
|
||||
}
|
||||
}
|
||||
|
||||
withdrawal.setAuditUserId(auditUserId);
|
||||
withdrawal.setAuditTime(LocalDateTime.now());
|
||||
withdrawal.setAuditRemark(dto.getRemark());
|
||||
guideWithdrawalMapper.updateById(withdrawal);
|
||||
|
||||
log.info("提现审核完成: withdrawalId={}, approved={}", withdrawalId, dto.getApproved());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void executeTransfer(Long withdrawalId) {
|
||||
GuideWithdrawal withdrawal = guideWithdrawalMapper.selectById(withdrawalId);
|
||||
if (withdrawal == null) {
|
||||
throw new RuntimeException("提现申请不存在");
|
||||
}
|
||||
if (!WithdrawalStatusEnum.APPROVED.getId().equals(withdrawal.getStatus())) {
|
||||
throw new RuntimeException("提现申请状态不允许打款");
|
||||
}
|
||||
|
||||
// 更新状态为打款中
|
||||
withdrawal.setStatus(WithdrawalStatusEnum.TRANSFERRING.getId());
|
||||
guideWithdrawalMapper.updateById(withdrawal);
|
||||
|
||||
// TODO: 调用微信企业付款API或银行转账API
|
||||
// 这里需要根据实际情况对接支付接口
|
||||
|
||||
log.info("开始执行打款: withdrawalId={}, amount={}", withdrawalId, withdrawal.getActualAmount());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void confirmTransfer(Long withdrawalId, String transferNo) {
|
||||
GuideWithdrawal withdrawal = guideWithdrawalMapper.selectById(withdrawalId);
|
||||
if (withdrawal == null) {
|
||||
throw new RuntimeException("提现申请不存在");
|
||||
}
|
||||
|
||||
// 更新状态为已到账
|
||||
withdrawal.setStatus(WithdrawalStatusEnum.COMPLETED.getId());
|
||||
withdrawal.setTransferTime(LocalDateTime.now());
|
||||
withdrawal.setTransferNo(transferNo);
|
||||
guideWithdrawalMapper.updateById(withdrawal);
|
||||
|
||||
// 完成提现:从冻结转到已提现
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(withdrawal.getGuideId());
|
||||
if (profile != null) {
|
||||
guideProfileMapper.completeWithdrawal(profile.getId(), withdrawal.getAmount());
|
||||
}
|
||||
|
||||
log.info("打款完成: withdrawalId={}, transferNo={}", withdrawalId, transferNo);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void transferFailed(Long withdrawalId, String failReason) {
|
||||
GuideWithdrawal withdrawal = guideWithdrawalMapper.selectById(withdrawalId);
|
||||
if (withdrawal == null) {
|
||||
throw new RuntimeException("提现申请不存在");
|
||||
}
|
||||
|
||||
// 更新状态为打款失败
|
||||
withdrawal.setStatus(WithdrawalStatusEnum.FAILED.getId());
|
||||
withdrawal.setFailReason(failReason);
|
||||
guideWithdrawalMapper.updateById(withdrawal);
|
||||
|
||||
// 解冻金额
|
||||
GuideProfile profile = guideProfileMapper.selectByTourismId(withdrawal.getGuideId());
|
||||
if (profile != null) {
|
||||
guideProfileMapper.unfreezeCommission(profile.getId(), withdrawal.getAmount());
|
||||
}
|
||||
|
||||
log.info("打款失败: withdrawalId={}, reason={}", withdrawalId, failReason);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成提现单号
|
||||
*/
|
||||
private String generateWithdrawNo() {
|
||||
String dateStr = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyyMMdd"));
|
||||
int seq = WITHDRAW_NO_COUNTER.incrementAndGet() % 100000;
|
||||
return String.format("W%s%05d", dateStr, seq);
|
||||
}
|
||||
}
|
||||
@@ -134,5 +134,24 @@ public class TourismFileServiceImpl extends SuperServiceImpl<TourismFileMapper,
|
||||
|
||||
return PageResult.<TourismFileGroupVO>builder().data(result).resp_code(0).count(total).build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TourismFile> findByIds(List<Long> ids) {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
List<TourismFile> files = baseMapper.findByIds(ids);
|
||||
// 转换图片URL
|
||||
if (files != null) {
|
||||
for (TourismFile f : files) {
|
||||
if (f != null && f.getImageUrl() != null) {
|
||||
try {
|
||||
f.setImageUrl(fileCenterService.getViewUrlByPath(f.getImageUrl()));
|
||||
} catch (Exception ignored) {}
|
||||
}
|
||||
}
|
||||
}
|
||||
return files == null ? Collections.emptyList() : files;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,5 +37,16 @@
|
||||
</where>
|
||||
ORDER BY id DESC
|
||||
</select>
|
||||
|
||||
<!-- 根据素材ID列表查询 -->
|
||||
<select id="findByIds" resultType="com.central.order.model.TourismFile">
|
||||
SELECT * FROM tourisms_files
|
||||
WHERE id IN
|
||||
<foreach collection="ids" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
AND (is_del = 0 OR is_del IS NULL)
|
||||
ORDER BY id DESC
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
|
||||
@@ -0,0 +1,112 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.central.order.mapper.guide.GuideCommissionMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.central.order.model.guide.GuideCommission">
|
||||
<id column="id" property="id"/>
|
||||
<result column="commission_no" property="commissionNo"/>
|
||||
<result column="guide_id" property="guideId"/>
|
||||
<result column="order_no" property="orderNo"/>
|
||||
<result column="order_amount" property="orderAmount"/>
|
||||
<result column="commission_rate" property="commissionRate"/>
|
||||
<result column="commission_amount" property="commissionAmount"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="settle_time" property="settleTime"/>
|
||||
<result column="remark" property="remark"/>
|
||||
<result column="tenant_id" property="tenantId"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="guide_name" property="guideName"/>
|
||||
<result column="guide_no" property="guideNo"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByOrderNo" resultMap="BaseResultMap">
|
||||
SELECT gc.*, t.tourism_name as guide_name, gp.guide_no
|
||||
FROM guide_commissions gc
|
||||
LEFT JOIN tourisms t ON gc.guide_id = t.id
|
||||
LEFT JOIN guide_profiles gp ON gc.guide_id = gp.tourism_id
|
||||
WHERE gc.order_no = #{orderNo}
|
||||
</select>
|
||||
|
||||
<select id="selectByCommissionNo" resultMap="BaseResultMap">
|
||||
SELECT gc.*, t.tourism_name as guide_name, gp.guide_no
|
||||
FROM guide_commissions gc
|
||||
LEFT JOIN tourisms t ON gc.guide_id = t.id
|
||||
LEFT JOIN guide_profiles gp ON gc.guide_id = gp.tourism_id
|
||||
WHERE gc.commission_no = #{commissionNo}
|
||||
</select>
|
||||
|
||||
<select id="findList" resultMap="BaseResultMap">
|
||||
SELECT gc.*, t.tourism_name as guide_name, gp.guide_no
|
||||
FROM guide_commissions gc
|
||||
LEFT JOIN tourisms t ON gc.guide_id = t.id
|
||||
LEFT JOIN guide_profiles gp ON gc.guide_id = gp.tourism_id
|
||||
<where>
|
||||
<if test="p.tenantIds != null and p.tenantIds.size > 0">
|
||||
AND gc.tenant_id IN
|
||||
<foreach collection="p.tenantIds" item="tid" open="(" separator="," close=")">
|
||||
#{tid}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="(p.tenantIds == null or p.tenantIds.size == 0) and p.tenantId != null and p.tenantId != ''">
|
||||
AND gc.tenant_id = #{p.tenantId}
|
||||
</if>
|
||||
<if test="p.guideId != null">
|
||||
AND gc.guide_id = #{p.guideId}
|
||||
</if>
|
||||
<if test="p.status != null">
|
||||
AND gc.status = #{p.status}
|
||||
</if>
|
||||
<if test="p.orderNo != null and p.orderNo != ''">
|
||||
AND gc.order_no = #{p.orderNo}
|
||||
</if>
|
||||
<if test="p.commissionNo != null and p.commissionNo != ''">
|
||||
AND gc.commission_no = #{p.commissionNo}
|
||||
</if>
|
||||
<if test="p.startTime != null">
|
||||
AND gc.create_time >= #{p.startTime}
|
||||
</if>
|
||||
<if test="p.endTime != null">
|
||||
AND gc.create_time <= #{p.endTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY gc.id DESC
|
||||
</select>
|
||||
|
||||
<select id="selectPendingSettleList" resultMap="BaseResultMap">
|
||||
SELECT gc.*, t.tourism_name as guide_name, gp.guide_no
|
||||
FROM guide_commissions gc
|
||||
LEFT JOIN tourisms t ON gc.guide_id = t.id
|
||||
LEFT JOIN guide_profiles gp ON gc.guide_id = gp.tourism_id
|
||||
WHERE gc.status = 0
|
||||
AND gc.create_time <= #{beforeTime}
|
||||
ORDER BY gc.create_time ASC
|
||||
<if test="limit != null and limit > 0">
|
||||
LIMIT #{limit}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="sumTodayCommission" resultType="java.lang.Long">
|
||||
SELECT IFNULL(SUM(commission_amount), 0)
|
||||
FROM guide_commissions
|
||||
WHERE guide_id = #{guideId}
|
||||
AND DATE(create_time) = CURDATE()
|
||||
</select>
|
||||
|
||||
<select id="sumMonthCommission" resultType="java.lang.Long">
|
||||
SELECT IFNULL(SUM(commission_amount), 0)
|
||||
FROM guide_commissions
|
||||
WHERE guide_id = #{guideId}
|
||||
AND YEAR(create_time) = YEAR(CURDATE())
|
||||
AND MONTH(create_time) = MONTH(CURDATE())
|
||||
</select>
|
||||
|
||||
<select id="countPendingSettle" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM guide_commissions
|
||||
WHERE guide_id = #{guideId}
|
||||
AND status = 0
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.central.order.mapper.guide.GuideProfileMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.central.order.model.guide.GuideProfile">
|
||||
<id column="id" property="id"/>
|
||||
<result column="tourism_id" property="tourismId"/>
|
||||
<result column="user_id" property="userId"/>
|
||||
<result column="guide_no" property="guideNo"/>
|
||||
<result column="id_card" property="idCard"/>
|
||||
<result column="openid" property="openid"/>
|
||||
<result column="bank_account" property="bankAccount"/>
|
||||
<result column="bank_name" property="bankName"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="audit_remark" property="auditRemark"/>
|
||||
<result column="commission_rate" property="commissionRate"/>
|
||||
<result column="total_commission" property="totalCommission"/>
|
||||
<result column="available_commission" property="availableCommission"/>
|
||||
<result column="frozen_commission" property="frozenCommission"/>
|
||||
<result column="withdrawn_commission" property="withdrawnCommission"/>
|
||||
<result column="tenant_id" property="tenantId"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="guide_name" property="guideName"/>
|
||||
<result column="guide_phone" property="guidePhone"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByTourismId" resultMap="BaseResultMap">
|
||||
SELECT gp.*, t.tourism_name as guide_name, t.tourism_phone as guide_phone
|
||||
FROM guide_profiles gp
|
||||
LEFT JOIN tourisms t ON gp.tourism_id = t.id
|
||||
WHERE gp.tourism_id = #{tourismId}
|
||||
</select>
|
||||
|
||||
<select id="selectByUserId" resultMap="BaseResultMap">
|
||||
SELECT gp.*, t.tourism_name as guide_name, t.tourism_phone as guide_phone
|
||||
FROM guide_profiles gp
|
||||
LEFT JOIN tourisms t ON gp.tourism_id = t.id
|
||||
WHERE gp.user_id = #{userId}
|
||||
</select>
|
||||
|
||||
<select id="selectByGuideNo" resultMap="BaseResultMap">
|
||||
SELECT gp.*, t.tourism_name as guide_name, t.tourism_phone as guide_phone
|
||||
FROM guide_profiles gp
|
||||
LEFT JOIN tourisms t ON gp.tourism_id = t.id
|
||||
WHERE gp.guide_no = #{guideNo}
|
||||
</select>
|
||||
|
||||
<select id="findList" resultMap="BaseResultMap">
|
||||
SELECT gp.*, t.tourism_name as guide_name, t.tourism_phone as guide_phone
|
||||
FROM guide_profiles gp
|
||||
LEFT JOIN tourisms t ON gp.tourism_id = t.id
|
||||
WHERE t.tourism_type = 2
|
||||
<if test="p.tenantIds != null and p.tenantIds.size > 0">
|
||||
AND gp.tenant_id IN
|
||||
<foreach collection="p.tenantIds" item="tid" open="(" separator="," close=")">
|
||||
#{tid}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="(p.tenantIds == null or p.tenantIds.size == 0) and p.tenantId != null and p.tenantId != ''">
|
||||
AND gp.tenant_id = #{p.tenantId}
|
||||
</if>
|
||||
<if test="p.guideName != null and p.guideName != ''">
|
||||
AND t.tourism_name LIKE CONCAT('%', #{p.guideName}, '%')
|
||||
</if>
|
||||
<if test="p.guideNo != null and p.guideNo != ''">
|
||||
AND gp.guide_no = #{p.guideNo}
|
||||
</if>
|
||||
<if test="p.status != null">
|
||||
AND gp.status = #{p.status}
|
||||
</if>
|
||||
<if test="p.phone != null and p.phone != ''">
|
||||
AND t.tourism_phone = #{p.phone}
|
||||
</if>
|
||||
ORDER BY gp.id DESC
|
||||
</select>
|
||||
|
||||
<update id="addTotalCommission">
|
||||
UPDATE guide_profiles
|
||||
SET total_commission = total_commission + #{amount},
|
||||
update_time = NOW()
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="addAvailableCommission">
|
||||
UPDATE guide_profiles
|
||||
SET available_commission = available_commission + #{amount},
|
||||
update_time = NOW()
|
||||
WHERE id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="freezeCommission">
|
||||
UPDATE guide_profiles
|
||||
SET available_commission = available_commission - #{amount},
|
||||
frozen_commission = frozen_commission + #{amount},
|
||||
update_time = NOW()
|
||||
WHERE id = #{id}
|
||||
AND available_commission >= #{amount}
|
||||
</update>
|
||||
|
||||
<update id="unfreezeCommission">
|
||||
UPDATE guide_profiles
|
||||
SET available_commission = available_commission + #{amount},
|
||||
frozen_commission = frozen_commission - #{amount},
|
||||
update_time = NOW()
|
||||
WHERE id = #{id}
|
||||
AND frozen_commission >= #{amount}
|
||||
</update>
|
||||
|
||||
<update id="completeWithdrawal">
|
||||
UPDATE guide_profiles
|
||||
SET frozen_commission = frozen_commission - #{amount},
|
||||
withdrawn_commission = withdrawn_commission + #{amount},
|
||||
update_time = NOW()
|
||||
WHERE id = #{id}
|
||||
AND frozen_commission >= #{amount}
|
||||
</update>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,93 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.central.order.mapper.guide.GuideWithdrawalMapper">
|
||||
|
||||
<resultMap id="BaseResultMap" type="com.central.order.model.guide.GuideWithdrawal">
|
||||
<id column="id" property="id"/>
|
||||
<result column="withdraw_no" property="withdrawNo"/>
|
||||
<result column="guide_id" property="guideId"/>
|
||||
<result column="amount" property="amount"/>
|
||||
<result column="actual_amount" property="actualAmount"/>
|
||||
<result column="fee" property="fee"/>
|
||||
<result column="withdraw_type" property="withdrawType"/>
|
||||
<result column="account_info" property="accountInfo"/>
|
||||
<result column="status" property="status"/>
|
||||
<result column="apply_time" property="applyTime"/>
|
||||
<result column="audit_user_id" property="auditUserId"/>
|
||||
<result column="audit_time" property="auditTime"/>
|
||||
<result column="audit_remark" property="auditRemark"/>
|
||||
<result column="transfer_time" property="transferTime"/>
|
||||
<result column="transfer_no" property="transferNo"/>
|
||||
<result column="fail_reason" property="failReason"/>
|
||||
<result column="tenant_id" property="tenantId"/>
|
||||
<result column="create_time" property="createTime"/>
|
||||
<result column="update_time" property="updateTime"/>
|
||||
<result column="guide_name" property="guideName"/>
|
||||
<result column="guide_no" property="guideNo"/>
|
||||
<result column="guide_phone" property="guidePhone"/>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectByWithdrawNo" resultMap="BaseResultMap">
|
||||
SELECT gw.*, t.tourism_name as guide_name, t.tourism_phone as guide_phone, gp.guide_no
|
||||
FROM guide_withdrawals gw
|
||||
LEFT JOIN tourisms t ON gw.guide_id = t.id
|
||||
LEFT JOIN guide_profiles gp ON gw.guide_id = gp.tourism_id
|
||||
WHERE gw.withdraw_no = #{withdrawNo}
|
||||
</select>
|
||||
|
||||
<select id="findList" resultMap="BaseResultMap">
|
||||
SELECT gw.*, t.tourism_name as guide_name, t.tourism_phone as guide_phone, gp.guide_no
|
||||
FROM guide_withdrawals gw
|
||||
LEFT JOIN tourisms t ON gw.guide_id = t.id
|
||||
LEFT JOIN guide_profiles gp ON gw.guide_id = gp.tourism_id
|
||||
<where>
|
||||
<if test="p.tenantIds != null and p.tenantIds.size > 0">
|
||||
AND gw.tenant_id IN
|
||||
<foreach collection="p.tenantIds" item="tid" open="(" separator="," close=")">
|
||||
#{tid}
|
||||
</foreach>
|
||||
</if>
|
||||
<if test="(p.tenantIds == null or p.tenantIds.size == 0) and p.tenantId != null and p.tenantId != ''">
|
||||
AND gw.tenant_id = #{p.tenantId}
|
||||
</if>
|
||||
<if test="p.guideId != null">
|
||||
AND gw.guide_id = #{p.guideId}
|
||||
</if>
|
||||
<if test="p.status != null">
|
||||
AND gw.status = #{p.status}
|
||||
</if>
|
||||
<if test="p.withdrawNo != null and p.withdrawNo != ''">
|
||||
AND gw.withdraw_no = #{p.withdrawNo}
|
||||
</if>
|
||||
<if test="p.startTime != null">
|
||||
AND gw.apply_time >= #{p.startTime}
|
||||
</if>
|
||||
<if test="p.endTime != null">
|
||||
AND gw.apply_time <= #{p.endTime}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY gw.id DESC
|
||||
</select>
|
||||
|
||||
<select id="selectApprovedList" resultMap="BaseResultMap">
|
||||
SELECT gw.*, t.tourism_name as guide_name, t.tourism_phone as guide_phone, gp.guide_no
|
||||
FROM guide_withdrawals gw
|
||||
LEFT JOIN tourisms t ON gw.guide_id = t.id
|
||||
LEFT JOIN guide_profiles gp ON gw.guide_id = gp.tourism_id
|
||||
WHERE gw.status = 1
|
||||
ORDER BY gw.audit_time ASC
|
||||
<if test="limit != null and limit > 0">
|
||||
LIMIT #{limit}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="countTodayWithdrawal" resultType="java.lang.Integer">
|
||||
SELECT COUNT(*)
|
||||
FROM guide_withdrawals
|
||||
WHERE guide_id = #{guideId}
|
||||
AND DATE(apply_time) = CURDATE()
|
||||
AND status NOT IN (2, 5)
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,351 @@
|
||||
# 地图仪表盘功能分析报告
|
||||
|
||||
> 分析时间:2025-12-09
|
||||
> 涉及模块:device-center (后端) + react-web-next (前端)
|
||||
|
||||
---
|
||||
|
||||
## 一、功能概览
|
||||
|
||||
地图仪表盘是一个综合性的景区设备监控平台,支持 **2D高德地图** 和 **3D Cesium地球** 两种展示模式,集成了设备实时监控、3D模型展示、无人机操控等功能。
|
||||
|
||||
### 功能完成度统计
|
||||
|
||||
| 模块 | 已实现 | 待完善 | 未实现 | 完成率 |
|
||||
|-----|--------|--------|--------|--------|
|
||||
| 地图基础功能 | 12 | 2 | 0 | 86% |
|
||||
| 设备实时监控 | 8 | 1 | 0 | 89% |
|
||||
| 3D模型管理 | 10 | 1 | 0 | 91% |
|
||||
| 无人机控制 | 2 | 2 | 6 | 20% |
|
||||
| 实时视频 | 0 | 0 | 3 | 0% |
|
||||
| **总计** | **32** | **6** | **9** | **68%** |
|
||||
|
||||
---
|
||||
|
||||
## 二、已实现功能明细
|
||||
|
||||
### 2.1 地图基础功能 ✅
|
||||
|
||||
#### 高德2D地图 (AmapContainer.tsx)
|
||||
|
||||
| 功能 | 状态 | 代码位置 | 说明 |
|
||||
|-----|------|---------|------|
|
||||
| 地图SDK动态加载 | ✅ | `AmapContainer.tsx:20-45` | 异步加载高德地图SDK |
|
||||
| 景区标记点绘制 | ✅ | `AmapContainer.tsx:80-110` | 圆形标记,按状态配色 |
|
||||
| 鼠标悬停信息窗体 | ✅ | `AmapContainer.tsx:95-105` | 显示景区名称、地址 |
|
||||
| 景区点击跳转 | ✅ | `AmapContainer.tsx:100-108` | 跳转到设备详情页 |
|
||||
| 地图控件 | ✅ | `AmapContainer.tsx:60-65` | Scale、ToolBar控件 |
|
||||
|
||||
#### Cesium 3D地球 (CesiumContainer.tsx)
|
||||
|
||||
| 功能 | 状态 | 代码位置 | 说明 |
|
||||
|-----|------|---------|------|
|
||||
| Cesium Viewer初始化 | ✅ | `CesiumContainer.tsx:80-130` | 动态加载ArcGIS影像底图 |
|
||||
| 景区标记点绘制 | ✅ | `CesiumContainer.tsx:180-220` | Billboard+Label组合 |
|
||||
| 相机飞行动画 | ✅ | `CesiumContainer.tsx:250-280` | 飞向景区/飞回全球 |
|
||||
| 点击交互 | ✅ | `CesiumContainer.tsx:290-320` | pick景区实体 |
|
||||
| 鼠标悬停效果 | ✅ | `CesiumContainer.tsx:330-360` | 点大小变化、光标变化 |
|
||||
| Home按钮自定义 | ✅ | `CesiumContainer.tsx:135-145` | 重置为中国视角 |
|
||||
|
||||
### 2.2 设备实时监控功能 ✅
|
||||
|
||||
#### SSE实时数据连接 (useDeviceSSE.ts)
|
||||
|
||||
| 功能 | 状态 | 代码位置 | 说明 |
|
||||
|-----|------|---------|------|
|
||||
| SSE连接建立 | ✅ | `useDeviceSSE.ts:50-80` | 基于fetch的SSE实现 |
|
||||
| 自动断线重连 | ✅ | `useDeviceSSE.ts:120-140` | 5秒延迟重连 |
|
||||
| 页面卸载清理 | ✅ | `useDeviceSSE.ts:180-200` | beforeunload事件 |
|
||||
| 会话ID管理 | ✅ | `useDeviceSSE.ts:30-45` | 复用连接 |
|
||||
| 事件解析 | ✅ | `useDeviceSSE.ts:90-115` | device-data-update/heartbeat |
|
||||
| 错误处理 | ✅ | `useDeviceSSE.ts:150-170` | 完整的错误捕获 |
|
||||
|
||||
#### 设备数据展示 (TourismDeviceDetail.tsx)
|
||||
|
||||
| 功能 | 状态 | 代码位置 | 说明 |
|
||||
|-----|------|---------|------|
|
||||
| 机库信息显示 | ✅ | `TourismDeviceDetail.tsx:450-550` | SN/名称/状态/告警等 |
|
||||
| 无人机信息显示 | ✅ | `TourismDeviceDetail.tsx:560-680` | SN/型号/对频/定位等 |
|
||||
| 环境数据显示 | ✅ | `TourismDeviceDetail.tsx:690-800` | 温度/湿度/风速/降雨等 |
|
||||
| 电池状态显示 | ✅ | `TourismDeviceDetail.tsx:810-900` | 电量/电压/温度/充电状态 |
|
||||
| GPS定位显示 | ✅ | `TourismDeviceDetail.tsx:910-950` | 经纬度/高度/卫星数 |
|
||||
| 设备列表选择 | ✅ | `TourismDeviceDetail.tsx:200-280` | 支持多设备切换 |
|
||||
|
||||
### 2.3 3D模型管理功能 ✅
|
||||
|
||||
#### Tileset加载器 (useTilesetLoader.ts)
|
||||
|
||||
| 功能 | 状态 | 代码位置 | 说明 |
|
||||
|-----|------|---------|------|
|
||||
| 3D Tiles加载 | ✅ | `useTilesetLoader.ts:80-130` | Cesium3DTileset.fromUrl |
|
||||
| 高清晰度渲染 | ✅ | `useTilesetLoader.ts:90-110` | maximumScreenSpaceError:1 |
|
||||
| 加载进度监听 | ✅ | `useTilesetLoader.ts:140-160` | loadProgress事件 |
|
||||
| 模型位置调整 | ✅ | `useTilesetLoader.ts:170-200` | 经/纬/高偏移 |
|
||||
| 模型变换 | ✅ | `useTilesetLoader.ts:210-240` | 缩放/XYZ旋转 |
|
||||
| 飞行定位 | ✅ | `useTilesetLoader.ts:250-280` | 自动计算包围球 |
|
||||
| 可见性切换 | ✅ | `useTilesetLoader.ts:290-300` | show属性 |
|
||||
| 模型卸载 | ✅ | `useTilesetLoader.ts:310-325` | primitives.remove |
|
||||
|
||||
#### 模型管理面板 (TilesetPanel.tsx)
|
||||
|
||||
| 功能 | 状态 | 代码位置 | 说明 |
|
||||
|-----|------|---------|------|
|
||||
| 模型列表显示 | ✅ | `TilesetPanel/index.tsx:50-80` | 名称/类型/状态 |
|
||||
| 加载状态指示 | ✅ | `TilesetPanel/index.tsx:90-110` | 未加载/加载中/已加载/失败 |
|
||||
| 加载进度条 | ✅ | `TilesetPanel/index.tsx:120-135` | Progress组件 |
|
||||
| 操作按钮组 | ✅ | `TilesetPanel/index.tsx:140-180` | 加载/飞往/显隐/卸载/重试 |
|
||||
|
||||
### 2.4 景区信息面板功能 ✅
|
||||
|
||||
#### 右侧面板 (RightPanel.tsx)
|
||||
|
||||
| 功能 | 状态 | 代码位置 | 说明 |
|
||||
|-----|------|---------|------|
|
||||
| Tabs切换 | ✅ | `RightPanel.tsx:60-80` | 综合状态/详细状态 |
|
||||
| 设备横向滚动 | ✅ | `RightPanel.tsx:90-120` | 设备卡片列表 |
|
||||
| 在线状态指示 | ✅ | `RightPanel.tsx:130-150` | Badge组件 |
|
||||
| 进入操控台按钮 | ✅ | `RightPanel.tsx:160-175` | 跳转操控台 |
|
||||
|
||||
---
|
||||
|
||||
## 三、待完善功能明细
|
||||
|
||||
### 3.1 数据流优化 ⚠️
|
||||
|
||||
| 功能 | 位置 | 问题 | 建议 |
|
||||
|-----|------|------|------|
|
||||
| 模型加载时机 | `CesiumContainer.tsx:160-165` | 未考虑景区无模型的降级方案 | 添加空状态提示 |
|
||||
| 右侧面板SSE | `RightPanel.tsx:37` | 数据更新不同步 | 统一状态管理 |
|
||||
| 左侧操控台数据 | `LeftControlPanel.tsx:36-51` | 使用模拟数据 | 接入实时数据流 |
|
||||
|
||||
### 3.2 性能优化 ⚠️
|
||||
|
||||
| 功能 | 位置 | 问题 | 建议 |
|
||||
|-----|------|------|------|
|
||||
| 3D Tiles清晰度 | `useTilesetLoader.ts:91` | 高配置导致低端设备卡顿 | 添加设备能力检测 |
|
||||
| 内存泄漏 | `CesiumContainer.tsx:318-322` | destroy()后仍有引用 | 完善清理逻辑 |
|
||||
| 模型缓存 | 无 | 每次都网络加载 | 添加IndexedDB缓存 |
|
||||
|
||||
### 3.3 错误处理 ⚠️
|
||||
|
||||
| 功能 | 位置 | 问题 | 建议 |
|
||||
|-----|------|------|------|
|
||||
| SSE连接失败 | `useDeviceSSE.ts` | 无用户提示 | 添加Toast提示 |
|
||||
| 模型加载失败 | `useTilesetLoader.ts` | 重试机制不完善 | 添加指数退避重试 |
|
||||
| 地图加载失败 | `AmapContainer.tsx` | 无降级方案 | 添加备用底图 |
|
||||
|
||||
---
|
||||
|
||||
## 四、未实现功能明细
|
||||
|
||||
### 4.1 无人机控制功能 ❌
|
||||
|
||||
| 功能 | 位置 | 现状 | 优先级 |
|
||||
|-----|------|------|--------|
|
||||
| 一键起飞 | `TourismDeviceDetail.tsx:431` | 只有UI,无后端调用 | **高** |
|
||||
| 一键返航 | `LeftControlPanel.tsx:135` | 仅message提示 | **高** |
|
||||
| 紧急悬停 | `LeftControlPanel.tsx:138` | 仅message提示 | **高** |
|
||||
| 拍照功能 | `LeftControlPanel.tsx:141` | 仅message提示 | **中** |
|
||||
| 云台控制(上下左右归中) | `LeftControlPanel.tsx:182-186` | 仅message提示 | **中** |
|
||||
| 姿态控制(升降/偏航/水平移动) | `LeftControlPanel.tsx:145-175` | UI完成,无实现 | **中** |
|
||||
|
||||
### 4.2 实时视频功能 ❌
|
||||
|
||||
| 功能 | 位置 | 现状 | 优先级 |
|
||||
|-----|------|------|--------|
|
||||
| 实时视频播放 | `LeftControlPanel.tsx:72-93` | 占位符div | **高** |
|
||||
| 视频流切换 | 无 | 未实现 | **中** |
|
||||
| 视频截图 | 无 | 未实现 | **低** |
|
||||
|
||||
### 4.3 高级功能 ❌
|
||||
|
||||
| 功能 | 位置 | 现状 | 优先级 |
|
||||
|-----|------|------|--------|
|
||||
| 航线规划 | 无 | 未实现 | **中** |
|
||||
| 历史轨迹回放 | 无 | 未实现 | **低** |
|
||||
| 多机协同 | 无 | 未实现 | **低** |
|
||||
|
||||
---
|
||||
|
||||
## 五、后端API支持情况
|
||||
|
||||
### 5.1 已实现的API ✅
|
||||
|
||||
#### 设备管理 (device-center)
|
||||
|
||||
```
|
||||
GET /api-device/property/_query/{deviceId}/{property} 获取设备属性
|
||||
POST /api-device/setting/{deviceId}/property 设置设备属性
|
||||
GET /api-device/live/stream-urls?deviceId={deviceId} 获取直播流URL
|
||||
```
|
||||
|
||||
#### SSE实时数据 (device-center)
|
||||
|
||||
```
|
||||
GET /api-device/sse/device-status/{deviceSn} 订阅设备状态
|
||||
DELETE /api-device/sse/device-status/{deviceSn} 断开SSE连接
|
||||
```
|
||||
|
||||
#### 3D模型管理 (device-center)
|
||||
|
||||
```
|
||||
GET /api-device/3d-model 分页查询模型
|
||||
GET /api-device/3d-model/{id} 获取模型详情
|
||||
GET /api-device/3d-model/tourism/{tourismId} 景区关联模型
|
||||
POST /api-device/3d-model 创建模型
|
||||
PUT /api-device/3d-model 更新模型
|
||||
DELETE /api-device/3d-model/{id} 删除模型
|
||||
POST /api-device/3d-model/{modelId}/upload/single 上传文件
|
||||
PUT /api-device/3d-model/{id}/status 启用/禁用
|
||||
PUT /api-device/3d-model/{id}/bindTourism 关联景区
|
||||
```
|
||||
|
||||
#### 景区管理 (order-center)
|
||||
|
||||
```
|
||||
GET /api-order/tourism 获取景区列表
|
||||
GET /api-order/tourism/{tourismId}/device-sns 景区关联设备
|
||||
```
|
||||
|
||||
### 5.2 缺失的API ❌
|
||||
|
||||
| API | 用途 | 优先级 |
|
||||
|-----|------|--------|
|
||||
| `POST /api-device/control/takeoff` | 一键起飞 | **高** |
|
||||
| `POST /api-device/control/return-home` | 一键返航 | **高** |
|
||||
| `POST /api-device/control/hover` | 紧急悬停 | **高** |
|
||||
| `POST /api-device/control/photo` | 拍照 | **中** |
|
||||
| `POST /api-device/control/gimbal` | 云台控制 | **中** |
|
||||
| `POST /api-device/control/movement` | 姿态控制 | **中** |
|
||||
|
||||
---
|
||||
|
||||
## 六、核心文件清单
|
||||
|
||||
### 6.1 前端文件
|
||||
|
||||
| 文件路径 | 行数 | 功能 |
|
||||
|---------|------|------|
|
||||
| `src/pages/device/mapDashboard/index.tsx` | 206 | 主页面入口 |
|
||||
| `src/pages/device/mapDashboard/index.less` | - | 主页面样式 |
|
||||
| `src/pages/device/mapDashboard/TourismDeviceDetail.tsx` | 1261 | 设备详情页 |
|
||||
| `src/pages/device/mapDashboard/TourismDeviceDetail.less` | - | 详情页样式 |
|
||||
| `src/pages/device/mapDashboard/components/MapContainer/index.tsx` | 34 | 地图容器 |
|
||||
| `src/pages/device/mapDashboard/components/MapContainer/AmapContainer.tsx` | 182 | 高德2D地图 |
|
||||
| `src/pages/device/mapDashboard/components/MapContainer/CesiumContainer.tsx` | 515 | Cesium 3D地球 |
|
||||
| `src/pages/device/mapDashboard/components/MapContainer/3d/BottomPanel/RightPanel.tsx` | 256 | 右侧信息面板 |
|
||||
| `src/pages/device/mapDashboard/components/MapContainer/3d/BottomPanel/LeftControlPanel.tsx` | 197 | 左侧操控面板 |
|
||||
| `src/pages/device/mapDashboard/components/MapContainer/3d/TilesetPanel/index.tsx` | 203 | 3D模型管理 |
|
||||
| `src/pages/device/mapDashboard/components/MapContainer/3d/hooks/useDeviceSSE.ts` | 240 | SSE连接Hook |
|
||||
| `src/pages/device/mapDashboard/components/MapContainer/3d/hooks/useTilesetLoader.ts` | 331 | Tileset加载器 |
|
||||
| `src/services/device.ts` | 73 | 设备API服务 |
|
||||
| `src/services/threeDModel.ts` | 325 | 3D模型API服务 |
|
||||
|
||||
### 6.2 后端文件
|
||||
|
||||
| 文件路径 | 功能 |
|
||||
|---------|------|
|
||||
| `device-center/.../controller/ApiDeviceController.java` | 设备属性控制 |
|
||||
| `device-center/.../controller/LiveStreamController.java` | 直播流管理 |
|
||||
| `device-center/.../controller/ThreeDModelFileController.java` | 3D模型管理 |
|
||||
| `device-center/.../sse/controller/DeviceStatusSseController.java` | SSE端点 |
|
||||
| `device-center/.../sse/manager/SseEmitterManager.java` | SSE连接管理 |
|
||||
| `device-center/.../service/impl/ThreeDModelFileServiceImpl.java` | 3D模型服务 |
|
||||
| `order-center/.../controller/TourismController.java` | 景区管理 |
|
||||
|
||||
---
|
||||
|
||||
## 七、数据流架构
|
||||
|
||||
```
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ 前端 (React) │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ MapDashboard │
|
||||
│ ├── 景区列表获取 ─────────────► /api-order/tourism │
|
||||
│ ├── 2D模式 │
|
||||
│ │ └── AmapContainer ─────────► 高德地图SDK │
|
||||
│ └── 3D模式 │
|
||||
│ └── CesiumContainer │
|
||||
│ ├── 景区标记绘制 │
|
||||
│ ├── 3D模型加载 ───────► /api-device/3d-model/tourism/ │
|
||||
│ ├── SSE连接 ──────────► /api-device/sse/device-status/ │
|
||||
│ └── 实时数据展示 │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ 后端 (Spring Cloud) │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ Gateway ──────► device-center │
|
||||
│ ├── SSE Controller ◄──── SseEmitterManager │
|
||||
│ ├── 3D Model Controller ◄── ThreeDModelService │
|
||||
│ └── Device Controller ◄──── DeviceService │
|
||||
│ ──────► order-center │
|
||||
│ └── Tourism Controller ◄──── TourismService │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
│
|
||||
▼
|
||||
┌─────────────────────────────────────────────────────────────────┐
|
||||
│ 外部系统 │
|
||||
├─────────────────────────────────────────────────────────────────┤
|
||||
│ ├── 大疆IoT平台 (WebSocket) ──► 设备实时数据推送 │
|
||||
│ ├── MinIO/OSS ──────────────► 3D模型文件存储 │
|
||||
│ └── MySQL ──────────────────► 景区/设备/模型元数据 │
|
||||
└─────────────────────────────────────────────────────────────────┘
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 八、下一步开发建议
|
||||
|
||||
### 8.1 高优先级 (建议立即处理)
|
||||
|
||||
1. **实现无人机控制API**
|
||||
- 后端添加 `/api-device/control/*` 系列接口
|
||||
- 对接大疆IoT平台的控制指令下发
|
||||
- 前端 `LeftControlPanel` 接入真实API
|
||||
|
||||
2. **集成实时视频流**
|
||||
- 评估大疆直播SDK vs RTMP方案
|
||||
- 实现视频播放器组件
|
||||
- 处理多路视频切换
|
||||
|
||||
3. **完善错误处理**
|
||||
- SSE断连用户提示
|
||||
- 模型加载失败降级
|
||||
- 网络异常重试机制
|
||||
|
||||
### 8.2 中优先级 (下一迭代)
|
||||
|
||||
1. **性能优化**
|
||||
- 3D Tiles自适应清晰度
|
||||
- 模型离线缓存
|
||||
- 内存泄漏修复
|
||||
|
||||
2. **功能增强**
|
||||
- 航线规划功能
|
||||
- 设备告警通知
|
||||
- 操作日志记录
|
||||
|
||||
### 8.3 低优先级 (后续规划)
|
||||
|
||||
1. **高级功能**
|
||||
- 历史轨迹回放
|
||||
- 多机协同监控
|
||||
- AI图像识别集成
|
||||
|
||||
---
|
||||
|
||||
## 九、总体评估
|
||||
|
||||
| 维度 | 评分 | 说明 |
|
||||
|-----|------|------|
|
||||
| 功能完整度 | 7/10 | 监控功能完整,控制功能缺失 |
|
||||
| 代码质量 | 7/10 | 结构清晰,错误处理待完善 |
|
||||
| 性能表现 | 6/10 | 3D渲染可能卡顿 |
|
||||
| 用户体验 | 7/10 | UI美观,功能有缺失 |
|
||||
| 可维护性 | 8/10 | 前后端分离,Hook设计合理 |
|
||||
| 扩展性 | 7/10 | API设计良好 |
|
||||
|
||||
**综合评分:7.0/10** - 框架完整,基础功能齐全,实时控制功能需补完
|
||||
@@ -51,4 +51,15 @@ export default {
|
||||
nodeModulesTransform: { type: 'none' },
|
||||
mfsu: false,
|
||||
fastRefresh: {},
|
||||
// Cesium 静态资源配置
|
||||
chainWebpack: (config: any) => {
|
||||
// 配置 Cesium 资源路径
|
||||
config.plugin('define').tap((definitions: any) => {
|
||||
Object.assign(definitions[0], {
|
||||
'process.env.CESIUM_BASE_URL': JSON.stringify(isDev ? '/' : (APP_BASE.endsWith('/') ? APP_BASE : APP_BASE + '/')),
|
||||
});
|
||||
return definitions;
|
||||
});
|
||||
return config;
|
||||
},
|
||||
} as any;
|
||||
|
||||
@@ -32,6 +32,8 @@ export default [
|
||||
{ path: '/orders/editTask.html', component: '@/pages/orders/EditTask' },
|
||||
{ path: '/orders/wxMessage.html', component: '@/pages/orders/WxMessage' },
|
||||
{ path: '/orders/coupon.html', component: '@/pages/orders/Coupon' },
|
||||
// 导游管理模块(包含导游列表、佣金明细、提现审核)
|
||||
{ path: '/orders/guide.html', component: '@/pages/orders/Guide' },
|
||||
],
|
||||
},
|
||||
{
|
||||
@@ -39,6 +41,8 @@ export default [
|
||||
routes: [
|
||||
{ path: '/device/wayline.html', component: '@/pages/device/Wayline' },
|
||||
{ path: '/device/device.html', component: '@/pages/device/Device' },
|
||||
// 3D模型管理
|
||||
{ path: '/device/3dModel.html', name: '3D模型管理', component: '@/pages/device/ThreeDModel' },
|
||||
// 景区地图仪表盘
|
||||
{ path: '/device/mapDashboard.html', name: '地图仪表盘', component: '@/pages/device/mapDashboard', exact: true },
|
||||
{ path: '/device/mapDashboard/tourismDeviceDetail/:tourismId', component: '@/pages/device/mapDashboard/TourismDeviceDetail' },
|
||||
|
||||
@@ -3,15 +3,27 @@
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"copy:cesium": "node scripts/copy-cesium-assets.js",
|
||||
"prestart": "npm run copy:cesium",
|
||||
"prestart:dev": "npm run copy:cesium",
|
||||
"prestart:test": "npm run copy:cesium",
|
||||
"prestart:pre": "npm run copy:cesium",
|
||||
"prebuild": "npm run copy:cesium",
|
||||
"prebuild:test": "npm run copy:cesium",
|
||||
"prebuild:pre": "npm run copy:cesium",
|
||||
"prebuild:prod": "npm run copy:cesium",
|
||||
"prebuild:test:mgnt": "npm run copy:cesium",
|
||||
"prebuild:pre:mgnt": "npm run copy:cesium",
|
||||
"prebuild:prod:mgnt": "npm run copy:cesium",
|
||||
"start": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=dev GATEWAY_ORIGIN=http://127.0.0.1:9900 umi dev",
|
||||
"start:dev": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=dev GATEWAY_ORIGIN=http://127.0.0.1:9900 umi dev",
|
||||
"start:test": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=test GATEWAY_ORIGIN=https://socket.goflytec.com umi dev",
|
||||
"start:test": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=test GATEWAY_ORIGIN=https://test.goflytec.com umi dev",
|
||||
"start:pre": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=pre GATEWAY_ORIGIN=http://119.45.169.13:9900 umi dev",
|
||||
"build": "cross-env NODE_OPTIONS=--openssl-legacy-provider umi build",
|
||||
"build:test": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=test API_PREFIX=http://119.45.169.13:9900 umi build",
|
||||
"build:pre": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=pre API_PREFIX=http://119.45.169.13:9900 umi build",
|
||||
"build:prod": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=prod umi build",
|
||||
"build:test:mgnt": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=test APP_BASE=/mgnt API_PREFIX=https://socket.goflytec.com umi build",
|
||||
"build:test:mgnt": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=test APP_BASE=/mgnt API_PREFIX=https://test.goflytec.com umi build",
|
||||
"build:pre:mgnt": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=pre APP_BASE=/mgnt API_PREFIX=https://local.goflytec.com umi build",
|
||||
"build:prod:mgnt": "cross-env NODE_OPTIONS=--openssl-legacy-provider REACT_APP_ENV=prod APP_BASE=/mgnt umi build",
|
||||
"lint": "eslint --ext .ts,.tsx src",
|
||||
|
||||
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 4.1 KiB |
|
After Width: | Height: | Size: 7.5 KiB |
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 111 KiB |
|
After Width: | Height: | Size: 191 KiB |
|
After Width: | Height: | Size: 12 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 7.1 KiB |