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());
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 ->
@@ -915,10 +923,15 @@ public class OrderController {
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();
@@ -928,51 +941,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);
}
@@ -40,4 +40,11 @@ public interface QrCodeMapper extends SuperMapper<QrCode> {
*/
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:其他)")
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.order.model.QrCode;
import java.util.List;
import java.util.Map;
/**
@@ -42,5 +43,12 @@ public interface IQrCodeService extends ISuperService<QrCode> {
* @return 二维码信息
*/
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.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -56,6 +57,14 @@ public class QrCodeServiceImpl extends SuperServiceImpl<QrCodeMapper, QrCode> im
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">
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>
@@ -56,4 +59,13 @@
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>