fix[支付模块]:订单支付回调逻辑新增,退款逻辑回调逻辑新增完成,测试通过

This commit is contained in:
2025-02-24 17:40:50 +08:00
parent 59677f1c5f
commit 448e20b205
19 changed files with 381 additions and 200 deletions
@@ -3,7 +3,6 @@ package com.central.order.config;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.RSAAutoCertificateConfig;
import com.wechat.pay.java.core.notification.NotificationConfig;
import com.wechat.pay.java.core.notification.NotificationParser;
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
import com.wechat.pay.java.service.refund.RefundService;
import lombok.Getter;
@@ -59,7 +58,7 @@ public class TencentPayConfiguration {
* 微信支付配置获取
* @return
*/
private Config getConfig() {
public Config getConfig() {
return new RSAAutoCertificateConfig.Builder()
.merchantId(merchantId)
.privateKeyFromPath(privateKeyPath)
@@ -68,10 +67,6 @@ public class TencentPayConfiguration {
.build();
}
@Bean
public NotificationParser initialNotificationParser() {
return new NotificationParser(initialNotificationConfig());
}
@Bean
public NotificationConfig initialNotificationConfig() {
@@ -249,7 +249,7 @@ public class OrderController {
Assert.notNull(qrCode,"二维码CODEID不能为空");
Order order = orderService.getOrderyStatusAndUser(OrderStatus.PAID.getId(), user.getId());
Map<String, Object> map = new HashMap<>();
map.put("price",appendPriceStr(qrCode.getPrice()));
map.put("price",Integer.parseInt(qrCode.getPrice()) /100);
//如果用户存在已支付订单,则查询当前排在第几
if (order != null){
Integer count = orderService.getOrderRankingByOrderId(order.getId());
@@ -1,7 +1,9 @@
package com.central.order.controller;
import com.central.common.model.PageResult;
import com.central.common.model.Result;
import com.central.order.enums.OrderStatus;
import com.central.order.enums.RefundState;
import com.central.order.model.Order;
import com.central.order.service.IOrderService;
import com.central.order.service.IRefundService;
@@ -10,14 +12,16 @@ import com.wechat.pay.java.service.refund.model.AmountReq;
import com.wechat.pay.java.service.refund.model.CreateRequest;
import com.wechat.pay.java.service.refund.model.Refund;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.util.Map;
@RestController
@RequestMapping("/refund")
@@ -35,10 +39,46 @@ public class OrderRefundController {
@Value("${tencent.refund-notify-url}")
private String refundNotifyUrl;
/**
* 列表
*/
@Operation(summary = "查询全部列表")
@Parameters({
@Parameter(name = "page",description = "分页起始位置",required = true,in= ParameterIn.QUERY),
@Parameter(name = "limit",description = "分页结束位置",required = true,in=ParameterIn.QUERY)
})
@GetMapping("/list")
public PageResult list(@RequestParam Map<String, Object> params) {
return refundService.findList(params);
}
@Operation(summary = "创建退款单")
@PostMapping("/{orderNo}")
public Result<com.central.order.model.Refund> createRefundOrder(@PathVariable String orderNo) {
Order order = orderService.getOrderByNumber(orderNo);
Assert.notNull(order,"ORDER DATA不存在");
if (!order.getOrderStatus().equals(OrderStatus.PAID.getId())){
return Result.failed("该订单不支持退款操作");
}
// 创建退款订单
com.central.order.model.Refund refund = new com.central.order.model.Refund();
refund.setRefundNo("RF" + order.getOrderNo());
refund.setOrderNo(order.getOrderNo());
refund.setUserId(order.getUserId());
refund.setStatus(OrderStatus.REFUNDING.getId());
refund.setState(RefundState.APPROVING.getId());
boolean res = refundService.createRefund(refund);
if (res) {
order.setOrderStatus(OrderStatus.REFUNDING.getId());
return Result.succeed("退款成功");
}
return Result.failed("请重试");
}
@Operation(summary = "微信支付退款")
@PostMapping()
@Transactional(rollbackFor = Exception.class)
public Result<Refund> refundOrder(@RequestBody String orderNo) {
public Result<com.central.order.model.Refund> refundOrder(@RequestBody String orderNo) {
try {
// 检查订单是否存在
Order order = orderService.getOrderByNumber(orderNo);
@@ -64,17 +104,7 @@ public class OrderRefundController {
Refund response = service.create(request);
Assert.notNull(response, "退款失败");
// 创建退款订单
com.central.order.model.Refund refund = new com.central.order.model.Refund();
refund.setRefundNo("RF" + order.getOrderNo());
refund.setOrderNo(order.getOrderNo());
refund.setUserId(order.getUserId());
refund.setStatus(OrderStatus.REFUNDING.getId());
boolean res = refundService.createRefund(refund);
if (res) {
return Result.succeed("退款成功");
}
throw new RuntimeException("创建退款订单失败");
} catch (Exception e) {
// 记录异常信息
@@ -1,32 +1,22 @@
package com.central.order.controller;
import com.alibaba.fastjson.JSONObject;
import com.central.order.enums.OrderStatus;
import com.central.order.model.Order;
import com.central.order.service.IOrderService;
import com.central.order.service.IRefundService;
import com.central.order.util.HttpServletUtils;
import com.wechat.pay.java.core.exception.MalformedMessageException;
import com.wechat.pay.java.core.exception.ValidationException;
import com.wechat.pay.java.core.notification.NotificationConfig;
import com.wechat.pay.java.core.notification.NotificationParser;
import com.wechat.pay.java.core.notification.RequestParam;
import com.wechat.pay.java.service.payments.model.Transaction;
import com.wechat.pay.java.service.refund.model.RefundNotification;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import java.util.Date;
@Slf4j
@RestController
@@ -34,113 +24,81 @@ import java.util.Map;
@RequestMapping("/wechat")
public class WxPayController {
@Autowired
private NotificationConfig notificationConfig;
@Autowired
private IOrderService orderService;
@Autowired
private IRefundService refundService;
@Autowired
private NotificationParser notificationParser;
private NotificationConfig config;
/**
* 支付回调
*
* @param request
* @return
* @throws IOException
*/
@Operation(summary = "支付回调")
@PostMapping("/pay/Notify")
public String wechatPayNotify(HttpServletRequest request) throws IOException {
log.info("------收到微信支付回调通知------");
return payNotify(request);
}
/**
* 支付回调
* <pre>
* 注意:
* 对后台通知交互时,如果微信收到应答不是成功或超时,微信认为通知失败,微信会通过一定的策略定期重新发起通知,尽可能提高通知的成功率,但微信不保证通知最终能成功
*
* 同样的通知可能会多次发送给商户系统。商户系统必须能够正确处理重复的通知。 推荐的做法是,当商户系统收到通知进行处理时,先检查对应业务数据的状态,并判断该通知是否已经处理。如果未处理,则再进行处理;如果已处理,则直接返回结果成功。在对业务数据进行状态检查和处理之前,要采用数据锁进行并发控制,以避免函数重入造成的数据混乱。
* 如果在所有通知频率后没有收到微信侧回调。商户应调用查询订单接口确认订单状态。
* </pre>
*
* @param request
* @return
* @throws IOException
*/
public String payNotify(HttpServletRequest request) throws IOException {
// 请求头Wechatpay-Signature
String signature = request.getHeader("Wechatpay-Signature");
// 请求头Wechatpay-nonce
String nonce = request.getHeader("Wechatpay-Nonce");
// 请求头Wechatpay-Timestamp
String timestamp = request.getHeader("Wechatpay-Timestamp");
// 微信支付证书序列号
String serial = request.getHeader("Wechatpay-Serial");
// 签名方式
String signType = request.getHeader("Wechatpay-Signature-Type");
// 构造 RequestParam
RequestParam requestParam = new RequestParam.Builder()
.serialNumber(serial)
.nonce(nonce)
.signature(signature)
.timestamp(timestamp)
.signType(signType)
.body(HttpServletUtils.getRequestBody(request))
.build();
log.info("微信支付回调body信息:{}", requestParam.getBody());
// 初始化 NotificationParser
NotificationParser parser = new NotificationParser(notificationConfig);
// 以支付通知回调为例,验签、解密并转换成 Transaction
log.info("验签参数:{}", JSONObject.toJSONString(requestParam));
Map<String, String> returnMap = new HashMap<>(2);
returnMap.put("code", "FAIL");
returnMap.put("message", "失败");
Transaction transaction = null;
@PostMapping("/pay/notify")
public String handleCallback(@RequestHeader("Wechatpay-Signature") String signature,
@RequestHeader("Wechatpay-Timestamp") String timestamp,
@RequestHeader("Wechatpay-Nonce") String nonce,
@RequestHeader("Wechatpay-Serial") String serial,
@RequestBody String body) {
try {
transaction = parser.parse(requestParam, Transaction.class);
} catch (MalformedMessageException e) {
log.error("验签失败,解析微信支付应答或回调报文异常,返回信息:", e);
return JSONObject.toJSONString(returnMap);
} catch (ValidationException e) {
log.error("验签失败,验证签名失败,返回信息:", e);
return JSONObject.toJSONString(returnMap);
// 构建请求参数
RequestParam requestParam = new RequestParam
.Builder()
.body(body)
.nonce(nonce)
.signature(signature)
.serialNumber(serial)
.timestamp(timestamp)
.build();
NotificationParser notificationParser = new NotificationParser(config);
// 解析通知
Transaction transaction = notificationParser.parse(requestParam,Transaction.class);
// 处理支付结果
handlePaymentResult(transaction);
// 返回成功响应
return "{\"code\":\"SUCCESS\",\"message\":\"成功\"}";
} catch (Exception e) {
log.error("验签失败,返回信息:", e);
return JSONObject.toJSONString(returnMap);
// 处理异常,记录日志等
e.printStackTrace();
return "{\"code\":\"FAIL\",\"message\":\"失败\"}";
}
log.info("验签成功!-支付回调结果:{}", transaction.toString());
// 判断订单状态
if (Transaction.TradeStateEnum.SUCCESS != transaction.getTradeState()) {
log.info("内部订单号【{}】,微信支付订单号【{}】支付未成功", transaction.getOutTradeNo(), transaction.getTransactionId());
return JSONObject.toJSONString(returnMap);
}
Order order = orderService.getOrderByNumber(transaction.getOutTradeNo());
order.setOrderStatus(OrderStatus.PAID.getId());
boolean res = orderService.updateOrder(order);
if (res){
returnMap.put("code", "SUCCESS");
returnMap.put("message", "成功");
}else {
returnMap.put("code", "FAIL");
returnMap.put("message","失败");
}
return JSONObject.toJSONString(returnMap);
}
@PostMapping("/refund/Notify")
private void handlePaymentResult(Transaction transaction) {
// 获取支付通知中的关键信息
String outTradeNo = transaction.getOutTradeNo();
String tradeState = transaction.getTradeState().toString();
// 根据支付状态进行相应处理
if ("SUCCESS".equals(tradeState)) {
// 支付成功,更新订单状态等操作
System.out.println("支付成功,商户订单号:" + outTradeNo);
Order order = orderService.getOrderByNumber(transaction.getOutTradeNo());
order.setOrderStatus(OrderStatus.PAID.getId());
order.setPayTime(new Date());
orderService.updateOrder(order);
// 这里可以添加更新数据库订单状态的代码
} else {
// 其他支付状态,如支付中、失败等
System.out.println("支付状态:" + tradeState + ",商户订单号:" + outTradeNo);
}
}
@PostMapping("/refund/notify")
public String refundCallback(@RequestHeader("Wechatpay-Signature") String signature,
@RequestHeader("Wechatpay-Timestamp") String timestamp,
@RequestHeader("Wechatpay-Nonce") String nonce,
@RequestHeader("Wechatpay-Serial") String serial,
String body) {
@RequestBody String body) {
log.info("------收到微信退款回调通知------");
try {
// 构建请求参数
@@ -152,6 +110,8 @@ public class WxPayController {
.serialNumber(serial)
.timestamp(timestamp)
.build();
NotificationParser notificationParser = new NotificationParser(config);
// 解析通知
RefundNotification notification = notificationParser.parse(requestParam, RefundNotification.class);
@@ -182,6 +142,7 @@ public class WxPayController {
com.central.order.model.Refund refund = refundService.getRefundByNo(outRefundNo);
Assert.notNull(refund,"退款订单数据不存在");
refund.setStatus(OrderStatus.REFUNDED.getId());
refund.setRefundTime(new Date());
refundService.updateById(refund);
Order order = orderService.getOrderByNumber(refund.getOrderNo());
@@ -0,0 +1,26 @@
package com.central.order.enums;
import com.central.common.enums.ZltEnum;
import lombok.Getter;
/**
* 订单状态枚举类型
*
* @author lsl create by 2025/1/10
*/
@Getter
public enum RefundState implements ZltEnum {
APPROVING(0,"审核中"),
APPROVED(1, "已通过"),
REFUSED(2,"已拒绝");
RefundState(Integer id, String content) {
this.id = id;
this.content = content;
}
private Integer id;
private String content;
}
@@ -56,6 +56,6 @@ public interface OrderMapper extends SuperMapper<Order> {
"WHERE \n" +
" order_status = 1 \n" +
"ORDER BY \n" +
" create_time;")
" pay_time;")
List<OrderRanking> getOrderRanking1();
}
@@ -38,7 +38,7 @@ public class Order extends SuperEntity {
private transient String createdTime;
private transient String codeId;
private String codeId;
@TableField(fill = FieldFill.INSERT)
private Date createTime;
@TableField(fill = FieldFill.INSERT_UPDATE)
@@ -31,6 +31,9 @@ public class Refund extends SuperEntity {
private String refundReason;
private Integer status;
private Integer state;
private String approveReason;
private Date refundTime;
@TableField(fill = FieldFill.INSERT)
@@ -21,13 +21,7 @@ public class OrderTimeoutScheduler {
orderService.checkAndHandleOrderTimeout();
}
// 每隔一定时间(这里设置为每分钟检查一次,可根据实际情况调整)检查订单超时情况
// @Scheduled(fixedRate = 1 * 1000)
public void checkOrderPaySuccess() {
orderService.updateOrderStatus();
}
// 每隔一定时间(这里设置为每分钟检查一次,可根据实际情况调整)检查订单超时情况
// 每隔一定时间(这里设置为每分钟检查一次,可根据实际情况调整)检查是否存在未服务完成的订单
// @Scheduled(fixedRate = 60 * 1000)
public void processOrdersInQueue() {
orderService.processOrdersInQueue();
@@ -2,26 +2,18 @@ package com.central.order.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.central.common.lock.DistributedLock;
import com.central.common.model.PageResult;
import com.central.common.service.impl.SuperServiceImpl;
import com.central.order.mapper.OrderMapper;
import com.central.order.mapper.RefundMapper;
import com.central.order.mapper.TourismMapper;
import com.central.order.model.Refund;
import com.central.order.service.IRefundService;
import com.wechat.pay.java.service.payments.jsapi.JsapiServiceExtension;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.MapUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
/**
* Order information
@@ -34,23 +26,6 @@ import java.util.concurrent.Executors;
@Primary
public class RefundServiceImpl extends SuperServiceImpl<RefundMapper, Refund> implements IRefundService {
private final static String ORDER_LOCK = "order_lock_";
@Autowired
private DistributedLock lock;
private final ExecutorService executorService = Executors.newFixedThreadPool(10); // 线程池,可根据实际并发量调整大小
@Autowired
private JsapiServiceExtension service;
private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
@Autowired
private OrderMapper orderMapper;
@Autowired
private TourismMapper tourismMapper;
/**
* 列表
* @param params
@@ -72,10 +72,10 @@ zlt.wxpay.merchantSerialNumber=11F4AC03C50EB582D3EDE082591D1F9A65388D51
# 微信支付申请的应用ID
zlt.wxpay.appId=wx30a3c8de94a85584
# 微信支付异步通知地址(需外网可访问且与微信支付平台配置一致)
zlt.wxpay.notifyUrl= https://img.goflytec.com/api-order/wechat/pay/Notify
zlt.wxpay.notifyUrl=https://img.goflytec.com/api-order/wechat/pay/notify
# 微信退款异步通知地址(需外网可访问且与微信支付平台配置一致)
zlt.wxrefund.notifyUrl= https://img.goflytec.com/api-order/wechat/refund/Notify
zlt.wxrefund.notifyUrl= https://img.goflytec.com/api-order/wechat/refund/notify
# 商户API私钥路径
zlt.wxpay.privateKeyPath=D:\\wx\\WXCertUtil\\cert\\1703796518_20250114_cert\\apiclient_key.pem
zlt.wxpay.privateKeyPath=/data/zlt/cert/apiclient_key.pem
# 商户APIV3密钥
zlt.wxpay.apiV3Key=aIt5Vw3cYXSCSd4L5h14kIyDsoXBow7r
@@ -60,12 +60,13 @@ zlt.security.tencent.pagePath=/pages/link/link?uuid=
zlt.wxpay.merchantId=1703796518
# 商户证书序列号
zlt.wxpay.merchantSerialNumber=11F4AC03C50EB582D3EDE082591D1F9A65388D51
# 61CBFF26EC90204F8F308B6D318E90F14DF233FC
# 微信支付申请的应用ID
zlt.wxpay.appId=wx30a3c8de94a85584
# 微信支付异步通知地址(需外网可访问且与微信支付平台配置一致)
zlt.wxpay.notifyUrl=http://your_domain/weixin/pay/notify
zlt.wxpay.notifyUrl=https://img.goflytec.com/api-order/wechat/pay/notify
# 微信退款异步通知地址(需外网可访问且与微信支付平台配置一致)
zlt.wxrefund.notifyUrl= https://img.goflytec.com/api-order/wechat/refund/Notify
zlt.wxrefund.notifyUrl= https://img.goflytec.com/api-order/wechat/refund/notify
# 商户API私钥路径
zlt.wxpay.privateKeyPath=/data/zlt/cert/apiclient_key.pem
# 商户APIV3密钥
@@ -140,7 +140,8 @@ zlt:
/*/v3/api-docs/**,
/api-order/files/path,
/api-order/update,
/api-order/queue/first
/api-order/queue/first,
/api-order/wechat/**
auth:
urlPermission:
#是否开启url级别权限
@@ -6,7 +6,7 @@ import {
ProTable,
QueryFilter,
} from '@ant-design/pro-components';
import { Typography, message, Popconfirm, Tag } from 'antd';
import { Typography, Popconfirm, Tag } from 'antd';
import React, { useRef, useState } from 'react';
const { Link } = Typography;
@@ -0,0 +1 @@
@import (reference) '~antd/es/style/themes/index';
@@ -0,0 +1,120 @@
import { order } from '@/services/orders/api';
import type { ActionType, ProColumns } from '@ant-design/pro-components';
import {
PageContainer,
ProFormText,
ProTable,
QueryFilter,
} from '@ant-design/pro-components';
import { Typography, Popconfirm, Tag } from 'antd';
import React, { useRef, useState } from 'react';
const { Link } = Typography;
// const handleDelete = async (deletefile: FILES.File) => {
// const hide = message.loading('正在删除');
// try {
// const result = await deleteFile(deletefile.id);
// hide();
// if (result.resp_code === 0) {
// message.success('删除File成功');
// return true;
// } else {
// message.error(result.resp_msg);
// return false;
// }
// } catch (error) {
// hide();
// message.error('删除File失败');
// return false;
// }
// };
// 状态颜色映射
const statusColorMap = {
0: { color: 'yellow', text: '待处理' },
1: { color: 'orange', text: '待处理' },
3: { color: 'green', text: '已完成' },
2: { color: 'red', text: '已取消' },
};
// 渲染状态标签
const renderStatus = (status: {} | null | undefined) => {
const statusInfo = statusColorMap[status] || { color: 'gray', text: '未知状态' };
return <Tag color={statusInfo.color}>{statusInfo.text}</Tag>;
};
const TableList: React.FC = () => {
const actionRef = useRef<ActionType>();
const [params, setParams] = useState<Record<string, string | number>>({ });
const columns: ProColumns<ORDERS.Order>[] = [
{
dataIndex: 'index',
valueType: 'indexBorder',
},
{
title: '订单ID',
dataIndex: 'id',
},
{
title: '退款订单编号',
dataIndex: 'refundNo',
},
{
title: '状态',
dataIndex: 'status',
render: (status) => renderStatus(status),
},
{
title: '创建时间',
dataIndex: 'createTime',
valueType: 'dateTime',
},
{
title: '操作',
key: 'action',
render: (_, entity) => <Popconfirm
title={`确认删除文件[${entity.id}]?`}
onConfirm={async () => {
// const success = await handleDelete(entity);
// if (success) {
// if (actionRef.current) {
// actionRef.current.reload();
// }
// }
}}
>
<Link>删除</Link>
</Popconfirm>,
},
];
return (
<PageContainer header={{ subTitle: '管理任务' }}>
<QueryFilter
defaultCollapsed
split
span={6}
className="query-filter"
onFinish={async (values) => setParams(values)}
>
<ProFormText name="name" label="搜索" placeholder="输入关键字" />
</QueryFilter>
<ProTable<ORDERS.Order>
rowKey="id"
headerTitle="任务列表"
request={order}
actionRef={actionRef}
columns={columns}
search={false}
params={params}
pagination={{
showSizeChanger: true,
showQuickJumper: true,
}}
/>
</PageContainer>
);
};
export default TableList;
@@ -1,9 +1,15 @@
import { importImage } from '@/services/system/api';
import { UploadOutlined } from '@ant-design/icons';
import {
ModalForm,
ProForm,
ProFormSelect,
ProFormText,
} from '@ant-design/pro-components';
import { Form } from 'antd';
import { Button, Form, message, Upload } from 'antd';
import { RcFile } from 'antd/lib/upload';
import { useState } from 'react';
import styles from '../index.less';
export type FormValueType = Partial<ORDERS.TourismFile>;
@@ -14,8 +20,24 @@ export type UpdateFormProps = {
values?: ORDERS.Tourism;
};
const handleImport = async (file: RcFile) => {
const hide = message.loading('正在导入');
try {
const formData = new FormData();
formData.append('file', file);
const result = await importImage(formData);
hide();
message.success('上传素材成功');
return result;
} catch (error) {
hide();
message.error('上传素材失败');
return null;
}
};
const UpdateForm: React.FC<UpdateFormProps> = (props) => {
const [form] = Form.useForm();
const [file, setFile] = useState();
return (
<ModalForm
title="更新素材"
@@ -25,42 +47,74 @@ const UpdateForm: React.FC<UpdateFormProps> = (props) => {
onVisibleChange={props.onVisibleChange}
>
<ProForm.Group>
<ProFormText
rules={[
{
required: true,
message: '名称不为空',
},
]}
width="md"
name="tourismId"
label="景区名称"
placeholder="输入名称"
/>
<ProFormText
rules={[
{
required: true,
message: '地址不为空',
},
]}
width="md"
name="imageUrl"
label="素材地址"
placeholder="输入地址"
/>
<ProFormText
rules={[
{
required: true,
message: '链接页面不为空',
},
]}
width="md"
name="linkUrl"
label="链接地址"
placeholder="输入链接"
/>
<ProFormSelect
rules={[
{
required: true,
message: '景区不为空',
},
]}
width="md"
name="tourismId"
label="景区"
placeholder="请选择景区"
options={[
{ label: '北塘古镇', value: 33 },
{ label: '海丝首港', value: 32 },
{ label: '景区C', value: 2 },
// 添加更多选项...
]}
/>
<ProFormSelect
rules={[
{
required: true,
message: '素材类型不为空',
},
]}
width="md"
name="type"
label="景区"
placeholder="请选择景区"
options={[
{ label: '展示大图', value: 4 },
{ label: '拍照引导图', value: 3 },
{ label: '拍照角度展示图', value: 2 },
{ label: '活动', value: 1 },
// 添加更多选项...
]}
/>
<ProFormText
width="md"
name="linkUrl"
label="素材链接url"
placeholder="输入url"
/>
<ProFormText
width="md"
name="description"
label="素材描述"
placeholder="输入描述 "
/>
<Upload
maxCount={1}
action="/api-file/files-anon"
showUploadList={false}
beforeUpload={async (file) => {
const result = await handleImport(file);
if (result && result.name) {
setFile(result.name);
}
return false;
}}
>
<div className={styles.button_view}>
<Button>
<UploadOutlined />
上传素材
</Button>
</div>
</Upload>
</ProForm.Group>
</ModalForm>
);
@@ -127,4 +127,13 @@ export async function deleteHomeCarousel(id: number) {
method: 'DELETE',
});
return result;
}
}
export async function refund(params?: { [key: string]: string | number }) {
const { current, pageSize, ...rest } = params ?? {};
const result = await request<SYSTEM.Page<ORDERS.Refund>>('/api-order/refund', {
method: 'GET',
params: { page: current, limit: pageSize, ...rest },
});
return { data: result.data, total: result.count };
}
@@ -80,4 +80,15 @@ declare namespace ORDERS {
updateTime?: string;
}
type Refund = {
id: number;
orderNo: string;
refundNo: string;
status: number;
state: number;
approveReason: string;
createTime?: string;
tenantId?: string;
updateTime?: string;
}
}