fix(订单中心):用户相册接口查询逻辑更新V3版本
This commit is contained in:
+126
@@ -910,6 +910,132 @@ public class OrderController {
|
|||||||
return new PageResult<>();
|
return new PageResult<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新版:查询用户图片订单详情列表
|
||||||
|
*/
|
||||||
|
@Operation(summary = "新版-查询用户图片订单详情列表")
|
||||||
|
@Parameters({
|
||||||
|
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "fileType",description = "文件类型筛选",required = false,in=ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "fileTag",description = "文件标签筛选",required = false,in=ParameterIn.QUERY)
|
||||||
|
})
|
||||||
|
@GetMapping("/user/images")
|
||||||
|
public PageResult<Map> listImageOrdersByUser(@RequestParam Map<String, Object> params) {
|
||||||
|
LoginAppUser user = LoginUserContextHolder.getUser();
|
||||||
|
params.put("userId", user.getId());
|
||||||
|
List<Integer> orderStatusList = List.of(OrderStatus.COMPLETE.getId(), OrderStatus.UPLOADING.getId(), OrderStatus.UPLOADED.getId());
|
||||||
|
params.put("orderStatusList", orderStatusList);
|
||||||
|
|
||||||
|
PageResult<Order> result = orderService.findListByUser(params);
|
||||||
|
if (result.getCount() > 0){
|
||||||
|
List<Map> page = new ArrayList<>();
|
||||||
|
Map<String, String> fileMap = new HashMap<>();
|
||||||
|
fileMap.put("style", fileStyle);
|
||||||
|
for(Order order : result.getData()){
|
||||||
|
Map<String,Object> orderFileMap = new HashMap<>();
|
||||||
|
orderFileMap.put("time", sdf.format(order.getCreateTime()));
|
||||||
|
orderFileMap.put("addr", tourismService.getTourismById(order.getTourismId()).getTourismAddress());
|
||||||
|
orderFileMap.put("orderNo", order.getOrderNo());
|
||||||
|
|
||||||
|
// 只查一次所有文件
|
||||||
|
List<OrderFile> allFiles = orderFileService.getOrderFileByOrderNo(order.getOrderNo());
|
||||||
|
|
||||||
|
// 图片素材
|
||||||
|
List<OrderFile> imgFiles = allFiles.stream()
|
||||||
|
.filter(f -> "image/jpeg".equals(f.getFileType()))
|
||||||
|
.toList();
|
||||||
|
List<Map<String,String>> imgList = new ArrayList<>();
|
||||||
|
for (OrderFile orderFile : imgFiles){
|
||||||
|
Map<String,String> imgMap = new HashMap<>();
|
||||||
|
String url = fileCenterService.getViewUrlByPath(orderFile.getFilePath());
|
||||||
|
imgMap.put("url", url.replace(cdnOssUrl, cdnUrl));
|
||||||
|
imgMap.put("contentType", orderFile.getFileType());
|
||||||
|
imgMap.put("path", orderFile.getFilePath());
|
||||||
|
fileMap.put("path",orderFile.getFilePath());
|
||||||
|
imgMap.put("viewUrl", fileCenterService.getViewUrlByPathStyle(fileMap));
|
||||||
|
imgList.add(imgMap);
|
||||||
|
}
|
||||||
|
orderFileMap.put("imgList", imgList);
|
||||||
|
|
||||||
|
// 只返回有图片的订单
|
||||||
|
if (!imgList.isEmpty()) {
|
||||||
|
page.add(orderFileMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PageResult.<Map>builder().data(page).resp_code(0).count((long) page.size()).build();
|
||||||
|
}
|
||||||
|
return new PageResult<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 新版:查询用户视频订单详情列表
|
||||||
|
*/
|
||||||
|
@Operation(summary = "新版-查询用户视频订单详情列表")
|
||||||
|
@Parameters({
|
||||||
|
@Parameter(name = "page",description = "分页起始位置",required = true,in=ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "fileType",description = "文件类型筛选",required = false,in=ParameterIn.QUERY),
|
||||||
|
@Parameter(name = "fileTag",description = "文件标签筛选",required = false,in=ParameterIn.QUERY)
|
||||||
|
})
|
||||||
|
@GetMapping("/user/videos")
|
||||||
|
public PageResult<Map> listVideoOrdersByUser(@RequestParam Map<String, Object> params) {
|
||||||
|
LoginAppUser user = LoginUserContextHolder.getUser();
|
||||||
|
params.put("userId", user.getId());
|
||||||
|
List<Integer> orderStatusList = List.of(OrderStatus.COMPLETE.getId(), OrderStatus.UPLOADING.getId(), OrderStatus.UPLOADED.getId());
|
||||||
|
params.put("orderStatusList", orderStatusList);
|
||||||
|
|
||||||
|
PageResult<Order> result = orderService.findListByUser(params);
|
||||||
|
if (result.getCount() > 0){
|
||||||
|
List<Map> page = new ArrayList<>();
|
||||||
|
Map<String, String> fileMap = new HashMap<>();
|
||||||
|
fileMap.put("style", fileStyle);
|
||||||
|
for(Order order : result.getData()){
|
||||||
|
Map<String,Object> orderFileMap = new HashMap<>();
|
||||||
|
orderFileMap.put("time", sdf.format(order.getCreateTime()));
|
||||||
|
orderFileMap.put("addr", tourismService.getTourismById(order.getTourismId()).getTourismAddress());
|
||||||
|
orderFileMap.put("orderNo", order.getOrderNo());
|
||||||
|
|
||||||
|
// 只查一次所有文件
|
||||||
|
List<OrderFile> allFiles = orderFileService.getOrderFileByOrderNo(order.getOrderNo());
|
||||||
|
|
||||||
|
// aiVideo
|
||||||
|
List<OrderFile> aiVideoFiles = allFiles.stream()
|
||||||
|
.filter(f -> "ai_video".equals(f.getFileTag()))
|
||||||
|
.toList();
|
||||||
|
String aiVideoUrl = null;
|
||||||
|
if (!aiVideoFiles.isEmpty()) {
|
||||||
|
aiVideoUrl = fileCenterService.getViewUrlByPath(aiVideoFiles.get(0).getFilePath()).replace(cdnOssUrl, cdnUrl);
|
||||||
|
}
|
||||||
|
orderFileMap.put("aiVideo", aiVideoUrl);
|
||||||
|
|
||||||
|
// 视频素材
|
||||||
|
List<OrderFile> videoFiles = allFiles.stream()
|
||||||
|
.filter(f -> "raw_video".equals(f.getFileTag()))
|
||||||
|
.toList();
|
||||||
|
List<Map<String,String>> videoList = new ArrayList<>();
|
||||||
|
for (OrderFile orderFile : videoFiles){
|
||||||
|
Map<String,String> videoMap = new HashMap<>();
|
||||||
|
String url = fileCenterService.getViewUrlByPath(orderFile.getFilePath());
|
||||||
|
videoMap.put("url", url.replace(cdnOssUrl, cdnUrl));
|
||||||
|
videoMap.put("contentType", orderFile.getFileType());
|
||||||
|
videoMap.put("path", orderFile.getFilePath());
|
||||||
|
fileMap.put("path",orderFile.getFilePath());
|
||||||
|
videoMap.put("viewUrl", fileCenterService.getViewUrlByPathStyle(fileMap));
|
||||||
|
videoList.add(videoMap);
|
||||||
|
}
|
||||||
|
orderFileMap.put("videoList", videoList);
|
||||||
|
|
||||||
|
// 只返回有视频的订单(包括aiVideo或raw_video)
|
||||||
|
if (aiVideoUrl != null || !videoList.isEmpty()) {
|
||||||
|
page.add(orderFileMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return PageResult.<Map>builder().data(page).resp_code(0).count((long) page.size()).build();
|
||||||
|
}
|
||||||
|
return new PageResult<>();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 移除URL中的参数
|
* 移除URL中的参数
|
||||||
* @param url 原始URL
|
* @param url 原始URL
|
||||||
|
|||||||
Reference in New Issue
Block a user