Merge branch 'develop' of https://gitee.com/L-Shilin/go-fly-platform-services into feature_dzc
This commit is contained in:
@@ -0,0 +1,194 @@
|
||||
# 订单列表接口增强功能
|
||||
|
||||
## 功能描述
|
||||
|
||||
对 `listInfoByUserV2` 接口进行增强,添加订单对应二维码的"是否只显示一键成片"属性,并根据该属性控制返回的素材内容。
|
||||
|
||||
## 接口信息
|
||||
|
||||
### 基本信息
|
||||
- **接口路径**: `GET /user/v2`
|
||||
- **接口名称**: 新版-查询用户订单详情列表(含视频/图片/一键成片)
|
||||
- **功能增强**: 根据二维码配置控制返回的素材内容
|
||||
|
||||
### 新增返回字段
|
||||
|
||||
| 字段名 | 类型 | 说明 |
|
||||
|--------|------|------|
|
||||
| showVideoEditOnly | Integer | 是否只显示一键成片(0:否,1:是) |
|
||||
|
||||
## 功能逻辑
|
||||
|
||||
### 1. 二维码信息获取
|
||||
- 批量获取所有订单对应的二维码信息
|
||||
- 通过 `codeId` 关联订单和二维码
|
||||
- 缓存二维码信息以提高性能
|
||||
|
||||
### 2. 素材控制逻辑
|
||||
|
||||
#### 当 `showVideoEditOnly = 1` 时(只显示一键成片):
|
||||
- **返回字段**:
|
||||
- `aiVideo`: 一键成片视频(始终返回)
|
||||
- `imgList`: 空数组 `[]`
|
||||
- `videoList`: 空数组 `[]`
|
||||
- `showVideoEditOnly`: `1`
|
||||
|
||||
#### 当 `showVideoEditOnly = 0` 时(显示所有功能):
|
||||
- **返回字段**:
|
||||
- `aiVideo`: 一键成片视频
|
||||
- `imgList`: 图片素材列表
|
||||
- `videoList`: 视频素材列表
|
||||
- `showVideoEditOnly`: `0`
|
||||
|
||||
### 3. 默认值处理
|
||||
- 如果二维码信息不存在,默认 `showVideoEditOnly = 1`
|
||||
- 如果 `showVideoEditOnly` 为 `null`,默认按 `1` 处理
|
||||
|
||||
## 实现细节
|
||||
|
||||
### 后端实现
|
||||
|
||||
#### 1. 批量查询二维码信息
|
||||
```java
|
||||
// 批量获取所有二维码信息
|
||||
List<String> codeIds = result.getData().stream()
|
||||
.map(Order::getCodeId)
|
||||
.collect(Collectors.toList());
|
||||
List<QrCode> qrCodes = qrCodeService.getByCodeIds(codeIds);
|
||||
Map<String, QrCode> qrCodeMap = qrCodes.stream()
|
||||
.collect(Collectors.toMap(QrCode::getCodeId, qrCode -> qrCode));
|
||||
```
|
||||
|
||||
#### 2. 素材控制逻辑
|
||||
```java
|
||||
// 从缓存获取二维码信息
|
||||
QrCode qrCode = qrCodeMap.get(order.getCodeId());
|
||||
Integer showVideoEditOnly = qrCode != null ? qrCode.getShowVideoEditOnly() : 1;
|
||||
orderFileMap.put("showVideoEditOnly", showVideoEditOnly);
|
||||
|
||||
// 根据showVideoEditOnly属性决定是否返回图片和视频素材
|
||||
if (showVideoEditOnly == null || showVideoEditOnly == 1) {
|
||||
// 只显示一键成片,不返回图片和视频素材
|
||||
orderFileMap.put("imgList", new ArrayList<>());
|
||||
orderFileMap.put("videoList", new ArrayList<>());
|
||||
} else {
|
||||
// 显示所有功能,返回图片和视频素材
|
||||
// ... 处理图片和视频素材
|
||||
}
|
||||
```
|
||||
|
||||
### 数据库支持
|
||||
|
||||
#### 新增批量查询方法
|
||||
在 `QrCodeMapper.xml` 中添加:
|
||||
```xml
|
||||
<select id="getByCodeIds" resultMap="QrCodeResultMap">
|
||||
SELECT * FROM qrcodes
|
||||
WHERE code_id IN
|
||||
<foreach collection="codeIds" item="codeId" open="(" separator="," close=")">
|
||||
#{codeId}
|
||||
</foreach>
|
||||
AND is_del = 0
|
||||
</select>
|
||||
```
|
||||
|
||||
## 返回数据示例
|
||||
|
||||
### 只显示一键成片(showVideoEditOnly = 1)
|
||||
```json
|
||||
{
|
||||
"resp_code": 0,
|
||||
"count": 1,
|
||||
"data": [
|
||||
{
|
||||
"time": "2024-01-15 10:30:00",
|
||||
"addr": "景区地址",
|
||||
"orderNo": "ORDER123456",
|
||||
"orderStatus": 3,
|
||||
"showVideoEditOnly": 1,
|
||||
"aiVideo": "https://example.com/ai-video.mp4",
|
||||
"imgList": [],
|
||||
"videoList": []
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
### 显示所有功能(showVideoEditOnly = 0)
|
||||
```json
|
||||
{
|
||||
"resp_code": 0,
|
||||
"count": 1,
|
||||
"data": [
|
||||
{
|
||||
"time": "2024-01-15 10:30:00",
|
||||
"addr": "景区地址",
|
||||
"orderNo": "ORDER123456",
|
||||
"orderStatus": 3,
|
||||
"showVideoEditOnly": 0,
|
||||
"aiVideo": "https://example.com/ai-video.mp4",
|
||||
"imgList": [
|
||||
{
|
||||
"url": "https://example.com/image1.jpg",
|
||||
"contentType": "image/jpeg",
|
||||
"path": "/path/to/image1.jpg",
|
||||
"viewUrl": "https://example.com/image1_thumb.jpg"
|
||||
}
|
||||
],
|
||||
"videoList": [
|
||||
{
|
||||
"url": "https://example.com/video1.mp4",
|
||||
"contentType": "video/mp4",
|
||||
"path": "/path/to/video1.mp4",
|
||||
"viewUrl": "https://example.com/image1_thumb.jpg"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
## 性能优化
|
||||
|
||||
### 1. 批量查询
|
||||
- 使用 `IN` 查询批量获取二维码信息
|
||||
- 避免 N+1 查询问题
|
||||
|
||||
### 2. 缓存机制
|
||||
- 将二维码信息缓存到 Map 中
|
||||
- 避免重复查询相同二维码
|
||||
|
||||
### 3. 条件处理
|
||||
- 根据 `showVideoEditOnly` 属性决定是否处理图片和视频素材
|
||||
- 减少不必要的文件URL生成
|
||||
|
||||
## 使用场景
|
||||
|
||||
### 1. 简化界面
|
||||
- 当二维码设置为只显示一键成片时,前端可以隐藏图片和视频相关的UI组件
|
||||
- 提供更简洁的用户体验
|
||||
|
||||
### 2. 功能控制
|
||||
- 管理员可以通过二维码配置控制用户看到的内容
|
||||
- 支持不同业务场景的需求
|
||||
|
||||
### 3. 性能优化
|
||||
- 减少不必要的数据传输
|
||||
- 提高接口响应速度
|
||||
|
||||
## 相关文件
|
||||
|
||||
### 后端文件
|
||||
- 控制器:`zlt-business/order-center/src/main/java/com/central/order/controller/OrderController.java`
|
||||
- 服务接口:`zlt-business/order-center/src/main/java/com/central/order/service/IQrCodeService.java`
|
||||
- 服务实现:`zlt-business/order-center/src/main/java/com/central/order/service/impl/QrCodeServiceImpl.java`
|
||||
- 数据访问:`zlt-business/order-center/src/main/java/com/central/order/mapper/QrCodeMapper.java`
|
||||
- SQL映射:`zlt-business/order-center/src/main/resources/mapper/QrCodeMapper.xml`
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **向后兼容**:新增字段不会影响现有功能
|
||||
2. **默认行为**:如果二维码信息不存在,默认按只显示一键成片处理
|
||||
3. **性能考虑**:批量查询优化了数据库访问性能
|
||||
4. **数据一致性**:确保二维码配置与返回数据的一致性
|
||||
5. **前端适配**:前端需要根据 `showVideoEditOnly` 字段调整界面显示
|
||||
@@ -0,0 +1,171 @@
|
||||
# 二维码"是否只显示一键成片"功能
|
||||
|
||||
## 功能描述
|
||||
|
||||
为二维码新增"是否只显示一键成片"属性,用于控制用户扫码后界面的显示内容。当设置为"是"时,用户扫码后只显示一键成片功能,隐藏其他功能选项;当设置为"否"时,显示所有功能。
|
||||
|
||||
## 数据库变更
|
||||
|
||||
### 新增字段
|
||||
|
||||
在 `qrcodes` 表中新增 `show_video_edit_only` 字段:
|
||||
|
||||
```sql
|
||||
ALTER TABLE qrcodes
|
||||
ADD COLUMN show_video_edit_only TINYINT(1) DEFAULT 1 COMMENT '是否只显示一键成片(0:否,1:是),默认显示';
|
||||
```
|
||||
|
||||
### 字段说明
|
||||
|
||||
| 字段名 | 类型 | 默认值 | 说明 |
|
||||
|--------|------|--------|------|
|
||||
| show_video_edit_only | TINYINT(1) | 1 | 是否只显示一键成片(0:否,1:是) |
|
||||
|
||||
### 索引优化
|
||||
|
||||
```sql
|
||||
CREATE INDEX idx_show_video_edit_only ON qrcodes(show_video_edit_only);
|
||||
```
|
||||
|
||||
## 后端实现
|
||||
|
||||
### 实体类更新
|
||||
|
||||
在 `QrCode.java` 中新增字段:
|
||||
|
||||
```java
|
||||
/**
|
||||
* 是否只显示一键成片(0:否,1:是)
|
||||
*/
|
||||
@Schema(description = "是否只显示一键成片(0:否,1:是)")
|
||||
private Integer showVideoEditOnly;
|
||||
```
|
||||
|
||||
### 数据访问层
|
||||
|
||||
在 `QrCodeMapper.xml` 中添加查询条件支持:
|
||||
|
||||
```xml
|
||||
<if test="p.showVideoEditOnly != null">
|
||||
AND q.show_video_edit_only = #{p.showVideoEditOnly}
|
||||
</if>
|
||||
```
|
||||
|
||||
## 前端实现
|
||||
|
||||
### 类型定义
|
||||
|
||||
在 `typings.d.ts` 中新增字段:
|
||||
|
||||
```typescript
|
||||
showVideoEditOnly?: number; // 是否只显示一键成片(0:否,1:是)
|
||||
```
|
||||
|
||||
### 选项常量
|
||||
|
||||
```typescript
|
||||
export const SHOW_VIDEO_EDIT_ONLY_OPTIONS = [
|
||||
{ label: '否', value: 0 },
|
||||
{ label: '是', value: 1 },
|
||||
] as const;
|
||||
```
|
||||
|
||||
### 表格显示
|
||||
|
||||
在二维码管理页面的表格中添加新列:
|
||||
|
||||
```typescript
|
||||
{
|
||||
title: '是否只显示一键成片',
|
||||
dataIndex: 'showVideoEditOnly',
|
||||
width: 140,
|
||||
render: (_, record) => {
|
||||
const status = record.showVideoEditOnly === 1 ? '是' : '否';
|
||||
const color = record.showVideoEditOnly === 1 ? 'purple' : 'default';
|
||||
return <Tag color={color}>{status}</Tag>;
|
||||
},
|
||||
valueEnum: {
|
||||
0: { text: '否' },
|
||||
1: { text: '是' },
|
||||
},
|
||||
}
|
||||
```
|
||||
|
||||
### 查询筛选
|
||||
|
||||
在查询过滤器中添加筛选条件:
|
||||
|
||||
```typescript
|
||||
<ProFormSelect
|
||||
name="showVideoEditOnly"
|
||||
label="是否只显示一键成片"
|
||||
placeholder="请选择是否只显示一键成片"
|
||||
options={SHOW_VIDEO_EDIT_ONLY_OPTIONS}
|
||||
/>
|
||||
```
|
||||
|
||||
### 表单字段
|
||||
|
||||
在创建和编辑表单中添加字段:
|
||||
|
||||
```typescript
|
||||
<ProFormSelect
|
||||
width="md"
|
||||
name="showVideoEditOnly"
|
||||
label="是否只显示一键成片"
|
||||
options={SHOW_VIDEO_EDIT_ONLY_OPTIONS}
|
||||
rules={[{ required: true, message: '请选择是否只显示一键成片' }]}
|
||||
initialValue={1}
|
||||
tooltip="设置为是时,用户扫码后只显示一键成片功能,隐藏其他功能选项"
|
||||
/>
|
||||
```
|
||||
|
||||
## 功能特点
|
||||
|
||||
### 1. 默认值设置
|
||||
- 新创建的二维码默认值为 `1`(只显示一键成片)
|
||||
- 现有二维码数据自动设置为 `1`
|
||||
|
||||
### 2. 界面控制
|
||||
- 当 `showVideoEditOnly = 1` 时:用户扫码后只显示一键成片功能
|
||||
- 当 `showVideoEditOnly = 0` 时:用户扫码后显示所有功能选项
|
||||
|
||||
### 3. 管理便利
|
||||
- 在二维码管理页面可以查看和筛选该属性
|
||||
- 支持在创建和编辑二维码时设置该属性
|
||||
- 提供清晰的提示信息说明功能用途
|
||||
|
||||
## 使用场景
|
||||
|
||||
### 1. 简化用户体验
|
||||
- 对于只需要一键成片功能的场景,可以隐藏其他复杂选项
|
||||
- 减少用户选择困难,提高操作效率
|
||||
|
||||
### 2. 功能定制
|
||||
- 不同二维码可以设置不同的显示模式
|
||||
- 满足不同业务场景的需求
|
||||
|
||||
### 3. 渐进式功能
|
||||
- 可以先提供简化版本,后续再开放完整功能
|
||||
- 降低用户学习成本
|
||||
|
||||
## 相关文件
|
||||
|
||||
### 后端文件
|
||||
- 实体类:`zlt-business/order-center/src/main/java/com/central/order/model/QrCode.java`
|
||||
- 数据访问:`zlt-business/order-center/src/main/resources/mapper/QrCodeMapper.xml`
|
||||
- 数据库脚本:`zlt-business/order-center/sql/add_show_video_edit_only_field.sql`
|
||||
|
||||
### 前端文件
|
||||
- 类型定义:`zlt-web/react-web/src/main/frontend/src/services/orders/typings.d.ts`
|
||||
- 管理页面:`zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/index.tsx`
|
||||
- 创建表单:`zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/CreateForm.tsx`
|
||||
- 编辑表单:`zlt-web/react-web/src/main/frontend/src/pages/orders/Qrcode/components/UpdateForm.tsx`
|
||||
|
||||
## 注意事项
|
||||
|
||||
1. **数据库迁移**:执行 SQL 脚本时需要确保数据库连接正常
|
||||
2. **默认值处理**:现有数据会自动设置为默认值 `1`
|
||||
3. **前端兼容**:确保前端代码正确处理新增字段
|
||||
4. **业务逻辑**:需要在前端扫码页面中根据该字段控制界面显示
|
||||
5. **测试验证**:建议在测试环境验证功能正常后再部署到生产环境
|
||||
@@ -0,0 +1,23 @@
|
||||
-- 为 qrcodes 表添加类型字段
|
||||
-- 用于区分该二维码是游客下单、定时巡查,还是其他类型
|
||||
-- 执行时间:2024-01-XX
|
||||
|
||||
-- 1. 添加二维码类型字段
|
||||
ALTER TABLE qrcodes
|
||||
ADD COLUMN qrcode_type TINYINT(1) DEFAULT 1 COMMENT '二维码类型(1:游客下单,2:定时巡查,3:其他)';
|
||||
|
||||
-- 2. 创建索引以提高查询性能
|
||||
CREATE INDEX idx_qrcodes_type ON qrcodes(qrcode_type);
|
||||
|
||||
-- 3. 为现有二维码设置默认类型(默认为游客下单)
|
||||
UPDATE qrcodes SET qrcode_type = 1 WHERE qrcode_type IS NULL;
|
||||
|
||||
-- 4. 添加注释说明
|
||||
-- 二维码类型字段说明:
|
||||
-- - qrcode_type = 1:游客下单 - 普通游客扫码下单使用
|
||||
-- - qrcode_type = 2:定时巡查 - 用于定时巡查任务
|
||||
-- - qrcode_type = 3:其他 - 其他特殊用途
|
||||
-- - 默认值为1,表示大部分二维码都是游客下单类型
|
||||
|
||||
-- 5. 验证字段添加成功
|
||||
DESCRIBE qrcodes;
|
||||
@@ -0,0 +1,14 @@
|
||||
-- 为 tourisms 表添加 show_in_homepage 字段
|
||||
-- 用于控制景区是否在首页显示
|
||||
|
||||
ALTER TABLE tourisms
|
||||
ADD COLUMN show_in_homepage TINYINT(1) DEFAULT 1 COMMENT '是否在首页显示(0:不显示,1:显示),默认显示';
|
||||
|
||||
-- 为现有数据设置默认值(所有现有景区默认显示在首页)
|
||||
UPDATE tourisms SET show_in_homepage = 1 WHERE show_in_homepage IS NULL;
|
||||
|
||||
-- 添加索引以提高查询性能
|
||||
CREATE INDEX idx_show_in_homepage ON tourisms(show_in_homepage);
|
||||
|
||||
-- 验证字段添加成功
|
||||
DESCRIBE tourisms;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
package com.central.order.constants;
|
||||
|
||||
/**
|
||||
* 支付类型常量
|
||||
*
|
||||
* @author system
|
||||
* @date 2024-12-19
|
||||
*/
|
||||
public class PayTypeConstants {
|
||||
|
||||
/**
|
||||
* 微信支付
|
||||
*/
|
||||
public static final Integer WECHAT_PAY = 1;
|
||||
|
||||
/**
|
||||
* 优惠券支付
|
||||
*/
|
||||
public static final Integer COUPON_PAY = 2;
|
||||
|
||||
private PayTypeConstants() {
|
||||
// 私有构造函数,防止实例化
|
||||
}
|
||||
}
|
||||
+71
-43
@@ -766,6 +766,11 @@ public class OrderController {
|
||||
}
|
||||
orderFileMap.put("videoList", videoList);
|
||||
|
||||
// 添加showVideoEditOnly字段
|
||||
QrCode qrCode = qrCodeService.getByCodeId(order.getCodeId());
|
||||
Integer showVideoEditOnly = qrCode != null ? qrCode.getShowVideoEditOnly() : 1; // 默认值为1
|
||||
orderFileMap.put("showVideoEditOnly", showVideoEditOnly);
|
||||
|
||||
return Result.succeed(orderFileMap, "查询成功");
|
||||
}
|
||||
|
||||
@@ -878,6 +883,14 @@ public class OrderController {
|
||||
.collect(Collectors.toSet());
|
||||
Map<Long, Tourism> tourismMap = tourismService.getTourismsByIds(tourismIds);
|
||||
|
||||
// 批量获取所有二维码信息
|
||||
List<String> codeIds = result.getData().stream()
|
||||
.map(Order::getCodeId)
|
||||
.collect(Collectors.toList());
|
||||
List<QrCode> qrCodes = qrCodeService.getByCodeIds(codeIds);
|
||||
Map<String, QrCode> qrCodeMap = qrCodes.stream()
|
||||
.collect(Collectors.toMap(QrCode::getCodeId, qrCode -> qrCode));
|
||||
|
||||
// 预计算所有文件路径的URL,避免重复调用
|
||||
Set<String> allFilePaths = new HashSet<>();
|
||||
orderFilesMap.values().forEach(files ->
|
||||
@@ -913,11 +926,17 @@ public class OrderController {
|
||||
Tourism tourism = tourismMap.get(order.getTourismId());
|
||||
orderFileMap.put("addr", tourism != null ? tourism.getTourismAddress() : "");
|
||||
orderFileMap.put("orderNo", order.getOrderNo());
|
||||
orderFileMap.put("orderStatus", order.getOrderStatus());
|
||||
|
||||
// 从缓存获取二维码信息
|
||||
QrCode qrCode = qrCodeMap.get(order.getCodeId());
|
||||
Integer showVideoEditOnly = qrCode != null ? qrCode.getShowVideoEditOnly() : 1; // 默认值为1
|
||||
orderFileMap.put("showVideoEditOnly", showVideoEditOnly);
|
||||
|
||||
// 从缓存获取文件列表
|
||||
List<OrderFile> allFiles = orderFilesMap.getOrDefault(order.getOrderNo(), new ArrayList<>());
|
||||
|
||||
// aiVideo - 使用缓存URL
|
||||
// aiVideo - 使用缓存URL(始终返回)
|
||||
List<OrderFile> aiVideoFiles = allFiles.stream()
|
||||
.filter(f -> "ai_video".equals(f.getFileTag()))
|
||||
.toList();
|
||||
@@ -927,51 +946,60 @@ public class OrderController {
|
||||
}
|
||||
orderFileMap.put("aiVideo", aiVideoUrl);
|
||||
|
||||
// 图片素材 - 使用缓存URL
|
||||
List<OrderFile> imgFiles = allFiles.stream()
|
||||
.filter(f -> "image/jpeg".equals(f.getFileType()))
|
||||
.toList();
|
||||
List<Map<String,String>> imgList = new ArrayList<>();
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
fileMap.put("style", fileStyle);
|
||||
for (OrderFile orderFile : imgFiles){
|
||||
Map<String,String> imgMap = new HashMap<>();
|
||||
imgMap.put("url", fileUrlMap.get(orderFile.getFilePath()));
|
||||
imgMap.put("contentType", orderFile.getFileType());
|
||||
imgMap.put("path", orderFile.getFilePath());
|
||||
fileMap.put("path", orderFile.getFilePath());
|
||||
String viewUrl = fileCenterService.getViewUrlByPathStyle(fileMap);
|
||||
imgMap.put("viewUrl", viewUrl);
|
||||
imgList.add(imgMap);
|
||||
}
|
||||
orderFileMap.put("imgList", imgList);
|
||||
|
||||
// 视频素材 - 使用缓存URL
|
||||
List<OrderFile> videoFiles = allFiles.stream()
|
||||
.filter(f -> "raw_video".equals(f.getFileTag()))
|
||||
.toList();
|
||||
List<Map<String,String>> videoList = new ArrayList<>();
|
||||
for (int i = 0; i < videoFiles.size(); i++){
|
||||
OrderFile orderFile = videoFiles.get(i);
|
||||
Map<String,String> videoMap = new HashMap<>();
|
||||
videoMap.put("url", fileUrlMap.get(orderFile.getFilePath()));
|
||||
videoMap.put("contentType", orderFile.getFileType());
|
||||
videoMap.put("path", orderFile.getFilePath());
|
||||
// 根据showVideoEditOnly属性决定是否返回图片和视频素材
|
||||
if (showVideoEditOnly == null || showVideoEditOnly == 1) {
|
||||
// 只显示一键成片,不返回图片和视频素材
|
||||
orderFileMap.put("imgList", new ArrayList<>());
|
||||
orderFileMap.put("videoList", new ArrayList<>());
|
||||
} else {
|
||||
// 显示所有功能,返回图片和视频素材
|
||||
|
||||
// 为视频生成缩略图URL - 使用对应的图片作为缩略图
|
||||
String thumbnailUrl = null;
|
||||
if (!imgList.isEmpty() && i < imgList.size()) {
|
||||
// 使用对应索引的图片作为缩略图
|
||||
thumbnailUrl = imgList.get(i).get("viewUrl");
|
||||
} else if (!imgList.isEmpty()) {
|
||||
// 如果视频数量超过图片数量,使用第一张图片作为缩略图
|
||||
thumbnailUrl = imgList.get(0).get("viewUrl");
|
||||
// 图片素材 - 使用缓存URL
|
||||
List<OrderFile> imgFiles = allFiles.stream()
|
||||
.filter(f -> "image/jpeg".equals(f.getFileType()))
|
||||
.toList();
|
||||
List<Map<String,String>> imgList = new ArrayList<>();
|
||||
Map<String, String> fileMap = new HashMap<>();
|
||||
fileMap.put("style", fileStyle);
|
||||
for (OrderFile orderFile : imgFiles){
|
||||
Map<String,String> imgMap = new HashMap<>();
|
||||
imgMap.put("url", fileUrlMap.get(orderFile.getFilePath()));
|
||||
imgMap.put("contentType", orderFile.getFileType());
|
||||
imgMap.put("path", orderFile.getFilePath());
|
||||
fileMap.put("path", orderFile.getFilePath());
|
||||
String viewUrl = fileCenterService.getViewUrlByPathStyle(fileMap);
|
||||
imgMap.put("viewUrl", viewUrl);
|
||||
imgList.add(imgMap);
|
||||
}
|
||||
videoMap.put("viewUrl", thumbnailUrl);
|
||||
|
||||
videoList.add(videoMap);
|
||||
orderFileMap.put("imgList", imgList);
|
||||
|
||||
// 视频素材 - 使用缓存URL
|
||||
List<OrderFile> videoFiles = allFiles.stream()
|
||||
.filter(f -> "raw_video".equals(f.getFileTag()))
|
||||
.toList();
|
||||
List<Map<String,String>> videoList = new ArrayList<>();
|
||||
for (int i = 0; i < videoFiles.size(); i++){
|
||||
OrderFile orderFile = videoFiles.get(i);
|
||||
Map<String,String> videoMap = new HashMap<>();
|
||||
videoMap.put("url", fileUrlMap.get(orderFile.getFilePath()));
|
||||
videoMap.put("contentType", orderFile.getFileType());
|
||||
videoMap.put("path", orderFile.getFilePath());
|
||||
|
||||
// 为视频生成缩略图URL - 使用对应的图片作为缩略图
|
||||
String thumbnailUrl = null;
|
||||
if (!imgList.isEmpty() && i < imgList.size()) {
|
||||
// 使用对应索引的图片作为缩略图
|
||||
thumbnailUrl = imgList.get(i).get("viewUrl");
|
||||
} else if (!imgList.isEmpty()) {
|
||||
// 如果视频数量超过图片数量,使用第一张图片作为缩略图
|
||||
thumbnailUrl = imgList.get(0).get("viewUrl");
|
||||
}
|
||||
videoMap.put("viewUrl", thumbnailUrl);
|
||||
|
||||
videoList.add(videoMap);
|
||||
}
|
||||
orderFileMap.put("videoList", videoList);
|
||||
}
|
||||
orderFileMap.put("videoList", videoList);
|
||||
|
||||
page.add(orderFileMap);
|
||||
}
|
||||
|
||||
+18
-1
@@ -279,6 +279,18 @@ public class OrderFileController {
|
||||
|
||||
Tourism tourism = tourismService.getTourismById(qrCode.getTourismId());
|
||||
|
||||
// 自动更新订单状态为设备执行完成
|
||||
if (!OrderStatus.COMPLETE.getId().equals(order.getOrderStatus())) {
|
||||
order.setOrderStatus(OrderStatus.COMPLETE.getId());
|
||||
boolean updateResult = orderService.updateOrder(order);
|
||||
if (updateResult) {
|
||||
log.info("订单状态已自动更新为设备执行完成: orderNo={}, oldStatus={}, newStatus={}",
|
||||
order.getOrderNo(), order.getOrderStatus(), OrderStatus.COMPLETE.getId());
|
||||
} else {
|
||||
log.error("订单状态更新失败: orderNo={}", order.getOrderNo());
|
||||
}
|
||||
}
|
||||
|
||||
//发送用户素材上传成功通知
|
||||
sendMessageForResouresUploaded(order,tourism);
|
||||
|
||||
@@ -346,12 +358,17 @@ public class OrderFileController {
|
||||
String tip = "素材上传完成";
|
||||
String orderName = tourism.getTourismName();
|
||||
String pageUrl = "pages/album/album";
|
||||
// 处理支付时间为空的情况
|
||||
String payTimeStr = "";
|
||||
if (order.getPayTime() != null) {
|
||||
payTimeStr = DateUtils.sdf.format(order.getPayTime());
|
||||
}
|
||||
wxMiniSubscribeService.sendServiceProcessMsg(
|
||||
sysUser.getOpenId(),
|
||||
orderName,
|
||||
tip,
|
||||
order.getOrderNo(),
|
||||
DateUtils.sdf.format(order.getPayTime()),
|
||||
payTimeStr,
|
||||
"",
|
||||
pageUrl
|
||||
);
|
||||
|
||||
+15
@@ -149,4 +149,19 @@ public class QrCodeController {
|
||||
map.put("waylineId",qrCode.getWaylineId());
|
||||
return map;
|
||||
}
|
||||
|
||||
@GetMapping("/device/{deviceId}")
|
||||
public Map<String,Object> getQrcodeByDeviceId(@PathVariable("deviceId") String deviceId, @RequestParam("qrcodeType") Integer qrcodeType){
|
||||
// 根据设备ID和二维码类型查询二维码信息
|
||||
QrCode qrCode = qrCodeService.getByDeviceIdAndType(deviceId, qrcodeType);
|
||||
Assert.notNull(qrCode,"二维码数据不能为空");
|
||||
|
||||
String waylineFilePath = fileCenterService.getFileViewUrl(qrCode.getWaylineId());
|
||||
Map<String,Object> map = new HashMap<>();
|
||||
map.put("waylineFilePath",waylineFilePath);
|
||||
map.put("waylineId",qrCode.getWaylineId());
|
||||
map.put("codeId",qrCode.getCodeId());
|
||||
map.put("tourismId",qrCode.getTourismId());
|
||||
return map;
|
||||
}
|
||||
}
|
||||
|
||||
+6
-4
@@ -105,17 +105,19 @@ public class TourismController {
|
||||
@Parameter(name = "longitude", description = "经度", required = true, in = ParameterIn.QUERY),
|
||||
@Parameter(name = "latitude", description = "纬度", required = true, in = ParameterIn.QUERY),
|
||||
@Parameter(name = "radius", description = "搜索半径(公里),默认10km", required = false, in = ParameterIn.QUERY),
|
||||
@Parameter(name = "limit", description = "返回数量限制,默认20个", required = false, in = ParameterIn.QUERY)
|
||||
@Parameter(name = "limit", description = "返回数量限制,默认20个", required = false, in = ParameterIn.QUERY),
|
||||
@Parameter(name = "showInHomepage", description = "是否在首页显示(0:不显示,1:显示),默认1(只显示设置为显示的景区)", required = false, in = ParameterIn.QUERY)
|
||||
})
|
||||
@GetMapping("/nearby")
|
||||
public Result<List<TourismWithDistance>> findNearbyTourisms(
|
||||
@RequestParam BigDecimal longitude,
|
||||
@RequestParam BigDecimal latitude,
|
||||
@RequestParam(required = false) Double radius,
|
||||
@RequestParam(required = false) Integer limit) {
|
||||
@RequestParam(required = false) Integer limit,
|
||||
@RequestParam(required = false, defaultValue = "1") Integer showInHomepage) {
|
||||
try {
|
||||
log.info("查询附近景区,经度: {}, 纬度: {}, 半径: {}km, 限制数量: {}", longitude, latitude, radius, limit);
|
||||
List<TourismWithDistance> tourisms = tourismService.findNearbyTourisms(longitude, latitude, radius, limit);
|
||||
log.info("查询附近景区,经度: {}, 纬度: {}, 半径: {}km, 限制数量: {}, 首页显示: {}", longitude, latitude, radius, limit, showInHomepage);
|
||||
List<TourismWithDistance> tourisms = tourismService.findNearbyTourisms(longitude, latitude, radius, limit, showInHomepage);
|
||||
return Result.succeed(tourisms, "查询附近景区成功");
|
||||
} catch (Exception e) {
|
||||
log.error("查询附近景区失败", e);
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.central.order.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* 支付类型枚举
|
||||
*
|
||||
* @author system
|
||||
* @date 2024-12-19
|
||||
*/
|
||||
@Getter
|
||||
public enum PayTypeEnum {
|
||||
|
||||
/**
|
||||
* 微信支付
|
||||
*/
|
||||
WECHAT_PAY(1, "微信支付"),
|
||||
|
||||
/**
|
||||
* 优惠券支付
|
||||
*/
|
||||
COUPON_PAY(2, "优惠券支付");
|
||||
|
||||
private final Integer code;
|
||||
private final String desc;
|
||||
|
||||
PayTypeEnum(Integer code, String desc) {
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据code获取枚举
|
||||
*/
|
||||
public static PayTypeEnum getByCode(Integer code) {
|
||||
if (code == null) {
|
||||
return null;
|
||||
}
|
||||
for (PayTypeEnum payType : values()) {
|
||||
if (payType.getCode().equals(code)) {
|
||||
return payType;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断code是否有效
|
||||
*/
|
||||
public static boolean isValidCode(Integer code) {
|
||||
return getByCode(code) != null;
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -532,7 +532,7 @@ public interface DashboardMapper {
|
||||
|
||||
@Select({
|
||||
"<script>",
|
||||
"SELECT code_id as value, name as label FROM qrcodes",
|
||||
"SELECT code_id as value, CONCAT(name, ' | ¥', FORMAT(price/100, 2), '元') as label FROM qrcodes",
|
||||
"WHERE is_del = 0",
|
||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||
" AND is_test = 0",
|
||||
|
||||
@@ -32,4 +32,19 @@ public interface QrCodeMapper extends SuperMapper<QrCode> {
|
||||
// ID查询
|
||||
QrCode getByCodeId(@Param("codeId") String codeId);
|
||||
|
||||
/**
|
||||
* 根据设备ID和二维码类型查询二维码信息
|
||||
* @param deviceId 设备ID
|
||||
* @param qrcodeType 二维码类型
|
||||
* @return 二维码信息
|
||||
*/
|
||||
QrCode getByDeviceIdAndType(@Param("deviceId") String deviceId, @Param("qrcodeType") Integer qrcodeType);
|
||||
|
||||
/**
|
||||
* 根据二维码ID列表批量查询二维码信息
|
||||
* @param codeIds 二维码ID列表
|
||||
* @return 二维码信息列表
|
||||
*/
|
||||
List<QrCode> getByCodeIds(@Param("codeIds") List<String> codeIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -48,13 +48,15 @@ public interface TourismMapper extends SuperMapper<Tourism> {
|
||||
* @param latitude 纬度
|
||||
* @param radius 搜索半径(公里)
|
||||
* @param limit 返回数量限制
|
||||
* @param showInHomepage 是否在首页显示(0:不显示,1:显示,null:显示所有)
|
||||
* @return 附近景区列表(包含距离信息)
|
||||
*/
|
||||
List<TourismWithDistance> findNearbyTourisms(
|
||||
@Param("longitude") BigDecimal longitude,
|
||||
@Param("latitude") BigDecimal latitude,
|
||||
@Param("radius") Double radius,
|
||||
@Param("limit") Integer limit
|
||||
@Param("limit") Integer limit,
|
||||
@Param("showInHomepage") Integer showInHomepage
|
||||
);
|
||||
|
||||
/**
|
||||
|
||||
@@ -5,6 +5,8 @@ import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.central.common.model.SuperEntity;
|
||||
import com.central.order.enums.PayTypeEnum;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@@ -33,7 +35,11 @@ public class Order extends SuperEntity {
|
||||
private String workspaceId;
|
||||
|
||||
private String orderAmount;
|
||||
@Schema(description = "订单状态")
|
||||
private Integer orderStatus;
|
||||
|
||||
@Schema(description = "支付类型(1:微信支付,2:优惠券支付)")
|
||||
private Integer payType;
|
||||
|
||||
private Date payTime;
|
||||
|
||||
|
||||
@@ -105,4 +105,16 @@ public class QrCode extends SuperEntity {
|
||||
@Schema(description = "是否为测试二维码")
|
||||
private Integer isTest;
|
||||
|
||||
/**
|
||||
* 二维码类型(1:游客下单,2:定时巡查,3:其他)
|
||||
*/
|
||||
@Schema(description = "二维码类型(1:游客下单,2:定时巡查,3:其他)")
|
||||
private Integer qrcodeType;
|
||||
|
||||
/**
|
||||
* 是否只显示一键成片(0:否,1:是)
|
||||
*/
|
||||
@Schema(description = "是否只显示一键成片(0:否,1:是)")
|
||||
private Integer showVideoEditOnly;
|
||||
|
||||
}
|
||||
|
||||
@@ -54,4 +54,9 @@ public class Tourism extends SuperEntity {
|
||||
private String tenantId;
|
||||
private String company;
|
||||
private Integer isDel;
|
||||
|
||||
/**
|
||||
* 是否在首页显示(0:不显示,1:显示)
|
||||
*/
|
||||
private Integer showInHomepage;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.central.common.model.PageResult;
|
||||
import com.central.common.service.ISuperService;
|
||||
import com.central.order.model.QrCode;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -34,5 +35,20 @@ public interface IQrCodeService extends ISuperService<QrCode> {
|
||||
* @return
|
||||
*/
|
||||
QrCode getByCodeId(String codeId);
|
||||
|
||||
/**
|
||||
* 根据设备ID和二维码类型查询二维码信息
|
||||
* @param deviceId 设备ID
|
||||
* @param qrcodeType 二维码类型
|
||||
* @return 二维码信息
|
||||
*/
|
||||
QrCode getByDeviceIdAndType(String deviceId, Integer qrcodeType);
|
||||
|
||||
/**
|
||||
* 根据二维码ID列表批量查询二维码信息
|
||||
* @param codeIds 二维码ID列表
|
||||
* @return 二维码信息列表
|
||||
*/
|
||||
List<QrCode> getByCodeIds(List<String> codeIds);
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -53,9 +53,10 @@ public interface ITourismService extends ISuperService<Tourism> {
|
||||
* @param latitude 纬度
|
||||
* @param radius 搜索半径(公里)
|
||||
* @param limit 返回数量限制
|
||||
* @param showInHomepage 是否在首页显示(0:不显示,1:显示,null:显示所有)
|
||||
* @return 附近景区列表(包含距离信息)
|
||||
*/
|
||||
List<TourismWithDistance> findNearbyTourisms(BigDecimal longitude, BigDecimal latitude, Double radius, Integer limit);
|
||||
List<TourismWithDistance> findNearbyTourisms(BigDecimal longitude, BigDecimal latitude, Double radius, Integer limit, Integer showInHomepage);
|
||||
|
||||
/**
|
||||
* 根据经纬度范围查询景区
|
||||
|
||||
+14
@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -51,6 +52,19 @@ public class QrCodeServiceImpl extends SuperServiceImpl<QrCodeMapper, QrCode> im
|
||||
return baseMapper.getByCodeId(codeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public QrCode getByDeviceIdAndType(String deviceId, Integer qrcodeType) {
|
||||
return baseMapper.getByDeviceIdAndType(deviceId, qrcodeType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<QrCode> getByCodeIds(List<String> codeIds) {
|
||||
if (codeIds == null || codeIds.isEmpty()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
return baseMapper.getByCodeIds(codeIds);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
+8
-3
@@ -67,8 +67,8 @@ public class TourismServiceImpl extends SuperServiceImpl<TourismMapper, Tourism>
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<TourismWithDistance> findNearbyTourisms(BigDecimal longitude, BigDecimal latitude, Double radius, Integer limit) {
|
||||
log.info("查询附近景区,经度: {}, 纬度: {}, 半径: {}km, 限制数量: {}", longitude, latitude, radius, limit);
|
||||
public List<TourismWithDistance> findNearbyTourisms(BigDecimal longitude, BigDecimal latitude, Double radius, Integer limit, Integer showInHomepage) {
|
||||
log.info("查询附近景区,经度: {}, 纬度: {}, 半径: {}km, 限制数量: {}, 首页显示: {}", longitude, latitude, radius, limit, showInHomepage);
|
||||
|
||||
// 参数验证
|
||||
if (longitude == null || latitude == null) {
|
||||
@@ -84,7 +84,12 @@ public class TourismServiceImpl extends SuperServiceImpl<TourismMapper, Tourism>
|
||||
limit = 20; // 默认返回20个
|
||||
}
|
||||
|
||||
List<TourismWithDistance> tourisms = baseMapper.findNearbyTourisms(longitude, latitude, radius, limit);
|
||||
// 默认只显示设置为显示的景区
|
||||
if (showInHomepage == null) {
|
||||
showInHomepage = 1;
|
||||
}
|
||||
|
||||
List<TourismWithDistance> tourisms = baseMapper.findNearbyTourisms(longitude, latitude, radius, limit, showInHomepage);
|
||||
log.info("查询到附近景区数量: {}", tourisms.size());
|
||||
|
||||
// 为每个景区添加订单展示图片
|
||||
|
||||
@@ -30,6 +30,12 @@
|
||||
<if test="p.deviceSn != null and p.deviceSn != ''">
|
||||
AND q.device_sn = #{p.deviceSn}
|
||||
</if>
|
||||
<if test="p.qrcodeType != null">
|
||||
AND q.qrcode_type = #{p.qrcodeType}
|
||||
</if>
|
||||
<if test="p.showVideoEditOnly != null">
|
||||
AND q.show_video_edit_only = #{p.showVideoEditOnly}
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY q.create_time DESC
|
||||
</select>
|
||||
@@ -44,4 +50,22 @@
|
||||
INSERT INTO qrcodes (code_id, tourism_id, device_sn)
|
||||
VALUES (#{codeId}, #{tourismId}, #{deviceSn})
|
||||
</insert>
|
||||
|
||||
<select id="getByDeviceIdAndType" resultMap="QrCodeResultMap">
|
||||
SELECT * FROM qrcodes
|
||||
WHERE device_sn = #{deviceId}
|
||||
AND qrcode_type = #{qrcodeType}
|
||||
AND is_del = 0
|
||||
ORDER BY create_time DESC
|
||||
LIMIT 1
|
||||
</select>
|
||||
|
||||
<select id="getByCodeIds" resultMap="QrCodeResultMap">
|
||||
SELECT * FROM qrcodes
|
||||
WHERE code_id IN
|
||||
<foreach collection="codeIds" item="codeId" open="(" separator="," close=")">
|
||||
#{codeId}
|
||||
</foreach>
|
||||
AND is_del = 0
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -56,6 +56,21 @@
|
||||
AND status = 1
|
||||
AND longitude IS NOT NULL
|
||||
AND latitude IS NOT NULL
|
||||
]]>
|
||||
<choose>
|
||||
<when test="showInHomepage != null">
|
||||
<if test="showInHomepage == 1">
|
||||
AND (show_in_homepage = 1 OR show_in_homepage IS NULL)
|
||||
</if>
|
||||
<if test="showInHomepage == 0">
|
||||
AND show_in_homepage = 0
|
||||
</if>
|
||||
</when>
|
||||
<otherwise>
|
||||
AND (show_in_homepage = 1 OR show_in_homepage IS NULL)
|
||||
</otherwise>
|
||||
</choose>
|
||||
<![CDATA[
|
||||
HAVING distance <= #{radius}
|
||||
ORDER BY distance ASC
|
||||
]]>
|
||||
|
||||
Reference in New Issue
Block a user