mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-11-04 06:07:59 +08:00
优化部分代码
This commit is contained in:
@ -32,7 +32,7 @@
|
|||||||
<module name="IllegalTokenText">
|
<module name="IllegalTokenText">
|
||||||
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
||||||
<property name="format" value="\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
<property name="format" value="\\u00(09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
||||||
<property name="message" value="Consider using special escape sequence instead of octal value or Unicode escaped value."/>
|
<property name="message" value="考虑使用特殊的转义字符,而非八进制值或者Unicode转义值。"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="AvoidEscapedUnicodeCharacters">
|
<module name="AvoidEscapedUnicodeCharacters">
|
||||||
<property name="allowEscapesForControlCharacters" value="true"/>
|
<property name="allowEscapesForControlCharacters" value="true"/>
|
||||||
@ -69,9 +69,9 @@
|
|||||||
<property name="allowEmptyTypes" value="true"/>
|
<property name="allowEmptyTypes" value="true"/>
|
||||||
<property name="allowEmptyLoops" value="true"/>
|
<property name="allowEmptyLoops" value="true"/>
|
||||||
<message key="ws.notFollowed"
|
<message key="ws.notFollowed"
|
||||||
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
|
value="WhitespaceAround: ''{0}''后面没有空格。Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
|
||||||
<message key="ws.notPreceded"
|
<message key="ws.notPreceded"
|
||||||
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
|
value="WhitespaceAround: ''{0}''前面没有加空格。"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="OneStatementPerLine"/>
|
<module name="OneStatementPerLine"/>
|
||||||
<module name="MultipleVariableDeclarations"/>
|
<module name="MultipleVariableDeclarations"/>
|
||||||
@ -100,11 +100,11 @@
|
|||||||
<module name="PackageName">
|
<module name="PackageName">
|
||||||
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
|
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
|
||||||
<message key="name.invalidPattern"
|
<message key="name.invalidPattern"
|
||||||
value="Package name ''{0}'' must match pattern ''{1}''."/>
|
value="包名 ''{0}'' 必须匹配模式:''{1}''。"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="TypeName">
|
<module name="TypeName">
|
||||||
<message key="name.invalidPattern"
|
<message key="name.invalidPattern"
|
||||||
value="Type name ''{0}'' must match pattern ''{1}''."/>
|
value="类型名 ''{0}'' 必须匹配模式:''{1}''。"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="MemberName">
|
<module name="MemberName">
|
||||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9]*$"/>
|
||||||
@ -114,28 +114,28 @@
|
|||||||
<module name="ParameterName">
|
<module name="ParameterName">
|
||||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||||
<message key="name.invalidPattern"
|
<message key="name.invalidPattern"
|
||||||
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
|
value="参数名''{0}'' 必须匹配模式:''{1}''。"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="LocalVariableName">
|
<module name="LocalVariableName">
|
||||||
<property name="tokens" value="VARIABLE_DEF"/>
|
<property name="tokens" value="VARIABLE_DEF"/>
|
||||||
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
<property name="format" value="^[a-z]([a-z0-9][a-zA-Z0-9]*)?$"/>
|
||||||
<message key="name.invalidPattern"
|
<message key="name.invalidPattern"
|
||||||
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
|
value="本地变量名 ''{0}'' 必须匹配模式:''{1}''。"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="ClassTypeParameterName">
|
<module name="ClassTypeParameterName">
|
||||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||||
<message key="name.invalidPattern"
|
<message key="name.invalidPattern"
|
||||||
value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
value="类的类型名 ''{0}'' 必须匹配模式:''{1}''。"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="MethodTypeParameterName">
|
<module name="MethodTypeParameterName">
|
||||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||||
<message key="name.invalidPattern"
|
<message key="name.invalidPattern"
|
||||||
value="Method type name ''{0}'' must match pattern ''{1}''."/>
|
value="方法类型名 ''{0}'' 必须匹配模式:''{1}''。"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="InterfaceTypeParameterName">
|
<module name="InterfaceTypeParameterName">
|
||||||
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||||
<message key="name.invalidPattern"
|
<message key="name.invalidPattern"
|
||||||
value="Interface type name ''{0}'' must match pattern ''{1}''."/>
|
value="Interface type name ''{0}'' 必须匹配模式:''{1}''。"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="NoFinalizer"/>
|
<module name="NoFinalizer"/>
|
||||||
<module name="GenericWhitespace">
|
<module name="GenericWhitespace">
|
||||||
@ -148,14 +148,6 @@
|
|||||||
<message key="ws.notPreceded"
|
<message key="ws.notPreceded"
|
||||||
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
|
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
|
||||||
</module>
|
</module>
|
||||||
<module name="Indentation">
|
|
||||||
<property name="basicOffset" value="2"/>
|
|
||||||
<property name="braceAdjustment" value="0"/>
|
|
||||||
<property name="caseIndent" value="2"/>
|
|
||||||
<property name="throwsIndent" value="4"/>
|
|
||||||
<property name="lineWrappingIndentation" value="4"/>
|
|
||||||
<property name="arrayInitIndent" value="2"/>
|
|
||||||
</module>
|
|
||||||
<module name="AbbreviationAsWordInName">
|
<module name="AbbreviationAsWordInName">
|
||||||
<property name="ignoreFinal" value="false"/>
|
<property name="ignoreFinal" value="false"/>
|
||||||
<property name="allowedAbbreviationLength" value="1"/>
|
<property name="allowedAbbreviationLength" value="1"/>
|
||||||
@ -186,7 +178,6 @@
|
|||||||
<property name="allowSamelineMultipleAnnotations" value="true"/>
|
<property name="allowSamelineMultipleAnnotations" value="true"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="NonEmptyAtclauseDescription"/>
|
<module name="NonEmptyAtclauseDescription"/>
|
||||||
<module name="JavadocTagContinuationIndentation"/>
|
|
||||||
<module name="SummaryJavadoc">
|
<module name="SummaryJavadoc">
|
||||||
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
|
<property name="forbiddenSummaryFragments" value="^@return the *|^This method returns |^A [{]@code [a-zA-Z0-9]+[}]( is a )"/>
|
||||||
</module>
|
</module>
|
||||||
@ -207,7 +198,7 @@
|
|||||||
<module name="MethodName">
|
<module name="MethodName">
|
||||||
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
|
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
|
||||||
<message key="name.invalidPattern"
|
<message key="name.invalidPattern"
|
||||||
value="Method name ''{0}'' must match pattern ''{1}''."/>
|
value="方法名 ''{0}'' 必须匹配模式:''{1}''."/>
|
||||||
</module>
|
</module>
|
||||||
<module name="SingleLineJavadoc">
|
<module name="SingleLineJavadoc">
|
||||||
<property name="ignoreInlineTags" value="false"/>
|
<property name="ignoreInlineTags" value="false"/>
|
||||||
@ -215,6 +206,5 @@
|
|||||||
<module name="EmptyCatchBlock">
|
<module name="EmptyCatchBlock">
|
||||||
<property name="exceptionVariableName" value="expected"/>
|
<property name="exceptionVariableName" value="expected"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="CommentsIndentation"/>
|
|
||||||
</module>
|
</module>
|
||||||
</module>
|
</module>
|
||||||
|
|||||||
@ -11,7 +11,6 @@ import lombok.NoArgsConstructor;
|
|||||||
import me.chanjar.weixin.common.util.ToStringUtils;
|
import me.chanjar.weixin.common.util.ToStringUtils;
|
||||||
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
|
import me.chanjar.weixin.common.util.xml.XStreamInitializer;
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -25,12 +24,12 @@ import java.util.Map;
|
|||||||
@EqualsAndHashCode(callSuper = true)
|
@EqualsAndHashCode(callSuper = true)
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@XStreamAlias("xml")
|
@XStreamAlias("xml")
|
||||||
public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializable {
|
public class WxPayOrderNotifyResult extends BaseWxPayResult {
|
||||||
private static final long serialVersionUID = 5389718115223345496L;
|
private static final long serialVersionUID = 5389718115223345496L;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:设备号
|
* 字段名:设备号.
|
||||||
* 变量名:device_info
|
* 变量名:device_info
|
||||||
* 是否必填:否
|
* 是否必填:否
|
||||||
* 类型:String(32)
|
* 类型:String(32)
|
||||||
@ -43,7 +42,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:用户标识
|
* 字段名:用户标识.
|
||||||
* 变量名:openid
|
* 变量名:openid
|
||||||
* 是否必填:是
|
* 是否必填:是
|
||||||
* 类型:String(128)
|
* 类型:String(128)
|
||||||
@ -56,7 +55,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:是否关注公众账号
|
* 字段名:是否关注公众账号.
|
||||||
* 变量名:is_subscribe
|
* 变量名:is_subscribe
|
||||||
* 是否必填:否
|
* 是否必填:否
|
||||||
* 类型:String(1)
|
* 类型:String(1)
|
||||||
@ -69,7 +68,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:用户子标识
|
* 字段名:用户子标识.
|
||||||
* 变量名:sub_openid
|
* 变量名:sub_openid
|
||||||
* 是否必填:是
|
* 是否必填:是
|
||||||
* 类型:String(128)
|
* 类型:String(128)
|
||||||
@ -82,7 +81,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:是否关注子公众账号
|
* 字段名:是否关注子公众账号.
|
||||||
* 变量名:sub_is_subscribe
|
* 变量名:sub_is_subscribe
|
||||||
* 是否必填:否
|
* 是否必填:否
|
||||||
* 类型:String(1)
|
* 类型:String(1)
|
||||||
@ -96,7 +95,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:交易类型
|
* 字段名:交易类型.
|
||||||
* 变量名:trade_type
|
* 变量名:trade_type
|
||||||
* 是否必填:是
|
* 是否必填:是
|
||||||
* 类型:String(16)
|
* 类型:String(16)
|
||||||
@ -110,7 +109,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:付款银行
|
* 字段名:付款银行.
|
||||||
* 变量名:bank_type
|
* 变量名:bank_type
|
||||||
* 是否必填:是
|
* 是否必填:是
|
||||||
* 类型:String(16)
|
* 类型:String(16)
|
||||||
@ -123,7 +122,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:订单金额
|
* 字段名:订单金额.
|
||||||
* 变量名:total_fee
|
* 变量名:total_fee
|
||||||
* 是否必填:是
|
* 是否必填:是
|
||||||
* 类型:Int
|
* 类型:Int
|
||||||
@ -135,7 +134,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
private Integer totalFee;
|
private Integer totalFee;
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:应结订单金额
|
* 字段名:应结订单金额.
|
||||||
* 变量名:settlement_total_fee
|
* 变量名:settlement_total_fee
|
||||||
* 是否必填:否
|
* 是否必填:否
|
||||||
* 类型:Int
|
* 类型:Int
|
||||||
@ -147,7 +146,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
private Integer settlementTotalFee;
|
private Integer settlementTotalFee;
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:货币种类
|
* 字段名:货币种类.
|
||||||
* 变量名:fee_type
|
* 变量名:fee_type
|
||||||
* 是否必填:否
|
* 是否必填:否
|
||||||
* 类型:String(8)
|
* 类型:String(8)
|
||||||
@ -159,7 +158,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
private String feeType;
|
private String feeType;
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:现金支付金额
|
* 字段名:现金支付金额.
|
||||||
* 变量名:cash_fee
|
* 变量名:cash_fee
|
||||||
* 是否必填:是
|
* 是否必填:是
|
||||||
* 类型:Int
|
* 类型:Int
|
||||||
@ -171,7 +170,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
private Integer cashFee;
|
private Integer cashFee;
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:现金支付货币类型
|
* 字段名:现金支付货币类型.
|
||||||
* 变量名:cash_fee_type
|
* 变量名:cash_fee_type
|
||||||
* 是否必填:否
|
* 是否必填:否
|
||||||
* 类型:String(16)
|
* 类型:String(16)
|
||||||
@ -183,7 +182,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
private String cashFeeType;
|
private String cashFeeType;
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:总代金券金额
|
* 字段名:总代金券金额.
|
||||||
* 变量名:coupon_fee
|
* 变量名:coupon_fee
|
||||||
* 是否必填:否
|
* 是否必填:否
|
||||||
* 类型:Int
|
* 类型:Int
|
||||||
@ -196,7 +195,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:代金券使用数量
|
* 字段名:代金券使用数量.
|
||||||
* 变量名:coupon_count
|
* 变量名:coupon_count
|
||||||
* 是否必填:否
|
* 是否必填:否
|
||||||
* 类型:Int
|
* 类型:Int
|
||||||
@ -211,7 +210,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:微信支付订单号
|
* 字段名:微信支付订单号.
|
||||||
* 变量名:transaction_id
|
* 变量名:transaction_id
|
||||||
* 是否必填:是
|
* 是否必填:是
|
||||||
* 类型:String(32)
|
* 类型:String(32)
|
||||||
@ -224,7 +223,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:商户订单号
|
* 字段名:商户订单号.
|
||||||
* 变量名:out_trade_no
|
* 变量名:out_trade_no
|
||||||
* 是否必填:是
|
* 是否必填:是
|
||||||
* 类型:String(32)
|
* 类型:String(32)
|
||||||
@ -236,7 +235,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
private String outTradeNo;
|
private String outTradeNo;
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:商家数据包
|
* 字段名:商家数据包.
|
||||||
* 变量名:attach
|
* 变量名:attach
|
||||||
* 是否必填:否
|
* 是否必填:否
|
||||||
* 类型:String(128)
|
* 类型:String(128)
|
||||||
@ -248,7 +247,7 @@ public class WxPayOrderNotifyResult extends BaseWxPayResult implements Serializa
|
|||||||
private String attach;
|
private String attach;
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 字段名:支付完成时间
|
* 字段名:支付完成时间.
|
||||||
* 变量名:time_end
|
* 变量名:time_end
|
||||||
* 是否必填:是
|
* 是否必填:是
|
||||||
* 类型:String(14)
|
* 类型:String(14)
|
||||||
|
|||||||
@ -40,15 +40,13 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
@Data
|
@Data
|
||||||
public abstract class BaseWxPayResult implements Serializable {
|
public abstract class BaseWxPayResult implements Serializable {
|
||||||
private static final long serialVersionUID = 2416778827989487412L;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回状态码
|
* 返回状态码.
|
||||||
*/
|
*/
|
||||||
@XStreamAlias("return_code")
|
@XStreamAlias("return_code")
|
||||||
protected String returnCode;
|
protected String returnCode;
|
||||||
/**
|
/**
|
||||||
* 返回信息
|
* 返回信息.
|
||||||
*/
|
*/
|
||||||
@XStreamAlias("return_msg")
|
@XStreamAlias("return_msg")
|
||||||
protected String returnMsg;
|
protected String returnMsg;
|
||||||
@ -56,64 +54,64 @@ public abstract class BaseWxPayResult implements Serializable {
|
|||||||
//当return_code为SUCCESS的时候,还会包括以下字段:
|
//当return_code为SUCCESS的时候,还会包括以下字段:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 业务结果
|
* 业务结果.
|
||||||
*/
|
*/
|
||||||
@XStreamAlias("result_code")
|
@XStreamAlias("result_code")
|
||||||
private String resultCode;
|
private String resultCode;
|
||||||
/**
|
/**
|
||||||
* 错误代码
|
* 错误代码.
|
||||||
*/
|
*/
|
||||||
@XStreamAlias("err_code")
|
@XStreamAlias("err_code")
|
||||||
private String errCode;
|
private String errCode;
|
||||||
/**
|
/**
|
||||||
* 错误代码描述
|
* 错误代码描述.
|
||||||
*/
|
*/
|
||||||
@XStreamAlias("err_code_des")
|
@XStreamAlias("err_code_des")
|
||||||
private String errCodeDes;
|
private String errCodeDes;
|
||||||
/**
|
/**
|
||||||
* 公众账号ID
|
* 公众账号ID.
|
||||||
*/
|
*/
|
||||||
@XStreamAlias("appid")
|
@XStreamAlias("appid")
|
||||||
private String appid;
|
private String appid;
|
||||||
/**
|
/**
|
||||||
* 商户号
|
* 商户号.
|
||||||
*/
|
*/
|
||||||
@XStreamAlias("mch_id")
|
@XStreamAlias("mch_id")
|
||||||
private String mchId;
|
private String mchId;
|
||||||
/**
|
/**
|
||||||
* 服务商模式下的子公众账号ID
|
* 服务商模式下的子公众账号ID.
|
||||||
*/
|
*/
|
||||||
@XStreamAlias("sub_appid")
|
@XStreamAlias("sub_appid")
|
||||||
private String subAppId;
|
private String subAppId;
|
||||||
/**
|
/**
|
||||||
* 服务商模式下的子商户号
|
* 服务商模式下的子商户号.
|
||||||
*/
|
*/
|
||||||
@XStreamAlias("sub_mch_id")
|
@XStreamAlias("sub_mch_id")
|
||||||
private String subMchId;
|
private String subMchId;
|
||||||
/**
|
/**
|
||||||
* 随机字符串
|
* 随机字符串.
|
||||||
*/
|
*/
|
||||||
@XStreamAlias("nonce_str")
|
@XStreamAlias("nonce_str")
|
||||||
private String nonceStr;
|
private String nonceStr;
|
||||||
/**
|
/**
|
||||||
* 签名
|
* 签名.
|
||||||
*/
|
*/
|
||||||
@XStreamAlias("sign")
|
@XStreamAlias("sign")
|
||||||
private String sign;
|
private String sign;
|
||||||
|
|
||||||
//以下为辅助属性
|
//以下为辅助属性
|
||||||
/**
|
/**
|
||||||
* xml字符串
|
* xml字符串.
|
||||||
*/
|
*/
|
||||||
private String xmlString;
|
private String xmlString;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xml的Document对象,用于解析xml文本
|
* xml的Document对象,用于解析xml文本.
|
||||||
*/
|
*/
|
||||||
private Document xmlDoc;
|
private Document xmlDoc;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将单位分转换成单位圆
|
* 将单位分转换成单位圆.
|
||||||
*
|
*
|
||||||
* @param fee 将要被转换为元的分的数值
|
* @param fee 将要被转换为元的分的数值
|
||||||
*/
|
*/
|
||||||
@ -122,7 +120,7 @@ public abstract class BaseWxPayResult implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从xml字符串创建bean对象
|
* 从xml字符串创建bean对象.
|
||||||
*/
|
*/
|
||||||
public static <T extends BaseWxPayResult> T fromXML(String xmlString, Class<T> clz) {
|
public static <T extends BaseWxPayResult> T fromXML(String xmlString, Class<T> clz) {
|
||||||
XStream xstream = XStreamInitializer.getInstance();
|
XStream xstream = XStreamInitializer.getInstance();
|
||||||
@ -142,7 +140,7 @@ public abstract class BaseWxPayResult implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将bean通过保存的xml字符串转换成map
|
* 将bean通过保存的xml字符串转换成map.
|
||||||
*/
|
*/
|
||||||
public Map<String, String> toMap() {
|
public Map<String, String> toMap() {
|
||||||
if (StringUtils.isBlank(this.xmlString)) {
|
if (StringUtils.isBlank(this.xmlString)) {
|
||||||
@ -168,9 +166,9 @@ public abstract class BaseWxPayResult implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将xml字符串转换成Document对象,以便读取其元素值
|
* 将xml字符串转换成Document对象,以便读取其元素值.
|
||||||
*/
|
*/
|
||||||
protected Document getXmlDoc() {
|
private Document getXmlDoc() {
|
||||||
if (this.xmlDoc != null) {
|
if (this.xmlDoc != null) {
|
||||||
return this.xmlDoc;
|
return this.xmlDoc;
|
||||||
}
|
}
|
||||||
@ -188,9 +186,9 @@ public abstract class BaseWxPayResult implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取xml中元素的值
|
* 获取xml中元素的值.
|
||||||
*/
|
*/
|
||||||
protected String getXmlValue(String... path) {
|
String getXmlValue(String... path) {
|
||||||
Document doc = this.getXmlDoc();
|
Document doc = this.getXmlDoc();
|
||||||
String expression = String.format("/%s//text()", Joiner.on("/").join(path));
|
String expression = String.format("/%s//text()", Joiner.on("/").join(path));
|
||||||
try {
|
try {
|
||||||
@ -205,9 +203,9 @@ public abstract class BaseWxPayResult implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取xml中元素的值,作为int值返回
|
* 获取xml中元素的值,作为int值返回.
|
||||||
*/
|
*/
|
||||||
protected Integer getXmlValueAsInt(String... path) {
|
Integer getXmlValueAsInt(String... path) {
|
||||||
String result = this.getXmlValue(path);
|
String result = this.getXmlValue(path);
|
||||||
if (StringUtils.isBlank(result)) {
|
if (StringUtils.isBlank(result)) {
|
||||||
return null;
|
return null;
|
||||||
@ -217,7 +215,7 @@ public abstract class BaseWxPayResult implements Serializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 校验返回结果签名
|
* 校验返回结果签名.
|
||||||
*
|
*
|
||||||
* @param signType 签名类型
|
* @param signType 签名类型
|
||||||
* @param checkSuccess 是否同时检查结果是否成功
|
* @param checkSuccess 是否同时检查结果是否成功
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import lombok.NoArgsConstructor;
|
|||||||
public class WxPayAuthcode2OpenidResult extends BaseWxPayResult {
|
public class WxPayAuthcode2OpenidResult extends BaseWxPayResult {
|
||||||
/**
|
/**
|
||||||
* <pre>
|
* <pre>
|
||||||
* 用户标识
|
* 用户标识.
|
||||||
* openid
|
* openid
|
||||||
* 是
|
* 是
|
||||||
* String(128)
|
* String(128)
|
||||||
|
|||||||
@ -11,8 +11,8 @@ import org.testng.annotations.*;
|
|||||||
*/
|
*/
|
||||||
public class WxPayOrderQueryResultTest {
|
public class WxPayOrderQueryResultTest {
|
||||||
@Test
|
@Test
|
||||||
public void testComposeCoupons() throws Exception {
|
public void testComposeCoupons() {
|
||||||
/**
|
/*
|
||||||
* xml样例字符串来自于官方文档,并稍加改造加入了coupon相关的数据便于测试
|
* xml样例字符串来自于官方文档,并稍加改造加入了coupon相关的数据便于测试
|
||||||
*/
|
*/
|
||||||
String xmlString = "<xml>\n" +
|
String xmlString = "<xml>\n" +
|
||||||
|
|||||||
Reference in New Issue
Block a user