处理xml消息中后缀为$n的节点在签名时可能错误的问题
This commit is contained in:
+9
-9
@@ -31,15 +31,15 @@ import com.foxinmy.weixin4j.xml.ListWrapper;
|
||||
import com.foxinmy.weixin4j.xml.XmlStream;
|
||||
|
||||
/**
|
||||
* 对 后缀为_$n 的 xml节点转换
|
||||
* 对 后缀为_$n 的 xml节点反序列化
|
||||
*
|
||||
* @className ListsuffixResultConverter
|
||||
* @className ListsuffixResultDeserializer
|
||||
* @author jy
|
||||
* @date 2015年3月24日
|
||||
* @since JDK 1.7
|
||||
* @see
|
||||
*/
|
||||
public class ListsuffixResultConverter {
|
||||
public class ListsuffixResultDeserializer {
|
||||
|
||||
private final static Pattern SUFFIX_PATTERN = Pattern.compile("(_\\d)$");
|
||||
|
||||
@@ -53,8 +53,8 @@ public class ListsuffixResultConverter {
|
||||
* @param clazz
|
||||
* @return
|
||||
*/
|
||||
public static <T> T containCouponConvert(String content, Class<T> clazz) {
|
||||
return convert(content, clazz, "couponList");
|
||||
public static <T> T containCouponDeserialize(String content, Class<T> clazz) {
|
||||
return deserialize(content, clazz, "couponList");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -64,8 +64,8 @@ public class ListsuffixResultConverter {
|
||||
* @param clazz
|
||||
* @return
|
||||
*/
|
||||
public static <T> T containRefundConvert(String content, Class<T> clazz) {
|
||||
return convert(content, clazz, "refundList");
|
||||
public static <T> T containRefundDeserialize(String content, Class<T> clazz) {
|
||||
return deserialize(content, clazz, "refundList");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,7 +75,7 @@ public class ListsuffixResultConverter {
|
||||
* @param clazz
|
||||
* @return
|
||||
*/
|
||||
public static <T> T containRefundDetailConvert(String content,
|
||||
public static <T> T containRefundDetailDeserialize(String content,
|
||||
Class<T> clazz) {
|
||||
T t = XmlStream.fromXML(content, clazz);
|
||||
Class<?> wrapperClazz = ReflectionUtil.getFieldGenericType(t,
|
||||
@@ -205,7 +205,7 @@ public class ListsuffixResultConverter {
|
||||
return t;
|
||||
}
|
||||
|
||||
public static <T> T convert(String content, Class<T> clazz,
|
||||
public static <T> T deserialize(String content, Class<T> clazz,
|
||||
String listPropertyName) {
|
||||
T t = XmlStream.fromXML(content, clazz);
|
||||
Class<?> wrapperClazz = ReflectionUtil.getFieldGenericType(t,
|
||||
-33
@@ -1,33 +0,0 @@
|
||||
package com.foxinmy.weixin4j.mp.payment.conver;
|
||||
|
||||
/**
|
||||
* 对 后缀为_$n 的 xml节点序列化
|
||||
*
|
||||
* @className ListsuffixResultSerializer
|
||||
* @author jy
|
||||
* @date 2015年3月24日
|
||||
* @since JDK 1.7
|
||||
* @see
|
||||
*/
|
||||
public class ListsuffixResultSerializer {
|
||||
/**
|
||||
* 序列化为json
|
||||
*
|
||||
* @param object
|
||||
* @return json
|
||||
*/
|
||||
public String serializeToJSON(Object object) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 序列化为xml
|
||||
*
|
||||
* @param object
|
||||
* @return xml
|
||||
*/
|
||||
public String serializeToXML(Object object) {
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,6 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.mp.type.SignType;
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
|
||||
/**
|
||||
* 调用V2.x接口返回的公用字段
|
||||
@@ -28,13 +27,13 @@ public class ApiResult implements Serializable {
|
||||
/**
|
||||
* 是查询结果状态码,0 表明成功,其他表明错误;
|
||||
*/
|
||||
@JSONField(name = "ret_code")
|
||||
@JSONField(name = "retcode")
|
||||
@XmlElement(name = "retcode")
|
||||
private int retCode;
|
||||
private Integer retCode;
|
||||
/**
|
||||
* 是查询结果出错信息;
|
||||
*/
|
||||
@JSONField(name = "ret_msg")
|
||||
@JSONField(name = "retmsg")
|
||||
@XmlElement(name = "retmsg")
|
||||
private String retMsg;
|
||||
/**
|
||||
@@ -64,11 +63,11 @@ public class ApiResult implements Serializable {
|
||||
@XmlElement(name = "sign_type")
|
||||
private SignType signType;
|
||||
|
||||
protected ApiResult(){
|
||||
protected ApiResult() {
|
||||
// jaxb required
|
||||
}
|
||||
|
||||
public int getRetCode() {
|
||||
|
||||
public Integer getRetCode() {
|
||||
return retCode;
|
||||
}
|
||||
|
||||
@@ -77,7 +76,7 @@ public class ApiResult implements Serializable {
|
||||
}
|
||||
|
||||
public String getRetMsg() {
|
||||
return StringUtil.isNotBlank(retMsg) ? retMsg : null;
|
||||
return this.retMsg;
|
||||
}
|
||||
|
||||
public void setRetMsg(String retMsg) {
|
||||
|
||||
@@ -9,6 +9,7 @@ import javax.xml.bind.annotation.XmlRootElement;
|
||||
import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.xml.ListsuffixResult;
|
||||
|
||||
/**
|
||||
* V2退款记录
|
||||
@@ -42,18 +43,19 @@ public class RefundRecord extends ApiResult {
|
||||
*/
|
||||
@XmlElement(name = "refund_count")
|
||||
@JSONField(name = "refund_count")
|
||||
private int count;
|
||||
private int refundCount;
|
||||
/**
|
||||
* 退款详情
|
||||
*/
|
||||
@ListsuffixResult
|
||||
@XmlTransient
|
||||
@JSONField(serialize = false, deserialize = false)
|
||||
@JSONField(deserialize = false)
|
||||
private List<RefundDetail> refundList;
|
||||
|
||||
protected RefundRecord() {
|
||||
// jaxb required
|
||||
}
|
||||
|
||||
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
@@ -62,8 +64,8 @@ public class RefundRecord extends ApiResult {
|
||||
return outTradeNo;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
public int getRefundCount() {
|
||||
return refundCount;
|
||||
}
|
||||
|
||||
public List<RefundDetail> getRefundList() {
|
||||
@@ -77,7 +79,7 @@ public class RefundRecord extends ApiResult {
|
||||
@Override
|
||||
public String toString() {
|
||||
return "RefundRecord [transactionId=" + transactionId + ", outTradeNo="
|
||||
+ outTradeNo + ", count=" + count + ", refundList="
|
||||
+ outTradeNo + ", refundCount=" + refundCount + ", refundList="
|
||||
+ refundList + ", " + super.toString() + "]";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,6 +16,7 @@ import com.foxinmy.weixin4j.mp.type.TradeState;
|
||||
import com.foxinmy.weixin4j.mp.type.TradeType;
|
||||
import com.foxinmy.weixin4j.util.DateUtil;
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
import com.foxinmy.weixin4j.xml.ListsuffixResult;
|
||||
|
||||
/**
|
||||
* V3订单信息
|
||||
@@ -86,8 +87,9 @@ public class Order extends ApiResult {
|
||||
/**
|
||||
* 代金券信息 验证签名有点麻烦
|
||||
*/
|
||||
@ListsuffixResult
|
||||
@XmlTransient
|
||||
@JSONField(serialize = false, deserialize = false)
|
||||
@JSONField(deserialize = false)
|
||||
private List<CouponInfo> couponList;
|
||||
/**
|
||||
* 现金支付金额
|
||||
|
||||
@@ -14,6 +14,7 @@ import com.foxinmy.weixin4j.mp.type.CurrencyType;
|
||||
import com.foxinmy.weixin4j.mp.type.RefundChannel;
|
||||
import com.foxinmy.weixin4j.mp.type.RefundStatus;
|
||||
import com.foxinmy.weixin4j.util.StringUtil;
|
||||
import com.foxinmy.weixin4j.xml.ListsuffixResult;
|
||||
|
||||
/**
|
||||
* V3退款详细
|
||||
@@ -129,14 +130,15 @@ public class RefundDetail extends ApiResult {
|
||||
*
|
||||
* @see com.foxinmy.weixin4j.mp.payment.coupon.CouponInfo
|
||||
*/
|
||||
@ListsuffixResult
|
||||
@XmlTransient
|
||||
@JSONField(serialize = false, deserialize = false)
|
||||
@JSONField(deserialize = false)
|
||||
private List<CouponInfo> couponList;
|
||||
|
||||
protected RefundDetail() {
|
||||
// jaxb required
|
||||
}
|
||||
|
||||
|
||||
public String getOutRefundNo() {
|
||||
return outRefundNo;
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import javax.xml.bind.annotation.XmlTransient;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
import com.foxinmy.weixin4j.mp.type.CurrencyType;
|
||||
import com.foxinmy.weixin4j.xml.ListsuffixResult;
|
||||
|
||||
/**
|
||||
* V3退款记录
|
||||
@@ -82,20 +83,21 @@ public class RefundRecord extends ApiResult {
|
||||
*/
|
||||
@XmlElement(name = "refund_count")
|
||||
@JSONField(name = "refund_count")
|
||||
private int count;
|
||||
private int refundCount;
|
||||
/**
|
||||
* 退款详情
|
||||
*
|
||||
* @see com.foxinmy.weixin4j.mp.payment.v3.RefundDetail
|
||||
*/
|
||||
@ListsuffixResult
|
||||
@XmlTransient
|
||||
@JSONField(serialize = false, deserialize = false)
|
||||
@JSONField(deserialize = false)
|
||||
private List<RefundDetail> refundList;
|
||||
|
||||
protected RefundRecord() {
|
||||
// jaxb required
|
||||
}
|
||||
|
||||
|
||||
public String getTransactionId() {
|
||||
return transactionId;
|
||||
}
|
||||
@@ -154,8 +156,8 @@ public class RefundRecord extends ApiResult {
|
||||
return totalFee;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
public int getRefundCount() {
|
||||
return refundCount;
|
||||
}
|
||||
|
||||
public List<RefundDetail> getRefundList() {
|
||||
@@ -187,7 +189,7 @@ public class RefundRecord extends ApiResult {
|
||||
+ ", feeType=" + feeType + ", cashFee=" + getFormatCashFee()
|
||||
+ ", cashFeeType=" + cashFeeType + ", refundFee="
|
||||
+ getFormatRefundFee() + ", couponRefundFee="
|
||||
+ getFormatCouponRefundFee() + ", count=" + count
|
||||
+ getFormatCouponRefundFee() + ", refundCount=" + refundCount
|
||||
+ ", refundList=" + refundList + ", " + super.toString() + "]";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user