fix 处理分账字段空指针导致的聚合支付异常

This commit is contained in:
DaxPay
2024-05-14 19:44:50 +08:00
parent 326755fb31
commit d83f74110f
8 changed files with 27 additions and 10 deletions

View File

@@ -19,7 +19,7 @@ public class AggregatePayInfo {
/** 订单业务号 */
@Schema(description = "订单业务号")
private String businessNo;
private String bizOrderNo;
@Schema(description = "是否分账")
private Boolean allocation;

View File

@@ -18,7 +18,7 @@ import java.math.BigDecimal;
public class AggregateSimplePayParam {
@Schema(description = "业务号")
@NotNull
private String businessNo;
private String bizOrderNo;
@Schema(description = "是否分账")
private Boolean allocation;

View File

@@ -57,7 +57,7 @@ public class AggregateService {
.intValue();
AggregatePayInfo aggregatePayInfo = new AggregatePayInfo()
.setTitle(param.getTitle())
.setBusinessNo(param.getBusinessNo())
.setBizOrderNo(param.getBizOrderNo())
.setAllocation(param.getAllocation())
.setAmount(amount);
String code = IdUtil.getSnowflakeNextIdStr();
@@ -144,7 +144,7 @@ public class AggregateService {
AggregatePayInfo aggregatePayInfo = getInfo(aggregateCode);
// 拼装支付发起参数
PayParam simplePayParam = new PayParam();
simplePayParam.setBizOrderNo(aggregatePayInfo.getBusinessNo());
simplePayParam.setBizOrderNo(aggregatePayInfo.getBizOrderNo());
simplePayParam.setTitle(aggregatePayInfo.getTitle());
simplePayParam.setAmount(aggregatePayInfo.getAmount());
simplePayParam.setChannel(PayChannelEnum.WECHAT.getCode());
@@ -178,7 +178,7 @@ public class AggregateService {
public PayOrderResult aliH5Pay(String code) {
AggregatePayInfo aggregatePayInfo = getInfo(code);
PayParam payParam = new PayParam();
payParam.setBizOrderNo(aggregatePayInfo.getBusinessNo());
payParam.setBizOrderNo(aggregatePayInfo.getBizOrderNo());
payParam.setTitle(aggregatePayInfo.getTitle());
payParam.setAmount(aggregatePayInfo.getAmount());
payParam.setChannel(PayChannelEnum.ALI.getCode());
@@ -218,7 +218,7 @@ public class AggregateService {
.intValue();
PayParam simplePayParam = new PayParam();
simplePayParam.setBizOrderNo(param.getBusinessNo());
simplePayParam.setBizOrderNo(param.getBizOrderNo());
simplePayParam.setAllocation(param.getAllocation());
simplePayParam.setTitle(param.getTitle());
simplePayParam.setAmount(amount);

View File

@@ -1,7 +1,9 @@
package cn.daxpay.single.result.assist;
import cn.daxpay.single.result.PaymentCommonResult;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
@@ -9,10 +11,11 @@ import lombok.experimental.Accessors;
* @author xxm
* @since 2024/2/10
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "微信AccessToken")
public class WxAccessTokenResult {
public class WxAccessTokenResult extends PaymentCommonResult {
@Schema(description = "微信AccessToken")
private String accessToken;

View File

@@ -1,7 +1,9 @@
package cn.daxpay.single.result.assist;
import cn.daxpay.single.result.PaymentCommonResult;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
@@ -9,10 +11,11 @@ import lombok.experimental.Accessors;
* @author xxm
* @since 2024/2/10
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "微信oauth2授权的url")
public class WxAuthUrlResult {
public class WxAuthUrlResult extends PaymentCommonResult {
@Schema(description = "微信oauth2授权的url")
private String url;

View File

@@ -1,10 +1,12 @@
package cn.daxpay.single.result.order;
import cn.daxpay.single.code.RefundStatusEnum;
import cn.daxpay.single.result.PaymentCommonResult;
import cn.daxpay.single.serializer.LocalDateTimeToTimestampSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.math.BigDecimal;
@@ -15,10 +17,11 @@ import java.time.LocalDateTime;
* @author xxm
* @since 2024/1/16
*/
@EqualsAndHashCode(callSuper = true)
@Data
@Accessors(chain = true)
@Schema(title = "退款订单数据")
public class RefundOrderResult {
public class RefundOrderResult extends PaymentCommonResult {
@Schema(description = "退款号")
private String refundNo;

View File

@@ -75,7 +75,7 @@ public class WeChatPayService {
throw new PayFailureException("微信支付金额超限");
}
// 是否支持分账
if (payParam.getAllocation() && !weChatPayConfig.getAllocation()) {
if (Objects.equals(payParam.getAllocation(),true) && !Objects.equals(weChatPayConfig.getAllocation(),true)) {
throw new PayFailureException("未开启分账配置");
}
}

View File

@@ -19,6 +19,7 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.time.LocalDateTime;
import java.util.Objects;
/**
* 支付订单
@@ -120,6 +121,13 @@ public class PayOrder extends MpBaseEntity implements EntityBaseFunction<PayOrde
@TableField(updateStrategy = FieldStrategy.ALWAYS)
private String errorMsg;
/**
* 如果
*/
public Boolean getAllocation() {
return Objects.equals(this.allocation, true);
}
/**
* 转换
*/