mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-02 02:34:34 +00:00
refactor(sdk): 重构 SDK 参数和响应模型
- 更新了多个 SDK 参数和响应模型类的结构 - 优化了字段注解和数据校验 -统一了代码风格,提高了可读性和可维护性
This commit is contained in:
@@ -17,7 +17,7 @@ import java.util.Objects;
|
||||
@AllArgsConstructor
|
||||
public enum CheckoutAggregateEnum {
|
||||
|
||||
WECHAT("wechat", "微信支付"),
|
||||
WECHAT("wechat_pay", "微信支付"),
|
||||
ALIPAY("alipay", "支付宝"),
|
||||
;
|
||||
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package org.dromara.daxpay.core.param.checkout;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.daxpay.core.enums.CheckoutAggregateEnum;
|
||||
@@ -15,17 +17,23 @@ import org.dromara.daxpay.core.enums.CheckoutAggregateEnum;
|
||||
@Schema(title = "收银台聚合支付参数")
|
||||
public class CheckoutAggregatePayParam {
|
||||
|
||||
@Schema(description = "要支付的订单号")
|
||||
/** 支付订单号 */
|
||||
@NotBlank(message = "支付订单号不可为空")
|
||||
@Size(max = 32, message = "支付订单号不可超过32位")
|
||||
@Schema(description = "支付订单号")
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* 聚合支付类型
|
||||
* @see CheckoutAggregateEnum
|
||||
*/
|
||||
@NotBlank(message = "聚合支付类型不可为空")
|
||||
@Schema(description = "聚合支付类型")
|
||||
private String aggregateType;
|
||||
|
||||
@Schema(description = "唯一标识")
|
||||
/** 用户唯一标识 */
|
||||
@Size(max = 1024, message = "唯一标识不可超过1024位")
|
||||
@Schema(description = "用户唯一标识")
|
||||
private String openId;
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package org.dromara.daxpay.core.param.checkout;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.dromara.daxpay.core.enums.CheckoutAggregateEnum;
|
||||
@@ -15,8 +16,9 @@ import org.dromara.daxpay.core.enums.CheckoutAggregateEnum;
|
||||
@Schema(title = "获取收银台认证结果参数")
|
||||
public class CheckoutAuthCodeParam {
|
||||
|
||||
/** 要支付的订单号 */
|
||||
@Schema(description = "要支付的订单号")
|
||||
/** 支付订单号 */
|
||||
@NotBlank(message = "支付订单号不可为空")
|
||||
@Schema(description = "支付订单号")
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
|
@@ -28,6 +28,7 @@ public class CheckoutCreatParam extends PaymentCommonParam {
|
||||
* 收银台类型
|
||||
* @see CheckoutTypeEnum
|
||||
*/
|
||||
@Size(max = 100, message = "收银台类型不可超过32位")
|
||||
@NotBlank(message = "收银台类型不可为空")
|
||||
private String checkoutType;
|
||||
|
||||
|
@@ -3,7 +3,9 @@ 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 io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.daxpay.core.param.assist.AuthCodeParam;
|
||||
import org.dromara.daxpay.core.param.assist.GenerateAuthUrlParam;
|
||||
import org.dromara.daxpay.core.result.DaxResult;
|
||||
@@ -13,9 +15,6 @@ 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;
|
||||
@@ -37,10 +36,10 @@ public class ChannelUniAuthController {
|
||||
|
||||
private final PaymentAssistService paymentAssistService;
|
||||
|
||||
@PaymentVerify
|
||||
@Operation(summary = "获取授权链接")
|
||||
@PostMapping("/generateAuthUrl")
|
||||
public Result<AuthUrlResult> generateAuthUrl(@RequestBody GenerateAuthUrlParam param){
|
||||
ValidationUtil.validateParam(param);
|
||||
paymentAssistService.initMchApp(param.getAppId());
|
||||
return Res.ok(channelAuthService.generateAuthUrl(param));
|
||||
}
|
||||
|
@@ -7,16 +7,14 @@ import cn.bootx.platform.core.util.ValidationUtil;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.daxpay.core.param.checkout.CheckoutAuthCodeParam;
|
||||
import org.dromara.daxpay.core.param.checkout.CheckoutAuthUrlParam;
|
||||
import org.dromara.daxpay.core.param.checkout.CheckoutCreatParam;
|
||||
import org.dromara.daxpay.core.param.checkout.CheckoutPayParam;
|
||||
import org.dromara.daxpay.core.param.checkout.*;
|
||||
import org.dromara.daxpay.core.result.DaxResult;
|
||||
import org.dromara.daxpay.core.result.assist.AuthResult;
|
||||
import org.dromara.daxpay.core.result.checkout.CheckoutAggregateOrderAndConfigResult;
|
||||
import org.dromara.daxpay.core.result.checkout.CheckoutOrderAndConfigResult;
|
||||
import org.dromara.daxpay.core.result.checkout.CheckoutPayResult;
|
||||
import org.dromara.daxpay.core.result.checkout.CheckoutUrlResult;
|
||||
import org.dromara.daxpay.core.result.trade.pay.PayResult;
|
||||
import org.dromara.daxpay.core.util.DaxRes;
|
||||
import org.dromara.daxpay.service.common.anno.PaymentVerify;
|
||||
import org.dromara.daxpay.service.service.checkout.CheckoutQueryService;
|
||||
@@ -28,6 +26,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
* @author xxm
|
||||
* @since 2024/11/26
|
||||
*/
|
||||
@IgnoreAuth
|
||||
@Tag(name = "收银台服务")
|
||||
@RestController
|
||||
@RequestMapping("/unipay/checkout")
|
||||
@@ -43,21 +42,18 @@ public class CheckoutController {
|
||||
return DaxRes.ok(checkoutService.creat(checkoutParam));
|
||||
}
|
||||
|
||||
@IgnoreAuth
|
||||
@Operation(summary = "获取收银台订单和配置信息")
|
||||
@GetMapping("/getOrderAndConfig")
|
||||
public Result<CheckoutOrderAndConfigResult> getOrderAndConfig(String orderNo, String checkoutType){
|
||||
return Res.ok(checkoutQueryService.getOrderAndConfig(orderNo, checkoutType));
|
||||
}
|
||||
|
||||
@IgnoreAuth
|
||||
@Operation(summary = "获取聚合支付配置")
|
||||
@GetMapping("/getAggregateConfig")
|
||||
public Result<CheckoutAggregateOrderAndConfigResult> getAggregateConfig(String orderNo, String aggregateType){
|
||||
return Res.ok(checkoutQueryService.getAggregateConfig(orderNo, aggregateType));
|
||||
}
|
||||
|
||||
@IgnoreAuth
|
||||
@Operation(summary = "获取收银台所需授权链接, 用于获取OpenId一类的信息")
|
||||
@PostMapping("/generateAuthUrl")
|
||||
public Result<String> generateAuthUrl(@RequestBody CheckoutAuthUrlParam param){
|
||||
@@ -65,7 +61,6 @@ public class CheckoutController {
|
||||
return Res.ok(checkoutService.generateAuthUrl(param));
|
||||
}
|
||||
|
||||
@IgnoreAuth
|
||||
@Operation(summary = "获取授权结果")
|
||||
@PostMapping("/auth")
|
||||
public Result<AuthResult> auth(@RequestBody CheckoutAuthCodeParam param){
|
||||
@@ -74,11 +69,21 @@ public class CheckoutController {
|
||||
}
|
||||
|
||||
|
||||
@IgnoreAuth
|
||||
@Operation(summary = "发起支付")
|
||||
@Operation(summary = "发起支付(普通)")
|
||||
@PostMapping("/pay")
|
||||
public Result<CheckoutPayResult> pay(@RequestBody CheckoutPayParam checkoutParam){
|
||||
return Res.ok(checkoutService.pay(checkoutParam));
|
||||
public Result<CheckoutPayResult> pay(@RequestBody CheckoutPayParam param){
|
||||
ValidationUtil.validateParam(param);
|
||||
return Res.ok(checkoutService.pay(param));
|
||||
}
|
||||
|
||||
|
||||
@Operation(summary = "发起支付(聚合)")
|
||||
@PostMapping("/aggregatePay")
|
||||
public Result<PayResult> aggregatePay(@RequestBody CheckoutAggregatePayParam param){
|
||||
ValidationUtil.validateParam(param);
|
||||
return Res.ok(checkoutService.aggregatePay(param));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user