104 lines
3.3 KiB
Java
104 lines
3.3 KiB
Java
package com.cdzy.payment.controller;
|
||
|
||
import cn.dev33.satoken.stp.StpUtil;
|
||
import com.cdzy.common.model.response.JsonResult;
|
||
import com.cdzy.payment.model.dto.EbikeRefundDto;
|
||
import com.cdzy.payment.model.vo.EbikeWxHandleNotifyVo;
|
||
import com.cdzy.payment.service.EbikeWxPayService;
|
||
import com.fasterxml.jackson.databind.JsonNode;
|
||
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.*;
|
||
|
||
/**
|
||
* 用户订单微信支付 控制层。
|
||
*
|
||
* @author yanglei
|
||
* @since 2025-10-21 14:42
|
||
*/
|
||
|
||
@Slf4j
|
||
@RestController
|
||
@RequestMapping("/wxPayment")
|
||
public class EbikeWxPaymentController {
|
||
|
||
@Resource
|
||
private EbikeWxPayService wxPayService;
|
||
|
||
/**
|
||
* 微信支付下单
|
||
*
|
||
* @param orderId 骑行订单id
|
||
* @return 下单成功返回true,否则返回false
|
||
*/
|
||
@GetMapping("/prepay")
|
||
public JsonResult<?> prepay(@RequestParam(name = "orderId") Long orderId) {
|
||
JsonNode r = wxPayService.prepay(orderId);
|
||
return JsonResult.success(r);
|
||
}
|
||
|
||
/**
|
||
* 通过商户(骑行)订单号查询支付订单
|
||
*
|
||
* @param orderId 商户(骑行)订单号
|
||
* @return 支付订单信息
|
||
*/
|
||
@GetMapping("/queryOrder/{orderId}")
|
||
public JsonResult<?> queryOrderByOrderId(@PathVariable(name = "orderId") Long orderId) {
|
||
Transaction transaction = wxPayService.queryOrderByOrderId(orderId);
|
||
return JsonResult.success(transaction);
|
||
}
|
||
|
||
/**
|
||
* 通过商户(骑行)订单订单号查询支付订单状态
|
||
*
|
||
* @param orderId 微信支付订单号
|
||
* @return 订单信息支付状态
|
||
*/
|
||
@GetMapping("/queryOrderStatus/{orderId}")
|
||
public JsonResult<?> queryOrderStatusById(@PathVariable(name = "orderId") Long orderId) {
|
||
EbikeWxHandleNotifyVo r = wxPayService.queryOrderStatusByOrderId(orderId);
|
||
return JsonResult.success(r);
|
||
}
|
||
|
||
/**
|
||
* 通过退款记录主键id查询退款信息
|
||
*
|
||
* @param refundId 退款主键id
|
||
* @return 退款状态信息
|
||
*/
|
||
@GetMapping("/queryRefundStatus/{refundId}")
|
||
public JsonResult<?> queryRefundStatus(@PathVariable(name = "refundId") Long refundId) {
|
||
EbikeWxHandleNotifyVo notifyVo = wxPayService.queryRefundStatusById(refundId);
|
||
return JsonResult.success(notifyVo);
|
||
}
|
||
|
||
/**
|
||
* 调用退款接口
|
||
*
|
||
* @param refundDto 退款请求参数
|
||
* @return 退款成功返回true,否则返回false
|
||
*/
|
||
@PostMapping("/refund")
|
||
public JsonResult<?> refund(@RequestBody EbikeRefundDto refundDto) {
|
||
// 获取审核人信息
|
||
String loginId = (String) StpUtil.getLoginId();
|
||
EbikeWxHandleNotifyVo r = wxPayService.refund(refundDto, loginId);
|
||
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) {
|
||
Refund refund = wxPayService.queryRefundById(refundId);
|
||
return JsonResult.success(refund);
|
||
}
|
||
}
|