2025-10-22 10:13:57 +08:00
|
|
|
|
package com.cdzy.payment.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil;
|
|
|
|
|
|
import com.cdzy.common.model.response.JsonResult;
|
2025-11-14 16:24:04 +08:00
|
|
|
|
import com.cdzy.payment.model.dto.EbikeRefundDto;
|
|
|
|
|
|
import com.cdzy.payment.model.vo.EbikeWxHandleNotifyVo;
|
2025-10-24 10:09:53 +08:00
|
|
|
|
import com.cdzy.payment.service.EbikeWxPayService;
|
2025-10-30 09:21:18 +08:00
|
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
2025-10-22 10:13:57 +08:00
|
|
|
|
import com.wechat.pay.java.service.payments.model.Transaction;
|
|
|
|
|
|
import com.wechat.pay.java.service.refund.model.Refund;
|
|
|
|
|
|
import jakarta.annotation.Resource;
|
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 用户订单微信支付 控制层。
|
|
|
|
|
|
*
|
2025-11-14 16:24:04 +08:00
|
|
|
|
* @author yanglei
|
|
|
|
|
|
* @since 2025-10-21 14:42
|
2025-10-22 10:13:57 +08:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
@Slf4j
|
|
|
|
|
|
@RestController
|
|
|
|
|
|
@RequestMapping("/wxPayment")
|
|
|
|
|
|
public class EbikeWxPaymentController {
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
2025-10-24 10:09:53 +08:00
|
|
|
|
private EbikeWxPayService wxPayService;
|
2025-10-22 10:13:57 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 微信支付下单
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param orderId 骑行订单id
|
|
|
|
|
|
* @return 下单成功返回true,否则返回false
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/prepay")
|
2025-10-29 17:01:46 +08:00
|
|
|
|
public JsonResult<?> prepay(@RequestParam(name = "orderId") Long orderId) {
|
2025-10-30 09:21:18 +08:00
|
|
|
|
JsonNode r = wxPayService.prepay(orderId);
|
2025-10-29 14:06:51 +08:00
|
|
|
|
return JsonResult.success(r);
|
2025-10-22 10:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 通过商户(骑行)订单号查询支付订单
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param orderId 商户(骑行)订单号
|
|
|
|
|
|
* @return 支付订单信息
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/queryOrder/{orderId}")
|
2025-10-29 17:01:46 +08:00
|
|
|
|
public JsonResult<?> queryOrderByOrderId(@PathVariable(name = "orderId") Long orderId) {
|
2025-10-29 14:06:51 +08:00
|
|
|
|
Transaction transaction = wxPayService.queryOrderByOrderId(orderId);
|
|
|
|
|
|
return JsonResult.success(transaction);
|
2025-10-22 10:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 通过商户(骑行)订单订单号查询支付订单状态
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param orderId 微信支付订单号
|
|
|
|
|
|
* @return 订单信息支付状态
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/queryOrderStatus/{orderId}")
|
2025-10-29 17:01:46 +08:00
|
|
|
|
public JsonResult<?> queryOrderStatusById(@PathVariable(name = "orderId") Long orderId) {
|
2025-10-24 10:09:53 +08:00
|
|
|
|
EbikeWxHandleNotifyVo r = wxPayService.queryOrderStatusByOrderId(orderId);
|
2025-10-22 10:13:57 +08:00
|
|
|
|
return JsonResult.success(r);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2025-11-14 16:24:04 +08:00
|
|
|
|
* 通过退款记录主键id查询退款信息
|
2025-10-22 10:13:57 +08:00
|
|
|
|
*
|
2025-11-14 16:24:04 +08:00
|
|
|
|
* @param refundId 退款主键id
|
|
|
|
|
|
* @return 退款状态信息
|
2025-10-22 10:13:57 +08:00
|
|
|
|
*/
|
2025-11-14 16:24:04 +08:00
|
|
|
|
@GetMapping("/queryRefundStatus/{refundId}")
|
|
|
|
|
|
public JsonResult<?> queryRefundStatus(@PathVariable(name = "refundId") Long refundId) {
|
|
|
|
|
|
EbikeWxHandleNotifyVo notifyVo = wxPayService.queryRefundStatusById(refundId);
|
|
|
|
|
|
return JsonResult.success(notifyVo);
|
2025-10-22 10:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 调用退款接口
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param refundDto 退款请求参数
|
|
|
|
|
|
* @return 退款成功返回true,否则返回false
|
|
|
|
|
|
*/
|
|
|
|
|
|
@PostMapping("/refund")
|
2025-10-24 10:09:53 +08:00
|
|
|
|
public JsonResult<?> refund(@RequestBody EbikeRefundDto refundDto) {
|
2025-10-22 10:13:57 +08:00
|
|
|
|
// 获取审核人信息
|
|
|
|
|
|
String loginId = (String) StpUtil.getLoginId();
|
2025-10-24 10:09:53 +08:00
|
|
|
|
EbikeWxHandleNotifyVo r = wxPayService.refund(refundDto, loginId);
|
2025-10-22 10:13:57 +08:00
|
|
|
|
return r.isSuccess() ? JsonResult.success(true) : JsonResult.failed(r.getMessage());
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 通过退款单号查询退款信息
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param refundId 商户(骑行)退款id
|
|
|
|
|
|
* @return 退款信息
|
|
|
|
|
|
*/
|
|
|
|
|
|
@GetMapping("/queryRefund/{refundId}")
|
|
|
|
|
|
public JsonResult<?> refundQuery(@PathVariable(name = "refundId") Long refundId) {
|
2025-10-29 14:06:51 +08:00
|
|
|
|
Refund refund = wxPayService.queryRefundById(refundId);
|
|
|
|
|
|
return JsonResult.success(refund);
|
2025-10-22 10:13:57 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|