@@ -22,7 +22,10 @@
|
|||||||
"Bash(dir:*)",
|
"Bash(dir:*)",
|
||||||
"Bash(git add:*)",
|
"Bash(git add:*)",
|
||||||
"Bash(git commit -m \"$(cat <<''EOF''\nfix: 修复首页分账计算模块显示问题\n\n- 显示被隐藏的分账计算模块(移除 display: ''none'')\n- 调整 platformSharePercent 状态变量定义顺序\n- 优化 Slider 组件:\n - 设置标记文字颜色为深灰色 (#666),避免看不清\n - 添加 tooltip 提示框,拖动时显示当前百分比\n - 设置 tooltip 背景为深色,文字为白色,确保清晰可见\n- 移除重复的 90% 标记,只保留 0%、50%、100%\n\n🤖 Generated with Claude Code\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n)\")",
|
"Bash(git commit -m \"$(cat <<''EOF''\nfix: 修复首页分账计算模块显示问题\n\n- 显示被隐藏的分账计算模块(移除 display: ''none'')\n- 调整 platformSharePercent 状态变量定义顺序\n- 优化 Slider 组件:\n - 设置标记文字颜色为深灰色 (#666),避免看不清\n - 添加 tooltip 提示框,拖动时显示当前百分比\n - 设置 tooltip 背景为深色,文字为白色,确保清晰可见\n- 移除重复的 90% 标记,只保留 0%、50%、100%\n\n🤖 Generated with Claude Code\n\nCo-Authored-By: Claude <noreply@anthropic.com>\nEOF\n)\")",
|
||||||
"Bash(git commit:*)"
|
"Bash(git commit:*)",
|
||||||
|
"Read(//f/**)",
|
||||||
|
"Bash(git checkout:*)",
|
||||||
|
"Bash(git diff:*)"
|
||||||
],
|
],
|
||||||
"deny": [],
|
"deny": [],
|
||||||
"ask": []
|
"ask": []
|
||||||
|
|||||||
+4
-4
@@ -661,12 +661,12 @@ public class OrderController {
|
|||||||
|
|
||||||
for (OrderFile orderFile : orderFiles) {
|
for (OrderFile orderFile : orderFiles) {
|
||||||
Map<String, String> fileInfo = new HashMap<>();
|
Map<String, String> fileInfo = new HashMap<>();
|
||||||
String url = fileCenterService.getViewUrlByPath(orderFile.getFilePath());
|
String url = fileCenterService.getFileViewUrl(orderFile.getFileId());
|
||||||
// 去掉URL中的参数并替换域名
|
// 去掉URL中的参数并替换域名
|
||||||
// String cleanUrl = removeUrlParams(url.replace(cdnOssUrl, cdnUrl));
|
// String cleanUrl = removeUrlParams(url.replace(cdnOssUrl, cdnUrl));
|
||||||
fileInfo.put("url", url.replace(cdnOssUrl, cdnUrl));
|
fileInfo.put("url", url);
|
||||||
fileInfo.put("contentType", orderFile.getFileType());
|
fileInfo.put("contentType", orderFile.getFileType());
|
||||||
fileMap.put("path", orderFile.getFilePath());
|
fileMap.put("fileId", orderFile.getFileId());
|
||||||
fileInfo.put("viewUrl", fileCenterService.getViewUrlByPathStyle(fileMap));
|
fileInfo.put("viewUrl", fileCenterService.getViewUrlByPathStyle(fileMap));
|
||||||
fileList.add(fileInfo);
|
fileList.add(fileInfo);
|
||||||
}
|
}
|
||||||
@@ -1491,7 +1491,7 @@ public class OrderController {
|
|||||||
@GetMapping("/order/{orderNo}")
|
@GetMapping("/order/{orderNo}")
|
||||||
public Result<Order> getOrderByOrderNo(@PathVariable("orderNo") String orderNo) {
|
public Result<Order> getOrderByOrderNo(@PathVariable("orderNo") String orderNo) {
|
||||||
log.info("根据订单号获取订单信息,orderNo: {}", orderNo);
|
log.info("根据订单号获取订单信息,orderNo: {}", orderNo);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Order order = orderService.getOrderByNumber(orderNo);
|
Order order = orderService.getOrderByNumber(orderNo);
|
||||||
if (order == null) {
|
if (order == null) {
|
||||||
|
|||||||
+141
@@ -8,6 +8,7 @@ import com.central.order.constants.EditTaskStatus;
|
|||||||
import com.central.order.enums.OrderStatus;
|
import com.central.order.enums.OrderStatus;
|
||||||
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.model.params.FileDownloadRequest;
|
||||||
import com.central.order.service.*;
|
import com.central.order.service.*;
|
||||||
import com.central.order.util.DateUtils;
|
import com.central.order.util.DateUtils;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@@ -22,6 +23,15 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.util.CollectionUtils;
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.OutputStream;
|
||||||
|
import java.net.URL;
|
||||||
|
import java.net.URLConnection;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@@ -29,6 +39,8 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.zip.ZipEntry;
|
||||||
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order Files information
|
* Order Files information
|
||||||
@@ -570,4 +582,133 @@ public class OrderFileController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 代理下载单个文件 - 解决前端跨域问题
|
||||||
|
*/
|
||||||
|
@Operation(summary = "下载单个文件")
|
||||||
|
@PostMapping("/download")
|
||||||
|
public byte[] downloadFile(@RequestBody FileDownloadRequest request) throws IOException {
|
||||||
|
String fileUrl = request.getUrl();
|
||||||
|
log.info("开始代理下载文件: {}", fileUrl);
|
||||||
|
|
||||||
|
if (fileUrl == null || fileUrl.trim().isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("文件URL不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 从外部 CDN 下载文件
|
||||||
|
URL url = new URL(fileUrl);
|
||||||
|
URLConnection connection = url.openConnection();
|
||||||
|
|
||||||
|
// 设置超时
|
||||||
|
connection.setConnectTimeout(10000);
|
||||||
|
connection.setReadTimeout(30000);
|
||||||
|
|
||||||
|
// 获取文件内容
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int bytesRead;
|
||||||
|
java.io.ByteArrayOutputStream byteArrayOutputStream = new java.io.ByteArrayOutputStream();
|
||||||
|
|
||||||
|
try (InputStream input = connection.getInputStream()) {
|
||||||
|
while ((bytesRead = input.read(buffer)) != -1) {
|
||||||
|
byteArrayOutputStream.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("文件下载成功: {}", extractFileNameFromUrl(fileUrl));
|
||||||
|
return byteArrayOutputStream.toByteArray();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("文件下载失败: fileUrl={}", fileUrl, e);
|
||||||
|
throw new RuntimeException("文件下载失败: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 批量下载所有文件 - 打包为 ZIP
|
||||||
|
*/
|
||||||
|
@Operation(summary = "批量下载订单所有资源文件")
|
||||||
|
@PostMapping("/download/batch")
|
||||||
|
public byte[] batchDownloadFiles(@RequestBody FileDownloadRequest request) {
|
||||||
|
String orderNo = request.getOrderNo();
|
||||||
|
log.info("开始批量下载订单文件: {}", orderNo);
|
||||||
|
|
||||||
|
if (orderNo == null || orderNo.trim().isEmpty()) {
|
||||||
|
throw new IllegalArgumentException("订单编号不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 查询订单所有文件
|
||||||
|
List<OrderFile> orderFiles = orderFileService.getOrderFileByOrderNo(orderNo);
|
||||||
|
if (CollectionUtils.isEmpty(orderFiles)) {
|
||||||
|
throw new IllegalArgumentException("订单暂无资源文件");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建 ZIP 字节流
|
||||||
|
java.io.ByteArrayOutputStream byteArrayOutputStream = new java.io.ByteArrayOutputStream();
|
||||||
|
try (ZipOutputStream zipOut = new ZipOutputStream(byteArrayOutputStream)) {
|
||||||
|
for (OrderFile orderFile : orderFiles) {
|
||||||
|
String viewUrl = fileCenterService.getFileViewUrl(orderFile.getFileId());
|
||||||
|
if (viewUrl == null || viewUrl.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 下载单个文件
|
||||||
|
URL fileUrl = new URL(viewUrl);
|
||||||
|
URLConnection connection = fileUrl.openConnection();
|
||||||
|
connection.setConnectTimeout(10000);
|
||||||
|
connection.setReadTimeout(30000);
|
||||||
|
|
||||||
|
String fileName = extractFileNameFromUrl(viewUrl);
|
||||||
|
|
||||||
|
// 创建 ZIP 条目
|
||||||
|
ZipEntry zipEntry = new ZipEntry(fileName);
|
||||||
|
zipOut.putNextEntry(zipEntry);
|
||||||
|
|
||||||
|
// 写入文件内容到 ZIP
|
||||||
|
try (InputStream fileInput = connection.getInputStream()) {
|
||||||
|
byte[] buffer = new byte[4096];
|
||||||
|
int bytesRead;
|
||||||
|
while ((bytesRead = fileInput.read(buffer)) != -1) {
|
||||||
|
zipOut.write(buffer, 0, bytesRead);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
zipOut.closeEntry();
|
||||||
|
log.info("已添加文件到ZIP: {}", fileName);
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("添加文件到ZIP失败: {}", viewUrl, e);
|
||||||
|
// 继续处理其他文件
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("批量下载完成: {}", orderNo);
|
||||||
|
return byteArrayOutputStream.toByteArray();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("批量下载文件失败: orderNo={}", orderNo, e);
|
||||||
|
throw new RuntimeException("批量下载失败: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 从 URL 中提取文件名
|
||||||
|
*/
|
||||||
|
private String extractFileNameFromUrl(String url) {
|
||||||
|
if (url == null || url.isEmpty()) {
|
||||||
|
return "file_" + System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 移除查询参数
|
||||||
|
String urlWithoutParams = url.split("\\?")[0];
|
||||||
|
// 获取最后一个 /之后的部分
|
||||||
|
String[] parts = urlWithoutParams.split("/");
|
||||||
|
return parts.length > 0 ? parts[parts.length - 1] : "file_" + System.currentTimeMillis();
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("提取文件名失败: {}", url, e);
|
||||||
|
return "file_" + System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+126
@@ -9,10 +9,12 @@ import com.central.order.enums.OrderStatus;
|
|||||||
import com.central.order.enums.RefundState;
|
import com.central.order.enums.RefundState;
|
||||||
import com.central.order.model.Order;
|
import com.central.order.model.Order;
|
||||||
import com.central.order.model.QrCode;
|
import com.central.order.model.QrCode;
|
||||||
|
import com.central.order.model.params.ApproveCustomRefundAmountRequest;
|
||||||
import com.central.order.service.IOrderService;
|
import com.central.order.service.IOrderService;
|
||||||
import com.central.order.service.IQrCodeService;
|
import com.central.order.service.IQrCodeService;
|
||||||
import com.central.order.service.IRefundService;
|
import com.central.order.service.IRefundService;
|
||||||
import com.central.order.service.IWxTemplateMessageService;
|
import com.central.order.service.IWxTemplateMessageService;
|
||||||
|
import com.central.order.util.StringUtils;
|
||||||
import com.central.wechat.config.WxPayConfigFactory;
|
import com.central.wechat.config.WxPayConfigFactory;
|
||||||
import com.central.wechat.entity.WechatConfig;
|
import com.central.wechat.entity.WechatConfig;
|
||||||
import com.central.wechat.feign.WechatConfigService;
|
import com.central.wechat.feign.WechatConfigService;
|
||||||
@@ -26,6 +28,7 @@ import io.swagger.v3.oas.annotations.Parameters;
|
|||||||
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
import io.swagger.v3.oas.annotations.enums.ParameterIn;
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.poi.util.StringUtil;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@@ -77,6 +80,34 @@ public class RefundController {
|
|||||||
return refundService.findList(params);
|
return refundService.findList(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据订单编码获取退款订单详情(包含退款图片)
|
||||||
|
*/
|
||||||
|
@Operation(summary = "根据订单编码获取退款订单详情")
|
||||||
|
@Parameter(name = "orderNo", description = "订单编码", required = true, in = ParameterIn.QUERY)
|
||||||
|
@GetMapping("/detail")
|
||||||
|
public Result<Map<String, Object>> getRefundDetail(@RequestParam String orderNo) {
|
||||||
|
log.info("根据订单编码获取退款订单详情,orderNo: {}", orderNo);
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (orderNo == null || orderNo.isEmpty()) {
|
||||||
|
return Result.failed("订单编码不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
Map<String, Object> refundDetail = refundService.getRefundDetailByOrderNo(orderNo);
|
||||||
|
|
||||||
|
if (refundDetail == null || refundDetail.isEmpty()) {
|
||||||
|
return Result.failed("未找到该订单的退款记录");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result.succeed(refundDetail, "查询成功");
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取退款详情异常,orderNo: {}", orderNo, e);
|
||||||
|
return Result.failed("获取退款详情异常: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Operation(summary = "创建退款单")
|
@Operation(summary = "创建退款单")
|
||||||
@PostMapping("/{orderNo}")
|
@PostMapping("/{orderNo}")
|
||||||
public Result<com.central.order.model.Refund> createRefundOrder(@PathVariable String orderNo,@RequestBody com.central.order.model.Refund refundBody) {
|
public Result<com.central.order.model.Refund> createRefundOrder(@PathVariable String orderNo,@RequestBody com.central.order.model.Refund refundBody) {
|
||||||
@@ -142,6 +173,41 @@ public class RefundController {
|
|||||||
return Result.failed("处理退款失败");
|
return Result.failed("处理退款失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Operation(summary = "微信支付退款")
|
||||||
|
@PostMapping("/approve/custom")
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public Result<com.central.order.model.Refund> approveCustomOrderAmount(@RequestBody ApproveCustomRefundAmountRequest refundRequest) {
|
||||||
|
|
||||||
|
log.info("审批退款单,订单号: {}, 退款单号: {}", refundRequest.getOrderNo(), refundRequest.getRefundNo());
|
||||||
|
// 检查订单是否存在
|
||||||
|
Order order = orderService.getOrderByNumber(refundRequest.getOrderNo());
|
||||||
|
Assert.notNull(order, "ORDER DATA不存在");
|
||||||
|
com.central.order.model.Refund refundorder = refundService.getRefundByNo(refundRequest.getRefundNo());
|
||||||
|
Assert.notNull(order, "退款订单不存在");
|
||||||
|
if (!order.getOrderStatus().equals(OrderStatus.REFUNDING.getId())){
|
||||||
|
return Result.failed("订单状态不支持退款");
|
||||||
|
}
|
||||||
|
if (! refundRequest.getStatus().equals(OrderStatus.REFUNDING.getId())){
|
||||||
|
return Result.failed("该状态不支持审核");
|
||||||
|
}
|
||||||
|
if (refundRequest.getState().equals(RefundState.APPROVED.getId())){
|
||||||
|
dealCustomRefundAmountRequest(order,refundRequest.getRefundAmount());
|
||||||
|
refundorder.setRefundReason(refundRequest.getApproveReason());
|
||||||
|
if(refundRequest.getRefundAmount()!=null){
|
||||||
|
refundorder.setRefundAmount(refundRequest.getRefundAmount());
|
||||||
|
}
|
||||||
|
refundService.updateById(refundorder);
|
||||||
|
return Result.succeed("已处理退款");
|
||||||
|
}
|
||||||
|
if (refundRequest.getState().equals(RefundState.REFUSED.getId())){
|
||||||
|
order.setOrderStatus(OrderStatus.REFUND_FAILED.getId());
|
||||||
|
refundorder.setStatus(OrderStatus.REFUND_FAILED.getId());
|
||||||
|
orderService.updateOrder(order);
|
||||||
|
refundService.updateById(refundorder);
|
||||||
|
return Result.succeed("处理成功");
|
||||||
|
}
|
||||||
|
return Result.failed("处理退款失败");
|
||||||
|
}
|
||||||
|
|
||||||
@PutMapping("/auto")
|
@PutMapping("/auto")
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@@ -284,4 +350,64 @@ public class RefundController {
|
|||||||
throw new RuntimeException("退款失败: " + e.getMessage(), e);
|
throw new RuntimeException("退款失败: " + e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 微信退款申请
|
||||||
|
* @param order
|
||||||
|
*/
|
||||||
|
private void dealCustomRefundAmountRequest(Order order,String refundAmount) {
|
||||||
|
try {
|
||||||
|
// 获取二维码信息
|
||||||
|
QrCode qrCode = qrCodeService.getByCodeId(order.getCodeId());
|
||||||
|
if (qrCode == null) {
|
||||||
|
log.error("二维码不存在,订单号: {}", order.getOrderNo());
|
||||||
|
throw new RuntimeException("二维码不存在");
|
||||||
|
}
|
||||||
|
// 获取微信支付配置
|
||||||
|
WechatConfig wechatConfig = wechatConfigService.getConfig("PAY", qrCode.getTenantId());
|
||||||
|
if (wechatConfig == null) {
|
||||||
|
log.error("微信支付配置不存在,租户ID: {}", qrCode.getTenantId());
|
||||||
|
throw new RuntimeException("微信支付配置不存在");
|
||||||
|
}
|
||||||
|
// 创建微信退款请求
|
||||||
|
CreateRequest request = new CreateRequest();
|
||||||
|
request.setOutTradeNo(order.getOrderNo());
|
||||||
|
request.setOutRefundNo("RF" + order.getOrderNo());
|
||||||
|
request.setReason("用户申请退款");
|
||||||
|
request.setNotifyUrl(refundNotifyUrl);
|
||||||
|
// 设置退款金额
|
||||||
|
AmountReq amount = new AmountReq();
|
||||||
|
amount.setTotal(Long.valueOf(order.getOrderAmount()));
|
||||||
|
if(refundAmount!=null ){
|
||||||
|
amount.setRefund(Long.valueOf(refundAmount));
|
||||||
|
}else{
|
||||||
|
amount.setRefund(Long.valueOf(order.getOrderAmount())) ;
|
||||||
|
}
|
||||||
|
amount.setCurrency("CNY");
|
||||||
|
request.setAmount(amount);
|
||||||
|
// 根据是否为服务商模式设置不同的参数
|
||||||
|
RefundService refundService;
|
||||||
|
if (Boolean.TRUE.equals(wechatConfig.getIsServiceMode())) {
|
||||||
|
// 服务商模式:需要设置子商户号
|
||||||
|
request.setSubMchid(wechatConfig.getSubMchId());
|
||||||
|
log.info("服务商模式退款,子商户号: {}, 订单号: {}", wechatConfig.getSubMchId(), order.getOrderNo());
|
||||||
|
|
||||||
|
// 创建服务商模式的退款服务
|
||||||
|
refundService = wxPayConfigFactory.createRefundServiceBySubMchId(wechatConfig.getSubMchId());
|
||||||
|
} else {
|
||||||
|
// 普通商户模式
|
||||||
|
log.info("普通商户模式退款,商户号: {}, 订单号: {}", wechatConfig.getMerchantId(), order.getOrderNo());
|
||||||
|
refundService = wxPayConfigFactory.createRefundService(qrCode.getTenantId());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 发起退款请求
|
||||||
|
Refund response = refundService.create(request);
|
||||||
|
Assert.notNull(response, "退款失败");
|
||||||
|
|
||||||
|
log.info("退款请求成功,退款单号: {}, 订单号: {}", response.getRefundId(), order.getOrderNo());
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("退款请求失败,订单号: {}, 异常: {}", order.getOrderNo(), e.getMessage(), e);
|
||||||
|
throw new RuntimeException("退款失败: " + e.getMessage(), e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -382,9 +382,10 @@ public interface DashboardMapper {
|
|||||||
|
|
||||||
@Select({
|
@Select({
|
||||||
"<script>",
|
"<script>",
|
||||||
"SELECT COALESCE(SUM(o.order_amount), 0) as amount",
|
"SELECT COALESCE(SUM(r.refund_amount), 0) as amount",
|
||||||
"FROM orders o",
|
"FROM orders o",
|
||||||
"JOIN qrcodes q ON o.code_id = q.code_id",
|
"JOIN qrcodes q ON o.code_id = q.code_id",
|
||||||
|
"JOIN orders_refund r ON o.order_no = r.order_no",
|
||||||
"WHERE 1=1",
|
"WHERE 1=1",
|
||||||
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
"<if test='p.includeTestQrcodes == null or p.includeTestQrcodes == false'>",
|
||||||
" AND q.is_test = 0",
|
" AND q.is_test = 0",
|
||||||
|
|||||||
@@ -24,4 +24,11 @@ public interface RefundMapper extends SuperMapper<Refund> {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
List<Refund> findList(Page<Refund> page, @Param("p") Map<String, Object> params);
|
List<Refund> findList(Page<Refund> page, @Param("p") Map<String, Object> params);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据订单编码查询退款详情
|
||||||
|
* @param orderNo 订单编码
|
||||||
|
* @return 退款详情
|
||||||
|
*/
|
||||||
|
Refund selectByOrderNo(@Param("orderNo") String orderNo);
|
||||||
}
|
}
|
||||||
|
|||||||
+19
@@ -0,0 +1,19 @@
|
|||||||
|
package com.central.order.model.params;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class ApproveCustomRefundAmountRequest {
|
||||||
|
|
||||||
|
private String orderNo;
|
||||||
|
|
||||||
|
private String refundNo;
|
||||||
|
|
||||||
|
private String refundAmount;
|
||||||
|
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
private Integer state;
|
||||||
|
|
||||||
|
private String approveReason;
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
package com.central.order.model.params;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class FileDownloadRequest {
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
private String orderNo;
|
||||||
|
}
|
||||||
@@ -34,5 +34,12 @@ public interface IRefundService extends ISuperService<Refund> {
|
|||||||
*/
|
*/
|
||||||
Refund getRefundByNo(String refundNo) ;
|
Refund getRefundByNo(String refundNo) ;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据订单编码获取退款订单详情(包含图片)
|
||||||
|
* @param orderNo 订单编码
|
||||||
|
* @return 退款详情
|
||||||
|
*/
|
||||||
|
Map<String, Object> getRefundDetailByOrderNo(String orderNo);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+23
@@ -87,6 +87,29 @@ public class OrderServiceImpl extends SuperServiceImpl<OrderMapper, Order> imple
|
|||||||
@Override
|
@Override
|
||||||
public PageResult<Order> findList(Map<String, Object> params){
|
public PageResult<Order> findList(Map<String, Object> params){
|
||||||
log.info("查询订单列表,参数: {}", params);
|
log.info("查询订单列表,参数: {}", params);
|
||||||
|
|
||||||
|
// 获取租户ID,支持三级回退机制
|
||||||
|
String anchor = MapUtils.getString(params, "tenantId");
|
||||||
|
try {
|
||||||
|
if (anchor == null || anchor.isEmpty()) {
|
||||||
|
anchor = com.central.common.context.TenantQueryOverrideContext.getTenantId();
|
||||||
|
if (anchor == null || anchor.isEmpty()) {
|
||||||
|
anchor = com.central.common.context.LoginUserContextHolder.getCurrentTenantId();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("获取当前登录用户租户失败", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取租户及其所有子孙租户ID列表
|
||||||
|
List<String> tenantIds = userCenterService.getSonTenantIds(anchor);
|
||||||
|
|
||||||
|
// 根据租户ID列表查询该租户所属的景区
|
||||||
|
List<Long> tourismIds = tourismMapper.findTourismIdsByTenantIds(tenantIds);
|
||||||
|
|
||||||
|
// 将景区ID列表放入查询参数,用于查询订单
|
||||||
|
params.put("tourismIds", tourismIds);
|
||||||
|
|
||||||
Page<Order> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
|
Page<Order> page = new Page<>(MapUtils.getInteger(params, "page"), MapUtils.getInteger(params, "limit"));
|
||||||
List<Order> list = baseMapper.findList(page, params);
|
List<Order> list = baseMapper.findList(page, params);
|
||||||
log.info("查询结果数量: {}", list.size());
|
log.info("查询结果数量: {}", list.size());
|
||||||
|
|||||||
+78
@@ -14,6 +14,9 @@ import org.springframework.stereotype.Service;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Order information
|
* Order information
|
||||||
@@ -49,4 +52,79 @@ public class RefundServiceImpl extends SuperServiceImpl<RefundMapper, Refund> im
|
|||||||
return baseMapper.selectOne(new QueryWrapper<Refund>().eq("refund_no",refundNo));
|
return baseMapper.selectOne(new QueryWrapper<Refund>().eq("refund_no",refundNo));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将分转换为元
|
||||||
|
* @param centAmount 分数
|
||||||
|
* @return 元数
|
||||||
|
*/
|
||||||
|
private Double convertCentToYuan(String centAmount) {
|
||||||
|
if (centAmount == null || centAmount.isEmpty()) {
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
long cent = Long.parseLong(centAmount);
|
||||||
|
return cent / 100.0;
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
log.warn("金额转换失败,原始值: {}", centAmount, e);
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> getRefundDetailByOrderNo(String orderNo) {
|
||||||
|
log.info("根据订单编码获取退款详情,orderNo: {}", orderNo);
|
||||||
|
|
||||||
|
Refund refund = baseMapper.selectByOrderNo(orderNo);
|
||||||
|
|
||||||
|
Map<String, Object> result = new HashMap<>();
|
||||||
|
|
||||||
|
if (refund == null) {
|
||||||
|
log.warn("未找到订单编码为 {} 的退款记录", orderNo);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 构建返回数据
|
||||||
|
result.put("id", refund.getId());
|
||||||
|
result.put("refundNo", refund.getRefundNo());
|
||||||
|
result.put("orderNo", refund.getOrderNo());
|
||||||
|
// 金额单位转换:从分转换为元(除以100)
|
||||||
|
result.put("orderAmount", refund.getOrderAmount());
|
||||||
|
result.put("refundAmount", refund.getRefundAmount());
|
||||||
|
result.put("status", refund.getStatus());
|
||||||
|
result.put("reason", refund.getRefundReason());
|
||||||
|
result.put("refundReason", refund.getRefundReason());
|
||||||
|
result.put("createTime", refund.getCreateTime());
|
||||||
|
result.put("applyTime", refund.getCreateTime());
|
||||||
|
|
||||||
|
// 处理图片列表 - refundImgs 可能是逗号分隔的字符串或JSON
|
||||||
|
List<String> images = new ArrayList<>();
|
||||||
|
if (refund.getRefundImgs() != null && !refund.getRefundImgs().isEmpty()) {
|
||||||
|
String imgsStr = refund.getRefundImgs();
|
||||||
|
// 如果是逗号分隔,则分割
|
||||||
|
if (imgsStr.contains(",")) {
|
||||||
|
images = Arrays.asList(imgsStr.split(","));
|
||||||
|
} else if (imgsStr.startsWith("[")) {
|
||||||
|
// 如果是JSON数组格式,需要解析
|
||||||
|
try {
|
||||||
|
// 简单处理:去掉方括号和引号
|
||||||
|
imgsStr = imgsStr.replaceAll("[\\[\\]\"]", "");
|
||||||
|
String[] imgArray = imgsStr.split(",");
|
||||||
|
for (String img : imgArray) {
|
||||||
|
if (!img.trim().isEmpty()) {
|
||||||
|
images.add(img.trim());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.warn("解析退款图片失败,原始值: {}", imgsStr, e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
images.add(imgsStr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
result.put("images", images);
|
||||||
|
|
||||||
|
log.info("退款详情查询成功,orderNo: {}, refundNo: {}", orderNo, refund.getRefundNo());
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,14 @@
|
|||||||
<where>
|
<where>
|
||||||
<!-- 业务筛选条件 -->
|
<!-- 业务筛选条件 -->
|
||||||
<if test="p.orderNo != null and p.orderNo != ''">
|
<if test="p.orderNo != null and p.orderNo != ''">
|
||||||
AND o.order_no LIKE CONCAT('%', #{p.orderNo}, '%')
|
AND o.order_no = #{p.orderNo}
|
||||||
</if>
|
</if>
|
||||||
<if test="p.orderStatus != null">
|
<if test="p.orderStatus != null">
|
||||||
AND o.order_status = #{p.orderStatus}
|
AND o.order_status = #{p.orderStatus}
|
||||||
</if>
|
</if>
|
||||||
|
<if test="p.payType != null">
|
||||||
|
AND o.pay_type = #{p.payType}
|
||||||
|
</if>
|
||||||
<if test="p.tourismId != null">
|
<if test="p.tourismId != null">
|
||||||
AND o.tourism_id = #{p.tourismId}
|
AND o.tourism_id = #{p.tourismId}
|
||||||
</if>
|
</if>
|
||||||
|
|||||||
@@ -7,6 +7,11 @@
|
|||||||
select * from orders_refund t ORDER BY id DESC
|
select * from orders_refund t ORDER BY id DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<!-- 根据订单编码查询退款详情 -->
|
||||||
|
<select id="selectByOrderNo" resultType="com.central.order.model.Refund">
|
||||||
|
SELECT * FROM orders_refund
|
||||||
|
WHERE order_no = #{orderNo} AND is_del = 0
|
||||||
|
ORDER BY id DESC LIMIT 1
|
||||||
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
// UTF-8: 创建退款订单弹框组件
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import { Modal, Form, message, Spin } from 'antd';
|
||||||
|
import { ordersApi } from '@/services/orders';
|
||||||
|
|
||||||
|
interface CreateRefundModalProps {
|
||||||
|
visible: boolean;
|
||||||
|
orderNo: string;
|
||||||
|
onCancel: () => void;
|
||||||
|
onSuccess?: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
const CreateRefundModal: React.FC<CreateRefundModalProps> = ({
|
||||||
|
visible,
|
||||||
|
orderNo,
|
||||||
|
onCancel,
|
||||||
|
onSuccess,
|
||||||
|
}) => {
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
|
// 调用 RefundController 的 createRefundOrder 接口
|
||||||
|
await ordersApi.createRefundOrder(orderNo, {});
|
||||||
|
|
||||||
|
message.success('退款订单已创建');
|
||||||
|
onSuccess?.();
|
||||||
|
onCancel();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('创建退款订单失败:', error);
|
||||||
|
message.error('创建退款订单失败');
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
title="创建退款订单"
|
||||||
|
open={visible}
|
||||||
|
onCancel={onCancel}
|
||||||
|
onOk={handleSubmit}
|
||||||
|
okText="确定"
|
||||||
|
cancelText="取消"
|
||||||
|
confirmLoading={loading}
|
||||||
|
>
|
||||||
|
<Spin spinning={loading}>
|
||||||
|
<div style={{ padding: '20px 0' }}>
|
||||||
|
<p>确定要为订单 <strong>{orderNo}</strong> 创建退款订单吗?</p>
|
||||||
|
<p style={{ color: '#999', fontSize: 12 }}>创建退款后,订单状态将变为"退款中"</p>
|
||||||
|
</div>
|
||||||
|
</Spin>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CreateRefundModal;
|
||||||
@@ -0,0 +1,513 @@
|
|||||||
|
import React, { useState, useCallback } from 'react';
|
||||||
|
import { Modal, Spin, Empty, Image, Badge, Tabs, Space, Button, Tooltip } from 'antd';
|
||||||
|
import { DownloadOutlined, PictureOutlined, PlayCircleOutlined } from '@ant-design/icons';
|
||||||
|
import { ordersApi } from '@/services/orders';
|
||||||
|
import type { OrderItem } from '@/services/orders';
|
||||||
|
import {dateFormatterMap} from "@ant-design/pro-components";
|
||||||
|
|
||||||
|
interface OrderFile {
|
||||||
|
id?: number | string;
|
||||||
|
orderNo?: string;
|
||||||
|
fileId?: string;
|
||||||
|
viewUrl?: string;
|
||||||
|
zipViewUrl?: string;
|
||||||
|
fileType?: string;
|
||||||
|
filePath?: string;
|
||||||
|
fileTag?: string;
|
||||||
|
createTime?: string;
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface OrderResourcesModalProps {
|
||||||
|
visible: boolean;
|
||||||
|
record?: OrderItem;
|
||||||
|
onCancel: () => void;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 判断文件类型(通过 MIME type 或文件扩展名)
|
||||||
|
const isImageFile = (file: OrderFile): boolean => {
|
||||||
|
const fileType = file.fileType?.toLowerCase() || '';
|
||||||
|
const filePath = file.filePath?.toLowerCase() || '';
|
||||||
|
const viewUrl = file.viewUrl?.toLowerCase() || '';
|
||||||
|
|
||||||
|
const imageTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/webp', 'image/bmp', 'image/svg'];
|
||||||
|
const imageExts = /\.(jpg|jpeg|png|gif|webp|bmp|svg)$/i;
|
||||||
|
|
||||||
|
return (
|
||||||
|
imageTypes.some(type => fileType.includes(type)) ||
|
||||||
|
imageExts.test(filePath) ||
|
||||||
|
imageExts.test(viewUrl)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const isVideoFile = (file: OrderFile): boolean => {
|
||||||
|
const fileType = file.fileType?.toLowerCase() || '';
|
||||||
|
const filePath = file.filePath?.toLowerCase() || '';
|
||||||
|
const viewUrl = file.viewUrl?.toLowerCase() || '';
|
||||||
|
|
||||||
|
const videoTypes = ['video/mp4', 'video/webm', 'video/ogg', 'video/quicktime', 'video/x-msvideo'];
|
||||||
|
const videoExts = /\.(mp4|webm|ogg|mov|avi|mkv|flv)$/i;
|
||||||
|
|
||||||
|
return (
|
||||||
|
videoTypes.some(type => fileType.includes(type)) ||
|
||||||
|
videoExts.test(filePath) ||
|
||||||
|
videoExts.test(viewUrl)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const OrderResourcesModal: React.FC<OrderResourcesModalProps> = ({ visible, record, onCancel }) => {
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [resources, setResources] = useState<OrderFile[]>([]);
|
||||||
|
const [hasLoadedOnce, setHasLoadedOnce] = useState(false);
|
||||||
|
const [error, setError] = useState<string | null>(null);
|
||||||
|
const [batchDownloading, setBatchDownloading] = useState(false);
|
||||||
|
|
||||||
|
// 当弹窗打开时加载资源列表
|
||||||
|
const loadResources = useCallback(async () => {
|
||||||
|
const orderNo = record?.orderNo;
|
||||||
|
|
||||||
|
if (!orderNo) {
|
||||||
|
console.warn('⚠️ orderNo is missing:', record);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasLoadedOnce) {
|
||||||
|
console.log('⏭️ Resources already loaded, skipping...');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(`📥 Loading resources for order: ${orderNo}`);
|
||||||
|
setLoading(true);
|
||||||
|
setError(null);
|
||||||
|
|
||||||
|
try {
|
||||||
|
const data = await ordersApi.getOrderResources(orderNo);
|
||||||
|
console.log(`📊 Got ${data?.length || 0} resources:`, data);
|
||||||
|
setResources(Array.isArray(data) ? data : []);
|
||||||
|
setHasLoadedOnce(true);
|
||||||
|
} catch (error: any) {
|
||||||
|
const errorMsg = error?.message || JSON.stringify(error);
|
||||||
|
console.error(`❌ Failed to load resources:`, errorMsg);
|
||||||
|
setError(errorMsg);
|
||||||
|
setResources([]);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}, [record?.orderNo, hasLoadedOnce]);
|
||||||
|
|
||||||
|
// 分离图片和视频
|
||||||
|
const images = resources.filter(isImageFile);
|
||||||
|
const videos = resources.filter(isVideoFile);
|
||||||
|
|
||||||
|
// 处理下载 - 通过后端代理解决跨域问题
|
||||||
|
const handleDownload = async (url: string, fileName?: string) => {
|
||||||
|
if (!url) return;
|
||||||
|
|
||||||
|
const finalFileName = fileName || `file_${Date.now()}`;
|
||||||
|
console.log(`⬇️ Starting download: ${url} as ${finalFileName}`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 方式1: 通过后端代理下载(推荐 - 解决跨域问题)
|
||||||
|
console.log('📌 Downloading via backend proxy...');
|
||||||
|
const blob = await ordersApi.downloadFile(url);
|
||||||
|
|
||||||
|
const blobUrl = window.URL.createObjectURL(blob as Blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = blobUrl;
|
||||||
|
a.download = finalFileName;
|
||||||
|
a.style.display = 'none';
|
||||||
|
document.body.appendChild(a);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
a.click();
|
||||||
|
console.log(`✅ Download started via backend proxy: ${finalFileName}`);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
document.body.removeChild(a);
|
||||||
|
window.URL.revokeObjectURL(blobUrl);
|
||||||
|
}, 100);
|
||||||
|
}, 0);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`❌ Backend proxy download failed:`, error);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 方式2: 尝试 XMLHttpRequest(本地可用但跨域受限)
|
||||||
|
console.log('📌 Trying XHR method...');
|
||||||
|
return await new Promise((resolve, reject) => {
|
||||||
|
const xhr = new XMLHttpRequest();
|
||||||
|
xhr.open('GET', url, true);
|
||||||
|
xhr.responseType = 'blob';
|
||||||
|
|
||||||
|
xhr.onload = () => {
|
||||||
|
if (xhr.status === 200) {
|
||||||
|
const blob = xhr.response;
|
||||||
|
const blobUrl = window.URL.createObjectURL(blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = blobUrl;
|
||||||
|
a.download = finalFileName;
|
||||||
|
a.style.display = 'none';
|
||||||
|
document.body.appendChild(a);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
a.click();
|
||||||
|
console.log(`✅ Download started via XHR: ${finalFileName}`);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
document.body.removeChild(a);
|
||||||
|
window.URL.revokeObjectURL(blobUrl);
|
||||||
|
resolve(true);
|
||||||
|
}, 100);
|
||||||
|
}, 0);
|
||||||
|
} else {
|
||||||
|
reject(new Error(`HTTP ${xhr.status}`));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
xhr.onerror = () => {
|
||||||
|
console.error('XHR download failed:', xhr.status);
|
||||||
|
reject(new Error('XHR request failed'));
|
||||||
|
};
|
||||||
|
|
||||||
|
xhr.send();
|
||||||
|
});
|
||||||
|
} catch (xhrError) {
|
||||||
|
console.error(`❌ XHR方式失败:`, xhrError);
|
||||||
|
|
||||||
|
// 方式3: 降级到直接链接 + 新窗口
|
||||||
|
console.log('📌 Falling back to direct link in new window...');
|
||||||
|
if (url.includes('?')) {
|
||||||
|
window.open(`${url}&download=1`, '_blank');
|
||||||
|
} else {
|
||||||
|
window.open(`${url}?download=1`, '_blank');
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 批量下载所有文件 - 并发调用单个文件下载接口
|
||||||
|
const handleBatchDownload = async () => {
|
||||||
|
if (!record?.orderNo) {
|
||||||
|
console.warn('⚠️ orderNo is missing');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const orderNo = record.orderNo;
|
||||||
|
console.log(`⬇️ Starting batch download for order: ${orderNo}`);
|
||||||
|
console.log(`📊 Total files to download: ${resources.length}`);
|
||||||
|
setBatchDownloading(true);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 并发下载所有文件 - 让浏览器自动管理并发
|
||||||
|
const downloadPromises = resources.map(async (file, index) => {
|
||||||
|
if (!file.viewUrl) {
|
||||||
|
console.warn(`⚠️ Skipping file without URL: ${file.filePath}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const fileName = file.filePath ? file.filePath.split('/').pop() : `file_${index + 1}`;
|
||||||
|
console.log(`📥 Queuing download (${index + 1}/${resources.length}): ${fileName}`);
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 调用单个文件下载接口获取 blob
|
||||||
|
const blob = await ordersApi.downloadFile(file.viewUrl);
|
||||||
|
|
||||||
|
// 创建下载链接并触发浏览器下载
|
||||||
|
const blobUrl = window.URL.createObjectURL(blob as Blob);
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.href = blobUrl;
|
||||||
|
if (fileName != null) {
|
||||||
|
a.download = fileName;
|
||||||
|
}else {
|
||||||
|
a.download = '文件下载';
|
||||||
|
}
|
||||||
|
a.style.display = 'none';
|
||||||
|
document.body.appendChild(a);
|
||||||
|
// 添加延迟以错开下载请求,避免浏览器并发限制
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, index * 150));
|
||||||
|
a.click();
|
||||||
|
console.log(`✅ Download triggered: ${fileName}`);
|
||||||
|
|
||||||
|
// 清理资源
|
||||||
|
setTimeout(() => {
|
||||||
|
document.body.removeChild(a);
|
||||||
|
window.URL.revokeObjectURL(blobUrl);
|
||||||
|
}, 500);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`❌ Failed to download: ${fileName}`, error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// 等待所有下载请求完成(不等待浏览器下载完成)
|
||||||
|
const results = await Promise.all(downloadPromises);
|
||||||
|
const successCount = results.filter((r) => r).length;
|
||||||
|
const failureCount = results.filter((r) => !r).length;
|
||||||
|
|
||||||
|
const message = `✅ 批量下载已启动!\n\n成功启动: ${successCount}/${resources.length}\n失败: ${failureCount}\n\n📥 文件已经全部下载完成\n📋 请检查浏览器下载列表`;
|
||||||
|
console.log(`🎉 ${message}`);
|
||||||
|
alert(message);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`❌ Batch download failed:`, error);
|
||||||
|
alert('批量下载失败,请重试');
|
||||||
|
} finally {
|
||||||
|
setBatchDownloading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取文件显示名称
|
||||||
|
const getFileName = (file: OrderFile, index: number) => {
|
||||||
|
if (file.filePath) {
|
||||||
|
return file.filePath.split('/').pop() || `文件${index + 1}`;
|
||||||
|
}
|
||||||
|
return `文件${index + 1}`;
|
||||||
|
};
|
||||||
|
|
||||||
|
// 图片预览卡片
|
||||||
|
const ImageGallery = () => (
|
||||||
|
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(auto-fill, minmax(150px, 1fr))', gap: '16px', padding: '16px 0' }}>
|
||||||
|
{images.length === 0 ? (
|
||||||
|
<Empty description="暂无图片资源" />
|
||||||
|
) : (
|
||||||
|
images.map((item, idx) => {
|
||||||
|
const fileName = getFileName(item, idx);
|
||||||
|
return (
|
||||||
|
<Tooltip key={item.id || idx} title={fileName}>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
position: 'relative',
|
||||||
|
overflow: 'hidden',
|
||||||
|
borderRadius: '4px',
|
||||||
|
border: '1px solid #f0f0f0',
|
||||||
|
backgroundColor: '#fafafa',
|
||||||
|
cursor: 'pointer',
|
||||||
|
transition: 'all 0.3s ease',
|
||||||
|
}}
|
||||||
|
onMouseEnter={(e) => {
|
||||||
|
e.currentTarget.style.boxShadow = '0 2px 8px rgba(0,0,0,0.15)';
|
||||||
|
}}
|
||||||
|
onMouseLeave={(e) => {
|
||||||
|
e.currentTarget.style.boxShadow = 'none';
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
src={item.viewUrl}
|
||||||
|
preview={{ mask: '预览' }}
|
||||||
|
style={{ width: '100%', height: '120px', objectFit: 'cover', display: 'block' }}
|
||||||
|
alt={fileName}
|
||||||
|
fallback="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMIAAADDCAYAAADQvc6ZAAABRklEQVR4Xu3QQQEAAADCoPVPbQhfoAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAB4NehrD5aKxbkB/QAAAAASUVORK5CYII="
|
||||||
|
/>
|
||||||
|
<div style={{
|
||||||
|
padding: '4px 8px',
|
||||||
|
fontSize: '11px',
|
||||||
|
color: '#666',
|
||||||
|
overflow: 'hidden',
|
||||||
|
textOverflow: 'ellipsis',
|
||||||
|
whiteSpace: 'nowrap',
|
||||||
|
minHeight: '16px'
|
||||||
|
}}>
|
||||||
|
{fileName}
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
icon={<DownloadOutlined />}
|
||||||
|
onClick={async (e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
if (item.viewUrl) {
|
||||||
|
await handleDownload(item.viewUrl, fileName);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: '4px',
|
||||||
|
right: '4px',
|
||||||
|
opacity: 0.8
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
})
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
// 视频列表卡片
|
||||||
|
const VideoGallery = () => (
|
||||||
|
<div style={{ padding: '16px 0' }}>
|
||||||
|
{videos.length === 0 ? (
|
||||||
|
<Empty description="暂无视频资源" />
|
||||||
|
) : (
|
||||||
|
<div style={{ display: 'grid', gap: '16px' }}>
|
||||||
|
{videos.map((item, idx) => {
|
||||||
|
const fileName = getFileName(item, idx);
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={item.id || idx}
|
||||||
|
style={{
|
||||||
|
border: '1px solid #f0f0f0',
|
||||||
|
borderRadius: '4px',
|
||||||
|
overflow: 'hidden',
|
||||||
|
backgroundColor: '#fafafa',
|
||||||
|
padding: '12px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{/* 视频信息头 */}
|
||||||
|
<div style={{
|
||||||
|
marginBottom: '12px',
|
||||||
|
display: 'flex',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'center',
|
||||||
|
}}>
|
||||||
|
<div style={{ display: 'flex', alignItems: 'center', gap: '8px' }}>
|
||||||
|
<PlayCircleOutlined style={{ fontSize: '18px', color: '#1890ff' }} />
|
||||||
|
<span style={{ fontWeight: 500, maxWidth: '400px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>
|
||||||
|
{fileName}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
size="small"
|
||||||
|
icon={<DownloadOutlined />}
|
||||||
|
onClick={async () => {
|
||||||
|
if (item.viewUrl) {
|
||||||
|
await handleDownload(item.viewUrl, fileName);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
下载
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 视频播放器 */}
|
||||||
|
<div style={{
|
||||||
|
marginBottom: '12px',
|
||||||
|
borderRadius: '4px',
|
||||||
|
overflow: 'hidden',
|
||||||
|
backgroundColor: '#000',
|
||||||
|
}}>
|
||||||
|
<video
|
||||||
|
controls
|
||||||
|
style={{
|
||||||
|
width: '100%',
|
||||||
|
maxHeight: '500px',
|
||||||
|
display: 'block',
|
||||||
|
}}
|
||||||
|
controlsList="nodownload"
|
||||||
|
>
|
||||||
|
<source src={item.viewUrl} type="video/mp4" />
|
||||||
|
您的浏览器不支持 HTML5 视频播放
|
||||||
|
</video>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 视频元数据 */}
|
||||||
|
<div style={{ fontSize: '12px', color: '#999', display: 'grid', gap: '4px' }}>
|
||||||
|
{item.createTime && (
|
||||||
|
<div>
|
||||||
|
上传时间: {new Date(item.createTime).toLocaleString()}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{item.fileType && (
|
||||||
|
<div>
|
||||||
|
文件类型: {item.fileType}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{item.fileTag && (
|
||||||
|
<div>
|
||||||
|
文件标签: {item.fileTag}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
// 使用 effect 在 visible 变化时加载资源
|
||||||
|
React.useEffect(() => {
|
||||||
|
if (visible) {
|
||||||
|
console.log('🔓 Modal opened, loading resources...');
|
||||||
|
loadResources();
|
||||||
|
}
|
||||||
|
}, [visible, loadResources]);
|
||||||
|
|
||||||
|
// 生成模态框标题
|
||||||
|
const modalTitle = `订单资源列表 - ${record?.orderNo || ''}`;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
title={modalTitle}
|
||||||
|
visible={visible}
|
||||||
|
onCancel={onCancel}
|
||||||
|
width={1000}
|
||||||
|
footer={[
|
||||||
|
<Button key="cancel" onClick={onCancel}>
|
||||||
|
关闭
|
||||||
|
</Button>,
|
||||||
|
<Button
|
||||||
|
key="batch-download"
|
||||||
|
type="primary"
|
||||||
|
icon={<DownloadOutlined />}
|
||||||
|
loading={batchDownloading}
|
||||||
|
disabled={resources.length === 0 || loading}
|
||||||
|
onClick={handleBatchDownload}
|
||||||
|
>
|
||||||
|
下载全部文件
|
||||||
|
</Button>,
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Spin spinning={loading}>
|
||||||
|
{error && (
|
||||||
|
<div style={{ padding: '16px', background: '#fff2e8', border: '1px solid #ffbb96', borderRadius: '4px', marginBottom: '16px', color: '#d4380d' }}>
|
||||||
|
<strong>加载失败:</strong> {error}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
{resources.length === 0 && !loading && !error ? (
|
||||||
|
<Empty description="该订单暂无资源" />
|
||||||
|
) : (
|
||||||
|
<Tabs
|
||||||
|
defaultActiveKey="images"
|
||||||
|
>
|
||||||
|
<Tabs.TabPane
|
||||||
|
tab={
|
||||||
|
<Badge
|
||||||
|
count={images.length}
|
||||||
|
style={{ backgroundColor: '#52c41a' }}
|
||||||
|
>
|
||||||
|
<span>图片 ({images.length})</span>
|
||||||
|
</Badge>
|
||||||
|
}
|
||||||
|
key="images"
|
||||||
|
>
|
||||||
|
<ImageGallery />
|
||||||
|
</Tabs.TabPane>
|
||||||
|
<Tabs.TabPane
|
||||||
|
tab={
|
||||||
|
<Badge
|
||||||
|
count={videos.length}
|
||||||
|
style={{ backgroundColor: '#1890ff' }}
|
||||||
|
>
|
||||||
|
<span>视频 ({videos.length})</span>
|
||||||
|
</Badge>
|
||||||
|
}
|
||||||
|
key="videos"
|
||||||
|
>
|
||||||
|
<VideoGallery />
|
||||||
|
</Tabs.TabPane>
|
||||||
|
</Tabs>
|
||||||
|
)}
|
||||||
|
</Spin>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default OrderResourcesModal;
|
||||||
@@ -0,0 +1,361 @@
|
|||||||
|
// UTF-8: 退款审核弹框组件
|
||||||
|
import React, { useState, useEffect } from 'react';
|
||||||
|
import { Modal, Form, Select, Input, message, Empty, Image, Space, Row, Col, Divider, InputNumber, Button } from 'antd';
|
||||||
|
import { ordersApi } from '@/services/orders';
|
||||||
|
|
||||||
|
interface RefundReviewModalProps {
|
||||||
|
visible: boolean;
|
||||||
|
orderNo: string;
|
||||||
|
onCancel: () => void;
|
||||||
|
onSuccess?: () => void;
|
||||||
|
isReviewMode: boolean; // true: 审核模式,false: 查看模式
|
||||||
|
}
|
||||||
|
|
||||||
|
const RefundReviewModal: React.FC<RefundReviewModalProps> = ({
|
||||||
|
visible,
|
||||||
|
orderNo,
|
||||||
|
onCancel,
|
||||||
|
onSuccess,
|
||||||
|
isReviewMode = true,
|
||||||
|
}) => {
|
||||||
|
const [form] = Form.useForm();
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [refundData, setRefundData] = useState<any>(null);
|
||||||
|
const [fetching, setFetching] = useState(false);
|
||||||
|
const [editingAmount, setEditingAmount] = useState(false);
|
||||||
|
const [customRefundAmount, setCustomRefundAmount] = useState<number | null>(null);
|
||||||
|
|
||||||
|
// 审核结果选项
|
||||||
|
const reviewResults = [
|
||||||
|
{ label: '审核通过', value: 1 },
|
||||||
|
{ label: '审核拒绝', value: 0 },
|
||||||
|
];
|
||||||
|
|
||||||
|
// 格式化金额(分转元)
|
||||||
|
const formatAmount = (amount: any): string => {
|
||||||
|
if (!amount && amount !== 0) return '0.00';
|
||||||
|
const num = parseFloat(amount);
|
||||||
|
// 统一处理:分转元(除以100)
|
||||||
|
return (num / 100).toFixed(2);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 格式化时间
|
||||||
|
const formatTime = (time: any): string => {
|
||||||
|
if (!time) return '-';
|
||||||
|
try {
|
||||||
|
const date = new Date(time);
|
||||||
|
const year = date.getFullYear();
|
||||||
|
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||||
|
const day = String(date.getDate()).padStart(2, '0');
|
||||||
|
const hours = String(date.getHours()).padStart(2, '0');
|
||||||
|
const minutes = String(date.getMinutes()).padStart(2, '0');
|
||||||
|
const seconds = String(date.getSeconds()).padStart(2, '0');
|
||||||
|
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
|
||||||
|
} catch (e) {
|
||||||
|
return String(time);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// 根据status获取退款状态的文案和颜色
|
||||||
|
const getRefundStatusInfo = (status: number) => {
|
||||||
|
const statusMap: Record<number, { text: string; bgColor: string; textColor: string }> = {
|
||||||
|
7: { text: '退款中', bgColor: '#fff7e6', textColor: '#d46b08' }, // orange
|
||||||
|
8: { text: '退款成功', bgColor: '#f6ffed', textColor: '#52c41a' }, // lime
|
||||||
|
9: { text: '退款失败', bgColor: '#fff1f0', textColor: '#f5222d' }, // red
|
||||||
|
};
|
||||||
|
return statusMap[status] || { text: '未知状态', bgColor: '#f5f5f5', textColor: '#666' };
|
||||||
|
};
|
||||||
|
|
||||||
|
// 获取退款订单详情
|
||||||
|
useEffect(() => {
|
||||||
|
if (visible && orderNo) {
|
||||||
|
fetchRefundDetail();
|
||||||
|
// 打开弹窗时清空编辑状态
|
||||||
|
setEditingAmount(false);
|
||||||
|
setCustomRefundAmount(null);
|
||||||
|
}
|
||||||
|
}, [visible, orderNo]);
|
||||||
|
|
||||||
|
const fetchRefundDetail = async () => {
|
||||||
|
setFetching(true);
|
||||||
|
try {
|
||||||
|
// 调用后端接口根据订单编码获取退款订单详情
|
||||||
|
const data: any = await ordersApi.getRefundDetail(orderNo);
|
||||||
|
|
||||||
|
if (data) {
|
||||||
|
setRefundData(data);
|
||||||
|
console.log('退款详情:', data);
|
||||||
|
} else {
|
||||||
|
message.warning('未找到该订单的退款记录');
|
||||||
|
setRefundData(null);
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
message.error('获取退款详情失败');
|
||||||
|
console.error('获取退款详情失败:', error);
|
||||||
|
} finally {
|
||||||
|
setFetching(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleSubmit = async () => {
|
||||||
|
if (!isReviewMode) {
|
||||||
|
onCancel();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
const values = await form.validateFields();
|
||||||
|
setLoading(true);
|
||||||
|
|
||||||
|
// 计算实际退款金额(分)
|
||||||
|
// 如果用户编辑了退款金额,就用编辑的,否则用原始退款金额
|
||||||
|
const actualRefundAmount = customRefundAmount !== null
|
||||||
|
? Math.round(customRefundAmount * 100) // 元转分
|
||||||
|
: refundData?.refundAmount;
|
||||||
|
|
||||||
|
// 调用自定义金额的退款审核接口
|
||||||
|
const res = await ordersApi.approveRefundWithCustomAmount({
|
||||||
|
orderNo: refundData?.orderNo,
|
||||||
|
refundNo: refundData?.refundNo,
|
||||||
|
refundAmount: String(actualRefundAmount), // 后端期望字符串格式
|
||||||
|
status: 7, // 退款中状态码
|
||||||
|
state: values.reviewResult, // 审核状态:1=通过(APPROVED),0=拒绝(REFUSED)
|
||||||
|
approveReason: values.reviewComment, // 审核意见
|
||||||
|
});
|
||||||
|
|
||||||
|
// 显示后端返回的实际消息
|
||||||
|
const successMsg = res?.resp_msg || res?.message || '审核已提交';
|
||||||
|
message.success(successMsg);
|
||||||
|
onSuccess?.();
|
||||||
|
onCancel();
|
||||||
|
} catch (error) {
|
||||||
|
console.error('提交审核失败:', error);
|
||||||
|
message.error('提交审核失败');
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Modal
|
||||||
|
title={isReviewMode ? '退款审核' : '退款查看'}
|
||||||
|
open={visible}
|
||||||
|
onCancel={onCancel}
|
||||||
|
onOk={handleSubmit}
|
||||||
|
okText={isReviewMode ? '确定' : '关闭'}
|
||||||
|
cancelText="取消"
|
||||||
|
confirmLoading={loading}
|
||||||
|
width={650}
|
||||||
|
style={{ maxHeight: '80vh', overflow: 'auto' }}
|
||||||
|
>
|
||||||
|
{fetching ? (
|
||||||
|
<div style={{ textAlign: 'center', padding: '40px 0' }}>
|
||||||
|
加载中...
|
||||||
|
</div>
|
||||||
|
) : refundData ? (
|
||||||
|
<>
|
||||||
|
{/* 基本信息行 */}
|
||||||
|
<Row gutter={[16, 16]}>
|
||||||
|
<Col span={12}>
|
||||||
|
<div>
|
||||||
|
<span style={{ fontWeight: 'bold' }}>退款单号</span>
|
||||||
|
<div style={{ marginTop: 4, wordBreak: 'break-all' }}>{refundData?.refundNo || orderNo}</div>
|
||||||
|
</div>
|
||||||
|
</Col>
|
||||||
|
<Col span={12}>
|
||||||
|
<div>
|
||||||
|
<span style={{ fontWeight: 'bold' }}>订单编号</span>
|
||||||
|
<div style={{ marginTop: 4, wordBreak: 'break-all' }}>{refundData?.orderNo || orderNo}</div>
|
||||||
|
</div>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
{/* 金额信息 */}
|
||||||
|
<Row gutter={[16, 16]}>
|
||||||
|
<Col span={12}>
|
||||||
|
<div>
|
||||||
|
<span style={{ fontWeight: 'bold' }}>订单金额</span>
|
||||||
|
<div style={{ marginTop: 4 }}>¥ {formatAmount(refundData?.orderAmount)}</div>
|
||||||
|
</div>
|
||||||
|
</Col>
|
||||||
|
<Col span={12}>
|
||||||
|
<div>
|
||||||
|
<span style={{ fontWeight: 'bold' }}>退款金额</span>
|
||||||
|
{editingAmount ? (
|
||||||
|
<div style={{ marginTop: 4, display: 'flex', gap: 8, alignItems: 'center' }}>
|
||||||
|
<InputNumber
|
||||||
|
style={{ flex: 1 }}
|
||||||
|
value={customRefundAmount}
|
||||||
|
onChange={setCustomRefundAmount}
|
||||||
|
min={0.01}
|
||||||
|
max={parseFloat(formatAmount(refundData?.orderAmount))}
|
||||||
|
step={0.01}
|
||||||
|
precision={2}
|
||||||
|
prefix="¥"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
onClick={() => {
|
||||||
|
if (customRefundAmount === null || customRefundAmount <= 0) {
|
||||||
|
message.error('请输入大于0的退款金额');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 校验通过,关闭编辑模式
|
||||||
|
setEditingAmount(false);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
确定
|
||||||
|
</Button>
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
onClick={() => {
|
||||||
|
// 取消编辑,恢复原值
|
||||||
|
setEditingAmount(false);
|
||||||
|
setCustomRefundAmount(null);
|
||||||
|
message.info('已取消编辑');
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
取消
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
<div style={{ marginTop: 4, display: 'flex', gap: 8, alignItems: 'center' }}>
|
||||||
|
<span>¥ {customRefundAmount !== null ? customRefundAmount.toFixed(2) : formatAmount(refundData?.refundAmount)}</span>
|
||||||
|
{isReviewMode && (
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
onClick={() => {
|
||||||
|
// 编辑时,如果还没有自定义金额,则使用接口返回的原始金额
|
||||||
|
if (customRefundAmount === null) {
|
||||||
|
setCustomRefundAmount(parseFloat(formatAmount(refundData?.refundAmount)));
|
||||||
|
}
|
||||||
|
setEditingAmount(true);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
{/* 状态信息 */}
|
||||||
|
<Row gutter={[16, 16]}>
|
||||||
|
<Col span={12}>
|
||||||
|
<div>
|
||||||
|
<span style={{ fontWeight: 'bold' }}>退款状态</span>
|
||||||
|
<div style={{ marginTop: 4 }}>
|
||||||
|
{(() => {
|
||||||
|
const statusInfo = getRefundStatusInfo(refundData?.status);
|
||||||
|
return (
|
||||||
|
<span style={{
|
||||||
|
padding: '2px 8px',
|
||||||
|
backgroundColor: statusInfo.bgColor,
|
||||||
|
color: statusInfo.textColor,
|
||||||
|
borderRadius: 2
|
||||||
|
}}>
|
||||||
|
{statusInfo.text}
|
||||||
|
</span>
|
||||||
|
);
|
||||||
|
})()}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Col>
|
||||||
|
<Col span={12}>
|
||||||
|
<div>
|
||||||
|
<span style={{ fontWeight: 'bold' }}>订单状态</span>
|
||||||
|
<div style={{ marginTop: 4 }}>
|
||||||
|
<span style={{ padding: '2px 8px', backgroundColor: '#f6f8fb', color: '#000', borderRadius: 2 }}>
|
||||||
|
{refundData?.orderStatus || '-'}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
{/* 退款原因 */}
|
||||||
|
<div style={{ marginBottom: 16 }}>
|
||||||
|
<span style={{ fontWeight: 'bold' }}>退款原因</span>
|
||||||
|
<div style={{ marginTop: 4, padding: '8px', backgroundColor: '#fafafa', borderRadius: 2, minHeight: 40 }}>
|
||||||
|
{refundData?.reason || refundData?.refundReason || '-'}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* 退款凭证(图片) */}
|
||||||
|
{refundData?.images && refundData?.images.length > 0 && (
|
||||||
|
<>
|
||||||
|
<div style={{ marginBottom: 16 }}>
|
||||||
|
<span style={{ fontWeight: 'bold' }}>退款凭证</span>
|
||||||
|
<div style={{ marginTop: 8, display: 'flex', flexWrap: 'wrap', gap: 8 }}>
|
||||||
|
{Array.isArray(refundData?.images) ? (
|
||||||
|
refundData?.images.map((img: string | any, index: number) => {
|
||||||
|
const imgUrl = typeof img === 'string' ? img : img?.url || img?.path;
|
||||||
|
return imgUrl ? (
|
||||||
|
<div key={index} style={{ position: 'relative' }}>
|
||||||
|
<Image
|
||||||
|
src={imgUrl}
|
||||||
|
width={100}
|
||||||
|
height={100}
|
||||||
|
style={{ objectFit: 'cover', borderRadius: 4 }}
|
||||||
|
preview
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
) : null;
|
||||||
|
})
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{/* 申请时间 */}
|
||||||
|
<div style={{ marginBottom: 16 }}>
|
||||||
|
<span style={{ fontWeight: 'bold' }}>申请时间</span>
|
||||||
|
<div style={{ marginTop: 4 }}>{formatTime(refundData?.createTime || refundData?.applyTime)}</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<Divider />
|
||||||
|
|
||||||
|
{/* 审核表单(仅审核模式显示) */}
|
||||||
|
{isReviewMode && (
|
||||||
|
<Form form={form} layout="vertical">
|
||||||
|
<Form.Item
|
||||||
|
name="reviewResult"
|
||||||
|
label="审核结果"
|
||||||
|
rules={[{ required: true, message: '请选择审核结果' }]}
|
||||||
|
>
|
||||||
|
<Select placeholder="请选择" options={reviewResults} />
|
||||||
|
</Form.Item>
|
||||||
|
|
||||||
|
<Form.Item
|
||||||
|
name="reviewComment"
|
||||||
|
label="审核意见"
|
||||||
|
rules={[{ required: true, message: '请输入审核意见' }]}
|
||||||
|
>
|
||||||
|
<Input.TextArea
|
||||||
|
placeholder="请输入审核意见"
|
||||||
|
rows={3}
|
||||||
|
maxLength={500}
|
||||||
|
showCount
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
</Form>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<Empty description="无数据" />
|
||||||
|
)}
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default RefundReviewModal;
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
// UTF-8: 状态修改组件
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import { Modal, Select, message } from 'antd';
|
||||||
|
import { ORDER_STATUS_OPTIONS } from './constants';
|
||||||
|
import { ordersApi } from '@/services/orders';
|
||||||
|
|
||||||
|
interface Props {
|
||||||
|
record: any;
|
||||||
|
onUpdated?: () => void;
|
||||||
|
canModifyStatus?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const StatusUpdater: React.FC<Props> = ({ record, onUpdated, canModifyStatus = false }) => {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [value, setValue] = useState<number | undefined>(record?.orderStatus);
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
|
||||||
|
// 如果不是 webApp 租户,不显示修改状态按钮
|
||||||
|
if (!canModifyStatus) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const onOk = async () => {
|
||||||
|
if (typeof value === 'undefined') { message.warning('请选择订单状态'); return; }
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
await ordersApi.updateOrder({ id: record.id, orderStatus: value });
|
||||||
|
message.success('状态已更新');
|
||||||
|
setOpen(false);
|
||||||
|
onUpdated?.();
|
||||||
|
} catch (e) {
|
||||||
|
message.error('更新失败');
|
||||||
|
} finally { setLoading(false); }
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<a onClick={() => setOpen(true)}>修改状态</a>
|
||||||
|
<Modal
|
||||||
|
title={`修改订单状态 - ${record?.orderNo || record?.id}`}
|
||||||
|
open={open}
|
||||||
|
onOk={onOk}
|
||||||
|
okText="确定"
|
||||||
|
cancelText="取消"
|
||||||
|
confirmLoading={loading}
|
||||||
|
onCancel={() => setOpen(false)}
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<span style={{ marginRight: 8 }}>请选择状态:</span>
|
||||||
|
<Select
|
||||||
|
value={value}
|
||||||
|
onChange={setValue}
|
||||||
|
options={ORDER_STATUS_OPTIONS.map(o => ({ label: o.label, value: o.value }))}
|
||||||
|
style={{ minWidth: 200 }}
|
||||||
|
placeholder="请选择订单状态"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</Modal>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default StatusUpdater;
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
// UTF-8: 标签渲染组件
|
||||||
|
import React from 'react';
|
||||||
|
import { Tag } from 'antd';
|
||||||
|
import { ORDER_STATUS_OPTIONS, PAY_TYPE_OPTIONS, findColor, findLabel } from './constants';
|
||||||
|
|
||||||
|
export const PayTypeTag: React.FC<{ value?: number }> = ({ value }) => (
|
||||||
|
<Tag color={findColor(PAY_TYPE_OPTIONS, value)}>{findLabel(PAY_TYPE_OPTIONS, value)}</Tag>
|
||||||
|
);
|
||||||
|
|
||||||
|
export const OrderStatusTag: React.FC<{ value?: number }> = ({ value }) => (
|
||||||
|
<Tag color={findColor(ORDER_STATUS_OPTIONS, value)}>{findLabel(ORDER_STATUS_OPTIONS, value)}</Tag>
|
||||||
|
);
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
// UTF-8: 订单列表列定义(按截图样式)
|
||||||
|
import React, { useState } from 'react';
|
||||||
|
import type { ProColumns } from '@ant-design/pro-components';
|
||||||
|
import { Space, Typography } from 'antd';
|
||||||
|
import { PayTypeTag, OrderStatusTag } from './Tags';
|
||||||
|
import StatusUpdater from './StatusUpdater';
|
||||||
|
import OrderResourcesModal from './OrderResourcesModal';
|
||||||
|
import RefundReviewModal from './RefundReviewModal';
|
||||||
|
import CreateRefundModal from './CreateRefundModal';
|
||||||
|
import type { OrderItem } from '@/services/orders';
|
||||||
|
|
||||||
|
const { Link } = Typography;
|
||||||
|
|
||||||
|
// 订单状态常量
|
||||||
|
const ORDER_STATUS = {
|
||||||
|
COMPLETE: 3, // 任务完成
|
||||||
|
REFUNDING: 7, // 退款中
|
||||||
|
REFUND_SUCCESS: 8, // 退款成功
|
||||||
|
REFUND_FAILED: 9, // 退款失败
|
||||||
|
};
|
||||||
|
|
||||||
|
// 资源列表操作组件
|
||||||
|
const ResourcesActionCell: React.FC<{ record: OrderItem; onReload?: () => void; canModifyStatus?: boolean }> = ({ record, onReload, canModifyStatus }) => {
|
||||||
|
const [resourceModalVisible, setResourceModalVisible] = useState(false);
|
||||||
|
const [refundModalVisible, setRefundModalVisible] = useState(false);
|
||||||
|
const [createRefundModalVisible, setCreateRefundModalVisible] = useState(false);
|
||||||
|
|
||||||
|
// 判断是否显示创建退款按钮(订单状态为任务完成)
|
||||||
|
const isTaskComplete = record.orderStatus === ORDER_STATUS.COMPLETE;
|
||||||
|
// 判断是否显示退款审核按钮(订单状态为退款中)
|
||||||
|
const isRefunding = record.orderStatus === ORDER_STATUS.REFUNDING;
|
||||||
|
// 判断是否显示退款查看按钮(订单状态为退款成功或退款失败)
|
||||||
|
const isRefundResolved = record.orderStatus === ORDER_STATUS.REFUND_SUCCESS || record.orderStatus === ORDER_STATUS.REFUND_FAILED;
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Space size="small" wrap style={{ minWidth: 120 }}>
|
||||||
|
<Link onClick={() => setResourceModalVisible(true)}>资源列表</Link>
|
||||||
|
<StatusUpdater record={record} onUpdated={onReload} canModifyStatus={canModifyStatus} />
|
||||||
|
{isTaskComplete && (
|
||||||
|
<Link onClick={() => setCreateRefundModalVisible(true)}>创建退款</Link>
|
||||||
|
)}
|
||||||
|
{isRefunding && (
|
||||||
|
<Link onClick={() => setRefundModalVisible(true)}>退款审核</Link>
|
||||||
|
)}
|
||||||
|
{isRefundResolved && (
|
||||||
|
<Link onClick={() => setRefundModalVisible(true)}>退款查看</Link>
|
||||||
|
)}
|
||||||
|
</Space>
|
||||||
|
<OrderResourcesModal
|
||||||
|
visible={resourceModalVisible}
|
||||||
|
record={record}
|
||||||
|
onCancel={() => setResourceModalVisible(false)}
|
||||||
|
/>
|
||||||
|
<RefundReviewModal
|
||||||
|
visible={refundModalVisible}
|
||||||
|
orderNo={record.orderNo || ''}
|
||||||
|
onCancel={() => setRefundModalVisible(false)}
|
||||||
|
onSuccess={onReload}
|
||||||
|
isReviewMode={isRefunding}
|
||||||
|
/>
|
||||||
|
<CreateRefundModal
|
||||||
|
visible={createRefundModalVisible}
|
||||||
|
orderNo={record.orderNo || ''}
|
||||||
|
onCancel={() => setCreateRefundModalVisible(false)}
|
||||||
|
onSuccess={onReload}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// 格式化金额(分转元)
|
||||||
|
const formatAmount = (amount: any): string => {
|
||||||
|
if (!amount && amount !== 0) return '0.00';
|
||||||
|
const num = parseFloat(amount);
|
||||||
|
// 统一处理:分转元(除以100)
|
||||||
|
return (num / 100).toFixed(2);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const buildOrderColumns = (onReload?: () => void, canModifyStatus?: boolean): ProColumns<OrderItem>[] => [
|
||||||
|
{ dataIndex: 'index', valueType: 'indexBorder', width: 56 },
|
||||||
|
{ title: '订单ID', dataIndex: 'id', width: 100, copyable: true },
|
||||||
|
{ title: '景区名称', dataIndex: 'tourismName', width: 180, render: (v) => (<span>{v || '-'}</span>) },
|
||||||
|
{ title: '订单编号', dataIndex: 'orderNo', width: 180, copyable: true, ellipsis: true },
|
||||||
|
{ title: '订单金额', dataIndex: 'orderAmount', width: 120, render: (v) => <span>¥ {formatAmount(v)}</span> },
|
||||||
|
{ title: '状态', dataIndex: 'orderStatus', width: 100, render: (v) => <OrderStatusTag value={v as number} /> },
|
||||||
|
{ title: '支付类型', dataIndex: 'payType', width: 100, render: (v) => <PayTypeTag value={v as number} /> },
|
||||||
|
{ title: '用户手机号', dataIndex: 'mobile', width: 140, copyable: true },
|
||||||
|
{ title: '二维码ID', dataIndex: 'codeId', width: 120, copyable: true },
|
||||||
|
{ title: '设备编号', dataIndex: 'deviceSn', width: 160, copyable: true, ellipsis: true },
|
||||||
|
{ title: '创建时间', dataIndex: 'createTime', width: 180, valueType: 'dateTime' },
|
||||||
|
{title: '支付时间', dataIndex: 'payTime', width: 180, valueType: 'dateTime'},
|
||||||
|
{
|
||||||
|
title: '操作', valueType: 'option', width: 140, fixed: 'right',
|
||||||
|
render: (_, record) => <ResourcesActionCell record={record} onReload={onReload} canModifyStatus={canModifyStatus} />
|
||||||
|
},
|
||||||
|
];
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
// UTF-8: 常量映射 - 订单支付方式与订单状态
|
||||||
|
// 注意:仅用于前端展示,可根据需要在此新增/调整
|
||||||
|
|
||||||
|
export const PAY_TYPE_OPTIONS: { label: string; value: number; color?: string }[] = [
|
||||||
|
{ label: '微信支付', value: 1, color: 'green' },
|
||||||
|
{ label: '优惠券支付', value: 2, color: 'blue' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const ORDER_STATUS_OPTIONS: { label: string; value: number; color?: string }[] = [
|
||||||
|
{ label: '待支付', value: 0, color: 'default' },
|
||||||
|
{ label: '排队中', value: 1, color: 'gold' },
|
||||||
|
{ label: '已取消', value: 2, color: 'default' },
|
||||||
|
{ label: '任务完成', value: 3, color: 'cyan' },
|
||||||
|
{ label: '服务中', value: 4, color: 'blue' },
|
||||||
|
{ label: '素材上传中', value: 5, color: 'geekblue' },
|
||||||
|
{ label: '素材上传完成', value: 6, color: 'green' },
|
||||||
|
{ label: '退款中', value: 7, color: 'orange' },
|
||||||
|
{ label: '退款成功', value: 8, color: 'lime' },
|
||||||
|
{ label: '退款失败', value: 9, color: 'red' },
|
||||||
|
];
|
||||||
|
|
||||||
|
export const findLabel = (arr: { label: string; value: number }[], v?: number) => arr.find(o => o.value === v)?.label || '未知';
|
||||||
|
export const findColor = (arr: { color?: string; value: number }[], v?: number) => arr.find(o => o.value === v)?.color;
|
||||||
@@ -1,35 +1,41 @@
|
|||||||
import React, { useRef, useState } from 'react';
|
import React, { useRef, useMemo, useState, useEffect } from 'react';
|
||||||
import { PageContainer, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components';
|
import { PageContainer, ProFormSelect, ProFormText, ProTable } from '@ant-design/pro-components';
|
||||||
import type { ActionType } from '@ant-design/pro-components';
|
import type { ActionType } from '@ant-design/pro-components';
|
||||||
import { Tag } from 'antd';
|
|
||||||
import { ordersApi, OrderItem } from '@/services/orders';
|
import { ordersApi, OrderItem } from '@/services/orders';
|
||||||
|
import { tenantApi } from '@/services/tenant';
|
||||||
import { GlassCard, SearchBarPlus } from '@/components/ui';
|
import { GlassCard, SearchBarPlus } from '@/components/ui';
|
||||||
|
import { ORDER_STATUS_OPTIONS, PAY_TYPE_OPTIONS } from './components/constants';
|
||||||
const STATUS_OPTIONS = [
|
import { buildOrderColumns } from './components/buildColumns';
|
||||||
{ label: '未支付', value: 0 },
|
|
||||||
{ label: '已支付', value: 1 },
|
|
||||||
{ label: '已退款', value: 2 },
|
|
||||||
{ label: '已取消', value: 3 },
|
|
||||||
];
|
|
||||||
|
|
||||||
const PAY_TYPE_OPTIONS = [
|
|
||||||
{ label: '微信支付', value: 1 },
|
|
||||||
{ label: '优惠券支付', value: 2 },
|
|
||||||
];
|
|
||||||
|
|
||||||
const OrderPage: React.FC = () => {
|
const OrderPage: React.FC = () => {
|
||||||
const [params, setParams] = useState<Record<string, any>>({});
|
|
||||||
const actionRef = useRef<ActionType>();
|
const actionRef = useRef<ActionType>();
|
||||||
|
const [searchParams, setSearchParams] = useState<Record<string, any>>({});
|
||||||
|
const [canModifyStatus, setCanModifyStatus] = useState(false);
|
||||||
|
|
||||||
const columns: any[] = [
|
// 进入页面时获取当前租户信息
|
||||||
{ dataIndex: 'index', valueType: 'indexBorder', width: 48 },
|
useEffect(() => {
|
||||||
{ title: '订单编号', dataIndex: 'orderNo' },
|
const fetchTenantInfo = async () => {
|
||||||
{ title: '金额', dataIndex: 'amount' },
|
try {
|
||||||
{ title: '支付方式', dataIndex: 'payType', render: (v: number) => <Tag color={v === 1 ? 'green' : 'blue'}>{PAY_TYPE_OPTIONS.find(o => o.value === v)?.label || '未知'}</Tag> },
|
const res: any = await tenantApi.getCurrentTenant();
|
||||||
{ title: '状态', dataIndex: 'orderStatus', render: (v: number) => <Tag>{STATUS_OPTIONS.find(o => o.value === v)?.label || '未知'}</Tag> },
|
const tenantId = res?.data?.tenantId || res?.tenantId;
|
||||||
{ title: '旅游项目', dataIndex: 'tourismName' },
|
// 只有当租户ID为 'webApp' 时才能显示修改状态按钮
|
||||||
{ title: '创建时间', dataIndex: 'createTime', valueType: 'dateTime' },
|
setCanModifyStatus(tenantId === 'webApp');
|
||||||
];
|
} catch (error) {
|
||||||
|
console.error('获取租户信息失败:', error);
|
||||||
|
setCanModifyStatus(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
fetchTenantInfo();
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const handleSearch = (values: Record<string, any>) => {
|
||||||
|
// 重置为第一页,并保存搜索参数
|
||||||
|
setSearchParams(values);
|
||||||
|
// 重置分页到第一页
|
||||||
|
actionRef.current?.reset?.();
|
||||||
|
};
|
||||||
|
|
||||||
|
const columns = useMemo(() => buildOrderColumns(() => actionRef.current?.reload?.(), canModifyStatus), [canModifyStatus]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PageContainer header={{ title: '订单管理' }}>
|
<PageContainer header={{ title: '订单管理' }}>
|
||||||
@@ -37,11 +43,13 @@ const OrderPage: React.FC = () => {
|
|||||||
defaultCollapsed={false}
|
defaultCollapsed={false}
|
||||||
split
|
split
|
||||||
span={6}
|
span={6}
|
||||||
onTenantChanged={() => actionRef.current?.reload()}
|
onTenantChanged={() => actionRef.current?.reload?.()}
|
||||||
onFinish={async (values) => setParams(values)}
|
onFinish={handleSearch}
|
||||||
|
hideReset
|
||||||
>
|
>
|
||||||
<ProFormText name="orderNo" label="订单编号" placeholder="请输入订单编号" />
|
<ProFormText name="orderNo" label="订单编号" placeholder="请输入订单编号" />
|
||||||
<ProFormSelect name="orderStatus" label="订单状态" options={STATUS_OPTIONS} allowClear />
|
{/*<ProFormText name="mobile" label="用户手机号" placeholder="请输入手机号" />*/}
|
||||||
|
<ProFormSelect name="orderStatus" label="订单状态" options={ORDER_STATUS_OPTIONS} allowClear />
|
||||||
<ProFormSelect name="payType" label="支付方式" options={PAY_TYPE_OPTIONS} allowClear />
|
<ProFormSelect name="payType" label="支付方式" options={PAY_TYPE_OPTIONS} allowClear />
|
||||||
</SearchBarPlus>
|
</SearchBarPlus>
|
||||||
|
|
||||||
@@ -50,10 +58,19 @@ const OrderPage: React.FC = () => {
|
|||||||
rowKey="id"
|
rowKey="id"
|
||||||
headerTitle="订单列表"
|
headerTitle="订单列表"
|
||||||
actionRef={actionRef}
|
actionRef={actionRef}
|
||||||
request={(p) => ordersApi.order({ ...p, ...params } as any)}
|
request={(p) => {
|
||||||
|
// 构建请求参数:pageSize、current 来自 ProTable,搜索条件来自 searchParams
|
||||||
|
const params = {
|
||||||
|
...p,
|
||||||
|
...searchParams
|
||||||
|
};
|
||||||
|
console.log('ProTable request params:', params);
|
||||||
|
return ordersApi.order(params as any);
|
||||||
|
}}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
search={false}
|
search={false}
|
||||||
pagination={{ showSizeChanger: true, showQuickJumper: true, defaultPageSize: 20 }}
|
pagination={{ showSizeChanger: true, showQuickJumper: true, defaultPageSize: 20 }}
|
||||||
|
scroll={{ x: 1500 }}
|
||||||
/>
|
/>
|
||||||
</GlassCard>
|
</GlassCard>
|
||||||
</PageContainer>
|
</PageContainer>
|
||||||
|
|||||||
@@ -39,13 +39,21 @@ const LoginPage: React.FC = () => {
|
|||||||
const { ensureTenantCacheTokenGuard, setTenantTreeCache } = await import('@/utils/tenantCache');
|
const { ensureTenantCacheTokenGuard, setTenantTreeCache } = await import('@/utils/tenantCache');
|
||||||
const { tenantApi } = await import('@/services/tenant');
|
const { tenantApi } = await import('@/services/tenant');
|
||||||
ensureTenantCacheTokenGuard();
|
ensureTenantCacheTokenGuard();
|
||||||
|
|
||||||
|
// 获取当前用户的真实租户ID
|
||||||
|
const currentTenantRes: any = await tenantApi.getCurrentTenant();
|
||||||
|
const currentTenantId = currentTenantRes?.data?.tenantId || currentTenantRes?.tenantId;
|
||||||
|
if (currentTenantId) {
|
||||||
|
localStorage.setItem('current_tenant_id', currentTenantId);
|
||||||
|
}
|
||||||
|
|
||||||
const treeRes: any = await tenantApi.getAccessibleTenants();
|
const treeRes: any = await tenantApi.getAccessibleTenants();
|
||||||
let list: any[] = [];
|
let list: any[] = [];
|
||||||
if (typeof treeRes?.success !== 'undefined') list = treeRes.success ? (treeRes.data || []) : [];
|
if (typeof treeRes?.success !== 'undefined') list = treeRes.success ? (treeRes.data || []) : [];
|
||||||
else if (Array.isArray(treeRes)) list = treeRes as any[];
|
else if (Array.isArray(treeRes)) list = treeRes as any[];
|
||||||
if (list && list.length) setTenantTreeCache(list);
|
if (list && list.length) setTenantTreeCache(list);
|
||||||
} catch {}
|
} catch {}
|
||||||
localStorage.setItem('tenant_client_id', 'webApp');
|
// localStorage.setItem('tenant_client_id', 'webApp');
|
||||||
message.success('登录成功,正在跳转...');
|
message.success('登录成功,正在跳转...');
|
||||||
|
|
||||||
// 使用umi的history进行路由跳转
|
// 使用umi的history进行路由跳转
|
||||||
|
|||||||
@@ -9,10 +9,36 @@ export interface OrderItem {
|
|||||||
tourismId?: number;
|
tourismId?: number;
|
||||||
tourismName?: string;
|
tourismName?: string;
|
||||||
createTime?: string;
|
createTime?: string;
|
||||||
|
// 以下字段为展示所需,可后端返回时自动映射
|
||||||
|
userPhone?: string;
|
||||||
|
codeId?: string;
|
||||||
|
deviceNo?: string;
|
||||||
|
payTime?: string; // 支付时间
|
||||||
|
paySuccessTime?: string; // 兼容字段
|
||||||
|
paymentTime?: string; // 兼容字段
|
||||||
}
|
}
|
||||||
|
|
||||||
export const ordersApi = {
|
export const ordersApi = {
|
||||||
// 按租户分组获取景区资源(新接口)
|
|
||||||
|
// 首页统计
|
||||||
|
dashboard: async (params?: { tenantId?: string; includeChildren?: boolean; statType?: 'day' | 'month' | 'year'; [k: string]: any }) => {
|
||||||
|
const res = await request('/api-order/dashboard/statistics', { method: 'GET', params });
|
||||||
|
return res as any;
|
||||||
|
},
|
||||||
|
getDashboardOrders: async (params?: { [k: string]: any }) => {
|
||||||
|
const res = await request('/api-order/dashboard/orders', { method: 'GET', params });
|
||||||
|
return res as any;
|
||||||
|
},
|
||||||
|
getQrcodeOptions: async (params?: { [k: string]: any }) => {
|
||||||
|
const res = await request('/api-order/dashboard/qrcode/options', { method: 'GET', params });
|
||||||
|
return res as any;
|
||||||
|
},
|
||||||
|
// 订单时间序列(创建/完成/退款)
|
||||||
|
getOrderSeries: async (params?: { [k: string]: any }) => {
|
||||||
|
const res = await request('/api-order/dashboard/statistics/series', { method: 'GET', params });
|
||||||
|
return res as any;
|
||||||
|
},
|
||||||
|
// 景区文件分组 - 按租户查询资源列表接口
|
||||||
tourismFilesGroupedByTenant: async (params: { tenantId?: string; includeChildren?: boolean; type?: number; status?: number; description?: string; tourismId?: number; current?: number; pageSize?: number }) => {
|
tourismFilesGroupedByTenant: async (params: { tenantId?: string; includeChildren?: boolean; type?: number; status?: number; description?: string; tourismId?: number; current?: number; pageSize?: number }) => {
|
||||||
const { current, pageSize, ...rest } = params || {};
|
const { current, pageSize, ...rest } = params || {};
|
||||||
const res = await request('/api-order/tourism/files/grouped/by-tenant', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
const res = await request('/api-order/tourism/files/grouped/by-tenant', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
||||||
@@ -21,8 +47,8 @@ export const ordersApi = {
|
|||||||
return { data: (Array.isArray(list) ? list : []), total } as { data: Array<{ tourismId: number; tourismName?: string; files: any[] }>; total: number };
|
return { data: (Array.isArray(list) ? list : []), total } as { data: Array<{ tourismId: number; tourismName?: string; files: any[] }>; total: number };
|
||||||
},
|
},
|
||||||
|
|
||||||
// 订单列表
|
// 订单列表 - 根据租户ID查询(后端会根据租户先查景区,再查订单)
|
||||||
order: async (params: { current?: number; pageSize?: number; orderNo?: string; orderStatus?: number; tourismId?: number; payType?: number }) => {
|
order: async (params: { current?: number; pageSize?: number; orderNo?: string; orderStatus?: number; tourismId?: number; payType?: number; userPhone?: string; tenantId?: string; includeChildren?: boolean }) => {
|
||||||
const { current, pageSize, ...rest } = params || {};
|
const { current, pageSize, ...rest } = params || {};
|
||||||
const res = await request('/api-order/list', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
const res = await request('/api-order/list', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
||||||
return { data: (res as any).data, total: (res as any).count } as { data: OrderItem[]; total: number };
|
return { data: (res as any).data, total: (res as any).count } as { data: OrderItem[]; total: number };
|
||||||
@@ -32,7 +58,7 @@ export const ordersApi = {
|
|||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
|
|
||||||
// 订单文件
|
// 订单文件列表
|
||||||
orderFiles: async (params: { current?: number; pageSize?: number; [k: string]: any }) => {
|
orderFiles: async (params: { current?: number; pageSize?: number; [k: string]: any }) => {
|
||||||
const { current, pageSize, ...rest } = params || {};
|
const { current, pageSize, ...rest } = params || {};
|
||||||
const res = await request('/api-order/files', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
const res = await request('/api-order/files', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
||||||
@@ -43,7 +69,7 @@ export const ordersApi = {
|
|||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
|
|
||||||
// 二维码
|
// 二维码列表
|
||||||
qrcodeList: async (params: { current?: number; pageSize?: number }) => {
|
qrcodeList: async (params: { current?: number; pageSize?: number }) => {
|
||||||
const { current, pageSize } = params || {};
|
const { current, pageSize } = params || {};
|
||||||
const res = await request('/api-order/qrcode', { method: 'GET', params: { page: current, limit: pageSize } });
|
const res = await request('/api-order/qrcode', { method: 'GET', params: { page: current, limit: pageSize } });
|
||||||
@@ -61,14 +87,14 @@ export const ordersApi = {
|
|||||||
const res = await request(`/api-order/qrcode/${id}`, { method: 'DELETE' });
|
const res = await request(`/api-order/qrcode/${id}`, { method: 'DELETE' });
|
||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
// 按景区ID查询二维码列表
|
// 根据景区ID查询二维码列表
|
||||||
qrcodeListByTourism: async (params: { current?: number; pageSize?: number; tourismId: number; [k: string]: any }) => {
|
qrcodeListByTourism: async (params: { current?: number; pageSize?: number; tourismId: number; [k: string]: any }) => {
|
||||||
const { current, pageSize, ...rest } = params || {};
|
const { current, pageSize, ...rest } = params || {};
|
||||||
const res = await request('/api-order/qrcode', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
const res = await request('/api-order/qrcode', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
||||||
return { data: (res as any).data, total: (res as any).count };
|
return { data: (res as any).data, total: (res as any).count };
|
||||||
},
|
},
|
||||||
|
|
||||||
// 旅游景区
|
// 景区管理
|
||||||
tourism: async (params: { current?: number; pageSize?: number; [k: string]: any }) => {
|
tourism: async (params: { current?: number; pageSize?: number; [k: string]: any }) => {
|
||||||
const { current, pageSize, ...rest } = params || {};
|
const { current, pageSize, ...rest } = params || {};
|
||||||
const res = await request('/api-order/tourism', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
const res = await request('/api-order/tourism', { method: 'GET', params: { page: current, limit: pageSize, ...rest } });
|
||||||
@@ -79,7 +105,7 @@ export const ordersApi = {
|
|||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
deleteTourism: async (id: number) => {
|
deleteTourism: async (id: number) => {
|
||||||
// 后端删除接口:DELETE /tourism(从请求体读取 id),不支持 path 变量
|
// 调用删除接口,DELETE /tourism,由于接口取id参数,不支持 path 参数
|
||||||
const res = await request('/api-order/tourism', { method: 'DELETE', data: { id } });
|
const res = await request('/api-order/tourism', { method: 'DELETE', data: { id } });
|
||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
@@ -129,28 +155,27 @@ export const ordersApi = {
|
|||||||
const res = await request('/api-order/refund/approve', { method: 'POST', data });
|
const res = await request('/api-order/refund/approve', { method: 'POST', data });
|
||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
|
// 审核退款(支持自定义退款金额)
|
||||||
|
approveRefundWithCustomAmount: async (data: any) => {
|
||||||
|
const res = await request('/api-order/refund/approve/custom', { method: 'POST', data });
|
||||||
|
return (res as any).data || res;
|
||||||
|
},
|
||||||
createRefund: async (payload: { orderNo: string }) => {
|
createRefund: async (payload: { orderNo: string }) => {
|
||||||
const res = await request('/api-order/refund/auto', { method: 'PUT', data: payload });
|
const res = await request('/api-order/refund/auto', { method: 'PUT', data: payload });
|
||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
|
// 创建退款订单 - 调用 RefundController 的 createRefundOrder 接口
|
||||||
// 首页统计
|
createRefundOrder: async (orderNo: string, data?: any) => {
|
||||||
dashboard: async (params?: { tenantId?: string; includeChildren?: boolean; statType?: 'day' | 'month' | 'year'; [k: string]: any }) => {
|
const res = await request(`/api-order/refund/${orderNo}`, {
|
||||||
const res = await request('/api-order/dashboard/statistics', { method: 'GET', params });
|
method: 'POST',
|
||||||
return res as any;
|
data: data || {}
|
||||||
|
});
|
||||||
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
getDashboardOrders: async (params?: { [k: string]: any }) => {
|
// 根据订单编码获取退款订单详情(包含退款图片)
|
||||||
const res = await request('/api-order/dashboard/orders', { method: 'GET', params });
|
getRefundDetail: async (orderNo: string) => {
|
||||||
return res as any;
|
const res = await request('/api-order/refund/detail', { method: 'GET', params: { orderNo } });
|
||||||
},
|
return (res as any).data || res;
|
||||||
getQrcodeOptions: async (params?: { [k: string]: any }) => {
|
|
||||||
const res = await request('/api-order/dashboard/qrcode/options', { method: 'GET', params });
|
|
||||||
return res as any;
|
|
||||||
},
|
|
||||||
// 订单时间序列(创建/完成/退款)
|
|
||||||
getOrderSeries: async (params?: { [k: string]: any }) => {
|
|
||||||
const res = await request('/api-order/dashboard/statistics/series', { method: 'GET', params });
|
|
||||||
return res as any;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// 分账
|
// 分账
|
||||||
@@ -191,11 +216,11 @@ export const ordersApi = {
|
|||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
updateVideoTemplateStatus: async (id: number, status: number) => {
|
updateVideoTemplateStatus: async (id: number, status: number) => {
|
||||||
// 后端定义:/{id}/status/{status}
|
// 更新模板:/{id}/status/{status}
|
||||||
const res = await request(`/api-order/video/template/${id}/status/${status}`, { method: 'PUT' });
|
const res = await request(`/api-order/video/template/${id}/status/${status}`, { method: 'PUT' });
|
||||||
return (res as any).data || res;
|
return (res as any).data || res;
|
||||||
},
|
},
|
||||||
// 根据模板ID(templateId,字符串)查询模板信息(后端直查接口)
|
// 根据模板ID或templateId直接查询模板信息,不通过直接接口
|
||||||
getVideoTemplateByTemplateId: async (templateId: string) => {
|
getVideoTemplateByTemplateId: async (templateId: string) => {
|
||||||
const res = await request(`/api-order/video/template/templateId/${templateId}`, { method: 'GET' });
|
const res = await request(`/api-order/video/template/templateId/${templateId}`, { method: 'GET' });
|
||||||
return (res as any).data || res || null;
|
return (res as any).data || res || null;
|
||||||
@@ -282,6 +307,47 @@ export const ordersApi = {
|
|||||||
const list = ((res as any)?.data ?? (res as any)) as any[];
|
const list = ((res as any)?.data ?? (res as any)) as any[];
|
||||||
return Array.isArray(list) ? list : [];
|
return Array.isArray(list) ? list : [];
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// 查询订单资源列表(图片和视频)- 通过订单编号查询
|
||||||
|
getOrderResources: async (orderNo: string) => {
|
||||||
|
try {
|
||||||
|
const res = await request(`/api-order/files/order/${orderNo}`, { method: 'GET' });
|
||||||
|
console.log('✅ getOrderResources response:', res);
|
||||||
|
const data = (res as any)?.datas || (res as any)?.data || (res as any);
|
||||||
|
return Array.isArray(data) ? data : [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ getOrderResources error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 下载文件 - 通过后端代理(解决跨域问题)
|
||||||
|
downloadFile: async (fileUrl: string) => {
|
||||||
|
try {
|
||||||
|
const res = await request('/api-order/files/download', {
|
||||||
|
method: 'POST',
|
||||||
|
data: { url: fileUrl },
|
||||||
|
responseType: 'blob',
|
||||||
|
});
|
||||||
|
return res;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ downloadFile error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
// 批量下载所有文件 - 打包为 ZIP
|
||||||
|
batchDownloadFiles: async (orderNo: string) => {
|
||||||
|
try {
|
||||||
|
const res = await request('/api-order/files/download/batch', {
|
||||||
|
method: 'POST',
|
||||||
|
data: { orderNo },
|
||||||
|
responseType: 'blob',
|
||||||
|
});
|
||||||
|
return res;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('❌ batchDownloadFiles error:', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user