fix(订单中心):新增二维码是否只显示一键成片的属性字段,v2接口根据该属性进行素材的显示

This commit is contained in:
2025-08-26 00:05:07 +08:00
parent 7a75f7278d
commit c4d74f9d21
10 changed files with 153 additions and 45 deletions
@@ -878,6 +878,14 @@ public class OrderController {
.collect(Collectors.toSet()); .collect(Collectors.toSet());
Map<Long, Tourism> tourismMap = tourismService.getTourismsByIds(tourismIds); 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,避免重复调用 // 预计算所有文件路径的URL,避免重复调用
Set<String> allFilePaths = new HashSet<>(); Set<String> allFilePaths = new HashSet<>();
orderFilesMap.values().forEach(files -> orderFilesMap.values().forEach(files ->
@@ -915,10 +923,15 @@ public class OrderController {
orderFileMap.put("orderNo", order.getOrderNo()); orderFileMap.put("orderNo", order.getOrderNo());
orderFileMap.put("orderStatus", order.getOrderStatus()); 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<>()); List<OrderFile> allFiles = orderFilesMap.getOrDefault(order.getOrderNo(), new ArrayList<>());
// aiVideo - 使用缓存URL // aiVideo - 使用缓存URL(始终返回)
List<OrderFile> aiVideoFiles = allFiles.stream() List<OrderFile> aiVideoFiles = allFiles.stream()
.filter(f -> "ai_video".equals(f.getFileTag())) .filter(f -> "ai_video".equals(f.getFileTag()))
.toList(); .toList();
@@ -928,51 +941,60 @@ public class OrderController {
} }
orderFileMap.put("aiVideo", aiVideoUrl); orderFileMap.put("aiVideo", aiVideoUrl);
// 图片素材 - 使用缓存URL // 根据showVideoEditOnly属性决定是否返回图片和视频素材
List<OrderFile> imgFiles = allFiles.stream() if (showVideoEditOnly == null || showVideoEditOnly == 1) {
.filter(f -> "image/jpeg".equals(f.getFileType())) // 只显示一键成片,不返回图片和视频素材
.toList(); orderFileMap.put("imgList", new ArrayList<>());
List<Map<String,String>> imgList = new ArrayList<>(); orderFileMap.put("videoList", new ArrayList<>());
Map<String, String> fileMap = new HashMap<>(); } else {
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());
// 为视频生成缩略图URL - 使用对应的图片作为缩略图 // 图片素材 - 使用缓存URL
String thumbnailUrl = null; List<OrderFile> imgFiles = allFiles.stream()
if (!imgList.isEmpty() && i < imgList.size()) { .filter(f -> "image/jpeg".equals(f.getFileType()))
// 使用对应索引的图片作为缩略图 .toList();
thumbnailUrl = imgList.get(i).get("viewUrl"); List<Map<String,String>> imgList = new ArrayList<>();
} else if (!imgList.isEmpty()) { Map<String, String> fileMap = new HashMap<>();
// 如果视频数量超过图片数量,使用第一张图片作为缩略图 fileMap.put("style", fileStyle);
thumbnailUrl = imgList.get(0).get("viewUrl"); 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); orderFileMap.put("imgList", imgList);
videoList.add(videoMap); // 视频素材 - 使用缓存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); page.add(orderFileMap);
} }
@@ -40,4 +40,11 @@ public interface QrCodeMapper extends SuperMapper<QrCode> {
*/ */
QrCode getByDeviceIdAndType(@Param("deviceId") String deviceId, @Param("qrcodeType") Integer qrcodeType); QrCode getByDeviceIdAndType(@Param("deviceId") String deviceId, @Param("qrcodeType") Integer qrcodeType);
/**
* 根据二维码ID列表批量查询二维码信息
* @param codeIds 二维码ID列表
* @return 二维码信息列表
*/
List<QrCode> getByCodeIds(@Param("codeIds") List<String> codeIds);
} }
@@ -111,4 +111,10 @@ public class QrCode extends SuperEntity {
@Schema(description = "二维码类型(1:游客下单,2:定时巡查,3:其他)") @Schema(description = "二维码类型(1:游客下单,2:定时巡查,3:其他)")
private Integer qrcodeType; private Integer qrcodeType;
/**
* 是否只显示一键成片(0:否,1:是)
*/
@Schema(description = "是否只显示一键成片(0:否,1:是)")
private Integer showVideoEditOnly;
} }
@@ -4,6 +4,7 @@ import com.central.common.model.PageResult;
import com.central.common.service.ISuperService; import com.central.common.service.ISuperService;
import com.central.order.model.QrCode; import com.central.order.model.QrCode;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@@ -42,5 +43,12 @@ public interface IQrCodeService extends ISuperService<QrCode> {
* @return 二维码信息 * @return 二维码信息
*/ */
QrCode getByDeviceIdAndType(String deviceId, Integer qrcodeType); QrCode getByDeviceIdAndType(String deviceId, Integer qrcodeType);
/**
* 根据二维码ID列表批量查询二维码信息
* @param codeIds 二维码ID列表
* @return 二维码信息列表
*/
List<QrCode> getByCodeIds(List<String> codeIds);
} }
@@ -10,6 +10,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils; import org.apache.commons.collections4.MapUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@@ -56,6 +57,14 @@ public class QrCodeServiceImpl extends SuperServiceImpl<QrCodeMapper, QrCode> im
return baseMapper.getByDeviceIdAndType(deviceId, 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);
}
} }
@@ -33,6 +33,9 @@
<if test="p.qrcodeType != null"> <if test="p.qrcodeType != null">
AND q.qrcode_type = #{p.qrcodeType} AND q.qrcode_type = #{p.qrcodeType}
</if> </if>
<if test="p.showVideoEditOnly != null">
AND q.show_video_edit_only = #{p.showVideoEditOnly}
</if>
</where> </where>
ORDER BY q.create_time DESC ORDER BY q.create_time DESC
</select> </select>
@@ -56,4 +59,13 @@
ORDER BY create_time DESC ORDER BY create_time DESC
LIMIT 1 LIMIT 1
</select> </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> </mapper>
@@ -7,7 +7,7 @@ import {
ProFormDigit, ProFormDigit,
} from '@ant-design/pro-components'; } from '@ant-design/pro-components';
import { Form } from 'antd'; import { Form } from 'antd';
import { ENABLE_PROFIT_OPTIONS, PAYEE_TYPE_OPTIONS, ENABLE_VIDEO_EDIT_OPTIONS, QRCODE_TYPE_OPTIONS } from '../index'; import { ENABLE_PROFIT_OPTIONS, PAYEE_TYPE_OPTIONS, ENABLE_VIDEO_EDIT_OPTIONS, QRCODE_TYPE_OPTIONS, SHOW_VIDEO_EDIT_ONLY_OPTIONS } from '../index';
// 添加测试二维码选项常量 // 添加测试二维码选项常量
export const IS_TEST_OPTIONS = [ export const IS_TEST_OPTIONS = [
@@ -210,6 +210,15 @@ const CreateForm: React.FC<CreateFormProps> = ({
initialValue={1} initialValue={1}
tooltip="用于区分该二维码是游客下单、定时巡查,还是其他用途" tooltip="用于区分该二维码是游客下单、定时巡查,还是其他用途"
/> />
<ProFormSelect
width="md"
name="showVideoEditOnly"
label="是否只显示一键成片"
options={SHOW_VIDEO_EDIT_ONLY_OPTIONS}
rules={[{ required: true, message: '请选择是否只显示一键成片' }]}
initialValue={1}
tooltip="设置为是时,用户扫码后只显示一键成片功能,隐藏其他功能选项"
/>
</ProForm.Group> </ProForm.Group>
<ProForm.Group> <ProForm.Group>
@@ -6,7 +6,7 @@ import {
ProFormText, ProFormText,
ProFormDigit, ProFormDigit,
} from '@ant-design/pro-components'; } from '@ant-design/pro-components';
import { STATUS_OPTIONS, PAYEE_TYPE_OPTIONS, ENABLE_PROFIT_OPTIONS, ENABLE_VIDEO_EDIT_OPTIONS, QRCODE_TYPE_OPTIONS } from '../index'; import { STATUS_OPTIONS, PAYEE_TYPE_OPTIONS, ENABLE_PROFIT_OPTIONS, ENABLE_VIDEO_EDIT_OPTIONS, QRCODE_TYPE_OPTIONS, SHOW_VIDEO_EDIT_ONLY_OPTIONS } from '../index';
import { Form, Space } from 'antd'; import { Form, Space } from 'antd';
import styles from './index.less'; import styles from './index.less';
@@ -218,6 +218,14 @@ const UpdateForm: React.FC<UpdateFormProps> = ({
rules={[{ required: true, message: '请选择二维码类型' }]} rules={[{ required: true, message: '请选择二维码类型' }]}
tooltip="用于区分该二维码是游客下单、定时巡查,还是其他用途" tooltip="用于区分该二维码是游客下单、定时巡查,还是其他用途"
/> />
<ProFormSelect
width="md"
name="showVideoEditOnly"
label="是否只显示一键成片"
options={SHOW_VIDEO_EDIT_ONLY_OPTIONS}
rules={[{ required: true, message: '请选择是否只显示一键成片' }]}
tooltip="设置为是时,用户扫码后只显示一键成片功能,隐藏其他功能选项"
/>
</ProForm.Group> </ProForm.Group>
<ProForm.Group> <ProForm.Group>
@@ -68,6 +68,12 @@ export const QRCODE_TYPE_OPTIONS = [
{ label: '其他', value: 3 }, { label: '其他', value: 3 },
] as const; ] as const;
// 添加是否只显示一键成片选项常量
export const SHOW_VIDEO_EDIT_ONLY_OPTIONS = [
{ label: '否', value: 0 },
{ label: '是', value: 1 },
] as const;
const handleApiRequest = async ( const handleApiRequest = async (
apiCall: () => Promise<any>, apiCall: () => Promise<any>,
loadingMessage: string, loadingMessage: string,
@@ -487,6 +493,20 @@ const TableList: React.FC = () => {
3: { text: '其他' }, 3: { text: '其他' },
}, },
}, },
{
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: '是' },
},
},
{ {
title: '应用ID', title: '应用ID',
dataIndex: 'tenantId', dataIndex: 'tenantId',
@@ -574,6 +594,12 @@ const TableList: React.FC = () => {
placeholder="请选择二维码类型" placeholder="请选择二维码类型"
options={QRCODE_TYPE_OPTIONS} options={QRCODE_TYPE_OPTIONS}
/> />
<ProFormSelect
name="showVideoEditOnly"
label="是否只显示一键成片"
placeholder="请选择是否只显示一键成片"
options={SHOW_VIDEO_EDIT_ONLY_OPTIONS}
/>
<ProFormSelect <ProFormSelect
name="tenantId" name="tenantId"
label="应用ID" label="应用ID"
@@ -87,6 +87,7 @@ declare namespace ORDERS {
enableVideoEdit?: number; // 是否开启一键成片(0:否,1:是) enableVideoEdit?: number; // 是否开启一键成片(0:否,1:是)
waylineId?: string; // 航线ID waylineId?: string; // 航线ID
qrcodeType?: number; // 二维码类型(1:游客下单,2:定时巡查,3:其他) qrcodeType?: number; // 二维码类型(1:游客下单,2:定时巡查,3:其他)
showVideoEditOnly?: number; // 是否只显示一键成片(0:否,1:是)
} }
type HomeCarousel = { type HomeCarousel = {