diff --git a/daxpay-single-demo/src/main/java/cn/bootx/platform/daxpay/demo/param/CashierSimplePayParam.java b/daxpay-single-demo/src/main/java/cn/bootx/platform/daxpay/demo/param/CashierSimplePayParam.java index da989dad..89c4d330 100644 --- a/daxpay-single-demo/src/main/java/cn/bootx/platform/daxpay/demo/param/CashierSimplePayParam.java +++ b/daxpay-single-demo/src/main/java/cn/bootx/platform/daxpay/demo/param/CashierSimplePayParam.java @@ -18,31 +18,32 @@ import java.math.BigDecimal; @Schema(title = "结算台简单支付参数(单通道支付)") public class CashierSimplePayParam { - @Schema(description = "业务号") - @NotNull + @Schema(description = "商户订单号") + @NotNull(message = "商户订单号不能为空") private String bizOrderNo; @Schema(description = "是否分账") + @NotNull(message = "分账是否启用必输") private Boolean allocation; @Schema(description = "标题") - @NotNull + @NotNull(message = "标题不能为空") private String title; @Schema(description = "金额") - @NotNull + @NotNull(message = "金额不能为空") private BigDecimal amount; @Schema(description = "openId(微信支付时使用)") private String openId; @Schema(description = "支付通道") - @NotNull + @NotNull(message = "支付通道不能为空") private String channel; @Schema(description = "支付方式") - @NotNull - private String payWay; + @NotNull(message = "支付方式不能为空") + private String method; @Schema(description = "付款码") private String authCode; diff --git a/daxpay-single-demo/src/main/java/cn/bootx/platform/daxpay/demo/service/CashierService.java b/daxpay-single-demo/src/main/java/cn/bootx/platform/daxpay/demo/service/CashierService.java index a38967ab..febf039d 100644 --- a/daxpay-single-demo/src/main/java/cn/bootx/platform/daxpay/demo/service/CashierService.java +++ b/daxpay-single-demo/src/main/java/cn/bootx/platform/daxpay/demo/service/CashierService.java @@ -50,49 +50,49 @@ public class CashierService { */ public PayOrderResult simplePayCashier(CashierSimplePayParam param){ // 将参数转换为简单支付参数 - PayParam simplePayParam = new PayParam(); - simplePayParam.setBizOrderNo(param.getChannel()); - simplePayParam.setAllocation(param.getAllocation()); + PayParam payParam = new PayParam(); + payParam.setBizOrderNo(param.getBizOrderNo()); + payParam.setAllocation(param.getAllocation()); int amount = param.getAmount() .multiply(BigDecimal.valueOf(100)) .intValue(); - simplePayParam.setTitle(param.getTitle()); - simplePayParam.setAmount(amount); - simplePayParam.setChannel(param.getChannel()); - simplePayParam.setMethod(param.getPayWay()); + payParam.setTitle(param.getTitle()); + payParam.setAmount(amount); + payParam.setChannel(param.getChannel()); + payParam.setMethod(param.getMethod()); // 支付宝通道 if (Objects.equals(PayChannelEnum.ALI.getCode(), param.getChannel())){ // 付款码支付 - if (Objects.equals(PayMethodEnum.BARCODE.getCode(), param.getPayWay())){ + if (Objects.equals(PayMethodEnum.BARCODE.getCode(), param.getMethod())){ AliPayParam aliPayParam = new AliPayParam(); aliPayParam.setAuthCode(param.getAuthCode()); - simplePayParam.setExtraParam(aliPayParam); + payParam.setExtraParam(aliPayParam); } } // 微信通道 if (Objects.equals(PayChannelEnum.WECHAT.getCode(), param.getChannel())){ WeChatPayParam wechatPayParam = new WeChatPayParam(); // 付款码支付 - if (Objects.equals(PayMethodEnum.BARCODE.getCode(), param.getPayWay())){ + if (Objects.equals(PayMethodEnum.BARCODE.getCode(), param.getMethod())){ wechatPayParam.setAuthCode(param.getAuthCode()); - simplePayParam.setExtraParam(wechatPayParam); + payParam.setExtraParam(wechatPayParam); } // 微信jsapi 方式支付 - if (Objects.equals(PayMethodEnum.JSAPI.getCode(), param.getPayWay())){ + if (Objects.equals(PayMethodEnum.JSAPI.getCode(), param.getMethod())){ wechatPayParam.setOpenId(param.getOpenId()); - simplePayParam.setExtraParam(wechatPayParam); + payParam.setExtraParam(wechatPayParam); } } String ip = Optional.ofNullable(WebServletUtil.getRequest()) .map(ServletUtil::getClientIP) .orElse("127.0.0.1"); - simplePayParam.setClientIp(ip); + payParam.setClientIp(ip); // 同步回调地址 - simplePayParam.setReturnUrl(StrUtil.format("{}/result/success", daxPayDemoProperties.getFrontH5Url())); + payParam.setReturnUrl(StrUtil.format("{}/result/success", daxPayDemoProperties.getFrontH5Url())); // 发起支付 - DaxPayResult execute = DaxPayKit.execute(simplePayParam); + DaxPayResult execute = DaxPayKit.execute(payParam); // 判断是否支付成功 if (execute.getCode() != 0){ throw new BizException(execute.getMsg()); diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/configuration/DaxPayProperties.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/configuration/DaxPayProperties.java index df02532c..c7fb25f5 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/configuration/DaxPayProperties.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/configuration/DaxPayProperties.java @@ -23,8 +23,8 @@ public class DaxPayProperties { /** 前端地址(web) */ private String frontWebUrl; - /** 机器码, 御用控制生成流水号 */ - private String machineNo; + /** 机器码, 用于区分不同机器生成的流水号 */ + private String machineNo = "56"; public void setMachineNo(String machineNo) { this.machineNo = machineNo; diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayService.java index 3be97f84..5e09c80b 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/alipay/service/AliPayService.java @@ -62,7 +62,7 @@ public class AliPayService { throw new PayFailureException("支付宝支付金额超过限额"); } // 支付参数开启分账, 配置未开启分账 - if(payParam.getAllocation() && !Objects.equals(alipayConfig.getAllocation(),true)){ + if(Objects.equals(payParam.getAllocation(),true) && !Objects.equals(alipayConfig.getAllocation(),true)){ throw new PayFailureException("未开启分账配置"); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/union/service/UnionPayService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/union/service/UnionPayService.java index 7ed00c22..494d3a3c 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/union/service/UnionPayService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/channel/union/service/UnionPayService.java @@ -57,7 +57,7 @@ public class UnionPayService { throw new PayFailureException("云闪付支付金额超限"); } // 分账 - if (payParam.getAllocation()) { + if (Objects.equals(payParam.getAllocation(),true)) { throw new PayFailureException("云闪付不支持分账"); } } diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayAssistService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayAssistService.java index 08b785cc..8097a7c1 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayAssistService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayAssistService.java @@ -108,7 +108,7 @@ public class PayAssistService { PlatformLocal platform = PaymentContextLocal.get() .getPlatformInfo(); // 异步回调为开启状态 - if (!payParam.getNotNotify() && apiInfo.isNotice()) { + if (Objects.equals(payParam.getNotNotify(), true) && apiInfo.isNotice()) { // 首先读取请求参数 noticeInfo.setNotifyUrl(payParam.getNotifyUrl()); // 读取接口配置 diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayService.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayService.java index 92cc3016..c8bb352c 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayService.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/core/payment/pay/service/PayService.java @@ -77,6 +77,7 @@ public class PayService { return this.repeatPay(payParam,payOrder); } } catch (Exception e) { + log.error("支付异常",e); payResult.setMsg(e.getMessage()); return payResult; } finally { diff --git a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/order/PayOrderRefundParam.java b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/order/PayOrderRefundParam.java index eebf7243..dcff0fd2 100644 --- a/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/order/PayOrderRefundParam.java +++ b/daxpay-single/daxpay-single-service/src/main/java/cn/bootx/platform/daxpay/service/param/order/PayOrderRefundParam.java @@ -1,6 +1,5 @@ package cn.bootx.platform.daxpay.service.param.order; -import cn.bootx.platform.daxpay.code.PayChannelEnum; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; import lombok.experimental.Accessors; @@ -19,15 +18,8 @@ public class PayOrderRefundParam { @Schema(description = "支付订单号") private String orderNo; - /** - * 支付通道 - * @see PayChannelEnum#getCode() - */ - private String channel; - - /** - * 退款金额 - */ + /** 退款金额 */ + @Schema(description = "退款金额") private Integer amount; /** 原因 */ diff --git a/daxpay-single/daxpay-single-start/src/main/resources/application-dev.yml b/daxpay-single/daxpay-single-start/src/main/resources/application-dev.yml index 853435b7..20262fb2 100644 --- a/daxpay-single/daxpay-single-start/src/main/resources/application-dev.yml +++ b/daxpay-single/daxpay-single-start/src/main/resources/application-dev.yml @@ -162,6 +162,8 @@ dax-pay: front-h5-url: http://pay1.bootx.cn/h5/# # 前端web地址 front-web-url: http://localhost:9000/# + # 机器号码 + machine-no: 63 # 演示模块 demo: # 网关地址