mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-03 11:06:46 +00:00
ref controller控制器移植
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
package org.dromara.daxpay.service.aop;
|
||||
|
||||
import cn.bootx.platform.core.exception.ValidationFailedException;
|
||||
import cn.bootx.platform.core.util.ValidationUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.dromara.daxpay.core.exception.PayFailureException;
|
||||
import org.dromara.daxpay.core.param.PaymentCommonParam;
|
||||
import org.dromara.daxpay.core.result.DaxResult;
|
||||
import org.dromara.daxpay.service.service.assist.PaymentAssistService;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 支付签名切面, 用于对支付参数进行校验和签名
|
||||
* 执行顺序: 过滤器 -> 拦截器 -> 切面 -> 方法
|
||||
* @author xxm
|
||||
* @since 2023/12/24
|
||||
*/
|
||||
@Aspect
|
||||
@Slf4j
|
||||
@Component
|
||||
@Order()
|
||||
@RequiredArgsConstructor
|
||||
public class PaymentVerifyAspect {
|
||||
private final PaymentAssistService paymentAssistService;
|
||||
|
||||
/**
|
||||
* 切面处理
|
||||
*/
|
||||
@Around("@annotation(org.dromara.daxpay.service.common.anno.PaymentVerify)||within(@org.dromara.daxpay.service.common.anno.PaymentVerify *)")
|
||||
public Object methodPoint(ProceedingJoinPoint pjp) throws Throwable {
|
||||
Object[] args = pjp.getArgs();
|
||||
if (args.length == 0){
|
||||
throw new ValidationFailedException("支付方法至少有一个参数,并且需要签名的支付参数放在第一位");
|
||||
}
|
||||
Object param = args[0];
|
||||
if (param instanceof PaymentCommonParam paymentParam){
|
||||
// 参数校验
|
||||
ValidationUtil.validateParam(paymentParam);
|
||||
// 应用信息初始化
|
||||
paymentAssistService.initMchApp(paymentParam.getAppId());
|
||||
// 终端信息初始化
|
||||
paymentAssistService.initClient(paymentParam);
|
||||
// 参数签名校验
|
||||
paymentAssistService.signVerify(paymentParam);
|
||||
// 参数请求时间校验
|
||||
paymentAssistService.reqTimeoutVerify(paymentParam);
|
||||
|
||||
} else {
|
||||
throw new ValidationFailedException("参数需要继承PayCommonParam");
|
||||
}
|
||||
Object proceed;
|
||||
try {
|
||||
proceed = pjp.proceed();
|
||||
} catch (PayFailureException ex) {
|
||||
DaxResult<Void> result = new DaxResult<>(ex.getCode(), ex.getMessage());
|
||||
paymentAssistService.sign(result);
|
||||
return result;
|
||||
}
|
||||
// 对返回值进行签名
|
||||
if (proceed instanceof DaxResult<?> result){
|
||||
paymentAssistService.sign(result);
|
||||
} else {
|
||||
throw new ValidationFailedException("支付方法返回类型需要为 DaxResult 类型的对象");
|
||||
}
|
||||
return proceed;
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,63 @@
|
||||
package org.dromara.daxpay.service.controller.unipay;
|
||||
|
||||
import cn.bootx.platform.core.annotation.IgnoreAuth;
|
||||
import cn.bootx.platform.core.rest.Res;
|
||||
import cn.bootx.platform.core.rest.result.Result;
|
||||
import cn.bootx.platform.core.util.ValidationUtil;
|
||||
import org.dromara.daxpay.core.param.assist.AuthCodeParam;
|
||||
import org.dromara.daxpay.core.param.assist.GenerateAuthUrlParam;
|
||||
import org.dromara.daxpay.core.result.DaxResult;
|
||||
import org.dromara.daxpay.core.result.assist.AuthResult;
|
||||
import org.dromara.daxpay.core.result.assist.AuthUrlResult;
|
||||
import org.dromara.daxpay.core.util.DaxRes;
|
||||
import org.dromara.daxpay.service.common.anno.PaymentVerify;
|
||||
import org.dromara.daxpay.service.service.assist.ChannelAuthService;
|
||||
import org.dromara.daxpay.service.service.assist.PaymentAssistService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 通道认证服务
|
||||
* @author xxm
|
||||
* @since 2024/9/24
|
||||
*/
|
||||
@IgnoreAuth
|
||||
@Tag(name = "通道认证服务")
|
||||
@RestController
|
||||
@RequestMapping("/unipay/assist/channel/auth")
|
||||
@RequiredArgsConstructor
|
||||
public class ChannelAuthController {
|
||||
|
||||
private final ChannelAuthService channelAuthService;
|
||||
|
||||
private final PaymentAssistService paymentAssistService;
|
||||
|
||||
@Operation(summary = "获取授权链接")
|
||||
@PostMapping("/generateAuthUrl")
|
||||
public Result<AuthUrlResult> generateAuthUrl(@RequestBody GenerateAuthUrlParam param){
|
||||
ValidationUtil.validateParam(param);
|
||||
paymentAssistService.initMchAndApp(param.getAppId());
|
||||
return Res.ok(channelAuthService.generateAuthUrl(param));
|
||||
}
|
||||
|
||||
@PaymentVerify
|
||||
@Operation(summary = "通过AuthCode获取认证结果")
|
||||
@PostMapping("/auth")
|
||||
public DaxResult<AuthResult> auth(@RequestBody AuthCodeParam param){
|
||||
return DaxRes.ok(channelAuthService.auth(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过AuthCode获取并设置认证结果")
|
||||
@PostMapping("/authAndSet")
|
||||
public Result<Void> authAndSet(@RequestBody AuthCodeParam param){
|
||||
paymentAssistService.initMchAndApp(param.getAppId());
|
||||
channelAuthService.auth(param);
|
||||
return Res.ok();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,81 @@
|
||||
package org.dromara.daxpay.service.controller.unipay;
|
||||
|
||||
import cn.bootx.platform.core.annotation.IgnoreAuth;
|
||||
import cn.bootx.platform.core.rest.Res;
|
||||
import cn.bootx.platform.core.rest.result.Result;
|
||||
import cn.bootx.platform.core.util.ValidationUtil;
|
||||
import org.dromara.daxpay.core.param.cashier.CashierAuthCodeParam;
|
||||
import org.dromara.daxpay.core.param.cashier.CashierAuthUrlParam;
|
||||
import org.dromara.daxpay.core.param.cashier.CashierPayParam;
|
||||
import org.dromara.daxpay.core.result.assist.AuthResult;
|
||||
import org.dromara.daxpay.core.result.trade.pay.PayResult;
|
||||
import org.dromara.daxpay.service.common.cache.MerchantCacheService;
|
||||
import org.dromara.daxpay.service.entity.merchant.Merchant;
|
||||
import org.dromara.daxpay.service.result.config.ChannelCashierConfigResult;
|
||||
import org.dromara.daxpay.service.service.assist.PaymentAssistService;
|
||||
import org.dromara.daxpay.service.service.cashier.ChannelCashierService;
|
||||
import org.dromara.daxpay.service.service.config.ChannelCashierConfigService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
/**
|
||||
* 通道收银台服务
|
||||
* @author xxm
|
||||
* @since 2024/9/28
|
||||
*/
|
||||
@IgnoreAuth
|
||||
@Tag(name = "通道收银台服务")
|
||||
@RestController
|
||||
@RequestMapping("/unipay/ext/channel/cashier")
|
||||
@RequiredArgsConstructor
|
||||
public class ChannelCashierController {
|
||||
|
||||
private final ChannelCashierService channelCashierService;
|
||||
|
||||
private final PaymentAssistService paymentAssistService;
|
||||
|
||||
private final ChannelCashierConfigService cashierConfigService;
|
||||
|
||||
private final MerchantCacheService merchantCacheService;
|
||||
|
||||
@Operation(summary = "获取商户名称")
|
||||
@GetMapping("/getMchName")
|
||||
public Result<String> getMchName(String mchNo){
|
||||
Merchant merchant = merchantCacheService.get(mchNo);
|
||||
return Res.ok(merchant.getMchName());
|
||||
}
|
||||
|
||||
@Operation(summary = "获取收银台信息")
|
||||
@GetMapping("/getCashierType")
|
||||
public Result<ChannelCashierConfigResult> getCashierType(String cashierType,String appId){
|
||||
paymentAssistService.initMchAndApp(appId);
|
||||
return Res.ok(cashierConfigService.findByCashierType(cashierType));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "获取收银台所需授权链接, 用于获取OpenId一类的信息")
|
||||
@PostMapping("/generateAuthUrl")
|
||||
public Result<String> generateAuthUrl(@RequestBody CashierAuthUrlParam param){
|
||||
ValidationUtil.validateParam(param);
|
||||
paymentAssistService.initMchAndApp(param.getMchNo(), param.getAppId());
|
||||
return Res.ok(channelCashierService.generateAuthUrl(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "获取授权结果")
|
||||
@PostMapping("/auth")
|
||||
public Result<AuthResult> auth(@RequestBody CashierAuthCodeParam param){
|
||||
ValidationUtil.validateParam(param);
|
||||
paymentAssistService.initMchAndApp(param.getMchNo(), param.getAppId());
|
||||
return Res.ok(channelCashierService.auth(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "发起支付")
|
||||
@PostMapping("/pay")
|
||||
public Result<PayResult> cashierPay(@RequestBody CashierPayParam param){
|
||||
ValidationUtil.validateParam(param);
|
||||
paymentAssistService.initMchAndApp(param.getMchNo(), param.getAppId());
|
||||
return Res.ok(channelCashierService.cashierPay(param));
|
||||
}
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package org.dromara.daxpay.service.controller.unipay;
|
||||
|
||||
import cn.bootx.platform.core.annotation.IgnoreAuth;
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
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 java.util.Map;
|
||||
|
||||
/**
|
||||
* 测试回调接受控制器
|
||||
* @author xxm
|
||||
* @since 2024/8/30
|
||||
*/
|
||||
@Slf4j
|
||||
@Tag(name = "测试商户回调接收控制器")
|
||||
@RestController
|
||||
@RequestMapping("/test/callback")
|
||||
@RequiredArgsConstructor
|
||||
@IgnoreAuth
|
||||
public class TestCallbackController {
|
||||
|
||||
@Operation(summary = "notify")
|
||||
@PostMapping("/notify")
|
||||
public String notify(@RequestBody Map<String,Object> date){
|
||||
log.info("notify:{}",date);
|
||||
ThreadUtil.sleep(6*1000L);
|
||||
return "success";
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
package org.dromara.daxpay.service.controller.unipay;
|
||||
|
||||
import cn.bootx.platform.core.annotation.IgnoreAuth;
|
||||
import org.dromara.daxpay.core.result.DaxResult;
|
||||
import org.dromara.daxpay.core.util.DaxRes;
|
||||
import org.dromara.daxpay.service.common.anno.PaymentVerify;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* 分账控制器
|
||||
* @author xxm
|
||||
* @since 2024/5/17
|
||||
*/
|
||||
@PaymentVerify
|
||||
@IgnoreAuth
|
||||
@Tag(name = "分账控制器")
|
||||
@RestController
|
||||
@RequestMapping("/unipay/alloc")
|
||||
@RequiredArgsConstructor
|
||||
public class UniAllocationController {
|
||||
|
||||
@Operation(summary = "发起分账接口")
|
||||
@PostMapping("/start")
|
||||
public DaxResult<Void> start(){
|
||||
return DaxRes.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "分账完结接口")
|
||||
@PostMapping("/finish")
|
||||
public DaxResult<Void> finish(){
|
||||
return DaxRes.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "分账接收方添加接口")
|
||||
@PostMapping("/receiver/add")
|
||||
public DaxResult<Void> receiverAdd(){
|
||||
return DaxRes.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "分账接收方删除接口")
|
||||
@PostMapping("/receiver/remove")
|
||||
public DaxResult<Void> receiverRemove(){
|
||||
return DaxRes.ok();
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,59 @@
|
||||
package org.dromara.daxpay.service.controller.unipay;
|
||||
|
||||
import cn.bootx.platform.core.annotation.IgnoreAuth;
|
||||
import org.dromara.daxpay.core.param.trade.pay.QueryPayParam;
|
||||
import org.dromara.daxpay.core.param.trade.refund.QueryRefundParam;
|
||||
import org.dromara.daxpay.core.param.trade.transfer.QueryTransferParam;
|
||||
import org.dromara.daxpay.core.result.DaxResult;
|
||||
import org.dromara.daxpay.core.result.trade.pay.PayOrderResult;
|
||||
import org.dromara.daxpay.core.result.trade.refund.RefundOrderResult;
|
||||
import org.dromara.daxpay.core.result.trade.transfer.TransferOrderResult;
|
||||
import org.dromara.daxpay.core.util.DaxRes;
|
||||
import org.dromara.daxpay.service.common.anno.PaymentVerify;
|
||||
import org.dromara.daxpay.service.service.order.pay.PayOrderQueryService;
|
||||
import org.dromara.daxpay.service.service.order.refund.RefundOrderQueryService;
|
||||
import org.dromara.daxpay.service.service.order.transfer.TransferOrderQueryService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 统一查询接口
|
||||
* @author xxm
|
||||
* @since 2024/6/4
|
||||
*/
|
||||
@PaymentVerify
|
||||
@IgnoreAuth
|
||||
@Tag(name = "统一查询接口")
|
||||
@RestController
|
||||
@RequestMapping("/unipay/query")
|
||||
@RequiredArgsConstructor
|
||||
public class UniQueryController {
|
||||
|
||||
private final PayOrderQueryService payOrderQueryService;
|
||||
private final RefundOrderQueryService refundOrderQueryService;
|
||||
private final TransferOrderQueryService transferOrderQueryService;
|
||||
|
||||
@Operation(summary = "支付订单查询接口")
|
||||
@PostMapping("/payOrder")
|
||||
public DaxResult<PayOrderResult> queryPayOrder(@RequestBody QueryPayParam param){
|
||||
return DaxRes.ok(payOrderQueryService.queryPayOrder(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "退款订单查询接口")
|
||||
@PostMapping("/refundOrder")
|
||||
public DaxResult<RefundOrderResult> queryRefundOrder(@RequestBody QueryRefundParam param){
|
||||
return DaxRes.ok(refundOrderQueryService.queryRefundOrder(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "转账订单查询接口")
|
||||
@PostMapping("/transferOrder")
|
||||
public DaxResult<TransferOrderResult> transferOrder(@RequestBody QueryTransferParam param){
|
||||
return DaxRes.ok(transferOrderQueryService.queryTransferOrder(param));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
package org.dromara.daxpay.service.controller.unipay;
|
||||
|
||||
import cn.bootx.platform.core.annotation.IgnoreAuth;
|
||||
import org.dromara.daxpay.core.param.reconcile.ReconcileDownParam;
|
||||
import org.dromara.daxpay.core.result.DaxResult;
|
||||
import org.dromara.daxpay.core.result.reconcile.ReconcileDownResult;
|
||||
import org.dromara.daxpay.core.util.DaxRes;
|
||||
import org.dromara.daxpay.service.common.anno.PaymentVerify;
|
||||
import org.dromara.daxpay.service.service.reconcile.ReconcileStatementQueryService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 对账接口处理器
|
||||
* @author xxm
|
||||
* @since 2024/6/4
|
||||
*/
|
||||
@PaymentVerify
|
||||
@IgnoreAuth
|
||||
@Tag(name = "对账接口处理器")
|
||||
@RestController
|
||||
@RequestMapping("/unipay/reconcile")
|
||||
@RequiredArgsConstructor
|
||||
public class UniReconcileController {
|
||||
|
||||
private final ReconcileStatementQueryService statementQueryService;
|
||||
|
||||
@Operation(summary = "下载通道对账单链接")
|
||||
@PostMapping("/channelDownUrl")
|
||||
public DaxResult<ReconcileDownResult> channelDownUrl(@RequestBody ReconcileDownParam param){
|
||||
return DaxRes.ok(statementQueryService.getChannelDownUrl(param.getChannel(), param.getDate()));
|
||||
}
|
||||
|
||||
@Operation(summary = "下载平台对账单链接")
|
||||
@PostMapping("/platformDownUrl")
|
||||
public DaxResult<ReconcileDownResult> platformDownUrl(@RequestBody ReconcileDownParam param){
|
||||
return DaxRes.ok(statementQueryService.getPlatformDownUrl(param.getChannel(), param.getDate()));
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,61 @@
|
||||
package org.dromara.daxpay.service.controller.unipay;
|
||||
|
||||
import cn.bootx.platform.core.annotation.IgnoreAuth;
|
||||
import org.dromara.daxpay.core.param.trade.pay.PaySyncParam;
|
||||
import org.dromara.daxpay.core.param.trade.refund.RefundSyncParam;
|
||||
import org.dromara.daxpay.core.param.trade.transfer.TransferSyncParam;
|
||||
import org.dromara.daxpay.core.result.DaxResult;
|
||||
import org.dromara.daxpay.core.result.trade.pay.PaySyncResult;
|
||||
import org.dromara.daxpay.core.result.trade.refund.RefundSyncResult;
|
||||
import org.dromara.daxpay.core.result.trade.transfer.TransferSyncResult;
|
||||
import org.dromara.daxpay.core.util.DaxRes;
|
||||
import org.dromara.daxpay.service.common.anno.PaymentVerify;
|
||||
import org.dromara.daxpay.service.service.trade.pay.PaySyncService;
|
||||
import org.dromara.daxpay.service.service.trade.refund.RefundSyncService;
|
||||
import org.dromara.daxpay.service.service.trade.transfer.TransferSyncService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 统一同步接口
|
||||
* @author xxm
|
||||
* @since 2024/6/4
|
||||
*/
|
||||
@PaymentVerify
|
||||
@IgnoreAuth
|
||||
@Tag(name = "统一同步接口")
|
||||
@RestController
|
||||
@RequestMapping("/unipay/sync/order")
|
||||
@RequiredArgsConstructor
|
||||
public class UniSyncController {
|
||||
|
||||
private final PaySyncService paySyncService;
|
||||
|
||||
private final RefundSyncService refundSyncService;
|
||||
|
||||
private final TransferSyncService transferSyncService;
|
||||
|
||||
|
||||
@Operation(summary = "支付订单同步接口")
|
||||
@PostMapping("/pay")
|
||||
public DaxResult<PaySyncResult> pay(@RequestBody PaySyncParam param){
|
||||
return DaxRes.ok(paySyncService.sync(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "退款订单同步接口")
|
||||
@PostMapping("/refund")
|
||||
public DaxResult<RefundSyncResult> refund(@RequestBody RefundSyncParam param){
|
||||
return DaxRes.ok(refundSyncService.sync(param));
|
||||
}
|
||||
|
||||
@Operation(summary = "分账订单同步接口")
|
||||
@PostMapping("/allocation")
|
||||
public DaxResult<TransferSyncResult> allocation(@RequestBody TransferSyncParam param){
|
||||
return DaxRes.ok(transferSyncService.sync(param));
|
||||
}
|
||||
}
|
@@ -0,0 +1,67 @@
|
||||
package org.dromara.daxpay.service.controller.unipay;
|
||||
|
||||
import cn.bootx.platform.core.annotation.IgnoreAuth;
|
||||
import org.dromara.daxpay.core.param.trade.pay.PayCloseParam;
|
||||
import org.dromara.daxpay.core.param.trade.pay.PayParam;
|
||||
import org.dromara.daxpay.core.param.trade.refund.RefundParam;
|
||||
import org.dromara.daxpay.core.param.trade.transfer.TransferParam;
|
||||
import org.dromara.daxpay.core.result.DaxResult;
|
||||
import org.dromara.daxpay.core.result.trade.pay.PayResult;
|
||||
import org.dromara.daxpay.core.result.trade.refund.RefundResult;
|
||||
import org.dromara.daxpay.core.result.trade.transfer.TransferResult;
|
||||
import org.dromara.daxpay.core.util.DaxRes;
|
||||
import org.dromara.daxpay.service.common.anno.PaymentVerify;
|
||||
import org.dromara.daxpay.service.service.trade.pay.PayCloseService;
|
||||
import org.dromara.daxpay.service.service.trade.pay.PayService;
|
||||
import org.dromara.daxpay.service.service.trade.refund.RefundService;
|
||||
import org.dromara.daxpay.service.service.trade.transfer.TransferService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 统一支付接口
|
||||
* @author xxm
|
||||
* @since 2024/6/4
|
||||
*/
|
||||
@IgnoreAuth
|
||||
@Tag(name = "统一交易接口")
|
||||
@PaymentVerify // 所有接口都属于支付接口
|
||||
@RestController
|
||||
@RequestMapping("/unipay")
|
||||
@RequiredArgsConstructor
|
||||
public class UniTradeController {
|
||||
private final PayService payService;
|
||||
private final RefundService refundService;
|
||||
private final PayCloseService payCloseService;
|
||||
private final TransferService transferService;
|
||||
|
||||
@Operation(summary = "支付接口")
|
||||
@PostMapping("/pay")
|
||||
public DaxResult<PayResult> pay(@RequestBody PayParam payParam){
|
||||
return DaxRes.ok(payService.pay(payParam));
|
||||
}
|
||||
|
||||
@Operation(summary = "退款接口")
|
||||
@PostMapping("/refund")
|
||||
public DaxResult<RefundResult> refund(@RequestBody RefundParam payParam){
|
||||
return DaxRes.ok(refundService.refund(payParam));
|
||||
}
|
||||
|
||||
@Operation(summary = "关闭和撤销接口")
|
||||
@PostMapping("/close")
|
||||
public DaxResult<Void> reconcile(@RequestBody PayCloseParam param){
|
||||
payCloseService.close(param);
|
||||
return DaxRes.ok();
|
||||
}
|
||||
|
||||
@Operation(summary = "转账接口")
|
||||
@PostMapping("/transfer")
|
||||
public DaxResult<TransferResult> transfer(@RequestBody TransferParam transferParam){
|
||||
return DaxRes.ok(transferService.transfer(transferParam));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user