mirror of
https://gitee.com/dromara/dax-pay.git
synced 2025-09-03 19:16:21 +00:00
ref 参数修改+联调接口
This commit is contained in:
@@ -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;
|
||||
|
@@ -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<PayModel> execute = DaxPayKit.execute(simplePayParam);
|
||||
DaxPayResult<PayModel> execute = DaxPayKit.execute(payParam);
|
||||
// 判断是否支付成功
|
||||
if (execute.getCode() != 0){
|
||||
throw new BizException(execute.getMsg());
|
||||
|
@@ -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;
|
||||
|
@@ -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("未开启分账配置");
|
||||
}
|
||||
}
|
||||
|
@@ -57,7 +57,7 @@ public class UnionPayService {
|
||||
throw new PayFailureException("云闪付支付金额超限");
|
||||
}
|
||||
// 分账
|
||||
if (payParam.getAllocation()) {
|
||||
if (Objects.equals(payParam.getAllocation(),true)) {
|
||||
throw new PayFailureException("云闪付不支持分账");
|
||||
}
|
||||
}
|
||||
|
@@ -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());
|
||||
// 读取接口配置
|
||||
|
@@ -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 {
|
||||
|
@@ -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;
|
||||
|
||||
/** 原因 */
|
||||
|
@@ -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:
|
||||
# 网关地址
|
||||
|
Reference in New Issue
Block a user