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