!63 feat: 1:优化景区素材,查询景区素材从套餐中获取
Merge pull request !63 from 鸭先知/feature_dzc
This commit is contained in:
+24
-9
@@ -2,6 +2,7 @@ package com.central.order.controller;
|
|||||||
|
|
||||||
import com.central.common.model.PageResult;
|
import com.central.common.model.PageResult;
|
||||||
import com.central.common.model.Result;
|
import com.central.common.model.Result;
|
||||||
|
import com.central.common.utils.StringUtils;
|
||||||
import com.central.order.feign.FileCenterService;
|
import com.central.order.feign.FileCenterService;
|
||||||
import com.central.order.model.*;
|
import com.central.order.model.*;
|
||||||
import com.central.order.service.IOrderService;
|
import com.central.order.service.IOrderService;
|
||||||
@@ -25,11 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -127,16 +124,34 @@ public class QrCodeController {
|
|||||||
Assert.notNull(qrCode,"QRCODE不能为空");
|
Assert.notNull(qrCode,"QRCODE不能为空");
|
||||||
Tourism tourism = tourismService.getTourismById(qrCode.getTourismId());
|
Tourism tourism = tourismService.getTourismById(qrCode.getTourismId());
|
||||||
Assert.notNull(tourism,"TOURISM数据不能为空");
|
Assert.notNull(tourism,"TOURISM数据不能为空");
|
||||||
List<TourismFile> tourismFiles = tourismFileService.getByTourismId(qrCode.getTourismId());
|
tourism.setTourismName(StringUtils.isEmpty(qrCode.getName())?tourism.getTourismName():qrCode.getName());
|
||||||
if (!CollectionUtils.isEmpty(tourismFiles)) {
|
tourism.setTourismDesc(StringUtils.isEmpty(qrCode.getQrDescribe())?tourism.getTourismDesc():qrCode.getQrDescribe());
|
||||||
for (TourismFile tourismFile: tourismFiles) {
|
//根据codeId获取套餐
|
||||||
tourismFile.setImageUrl(fileCenterService.getViewUrlByPath(tourismFile.getImageUrl()));
|
List<PackagePlan> list = packagePlanService.getByCodeId(codeId);
|
||||||
|
List<TourismFile> tourismFiles = new ArrayList<>();
|
||||||
|
if(!CollectionUtils.isEmpty(list)){
|
||||||
|
PackagePlan plan = list.get(0);
|
||||||
|
String fileIds = plan.getTourismFileIds();
|
||||||
|
if(fileIds!=null){
|
||||||
|
List<Long> fileIdsList = Arrays.stream(fileIds.split(","))
|
||||||
|
.map(String::trim) // 去除空格
|
||||||
|
.filter(s -> !s.isEmpty()) // 过滤空字符串
|
||||||
|
.map(Long::parseLong)
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
for (Long fileId: fileIdsList ){
|
||||||
|
TourismFile tourismFile = tourismFileService.getById(fileId);
|
||||||
|
if(Objects.nonNull(tourismFile)){
|
||||||
|
tourismFile.setImageUrl(fileCenterService.getViewUrlByPath(tourismFile.getImageUrl()));
|
||||||
|
tourismFiles.add(tourismFile);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
QrCodeVO qrCodeVO = new QrCodeVO();
|
QrCodeVO qrCodeVO = new QrCodeVO();
|
||||||
qrCodeVO.setCodeId(codeId);
|
qrCodeVO.setCodeId(codeId);
|
||||||
qrCodeVO.setTourism(tourism);
|
qrCodeVO.setTourism(tourism);
|
||||||
qrCodeVO.setTourismFiles(tourismFiles);
|
qrCodeVO.setTourismFiles(tourismFiles);
|
||||||
|
// qrCodeVO.setQrCode(qrCode);
|
||||||
return Result.succeed(qrCodeVO,"获取成功");
|
return Result.succeed(qrCodeVO,"获取成功");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -117,4 +117,7 @@ public class QrCode extends SuperEntity {
|
|||||||
@Schema(description = "是否只显示一键成片(0:否,1:是)")
|
@Schema(description = "是否只显示一键成片(0:否,1:是)")
|
||||||
private Integer showVideoEditOnly;
|
private Integer showVideoEditOnly;
|
||||||
|
|
||||||
|
@Schema(description = "描述")
|
||||||
|
private String qrDescribe;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,5 +22,6 @@ public class QrCodeVO {
|
|||||||
private String codeId;
|
private String codeId;
|
||||||
private Tourism tourism;
|
private Tourism tourism;
|
||||||
private List<TourismFile> tourismFiles;
|
private List<TourismFile> tourismFiles;
|
||||||
|
// private QrCode qrCode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -300,9 +300,77 @@ const OrderResourcesModal: React.FC<OrderResourcesModalProps> = ({ visible, reco
|
|||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`❌ ZIP 打包失败:`, error);
|
console.error(`❌ ZIP 打包失败:`, error);
|
||||||
message.error('打包下载失败,请重试');
|
|
||||||
removeDownloadProgress('batch_all');
|
removeDownloadProgress('batch_all');
|
||||||
} finally {
|
|
||||||
|
// 判断错误类型并给出提示
|
||||||
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
||||||
|
if (errorMessage.includes('CORS') || errorMessage.includes('Failed to fetch')) {
|
||||||
|
message.error('ZIP打包失败:跨域问题,请使用"分别下载"功能');
|
||||||
|
} else {
|
||||||
|
message.error('打包下载失败,文件可能过大,建议使用"分别下载"');
|
||||||
|
}
|
||||||
|
setBatchDownloading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 批量分别下载(备用方案)- 使用 iframe 避免 CORS
|
||||||
|
const handleBatchDownloadSeparately = async () => {
|
||||||
|
if (!record?.orderNo) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const orderNo = record.orderNo;
|
||||||
|
console.log(`📦 开始分别下载: ${orderNo}`);
|
||||||
|
message.info('正在分别下载所有文件,请查看浏览器下载列表');
|
||||||
|
|
||||||
|
try {
|
||||||
|
let successCount = 0;
|
||||||
|
let failureCount = 0;
|
||||||
|
|
||||||
|
// 获取所有文件的下载URL
|
||||||
|
for (let i = 0; i < resources.length; i++) {
|
||||||
|
const file = resources[i];
|
||||||
|
try {
|
||||||
|
if (!file.fileId) {
|
||||||
|
failureCount++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const downloadUrl = await ordersApi.getFileDownloadUrl(file.fileId);
|
||||||
|
if (downloadUrl) {
|
||||||
|
// 使用 iframe 触发下载
|
||||||
|
setTimeout(() => {
|
||||||
|
const iframe = document.createElement('iframe');
|
||||||
|
iframe.style.display = 'none';
|
||||||
|
iframe.src = downloadUrl;
|
||||||
|
document.body.appendChild(iframe);
|
||||||
|
|
||||||
|
// 5秒后移除 iframe
|
||||||
|
setTimeout(() => {
|
||||||
|
document.body.removeChild(iframe);
|
||||||
|
}, 5000);
|
||||||
|
}, i * 100); // 每个文件间隔 100ms
|
||||||
|
|
||||||
|
successCount++;
|
||||||
|
console.log(`✅ 触发下载: ${file.fileId}`);
|
||||||
|
} else {
|
||||||
|
failureCount++;
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.warn(`⚠️ 获取下载链接失败: ${file.fileId}`, error);
|
||||||
|
failureCount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 延迟显示完成消息
|
||||||
|
setTimeout(() => {
|
||||||
|
message.success(`✅ 分别下载已启动!成功: ${successCount} 个,失败: ${failureCount} 个`);
|
||||||
|
setBatchDownloading(false);
|
||||||
|
}, resources.length * 100 + 500);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`❌ 分别下载失败:`, error);
|
||||||
|
message.error('下载失败,请重试');
|
||||||
setBatchDownloading(false);
|
setBatchDownloading(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -627,13 +695,23 @@ const OrderResourcesModal: React.FC<OrderResourcesModalProps> = ({ visible, reco
|
|||||||
关闭
|
关闭
|
||||||
</Button>,
|
</Button>,
|
||||||
<Button
|
<Button
|
||||||
key="batch-download"
|
key="separate-download"
|
||||||
type="primary"
|
type="primary"
|
||||||
|
icon={<DownloadOutlined />}
|
||||||
|
loading={batchDownloading}
|
||||||
|
disabled={resources.length === 0 || loading || batchDownloading}
|
||||||
|
onClick={handleBatchDownloadSeparately}
|
||||||
|
title="分别下载所有文件(推荐用于大文件)"
|
||||||
|
>
|
||||||
|
{batchDownloading ? '下载中...' : '分别下载'}
|
||||||
|
</Button>,
|
||||||
|
<Button
|
||||||
|
key="zip-download"
|
||||||
icon={<FileZipOutlined />}
|
icon={<FileZipOutlined />}
|
||||||
loading={batchDownloading}
|
loading={batchDownloading}
|
||||||
disabled={resources.length === 0 || loading || batchDownloading}
|
disabled={resources.length === 0 || loading || batchDownloading}
|
||||||
onClick={handleBatchDownload}
|
onClick={handleBatchDownload}
|
||||||
title={batchDownloading ? `正在打包下载中...` : '批量下载为ZIP'}
|
title="打包为ZIP下载(适合小文件,大文件可能导致浏览器崩溃)"
|
||||||
>
|
>
|
||||||
{batchDownloading ? (() => {
|
{batchDownloading ? (() => {
|
||||||
const batchProgress = Array.from(downloadingFiles.values()).find(
|
const batchProgress = Array.from(downloadingFiles.values()).find(
|
||||||
@@ -642,8 +720,8 @@ const OrderResourcesModal: React.FC<OrderResourcesModalProps> = ({ visible, reco
|
|||||||
if (batchProgress) {
|
if (batchProgress) {
|
||||||
return `打包中... ${batchProgress.progress}%`;
|
return `打包中... ${batchProgress.progress}%`;
|
||||||
}
|
}
|
||||||
return `打包中... ${batchDownloadProgress}%`;
|
return `打包中...`;
|
||||||
})() : '批量下载'}
|
})() : '打包ZIP'}
|
||||||
</Button>,
|
</Button>,
|
||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ export interface QrcodeItem {
|
|||||||
videoCount?: number;
|
videoCount?: number;
|
||||||
photoCount?: number;
|
photoCount?: number;
|
||||||
tourismFileIds?: number[];
|
tourismFileIds?: number[];
|
||||||
|
qrDescribe?: string;
|
||||||
}
|
}
|
||||||
export interface QrcodeFormProps {
|
export interface QrcodeFormProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import { ModalForm, ProForm, ProFormDigit, ProFormSelect, ProFormText } from '@ant-design/pro-components';
|
import { ModalForm, ProForm, ProFormDigit, ProFormSelect, ProFormText, ProFormTextArea } from '@ant-design/pro-components';
|
||||||
import { ordersApi } from '@/services/orders';
|
import { ordersApi } from '@/services/orders';
|
||||||
import { deviceApi } from '@/services/device';
|
import { deviceApi } from '@/services/device';
|
||||||
import { miniAppApi } from '@/services/miniapp';
|
import { miniAppApi } from '@/services/miniapp';
|
||||||
@@ -26,6 +26,7 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
|||||||
vlogCount: 0,
|
vlogCount: 0,
|
||||||
videoCount: 0,
|
videoCount: 0,
|
||||||
photoCount: 0,
|
photoCount: 0,
|
||||||
|
qrDescribe: '', // 描述
|
||||||
};
|
};
|
||||||
|
|
||||||
// 过滤 initialValues 中的 undefined,避免覆盖默认值
|
// 过滤 initialValues 中的 undefined,避免覆盖默认值
|
||||||
@@ -250,6 +251,18 @@ const QrcodeTourismForm: React.FC<QrcodeTourismFormProps> = ({ open, title, init
|
|||||||
colProps={{ span: 12 }}
|
colProps={{ span: 12 }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<ProFormTextArea
|
||||||
|
name="qrDescribe"
|
||||||
|
label="描述"
|
||||||
|
placeholder="请输入二维码描述"
|
||||||
|
fieldProps={{
|
||||||
|
rows: 3,
|
||||||
|
showCount: true,
|
||||||
|
maxLength: 500,
|
||||||
|
}}
|
||||||
|
colProps={{ span: 24 }}
|
||||||
|
/>
|
||||||
|
|
||||||
{/* 注册一个隐藏字段以提交素材ID数组 */}
|
{/* 注册一个隐藏字段以提交素材ID数组 */}
|
||||||
<ProForm.Item name="tourismFileIds" hidden>
|
<ProForm.Item name="tourismFileIds" hidden>
|
||||||
<div />
|
<div />
|
||||||
|
|||||||
Reference in New Issue
Block a user