diff --git a/zlt-business/order-center/src/main/java/com/central/order/config/TencentPayConfiguration.java b/zlt-business/order-center/src/main/java/com/central/order/config/TencentPayConfiguration.java index cd9b4838..ad1fdb9f 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/config/TencentPayConfiguration.java +++ b/zlt-business/order-center/src/main/java/com/central/order/config/TencentPayConfiguration.java @@ -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() { diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/OrderController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/OrderController.java index de3038e7..218917e3 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/controller/OrderController.java +++ b/zlt-business/order-center/src/main/java/com/central/order/controller/OrderController.java @@ -249,7 +249,7 @@ public class OrderController { Assert.notNull(qrCode,"二维码CODEID不能为空"); Order order = orderService.getOrderyStatusAndUser(OrderStatus.PAID.getId(), user.getId()); Map 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()); diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/OrderRefundController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/OrderRefundController.java index 7f83e3e1..f7ed19bb 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/controller/OrderRefundController.java +++ b/zlt-business/order-center/src/main/java/com/central/order/controller/OrderRefundController.java @@ -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 params) { + return refundService.findList(params); + } + + @Operation(summary = "创建退款单") + @PostMapping("/{orderNo}") + public Result 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 refundOrder(@RequestBody String orderNo) { + public Result 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) { // 记录异常信息 diff --git a/zlt-business/order-center/src/main/java/com/central/order/controller/WxPayController.java b/zlt-business/order-center/src/main/java/com/central/order/controller/WxPayController.java index 723259ef..c85aa51d 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/controller/WxPayController.java +++ b/zlt-business/order-center/src/main/java/com/central/order/controller/WxPayController.java @@ -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); - } - - /** - * 支付回调 - *
-     * 注意:
-     * 对后台通知交互时,如果微信收到应答不是成功或超时,微信认为通知失败,微信会通过一定的策略定期重新发起通知,尽可能提高通知的成功率,但微信不保证通知最终能成功
-     *
-     * 同样的通知可能会多次发送给商户系统。商户系统必须能够正确处理重复的通知。 推荐的做法是,当商户系统收到通知进行处理时,先检查对应业务数据的状态,并判断该通知是否已经处理。如果未处理,则再进行处理;如果已处理,则直接返回结果成功。在对业务数据进行状态检查和处理之前,要采用数据锁进行并发控制,以避免函数重入造成的数据混乱。
-     * 如果在所有通知频率后没有收到微信侧回调。商户应调用查询订单接口确认订单状态。
-     * 
- * - * @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 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()); diff --git a/zlt-business/order-center/src/main/java/com/central/order/enums/RefundState.java b/zlt-business/order-center/src/main/java/com/central/order/enums/RefundState.java new file mode 100644 index 00000000..0fb44523 --- /dev/null +++ b/zlt-business/order-center/src/main/java/com/central/order/enums/RefundState.java @@ -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; + +} diff --git a/zlt-business/order-center/src/main/java/com/central/order/mapper/OrderMapper.java b/zlt-business/order-center/src/main/java/com/central/order/mapper/OrderMapper.java index 8586306a..a44c8e17 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/mapper/OrderMapper.java +++ b/zlt-business/order-center/src/main/java/com/central/order/mapper/OrderMapper.java @@ -56,6 +56,6 @@ public interface OrderMapper extends SuperMapper { "WHERE \n" + " order_status = 1 \n" + "ORDER BY \n" + - " create_time;") + " pay_time;") List getOrderRanking1(); } diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/Order.java b/zlt-business/order-center/src/main/java/com/central/order/model/Order.java index 94f24969..d62ec245 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/model/Order.java +++ b/zlt-business/order-center/src/main/java/com/central/order/model/Order.java @@ -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) diff --git a/zlt-business/order-center/src/main/java/com/central/order/model/Refund.java b/zlt-business/order-center/src/main/java/com/central/order/model/Refund.java index 3694004e..838fd080 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/model/Refund.java +++ b/zlt-business/order-center/src/main/java/com/central/order/model/Refund.java @@ -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) diff --git a/zlt-business/order-center/src/main/java/com/central/order/scheduler/OrderTimeoutScheduler.java b/zlt-business/order-center/src/main/java/com/central/order/scheduler/OrderTimeoutScheduler.java index d86430ce..3dac3551 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/scheduler/OrderTimeoutScheduler.java +++ b/zlt-business/order-center/src/main/java/com/central/order/scheduler/OrderTimeoutScheduler.java @@ -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(); diff --git a/zlt-business/order-center/src/main/java/com/central/order/service/impl/RefundServiceImpl.java b/zlt-business/order-center/src/main/java/com/central/order/service/impl/RefundServiceImpl.java index a28af71a..5265940f 100644 --- a/zlt-business/order-center/src/main/java/com/central/order/service/impl/RefundServiceImpl.java +++ b/zlt-business/order-center/src/main/java/com/central/order/service/impl/RefundServiceImpl.java @@ -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 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 diff --git a/zlt-config/src/main/resources/application-dev.properties b/zlt-config/src/main/resources/application-dev.properties index 5dd35b00..a5b21e88 100644 --- a/zlt-config/src/main/resources/application-dev.properties +++ b/zlt-config/src/main/resources/application-dev.properties @@ -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 diff --git a/zlt-config/src/main/resources/application-prod.properties b/zlt-config/src/main/resources/application-prod.properties index 72df9c66..6654cafd 100644 --- a/zlt-config/src/main/resources/application-prod.properties +++ b/zlt-config/src/main/resources/application-prod.properties @@ -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密钥 diff --git a/zlt-gateway/sc-gateway/src/main/resources/application.yml b/zlt-gateway/sc-gateway/src/main/resources/application.yml index 344a2df0..75841b83 100644 --- a/zlt-gateway/sc-gateway/src/main/resources/application.yml +++ b/zlt-gateway/sc-gateway/src/main/resources/application.yml @@ -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级别权限 diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/Order/index.tsx b/zlt-web/react-web/src/main/frontend/src/pages/orders/Order/index.tsx index 9be1310c..991d6811 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/orders/Order/index.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/Order/index.tsx @@ -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; diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/Refund/index.less b/zlt-web/react-web/src/main/frontend/src/pages/orders/Refund/index.less new file mode 100644 index 00000000..8d289828 --- /dev/null +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/Refund/index.less @@ -0,0 +1 @@ +@import (reference) '~antd/es/style/themes/index'; diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/Refund/index.tsx b/zlt-web/react-web/src/main/frontend/src/pages/orders/Refund/index.tsx new file mode 100644 index 00000000..a1d810da --- /dev/null +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/Refund/index.tsx @@ -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 {statusInfo.text}; +}; + +const TableList: React.FC = () => { + const actionRef = useRef(); + const [params, setParams] = useState>({ }); + const columns: ProColumns[] = [ + { + 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) => { + // const success = await handleDelete(entity); + // if (success) { + // if (actionRef.current) { + // actionRef.current.reload(); + // } + // } + }} + > + 删除 + , + }, + ]; + + return ( + + setParams(values)} + > + + + + rowKey="id" + headerTitle="任务列表" + request={order} + actionRef={actionRef} + columns={columns} + search={false} + params={params} + pagination={{ + showSizeChanger: true, + showQuickJumper: true, + }} + /> + + ); +}; + +export default TableList; diff --git a/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/components/UpdateForm.tsx b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/components/UpdateForm.tsx index fd71c90f..9c2b9aaa 100644 --- a/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/components/UpdateForm.tsx +++ b/zlt-web/react-web/src/main/frontend/src/pages/orders/TourismFile/components/UpdateForm.tsx @@ -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; @@ -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 = (props) => { const [form] = Form.useForm(); + const [file, setFile] = useState(); return ( = (props) => { onVisibleChange={props.onVisibleChange} > - - - + + + + + { + const result = await handleImport(file); + if (result && result.name) { + setFile(result.name); + } + return false; + }} + > +
+ +
+
); diff --git a/zlt-web/react-web/src/main/frontend/src/services/orders/api.ts b/zlt-web/react-web/src/main/frontend/src/services/orders/api.ts index 59cb76d5..f08f163d 100644 --- a/zlt-web/react-web/src/main/frontend/src/services/orders/api.ts +++ b/zlt-web/react-web/src/main/frontend/src/services/orders/api.ts @@ -127,4 +127,13 @@ export async function deleteHomeCarousel(id: number) { method: 'DELETE', }); return result; -} \ No newline at end of file +} + +export async function refund(params?: { [key: string]: string | number }) { + const { current, pageSize, ...rest } = params ?? {}; + const result = await request>('/api-order/refund', { + method: 'GET', + params: { page: current, limit: pageSize, ...rest }, + }); + return { data: result.data, total: result.count }; +} diff --git a/zlt-web/react-web/src/main/frontend/src/services/orders/typings.d.ts b/zlt-web/react-web/src/main/frontend/src/services/orders/typings.d.ts index 1eab9ece..41abd891 100644 --- a/zlt-web/react-web/src/main/frontend/src/services/orders/typings.d.ts +++ b/zlt-web/react-web/src/main/frontend/src/services/orders/typings.d.ts @@ -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; + } } \ No newline at end of file