订单查询接口
This commit is contained in:
@ -2,6 +2,8 @@ package com.sczx.pay.controller;
|
|||||||
|
|
||||||
import com.sczx.pay.dto.*;
|
import com.sczx.pay.dto.*;
|
||||||
import com.sczx.pay.service.AlipayService;
|
import com.sczx.pay.service.AlipayService;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
@ -11,6 +13,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Api(value = "支付宝支付接口", tags = "支付宝支付接口")
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/api/alipay")
|
@RequestMapping("/api/alipay")
|
||||||
@ -22,6 +25,7 @@ public class AliPaymentController {
|
|||||||
/**
|
/**
|
||||||
* 支付宝统一下单接口
|
* 支付宝统一下单接口
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation(value = "支付宝统一下单接口")
|
||||||
@PostMapping("/unifiedOrder")
|
@PostMapping("/unifiedOrder")
|
||||||
public AlipayCreateResponse aliPayUnifiedOrder(@RequestBody AlipayCreateRequest request) {
|
public AlipayCreateResponse aliPayUnifiedOrder(@RequestBody AlipayCreateRequest request) {
|
||||||
log.info("收到支付宝支付请求: {}", request);
|
log.info("收到支付宝支付请求: {}", request);
|
||||||
@ -31,15 +35,17 @@ public class AliPaymentController {
|
|||||||
/**
|
/**
|
||||||
* 查询订单接口
|
* 查询订单接口
|
||||||
*/
|
*/
|
||||||
@GetMapping("/query/{companyId}/{outTradeNo}")
|
@ApiOperation(value = "查询订单接口")
|
||||||
public AlipayQueryResponse alipayOrderQuery(@PathVariable Long companyId, @PathVariable String outTradeNo) {
|
@GetMapping("/query/{outTradeNo}")
|
||||||
log.info("收到支付宝订单查询请求,公司ID: {}, 订单号: {}", companyId, outTradeNo);
|
public AlipayQueryResponse alipayOrderQuery(@PathVariable String outTradeNo) {
|
||||||
return alipayService.orderQuery(companyId, outTradeNo);
|
log.info("收到支付宝订单查询请求, 订单号: {}", outTradeNo);
|
||||||
|
return alipayService.orderQuery(outTradeNo);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭订单接口
|
* 关闭订单接口
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation(value = "关闭订单接口")
|
||||||
@PostMapping("/close")
|
@PostMapping("/close")
|
||||||
public AlipayResponse alipayCloseOrder(@RequestBody AlipayCloseRequest request) {
|
public AlipayResponse alipayCloseOrder(@RequestBody AlipayCloseRequest request) {
|
||||||
log.info("收到支付宝关闭订单请求: {}", request);
|
log.info("收到支付宝关闭订单请求: {}", request);
|
||||||
@ -49,6 +55,7 @@ public class AliPaymentController {
|
|||||||
/**
|
/**
|
||||||
* 申请退款接口
|
* 申请退款接口
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation(value = "申请退款接口")
|
||||||
@PostMapping("/refund")
|
@PostMapping("/refund")
|
||||||
public AlipayResponse alipayRefund(@RequestBody AlipayRefundRequest request) {
|
public AlipayResponse alipayRefund(@RequestBody AlipayRefundRequest request) {
|
||||||
log.info("收到支付宝退款请求: {}", request);
|
log.info("收到支付宝退款请求: {}", request);
|
||||||
@ -58,6 +65,7 @@ public class AliPaymentController {
|
|||||||
/**
|
/**
|
||||||
* 查询退款接口
|
* 查询退款接口
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation(value = "查询退款接口")
|
||||||
@PostMapping("/refundQuery")
|
@PostMapping("/refundQuery")
|
||||||
public AlipayResponse alipayRefundQuery(@RequestBody AlipayRefundRequest request) {
|
public AlipayResponse alipayRefundQuery(@RequestBody AlipayRefundRequest request) {
|
||||||
log.info("收到支付宝退款查询请求: {}", request);
|
log.info("收到支付宝退款查询请求: {}", request);
|
||||||
@ -67,6 +75,7 @@ public class AliPaymentController {
|
|||||||
/**
|
/**
|
||||||
* 支付宝支付结果通知
|
* 支付宝支付结果通知
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation(value = "支付宝支付结果通知")
|
||||||
@PostMapping("/notify")
|
@PostMapping("/notify")
|
||||||
public String alipayNotify(HttpServletRequest request) {
|
public String alipayNotify(HttpServletRequest request) {
|
||||||
try {
|
try {
|
||||||
@ -125,6 +134,7 @@ public class AliPaymentController {
|
|||||||
/**
|
/**
|
||||||
* 支付宝退款结果通知
|
* 支付宝退款结果通知
|
||||||
*/
|
*/
|
||||||
|
@ApiOperation(value = "支付宝退款结果通知")
|
||||||
@PostMapping("/refundNotify")
|
@PostMapping("/refundNotify")
|
||||||
public String alipayRefundNotify(HttpServletRequest request) {
|
public String alipayRefundNotify(HttpServletRequest request) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@ -13,7 +13,7 @@ public interface AlipayService {
|
|||||||
/**
|
/**
|
||||||
* 查询订单
|
* 查询订单
|
||||||
*/
|
*/
|
||||||
AlipayQueryResponse orderQuery(Long companyId, String outTradeNo);
|
AlipayQueryResponse orderQuery(String outTradeNo);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 关闭订单
|
* 关闭订单
|
||||||
|
|||||||
@ -122,7 +122,7 @@ public class AlipayServiceImpl implements AlipayService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public AlipayQueryResponse orderQuery(Long companyId, String outTradeNo) {
|
public AlipayQueryResponse orderQuery(String outTradeNo) {
|
||||||
AlipayQueryResponse response = new AlipayQueryResponse();
|
AlipayQueryResponse response = new AlipayQueryResponse();
|
||||||
try {
|
try {
|
||||||
// AlipayClient alipayClient = alipayConf.alipayClient();
|
// AlipayClient alipayClient = alipayConf.alipayClient();
|
||||||
@ -155,7 +155,7 @@ public class AlipayServiceImpl implements AlipayService {
|
|||||||
response.setMessage("查询支付单失败: " + alipayResponse.getMsg() + ":" + alipayResponse.getSubMsg());
|
response.setMessage("查询支付单失败: " + alipayResponse.getMsg() + ":" + alipayResponse.getSubMsg());
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.error("支付宝订单查询异常,公司ID: {}, 订单号: {}", companyId, outTradeNo, e);
|
log.error("支付宝订单查询异常,订单号: {}", outTradeNo, e);
|
||||||
response.setSuccess(false);
|
response.setSuccess(false);
|
||||||
response.setCode("FAIL");
|
response.setCode("FAIL");
|
||||||
response.setMessage("支付宝订单查询败异常: " + e.getMessage());
|
response.setMessage("支付宝订单查询败异常: " + e.getMessage());
|
||||||
|
|||||||
Reference in New Issue
Block a user