1
0
mirror of synced 2025-12-22 00:48:00 +08:00

🎨 升级部分依赖版本,优化代码,部分代码增加泛型参数

This commit is contained in:
altusea
2025-05-13 15:56:14 +08:00
committed by GitHub
parent a7b007f853
commit 063fbb7f19
263 changed files with 559 additions and 607 deletions

View File

@@ -1,7 +1,6 @@
package com.github.binarywang.wxpay.bean.applyconfirm;
import com.github.binarywang.wxpay.bean.applyconfirm.enums.AuthorizeStateEnum;
import com.github.binarywang.wxpay.bean.applyment.enums.ApplymentStateEnum;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Builder;

View File

@@ -2,8 +2,6 @@ package com.github.binarywang.wxpay.bean.bank;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.List;

View File

@@ -2,8 +2,6 @@ package com.github.binarywang.wxpay.bean.bank;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;

View File

@@ -2,11 +2,8 @@ package com.github.binarywang.wxpay.bean.bank;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.util.List;
/**
* 支行列表

View File

@@ -1,13 +1,10 @@
package com.github.binarywang.wxpay.bean.complaint;
import com.github.binarywang.wxpay.bean.media.MarketingImageUploadResult;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
import java.util.List;
/**
* 微信消费者投诉2.0

View File

@@ -1,6 +1,5 @@
package com.github.binarywang.wxpay.bean.customs;
import com.github.binarywang.wxpay.v3.SpecEncrypt;
import com.google.gson.annotations.SerializedName;
import lombok.Data;

View File

@@ -10,7 +10,6 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.Date;
/**
* 退款结果

View File

@@ -5,7 +5,6 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
import java.util.List;
/**

View File

@@ -4,7 +4,6 @@ import com.google.gson.annotations.SerializedName;
import lombok.*;
import java.io.Serializable;
import java.util.Date;
/**

View File

@@ -7,7 +7,6 @@ import lombok.NoArgsConstructor;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;
import java.util.Date;
/**
* <pre>

View File

@@ -387,7 +387,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
if (this.couponCount == null || this.couponCount == 0) {
return;
}
this.couponList = new ArrayList(couponCount);
this.couponList = new ArrayList<>(couponCount);
for (int i = 0; i < this.couponCount; i++) {
WxPayOrderNotifyCoupon coupon = new WxPayOrderNotifyCoupon();
coupon.setCouponId(this.getXmlValue("xml/coupon_id_" + i));

View File

@@ -4,7 +4,6 @@ import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import me.chanjar.weixin.common.util.json.WxGsonBuilder;
import java.io.Serializable;

View File

@@ -12,7 +12,7 @@ import java.util.ArrayList;
public class ReceiverList implements Serializable {
private static final long serialVersionUID = -1316860887694489921L;
ArrayList list;
ArrayList<Receiver> list;
private ReceiverList() {
}
@@ -23,7 +23,7 @@ public class ReceiverList implements Serializable {
*/
public static ReceiverList getInstance() {
ReceiverList receiverList = new ReceiverList();
receiverList.list = new ArrayList();
receiverList.list = new ArrayList<>();
return receiverList;
}

View File

@@ -1,16 +1,10 @@
package com.github.binarywang.wxpay.bean.profitsharing.request;
import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
import com.github.binarywang.wxpay.constant.WxPayConstants;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.v3.SpecEncrypt;
import com.google.gson.annotations.SerializedName;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.*;
import me.chanjar.weixin.common.annotation.Required;
import java.io.Serializable;
import java.util.Map;
/**
* 添加/删除分账接受方请求对象

View File

@@ -3,14 +3,10 @@ package com.github.binarywang.wxpay.bean.profitsharing.request;
import com.github.binarywang.wxpay.bean.request.BaseWxPayRequest;
import com.github.binarywang.wxpay.constant.WxPayConstants;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.v3.SpecEncrypt;
import com.google.gson.Gson;
import com.google.gson.annotations.SerializedName;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.*;
import me.chanjar.weixin.common.annotation.Required;
import java.io.Serializable;
import java.util.Map;
/**

View File

@@ -92,7 +92,7 @@ public class ProfitSharingQueryResult extends BaseWxPayResult implements Seriali
}
@Data
public class Receiver {
public static class Receiver {
/**
* 分账接收方类型
*/

View File

@@ -1,13 +1,8 @@
package com.github.binarywang.wxpay.bean.profitsharing.result;
import com.github.binarywang.wxpay.bean.result.BaseWxPayResult;
import com.github.binarywang.wxpay.v3.SpecEncrypt;
import com.google.gson.annotations.SerializedName;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.w3c.dom.Document;
import java.io.Serializable;

View File

@@ -20,9 +20,9 @@ import org.dom4j.Element;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
import static com.github.binarywang.wxpay.constant.WxPayConstants.SignType.ALL_SIGN_TYPES;
@@ -147,21 +147,21 @@ public abstract class BaseWxPayRequest implements Serializable {
* @return the integer
*/
public static Integer yuanToFen(String yuan) {
return new BigDecimal(yuan).setScale(2, BigDecimal.ROUND_HALF_UP).multiply(new BigDecimal(100)).intValue();
return new BigDecimal(yuan).setScale(2, RoundingMode.HALF_UP).multiply(new BigDecimal(100)).intValue();
}
/**
* 元转分
*/
public static Integer yuan2Fen(BigDecimal yuan) {
return yuan.multiply(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_HALF_UP).intValue();
return yuan.multiply(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP).intValue();
}
/**
* 分转元
*/
public static BigDecimal fen2Yuan(BigDecimal fen) {
return fen.divide(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_HALF_UP);
return fen.divide(BigDecimal.valueOf(100)).setScale(2, RoundingMode.HALF_UP);
}
/**

View File

@@ -6,7 +6,6 @@ import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.List;
/**
* 微信支付服务商退款请求

View File

@@ -194,7 +194,7 @@ public abstract class BaseWxPayResult {
protected static Integer readXmlInteger(Node d, String tagName) {
String content = readXmlString(d, tagName);
if (content == null || content.trim().length() == 0) {
if (content == null || content.trim().isEmpty()) {
return null;
}
return Integer.parseInt(content);
@@ -232,7 +232,7 @@ public abstract class BaseWxPayResult {
protected static Integer readXmlInteger(Document d, String tagName) {
String content = readXmlString(d, tagName);
if (content == null || content.trim().length() == 0) {
if (content == null || content.trim().isEmpty()) {
return null;
}
@@ -241,7 +241,7 @@ public abstract class BaseWxPayResult {
protected static Long readXmlLong(Document d, String tagName) {
String content = readXmlString(d, tagName);
if (content == null || content.trim().length() == 0) {
if (content == null || content.trim().isEmpty()) {
return null;
}

View File

@@ -224,7 +224,7 @@ public class WxWithholdNotifyResult extends BaseWxPayResult {
if (this.couponCount == null || this.couponCount == 0) {
return;
}
this.couponList = new ArrayList(couponCount);
this.couponList = new ArrayList<>(couponCount);
for (int i = 0; i < this.couponCount; i++) {
WxPayOrderNotifyCoupon coupon = new WxPayOrderNotifyCoupon();
coupon.setCouponId(this.getXmlValue("xml/coupon_id_" + i));

View File

@@ -147,7 +147,7 @@ public class WxWithholdOrderQueryResult extends BaseWxPayResult implements Seria
if (this.couponCount == null || this.couponCount == 0) {
return;
}
this.couponList = new ArrayList(couponCount);
this.couponList = new ArrayList<>(couponCount);
for (int i = 0; i < this.couponCount; i++) {
WxPayOrderNotifyCoupon coupon = new WxPayOrderNotifyCoupon();
coupon.setCouponId(this.getXmlValue("xml/coupon_id_" + i));

View File

@@ -34,8 +34,6 @@ import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxRuntimeException;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.reflect.ConstructorUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.io.IOException;

View File

@@ -44,7 +44,7 @@ public class BrandMerchantTransferServiceImpl implements BrandMerchantTransferSe
if (request.getNeedQueryDetail() != null) {
url = String.format("%s?need_query_detail=%b", url, request.getNeedQueryDetail());
}
if (request.getDetailState() != null && request.getDetailState().length() != 0) {
if (request.getDetailState() != null && !request.getDetailState().isEmpty()) {
url = String.format("%s&detail_state=%s", url, request.getDetailState());
}
@@ -68,7 +68,7 @@ public class BrandMerchantTransferServiceImpl implements BrandMerchantTransferSe
if (request.getNeedQueryDetail() != null) {
url = String.format("%s?need_query_detail=%b", url, request.getNeedQueryDetail());
}
if (request.getDetailState() != null && request.getDetailState().length() != 0) {
if (request.getDetailState() != null && !request.getDetailState().isEmpty()) {
url = String.format("%s&detail_state=%s", url, request.getDetailState());
}

View File

@@ -4,7 +4,6 @@ import com.github.binarywang.wxpay.bean.customs.*;
import com.github.binarywang.wxpay.exception.WxPayException;
import com.github.binarywang.wxpay.service.CustomDeclarationService;
import com.github.binarywang.wxpay.service.WxPayService;
import com.github.binarywang.wxpay.v3.util.RsaCryptoUtil;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import lombok.RequiredArgsConstructor;

View File

@@ -294,7 +294,7 @@ public class EcommerceServiceImpl implements EcommerceService {
@Override
public ReturnAdvanceResult refundsReturnAdvance(String subMchid, String refundId) throws WxPayException {
String url = String.format("%s/v3/ecommerce/refunds/%s/return-advance", this.payService.getPayBaseUrl(), refundId);
Map request = new HashMap();
Map<String, String> request = new HashMap<>();
request.put("sub_mchid",subMchid);
String response = this.payService.postV3(url, GSON.toJson(request));
return GSON.fromJson(response, ReturnAdvanceResult.class);
@@ -489,7 +489,7 @@ public class EcommerceServiceImpl implements EcommerceService {
public static Map<Object, Object> getObjectToMap(Object obj) {
try {
Map<Object, Object> result = new LinkedHashMap<>();
final Class<? extends Object> beanClass = obj.getClass();
final Class<?> beanClass = obj.getClass();
final BeanInfo beanInfo = Introspector.getBeanInfo(beanClass);
final PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors();
if (propertyDescriptors != null) {

View File

@@ -47,7 +47,7 @@ public class MerchantTransferServiceImpl implements MerchantTransferService {
if (request.getLimit() != null) {
url = String.format("%s&limit=%d", url, request.getLimit());
}
if (request.getDetailStatus() != null && request.getDetailStatus().length() != 0) {
if (request.getDetailStatus() != null && !request.getDetailStatus().isEmpty()) {
url = String.format("%s&detail_status=%s", url, request.getDetailStatus());
}
@@ -74,7 +74,7 @@ public class MerchantTransferServiceImpl implements MerchantTransferService {
if (request.getLimit() != null) {
url = String.format("%s&limit=%d", url, request.getLimit());
}
if (request.getDetailStatus() != null && request.getDetailStatus().length() != 0) {
if (request.getDetailStatus() != null && !request.getDetailStatus().isEmpty()) {
url = String.format("%s&detail_status=%s", url, request.getDetailStatus());
}

View File

@@ -87,7 +87,7 @@ public class TransferServiceImpl implements TransferService {
@Override
public TransferBillsResult transferBills(TransferBillsRequest request) throws WxPayException {
String url = String.format("%s/v3/fund-app/mch-transfer/transfer-bills", this.payService.getPayBaseUrl());
if (request.getUserName() != null && request.getUserName().length() > 0) {
if (request.getUserName() != null && !request.getUserName().isEmpty()) {
X509Certificate validCertificate = this.payService.getConfig().getVerifier().getValidCertificate();
RsaCryptoUtil.encryptFields(request, validCertificate);
}

View File

@@ -2,13 +2,9 @@ package com.github.binarywang.wxpay.v3;
import java.security.PrivateKey;
import java.security.cert.X509Certificate;
import java.util.List;
import com.github.binarywang.wxpay.v3.auth.CertificatesVerifier;
import com.github.binarywang.wxpay.v3.auth.PrivateKeySigner;
import com.github.binarywang.wxpay.v3.auth.WxPayCredentials;
import com.github.binarywang.wxpay.v3.auth.WxPayValidator;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.impl.execchain.ClientExecChain;

View File

@@ -135,7 +135,7 @@ public class AutoUpdateCertificatesVerifier implements Verifier {
//更新时间
instant = Instant.now();
} catch (GeneralSecurityException | IOException e) {
log.warn("Auto update cert failed, exception = " + e);
log.warn("Auto update cert failed, exception = {}", e);
} finally {
lock.unlock();
}
@@ -169,7 +169,7 @@ public class AutoUpdateCertificatesVerifier implements Verifier {
}
this.verifier = new CertificatesVerifier(newCertList);
} else {
log.warn("Auto update cert failed, statusCode = " + statusCode + ",body = " + body);
log.warn("Auto update cert failed, statusCode = {},body = {}", statusCode, body);
throw new WxRuntimeException(this.getErrorMsg(body));
}
}

View File

@@ -10,6 +10,7 @@ import org.apache.http.entity.ContentType;
import org.apache.http.util.EntityUtils;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
/**
* @author spvycf & F00lish
@@ -39,7 +40,7 @@ public class WxPayValidator implements Validator {
}
String message = buildMessage(response);
return verifier.verify(serialNo.getValue(), message.getBytes("utf-8"), sign.getValue());
return verifier.verify(serialNo.getValue(), message.getBytes(StandardCharsets.UTF_8), sign.getValue());
}
protected final String buildMessage(CloseableHttpResponse response) throws IOException {

View File

@@ -47,7 +47,7 @@ public class RsaCryptoUtil {
Object oldValue = field.get(encryptObject);
if (oldValue != null) {
String oldStr = (String) oldValue;
if (!"".equals(oldStr.trim())) {
if (!oldStr.trim().isEmpty()) {
field.set(encryptObject, encryptOAEP(oldStr, certificate));
}
}
@@ -57,8 +57,8 @@ public class RsaCryptoUtil {
if (obj == null) {
continue;
}
if (obj instanceof Collection) {
Collection collection = (Collection) obj;
if (obj instanceof Collection<?>) {
Collection<?> collection = (Collection<?>) obj;
for (Object o : collection) {
if (o != null) {
encryptField(o, certificate);