主要去掉了实体类中的字段上@JSONFiled上的deserialize=false属性和不合理的format方法

This commit is contained in:
jinyu
2015-08-07 15:21:02 +08:00
parent 418f63d501
commit 4d5a6b228b
61 changed files with 946 additions and 760 deletions
@@ -56,7 +56,8 @@ public class Button implements Serializable {
@JSONField(name = "sub_button")
private List<Button> subs;
public Button() {
protected Button() {
this.subs = new ArrayList<Button>();
}
/**
@@ -73,6 +74,7 @@ public class Button implements Serializable {
this.name = name;
this.content = content;
this.type = type;
this.subs = new ArrayList<Button>();
}
public String getName() {
@@ -108,9 +110,6 @@ public class Button implements Serializable {
}
public Button pushSub(Button btn) {
if (this.subs == null) {
this.subs = new ArrayList<Button>();
}
this.subs.add(btn);
return this;
}
@@ -5,6 +5,7 @@ import java.util.Date;
import java.util.List;
import com.alibaba.fastjson.annotation.JSONField;
import com.alibaba.fastjson.util.TypeUtils;
import com.foxinmy.weixin4j.tuple.MpArticle;
/**
@@ -33,7 +34,7 @@ public class MediaItem implements Serializable {
* 媒体素材最后更新时间
*/
@JSONField(name = "update_time")
private Date updateTime;
private String updateTime;
/**
* 图文素材列表
*/
@@ -56,11 +57,16 @@ public class MediaItem implements Serializable {
this.name = name;
}
public Date getUpdateTime() {
public String getUpdateTime() {
return updateTime;
}
public void setUpdateTime(Date updateTime) {
@JSONField(serialize = false)
public Date getForamtUpdateTime() {
return updateTime != null ? TypeUtils.castToDate(updateTime) : null;
}
public void setUpdateTime(String updateTime) {
this.updateTime = updateTime;
}
@@ -25,42 +25,36 @@ public class JsPayNotify extends PayBaseInfo {
/**
* 用户的openid
*/
@JSONField(name = "OpenId")
@XmlElement(name = "OpenId")
private String openid;
private String openId;
/**
* 是否关注公众号
*/
@JSONField(name = "IsSubscribe")
@XmlElement(name = "IsSubscribe")
private int issubscribe;
private int isSubscribe;
public JsPayNotify() {
}
public String getOpenid() {
return openid;
public String getOpenId() {
return openId;
}
public void setOpenid(String openid) {
this.openid = openid;
public int getIsSubscribe() {
return isSubscribe;
}
public int getIssubscribe() {
return issubscribe;
}
public void setIssubscribe(int issubscribe) {
this.issubscribe = issubscribe;
}
@JSONField(serialize = false, deserialize = false)
public boolean getFormatIssubscribe() {
return issubscribe == 1;
@JSONField(serialize = false)
public boolean getFormatIsSubscribe() {
return isSubscribe == 1;
}
@Override
public String toString() {
return "openid=" + openid + ", issubscribe=" + getFormatIssubscribe()
return "openId=" + openId + ", isSubscribe=" + getFormatIsSubscribe()
+ ", " + super.toString();
}
}
@@ -28,7 +28,9 @@ public class MicroPayPackage extends PayPackage {
/**
* 微信分配的公众账号 必须
*/
private String appid;
@XmlElement(name = "appid")
@JSONField(name = "appid")
private String appId;
/**
* 微信支付分配的商户号 必须
*/
@@ -58,10 +60,10 @@ public class MicroPayPackage extends PayPackage {
@JSONField(name = "auth_code")
private String authCode;
protected MicroPayPackage(){
protected MicroPayPackage() {
// jaxb required
}
public MicroPayPackage(WeixinPayAccount weixinAccount, String body,
String attach, String outTradeNo, double totalFee,
String spbillCreateIp, String authCode) {
@@ -71,21 +73,21 @@ public class MicroPayPackage extends PayPackage {
authCode);
}
public MicroPayPackage(String appid, String mchId, String deviceInfo,
public MicroPayPackage(String appId, String mchId, String deviceInfo,
String nonceStr, String body, String attach, String outTradeNo,
double totalFee, String spbillCreateIp, Date timeStart,
Date timeExpire, String goodsTag, String authCode) {
super(body, attach, outTradeNo, totalFee, spbillCreateIp, timeStart,
timeExpire, goodsTag, null);
this.appid = appid;
this.appId = appId;
this.mchId = mchId;
this.deviceInfo = deviceInfo;
this.nonceStr = nonceStr;
this.authCode = authCode;
}
public String getAppid() {
return appid;
public String getAppId() {
return appId;
}
public String getMchId() {
@@ -118,7 +120,7 @@ public class MicroPayPackage extends PayPackage {
@Override
public String toString() {
return "MicroPayPackage [appid=" + appid + ", mchId=" + mchId
return "MicroPayPackage [appId=" + appId + ", mchId=" + mchId
+ ", deviceInfo=" + deviceInfo + ", nonceStr=" + nonceStr
+ ", sign=" + sign + ", authCode=" + authCode + ", "
+ super.toString() + "]";
@@ -28,26 +28,31 @@ public class PayBaseInfo implements Serializable {
/**
* 公众号ID
*/
@JSONField(name = "AppId")
@XmlElement(name = "AppId")
private String appId;
/**
* 时间戳
*/
@JSONField(name = "TimeStamp")
@XmlElement(name = "TimeStamp")
private String timeStamp;
/**
* 随机字符串
*/
@JSONField(name = "NonceStr")
@XmlElement(name = "NonceStr")
private String nonceStr;
/**
* 签名结果
*/
@JSONField(name = "AppSignature")
@XmlElement(name = "AppSignature")
private String paySign;
/**
* 签名方式
*/
@JSONField(name = "SignMethod")
@XmlElement(name = "SignMethod")
private String signType;
@@ -87,17 +92,14 @@ public class PayBaseInfo implements Serializable {
return signType;
}
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public SignType getFormatSignType() {
return SignType.valueOf(signType.toUpperCase());
return signType != null ? SignType.valueOf(signType.toUpperCase())
: null;
}
public void setSignType(SignType signType) {
if (signType != null) {
this.signType = signType.name();
} else {
this.signType = null;
}
this.signType = signType != null ? signType.name() : null;
}
public PayBaseInfo() {
@@ -13,7 +13,6 @@ import com.foxinmy.weixin4j.type.CouponStatus;
import com.foxinmy.weixin4j.type.CouponStockType;
import com.foxinmy.weixin4j.type.CouponType;
import com.foxinmy.weixin4j.util.DateUtil;
import com.foxinmy.weixin4j.util.StringUtil;
/**
* 代金券详细
@@ -173,10 +172,10 @@ public class CouponDetail extends ApiResult {
@JSONField(name = "is_partial_use")
private int isPartialUse;
public CouponDetail(){
public CouponDetail() {
}
public String getCouponStockId() {
return couponStockId;
}
@@ -185,7 +184,7 @@ public class CouponDetail extends ApiResult {
return couponStockType;
}
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public CouponStockType getFormatCouponStockType() {
for (CouponStockType couponStockType : CouponStockType.values()) {
if (couponStockType.getVal() == this.couponStockType) {
@@ -208,7 +207,7 @@ public class CouponDetail extends ApiResult {
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatCouponValue() {
return couponValue / 100d;
}
@@ -222,7 +221,7 @@ public class CouponDetail extends ApiResult {
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatCouponMininum() {
return couponMininum / 100d;
}
@@ -235,7 +234,7 @@ public class CouponDetail extends ApiResult {
return couponStatus;
}
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public CouponStatus getFormatCouponStatus() {
for (CouponStatus couponStatus : CouponStatus.values()) {
if (couponStatus.getVal() == this.couponStatus) {
@@ -272,7 +271,7 @@ public class CouponDetail extends ApiResult {
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatCouponUseValue() {
return couponUseValue / 100d;
}
@@ -286,7 +285,7 @@ public class CouponDetail extends ApiResult {
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatCouponRemainValue() {
return couponRemainValue / 100d;
}
@@ -295,37 +294,38 @@ public class CouponDetail extends ApiResult {
return beginTime;
}
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public Date getFormatBeginTime() {
return DateUtil.parse2yyyyMMddHHmmss(beginTime);
return beginTime != null ? DateUtil.parse2yyyyMMddHHmmss(beginTime)
: null;
}
public String getEndTime() {
return endTime;
}
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public Date getFormatEndTime() {
return DateUtil.parse2yyyyMMddHHmmss(endTime);
return endTime != null ? DateUtil.parse2yyyyMMddHHmmss(endTime) : null;
}
public String getSendTime() {
return sendTime;
}
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public Date getFormatSendTime() {
return DateUtil.parse2yyyyMMddHHmmss(sendTime);
return sendTime != null ? DateUtil.parse2yyyyMMddHHmmss(sendTime)
: null;
}
public String getUseTime() {
return useTime;
}
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public Date getFormatUseTime() {
return StringUtil.isNotBlank(useTime) ? DateUtil
.parse2yyyyMMddHHmmss(useTime) : null;
return useTime != null ? DateUtil.parse2yyyyMMddHHmmss(useTime) : null;
}
public String getTradeNo() {
@@ -352,7 +352,7 @@ public class CouponDetail extends ApiResult {
return isPartialUse;
}
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public boolean getFormatIsPartialUse() {
return isPartialUse == 1;
}
@@ -374,7 +374,6 @@ public class CouponDetail extends ApiResult {
+ ", consumerMchId=" + consumerMchId + ", consumerMchName="
+ consumerMchName + ", consumerMchAppid=" + consumerMchAppid
+ ", sendSource=" + sendSource + ", isPartialUse="
+ getFormatIsPartialUse() + ", " + super.toString()
+ "]";
+ getFormatIsPartialUse() + ", " + super.toString() + "]";
}
}
@@ -43,10 +43,10 @@ public class CouponInfo implements Serializable {
@JSONField(name = "coupon_fee")
private Integer couponFee;
public CouponInfo(){
public CouponInfo() {
}
public String getCouponBatchId() {
return couponBatchId;
}
@@ -64,9 +64,9 @@ public class CouponInfo implements Serializable {
*
* @return 元单位
*/
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public double getFormatCouponFee() {
return couponFee / 100d;
return couponFee != null ? couponFee.doubleValue() / 100d : 0d;
}
public void setCouponId(String couponId) {
@@ -71,11 +71,11 @@ public class CouponResult extends ApiResult {
@XmlElement(name = "ret_msg")
@JSONField(name = "ret_msg")
private String retMsg;
public CouponResult(){
public CouponResult() {
}
public String getCouponStockId() {
return couponStockId;
}
@@ -84,37 +84,30 @@ public class CouponResult extends ApiResult {
return responseCount;
}
public int getSuccessCount() {
return successCount;
}
public int getFailedCount() {
return failedCount;
}
public String getOpenId() {
return openId;
}
public String getRetCode() {
return retCode;
}
public String getCouponId() {
return couponId;
}
public String getRetMsg() {
return retMsg;
}
@Override
public String toString() {
return "CouponResult [couponStockId=" + couponStockId
@@ -119,10 +119,10 @@ public class CouponStock extends ApiResult {
@JSONField(name = "coupon_budget")
private Integer couponBudget;
public CouponStock(){
public CouponStock() {
}
public String getCouponStockId() {
return couponStockId;
}
@@ -140,7 +140,7 @@ public class CouponStock extends ApiResult {
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatCouponValue() {
return couponValue / 100d;
}
@@ -154,7 +154,7 @@ public class CouponStock extends ApiResult {
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatCouponMininumn() {
return couponMininumn != null ? couponMininumn.intValue() / 100d : 0d;
}
@@ -163,7 +163,7 @@ public class CouponStock extends ApiResult {
return couponType;
}
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public CouponType getFormatCouponType() {
for (CouponType couponType : CouponType.values()) {
if (couponType.getVal() == this.couponType) {
@@ -177,7 +177,7 @@ public class CouponStock extends ApiResult {
return couponStockStatus;
}
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public CouponStockStatus getFormatCouponStockStatus() {
for (CouponStockStatus couponStockStatus : CouponStockStatus.values()) {
if (couponStockStatus.getVal() == this.couponStockStatus) {
@@ -200,7 +200,7 @@ public class CouponStock extends ApiResult {
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatMaxQuota() {
return maxQuota != null ? maxQuota.intValue() / 100d : 0d;
}
@@ -214,7 +214,7 @@ public class CouponStock extends ApiResult {
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatLockedNum() {
return lockedNum != null ? lockedNum.intValue() / 100d : 0d;
}
@@ -228,7 +228,7 @@ public class CouponStock extends ApiResult {
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatUsedNum() {
return usedNum != null ? usedNum.intValue() / 100d : 0d;
}
@@ -242,7 +242,7 @@ public class CouponStock extends ApiResult {
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatSendNum() {
return sendNum != null ? sendNum.intValue() / 100d : 0d;
}
@@ -251,27 +251,29 @@ public class CouponStock extends ApiResult {
return beginTime;
}
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public Date getFormatBeginTime() {
return DateUtil.parse2yyyyMMddHHmmss(beginTime);
return beginTime != null ? DateUtil.parse2yyyyMMddHHmmss(beginTime)
: null;
}
public String getEndTime() {
return endTime;
}
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public Date getFormatEndTime() {
return DateUtil.parse2yyyyMMddHHmmss(endTime);
return endTime != null ? DateUtil.parse2yyyyMMddHHmmss(endTime) : null;
}
public String getCreateTime() {
return createTime;
}
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public Date getFormatCreateTime() {
return DateUtil.parse2yyyyMMddHHmmss(createTime);
return createTime != null ? DateUtil.parse2yyyyMMddHHmmss(createTime)
: null;
}
public Integer getCouponBudget() {
@@ -283,7 +285,7 @@ public class CouponStock extends ApiResult {
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatCouponBudget() {
return couponBudget != null ? couponBudget.intValue() / 100d : 0d;
}
@@ -7,7 +7,6 @@ import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.http.weixin.XmlResult;
import com.foxinmy.weixin4j.util.StringUtil;
/**
* 调用V3.x接口返回的公用字段
@@ -88,7 +87,7 @@ public class ApiResult extends XmlResult {
}
public String getSubMchId() {
return StringUtil.isNotBlank(subMchId) ? subMchId : null;
return subMchId;
}
public void setSubMchId(String subMchId) {
@@ -127,7 +126,7 @@ public class ApiResult extends XmlResult {
this.recall = recall;
}
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public boolean getFormatRecall() {
return recall != null && recall.equalsIgnoreCase("y");
}
@@ -34,7 +34,9 @@ public class MPPayment implements Serializable {
/**
* 接收红包的用户的openid
*/
private String openid;
@JSONField(name = "openid")
@XmlElement(name = "openid")
private String openId;
/**
* 校验用户姓名选项
*
@@ -71,17 +73,17 @@ public class MPPayment implements Serializable {
/**
* 企业付款
* @param outTradeNo 商户的订单号
* @param openid 用户的openid
* @param openId 用户的openid
* @param checkNameType 校验用户姓名选项
* @param desc 描述
* @param amount 金额
* @param clientIp 调用接口IP
*/
public MPPayment(String outTradeNo, String openid,
public MPPayment(String outTradeNo, String openId,
MPPaymentCheckNameType checkNameType, String desc, double amount,
String clientIp) {
this.outTradeNo = outTradeNo;
this.openid = openid;
this.openId = openId;
this.checkNameType = checkNameType;
this.desc = desc;
this.amount = DateUtil.formaFee2Fen(amount);
@@ -92,8 +94,8 @@ public class MPPayment implements Serializable {
return outTradeNo;
}
public String getOpenid() {
return openid;
public String getOpenId() {
return openId;
}
public MPPaymentCheckNameType getCheckNameType() {
@@ -122,7 +124,7 @@ public class MPPayment implements Serializable {
@Override
public String toString() {
return "MPPayment [outTradeNo=" + outTradeNo + ", openid=" + openid
return "MPPayment [outTradeNo=" + outTradeNo + ", openId=" + openId
+ ", checkNameType=" + checkNameType + ", userName=" + userName
+ ", desc=" + desc + ", amount=" + amount + ", clientIp="
+ clientIp + "]";
@@ -53,8 +53,9 @@ public class MPPaymentRecord extends ApiResult {
/**
* 收款用户openid
*/
@JSONField(name = "openid")
@XmlElement(name = "openid")
private String openid;
private String openId;
/**
* 收款用户姓名
*/
@@ -80,7 +81,7 @@ public class MPPaymentRecord extends ApiResult {
*/
@XmlElement(name = "check_name")
@JSONField(name = "check_name")
private MPPaymentCheckNameType checkNameType;
private String checkNameType;
/**
* 企业付款描述信息
*/
@@ -123,8 +124,8 @@ public class MPPaymentRecord extends ApiResult {
return failureReason;
}
public String getOpenid() {
return openid;
public String getOpenId() {
return openId;
}
public String getTransferName() {
@@ -156,13 +157,20 @@ public class MPPaymentRecord extends ApiResult {
*/
@JSONField(serialize = false)
public Date getFormatTransferTime() {
return DateUtil.parse2yyyyMMddHHmmss(transferTime);
return transferTime != null ? DateUtil
.parse2yyyyMMddHHmmss(transferTime) : null;
}
public MPPaymentCheckNameType getCheckNameType() {
public String getCheckNameType() {
return checkNameType;
}
@JSONField(serialize = false)
public MPPaymentCheckNameType getFormatCheckNameType() {
return checkNameType != null ? MPPaymentCheckNameType
.valueOf(checkNameType) : null;
}
public String getDesc() {
return desc;
}
@@ -186,7 +194,7 @@ public class MPPaymentRecord extends ApiResult {
return "MPPaymentRecord [transactionId=" + transactionId
+ ", outTradeNo=" + outTradeNo + ", transactionStatus="
+ getFormatTransactionStatus() + ", failureReason="
+ failureReason + ", openid=" + openid + ", transferName="
+ failureReason + ", openId=" + openId + ", transferName="
+ transferName + ", paymentAmount=" + getFormatPaymentAmount()
+ ", transferTime=" + transferTime + ", checkNameType="
+ checkNameType + ", desc=" + desc + ", checkNameResult="
@@ -31,7 +31,9 @@ public class MchPayPackage extends PayPackage {
/**
* 微信分配的公众账号 必须
*/
private String appid;
@XmlElement(name = "appid")
@JSONField(name = "appid")
private String appId;
/**
* 微信支付分配的商户号 必须
*/
@@ -63,7 +65,9 @@ public class MchPayPackage extends PayPackage {
/**
* 用户在商户 appid 下的唯一 标识, trade_type 为 JSAPI 时,此参数必传
*/
private String openid;
@XmlElement(name = "openid")
@JSONField(name = "openid")
private String openId;
/**
* 只在 trade_type 为 NATIVE 时需要填写 非必须
*/
@@ -91,24 +95,24 @@ public class MchPayPackage extends PayPackage {
notifyUrl, tradeType, openId, null);
}
public MchPayPackage(String appid, String mchId, String deviceInfo,
public MchPayPackage(String appId, String mchId, String deviceInfo,
String nonceStr, String body, String attach, String outTradeNo,
double totalFee, String spbillCreateIp, Date timeStart,
Date timeExpire, String goodsTag, String notifyUrl,
TradeType tradeType, String openid, String productId) {
TradeType tradeType, String openId, String productId) {
super(body, attach, outTradeNo, totalFee, spbillCreateIp, timeStart,
timeExpire, goodsTag, notifyUrl);
this.appid = appid;
this.appId = appId;
this.mchId = mchId;
this.deviceInfo = deviceInfo;
this.nonceStr = nonceStr;
this.tradeType = tradeType.name();
this.openid = openid;
this.openId = openId;
this.productId = productId;
}
public String getAppid() {
return appid;
public String getAppId() {
return appId;
}
public String getMchId() {
@@ -135,8 +139,8 @@ public class MchPayPackage extends PayPackage {
return tradeType;
}
public String getOpenid() {
return openid;
public String getOpenId() {
return openId;
}
public String getProductId() {
@@ -149,10 +153,10 @@ public class MchPayPackage extends PayPackage {
@Override
public String toString() {
return "MchPayPackage [appid=" + appid + ", mchId=" + mchId
return "MchPayPackage [appId=" + appId + ", mchId=" + mchId
+ ", deviceInfo=" + deviceInfo + ", nonceStr=" + nonceStr
+ ", sign=" + sign + ", tradeType=" + tradeType + ", openid="
+ openid + ", productId=" + productId + ", " + super.toString()
+ ", sign=" + sign + ", tradeType=" + tradeType + ", openId="
+ openId + ", productId=" + productId + ", " + super.toString()
+ "]";
}
}
@@ -30,7 +30,8 @@ public class NativePayResponse extends ApiResult {
@JSONField(serialize = false)
private PrePay prePay;
private String prepay_id;
@JSONField(name = "prepay_id")
private String prepayId;
protected NativePayResponse() {
// jaxb required
@@ -64,24 +65,24 @@ public class NativePayResponse extends ApiResult {
super.setReturnCode(Consts.SUCCESS);
this.setResultCode(Consts.SUCCESS);
this.setMchId(payPackage.getMchId());
this.setAppId(payPackage.getAppid());
this.setAppId(payPackage.getAppId());
this.setNonceStr(RandomUtil.generateString(16));
this.prePay = PayUtil.createPrePay(payPackage, paysignKey);
this.prepay_id = prePay.getPrepayId();
this.prepayId = prePay.getPrepayId();
}
public String getPrepay_id() {
return prepay_id;
public String getPrepayId() {
return prepayId;
}
public void setPrepay_id(String prepay_id) {
this.prepay_id = prepay_id;
public void setPrepayId(String prepayId) {
this.prepayId = prepayId;
}
@Override
public String toString() {
return "NativePayResponseV3 [prePay=" + prePay + ", prepay_id="
+ prepay_id + ", " + super.toString() + "]";
return "NativePayResponseV3 [prePay=" + prePay + ", prepayId="
+ prepayId + ", " + super.toString() + "]";
}
}
@@ -14,7 +14,6 @@ import com.foxinmy.weixin4j.type.CurrencyType;
import com.foxinmy.weixin4j.type.TradeState;
import com.foxinmy.weixin4j.type.TradeType;
import com.foxinmy.weixin4j.util.DateUtil;
import com.foxinmy.weixin4j.util.StringUtil;
import com.foxinmy.weixin4j.xml.ListsuffixResult;
/**
@@ -38,7 +37,7 @@ public class Order extends ApiResult {
*/
@XmlElement(name = "trade_state")
@JSONField(name = "trade_state")
private TradeState tradeState;
private String tradeState;
/**
* 用户的openid
*/
@@ -58,7 +57,7 @@ public class Order extends ApiResult {
*/
@XmlElement(name = "trade_type")
@JSONField(name = "trade_type")
private TradeType tradeType;
private String tradeType;
/**
* 银行类型
*/
@@ -101,7 +100,7 @@ public class Order extends ApiResult {
*/
@XmlElement(name = "fee_type")
@JSONField(name = "fee_type")
private CurrencyType feeType;
private String feeType;
/**
* 微信支付订单号
*/
@@ -135,8 +134,9 @@ public class Order extends ApiResult {
// jaxb required
}
public TradeState getTradeState() {
return tradeState;
@JSONField(serialize = false)
public TradeState getFormatTradeState() {
return tradeState != null ? TradeState.valueOf(tradeState.toUpperCase()) : null;
}
public String getOpenId() {
@@ -147,13 +147,14 @@ public class Order extends ApiResult {
return isSubscribe;
}
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public boolean getFormatIsSubscribe() {
return isSubscribe != null && isSubscribe.equalsIgnoreCase("y");
}
public TradeType getTradeType() {
return tradeType;
@JSONField(serialize = false)
public TradeType getFormatTradeType() {
return tradeType != null ? TradeType.valueOf(tradeType.toUpperCase()) : null;
}
public String getBankType() {
@@ -169,7 +170,7 @@ public class Order extends ApiResult {
*
* @return 元单位
*/
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public double getFormatTotalFee() {
return totalFee / 100d;
}
@@ -183,7 +184,7 @@ public class Order extends ApiResult {
*
* @return 元单位
*/
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public double getFormatCouponFee() {
return couponFee != null ? couponFee / 100d : 0d;
}
@@ -192,11 +193,6 @@ public class Order extends ApiResult {
return couponCount;
}
@JSONField(serialize = false, deserialize = false)
public int getFormatCouponCount() {
return couponCount != null ? couponCount.intValue() : 0;
}
public int getCashFee() {
return cashFee;
}
@@ -206,12 +202,25 @@ public class Order extends ApiResult {
*
* @return 元单位
*/
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public double getFormatCashFee() {
return cashFee / 100d;
}
public CurrencyType getFeeType() {
@JSONField(serialize = false)
public CurrencyType getFormatFeeType() {
return feeType != null ? CurrencyType.valueOf(feeType.toUpperCase()) : null;
}
public String getTradeState() {
return tradeState;
}
public String getTradeType() {
return tradeType;
}
public String getFeeType() {
return feeType;
}
@@ -231,12 +240,9 @@ public class Order extends ApiResult {
return timeEnd;
}
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public Date getFormatTimeEnd() {
if (StringUtil.isNotBlank(timeEnd)) {
return DateUtil.parse2yyyyMMddHHmmss(timeEnd);
}
return null;
return timeEnd != null ? DateUtil.parse2yyyyMMddHHmmss(timeEnd) : null;
}
public String getTradeStateDesc() {
@@ -259,10 +265,10 @@ public class Order extends ApiResult {
+ ", transactionId=" + transactionId + ", outTradeNo="
+ outTradeNo + ", attach=" + attach + ", timeEnd=" + timeEnd
+ ", totalFee=" + getFormatTotalFee() + ", couponFee="
+ getFormatCouponFee() + ", couponCount="
+ getFormatCouponCount() + ", couponList=" + couponList
+ ", cashFee=" + getFormatCashFee() + ", timeEnd="
+ getFormatTimeEnd() + ", tradeStateDesc=" + tradeStateDesc
+ ", " + super.toString() + "]";
+ getFormatCouponFee() + ", couponCount=" + couponCount
+ ", couponList=" + couponList + ", cashFee="
+ getFormatCashFee() + ", timeEnd=" + getFormatTimeEnd()
+ ", tradeStateDesc=" + tradeStateDesc + ", "
+ super.toString() + "]";
}
}
@@ -16,7 +16,6 @@ import com.foxinmy.weixin4j.type.RedpacketSendType;
import com.foxinmy.weixin4j.type.RedpacketStatus;
import com.foxinmy.weixin4j.type.RedpacketType;
import com.foxinmy.weixin4j.util.DateUtil;
import com.foxinmy.weixin4j.util.StringUtil;
/**
* 红包记录
@@ -56,19 +55,19 @@ public class RedpacketRecord extends XmlResult {
* 红包状态
*/
@XmlElement(name = "status")
private RedpacketStatus status;
private String status;
/**
* 发放类型
*/
@XmlElement(name = "send_type")
@JSONField(name = "send_type")
private RedpacketSendType sendType;
private String sendType;
/**
* 红包类型
*/
@XmlElement(name = "hb_type")
@JSONField(name = "hb_type")
private RedpacketType type;
private String hbType;
/**
* 红包个数
*/
@@ -140,16 +139,32 @@ public class RedpacketRecord extends XmlResult {
return repacketId;
}
public RedpacketStatus getStatus() {
@JSONField(serialize = false)
public RedpacketStatus getFormatStatus() {
return status != null ? RedpacketStatus.valueOf(status.toUpperCase())
: null;
}
@JSONField(serialize = false)
public RedpacketSendType getFormatSendType() {
return sendType != null ? RedpacketSendType.valueOf(sendType) : null;
}
@JSONField(serialize = false)
public RedpacketType getFomatHbType() {
return hbType != null ? RedpacketType.valueOf(hbType) : null;
}
public String getStatus() {
return status;
}
public RedpacketSendType getSendType() {
public String getSendType() {
return sendType;
}
public RedpacketType getType() {
return type;
public String getHbType() {
return hbType;
}
public int getTotalNum() {
@@ -165,7 +180,7 @@ public class RedpacketRecord extends XmlResult {
*
* @return 元单位
*/
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public double getFormatTotalAmount() {
return totalAmount / 100d;
}
@@ -178,21 +193,20 @@ public class RedpacketRecord extends XmlResult {
return sendTime;
}
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public Date getFormatSendTime() {
return DateUtil.parse2yyyyMMddHHmmss(sendTime);
return sendTime != null ? DateUtil.parse2yyyyMMddHHmmss(sendTime)
: null;
}
public String getRefundTime() {
return refundTime;
}
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public Date getFormatRefundTime() {
if (StringUtil.isNotBlank(refundTime)) {
return DateUtil.parse2yyyyMMddHHmmss(refundTime);
}
return null;
return refundTime != null ? DateUtil.parse2yyyyMMddHHmmss(refundTime)
: null;
}
public Integer getRefundAmount() {
@@ -204,12 +218,9 @@ public class RedpacketRecord extends XmlResult {
*
* @return 元单位
*/
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public double getFormatRefundAmount() {
if (refundAmount != null) {
return refundAmount.intValue() / 100d;
}
return 0d;
return refundAmount != null ? refundAmount.intValue() / 100d : 0d;
}
public String getWishing() {
@@ -231,9 +242,9 @@ public class RedpacketRecord extends XmlResult {
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public static class RedpacketReceiver implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 领取红包的Openid
*/
@@ -276,14 +287,15 @@ public class RedpacketRecord extends XmlResult {
*
* @return 元单位
*/
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public double getFormatAmount() {
return amount / 100d;
}
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public Date getFormatReceiveTime() {
return DateUtil.parse2yyyyMMddHHmmss(receiveTime);
return receiveTime != null ? DateUtil
.parse2yyyyMMddHHmmss(receiveTime) : null;
}
@Override
@@ -298,10 +310,10 @@ public class RedpacketRecord extends XmlResult {
public String toString() {
return "RedpacketRecord [outTradeNo=" + outTradeNo + ", mchId=" + mchId
+ ", repacketId=" + repacketId + ", status=" + status
+ ", sendType=" + sendType + ", type=" + type + ", totalNum="
+ totalNum + ", totalAmount=" + getFormatTotalAmount()
+ ", reason=" + reason + ", sendTime=" + sendTime
+ ", refundTime=" + refundTime + ", refundAmount="
+ ", sendType=" + sendType + ", hbType=" + hbType
+ ", totalNum=" + totalNum + ", totalAmount="
+ getFormatTotalAmount() + ", reason=" + reason + ", sendTime="
+ sendTime + ", refundTime=" + refundTime + ", refundAmount="
+ getFormatRefundAmount() + ", wishing=" + wishing
+ ", remark=" + remark + ", actName=" + actName
+ ", receivers=" + receivers + "]";
@@ -27,7 +27,7 @@ public class RedpacketSendResult extends XmlResult {
*/
@XmlElement(name = "wxappid")
@JSONField(name = "wxappid")
private String appid;
private String appId;
/**
* 微信支付分配的商户号
*/
@@ -45,7 +45,7 @@ public class RedpacketSendResult extends XmlResult {
*/
@XmlElement(name = "re_openid")
@JSONField(name = "re_openid")
private String openid;
private String openId;
/**
* 付款金额 单位为分
*/
@@ -56,9 +56,9 @@ public class RedpacketSendResult extends XmlResult {
protected RedpacketSendResult() {
// jaxb required
}
public String getAppid() {
return appid;
public String getAppId() {
return appId;
}
public String getMchId() {
@@ -69,8 +69,8 @@ public class RedpacketSendResult extends XmlResult {
return outTradeNo;
}
public String getOpenid() {
return openid;
public String getOpenId() {
return openId;
}
public int getTotalAmount() {
@@ -82,15 +82,15 @@ public class RedpacketSendResult extends XmlResult {
*
* @return 元单位
*/
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public double getFormatTotalAmount() {
return totalAmount / 100d;
}
@Override
public String toString() {
return "RedpacketSendResult [appid=" + appid + ", mchId=" + mchId
+ ", outTradeNo=" + outTradeNo + ", openid=" + openid
return "RedpacketSendResult [appId=" + appId + ", mchId=" + mchId
+ ", outTradeNo=" + outTradeNo + ", openId=" + openId
+ ", totalAmount=" + totalAmount + ", " + super.toString()
+ "]";
}
@@ -12,7 +12,6 @@ import com.foxinmy.weixin4j.payment.coupon.CouponInfo;
import com.foxinmy.weixin4j.type.CurrencyType;
import com.foxinmy.weixin4j.type.RefundChannel;
import com.foxinmy.weixin4j.type.RefundStatus;
import com.foxinmy.weixin4j.util.StringUtil;
import com.foxinmy.weixin4j.xml.ListsuffixResult;
/**
@@ -61,7 +60,7 @@ public class RefundDetail extends ApiResult {
*/
@XmlElement(name = "refund_fee_type")
@JSONField(name = "refund_fee_type")
private CurrencyType refundFeeType;
private String refundFeeType;
/**
* 订单总金额
*/
@@ -75,7 +74,7 @@ public class RefundDetail extends ApiResult {
*/
@XmlElement(name = "fee_type")
@JSONField(name = "fee_type")
private CurrencyType feeType;
private String feeType;
/**
* 现金支付金额
*/
@@ -89,7 +88,7 @@ public class RefundDetail extends ApiResult {
*/
@XmlElement(name = "cash_fee_type")
@JSONField(name = "cash_fee_type")
private CurrencyType cashFeeType;
private String cashFeeType;
/**
* 现金退款金额
*/
@@ -103,7 +102,7 @@ public class RefundDetail extends ApiResult {
*/
@XmlElement(name = "cash_refund_fee_type")
@JSONField(name = "cash_refund_fee_type")
private CurrencyType cashRefundFeeType;
private String cashRefundFeeType;
/**
* 退款状态
*/
@@ -148,28 +147,32 @@ public class RefundDetail extends ApiResult {
return refundChannel;
}
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public RefundChannel getFormatRefundChannel() {
if (StringUtil.isNotBlank(refundChannel)) {
return RefundChannel.valueOf(refundChannel.toUpperCase());
}
return null;
return refundChannel != null ? RefundChannel.valueOf(refundChannel
.toUpperCase()) : null;
}
public int getRefundFee() {
return refundFee;
}
public CurrencyType getFeeType() {
public String getFeeType() {
return feeType;
}
@JSONField(serialize = false)
public CurrencyType getFormatFeeType() {
return feeType != null ? CurrencyType.valueOf(feeType.toUpperCase())
: null;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatRefundFee() {
return refundFee / 100d;
}
@@ -178,12 +181,10 @@ public class RefundDetail extends ApiResult {
return refundStatus;
}
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public RefundStatus getFormatRefundStatus() {
if (StringUtil.isNotBlank(refundStatus)) {
return RefundStatus.valueOf(refundStatus);
}
return null;
return refundStatus != null ? RefundStatus.valueOf(refundStatus
.toUpperCase()) : null;
}
public Integer getCouponRefundFee() {
@@ -195,15 +196,21 @@ public class RefundDetail extends ApiResult {
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatCouponRefundFee() {
return couponRefundFee != null ? couponRefundFee.intValue() / 100d : 0d;
}
public CurrencyType getRefundFeeType() {
public String getRefundFeeType() {
return refundFeeType;
}
@JSONField(serialize = false)
public CurrencyType getFormatRefundFeeType() {
return refundFeeType != null ? CurrencyType.valueOf(refundFeeType
.toUpperCase()) : null;
}
public int getTotalFee() {
return totalFee;
}
@@ -213,7 +220,7 @@ public class RefundDetail extends ApiResult {
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatTotalFee() {
return totalFee / 100d;
}
@@ -227,15 +234,21 @@ public class RefundDetail extends ApiResult {
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatCashFee() {
return cashFee / 100d;
}
public CurrencyType getCashFeeType() {
public String getCashFeeType() {
return cashFeeType;
}
@JSONField(serialize = false)
public CurrencyType getFormatCashFeeType() {
return cashFeeType != null ? CurrencyType.valueOf(cashFeeType
.toUpperCase()) : null;
}
public Integer getCashRefundFee() {
return cashRefundFee;
}
@@ -245,24 +258,25 @@ public class RefundDetail extends ApiResult {
*
* @return 元单位
*/
@JSONField(deserialize = false, serialize = false)
@JSONField(serialize = false)
public double getFormatCashRefundFee() {
return cashRefundFee != null ? cashRefundFee.intValue() / 100d : 0d;
}
public CurrencyType getCashRefundFeeType() {
public String getCashRefundFeeType() {
return cashRefundFeeType;
}
@JSONField(serialize = false)
public CurrencyType getFormatCashRefundFeeType() {
return cashRefundFeeType != null ? CurrencyType
.valueOf(cashRefundFeeType.toUpperCase()) : null;
}
public Integer getCouponRefundCount() {
return couponRefundCount;
}
@JSONField(deserialize = false, serialize = false)
public int getFormatCouponRefundCount() {
return couponRefundCount != null ? couponRefundCount.intValue() : 0;
}
public List<CouponInfo> getCouponList() {
return couponList;
}
@@ -282,7 +296,7 @@ public class RefundDetail extends ApiResult {
+ getFormatCashRefundFee() + ", cashRefundFeeType="
+ cashRefundFeeType + ", refundStatus=" + refundStatus
+ ", couponRefundFee=" + getFormatCouponRefundFee()
+ ", couponCount=" + getCouponRefundCount() + ", couponList="
+ ", couponRefundCount=" + couponRefundCount + ", couponList="
+ couponList + ", " + super.toString() + "]";
}
}
@@ -50,7 +50,7 @@ public class RefundRecord extends ApiResult {
*/
@XmlElement(name = "fee_type")
@JSONField(name = "fee_type")
private CurrencyType feeType;
private String feeType;
/**
* 现金支付金额
*/
@@ -64,7 +64,7 @@ public class RefundRecord extends ApiResult {
*/
@XmlElement(name = "cash_fee_type")
@JSONField(name = "cash_fee_type")
private CurrencyType cashFeeType;
private String cashFeeType;
/**
* 退款总金额
*/
@@ -108,7 +108,7 @@ public class RefundRecord extends ApiResult {
*
* @return 元单位
*/
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public double getFormatCashFee() {
return cashFee / 100d;
}
@@ -117,20 +117,32 @@ public class RefundRecord extends ApiResult {
return cashFee;
}
public CurrencyType getFeeType() {
public String getFeeType() {
return feeType;
}
public CurrencyType getCashFeeType() {
public String getCashFeeType() {
return cashFeeType;
}
@JSONField(serialize = false)
public CurrencyType getFormatFeeType() {
return feeType != null ? CurrencyType.valueOf(feeType.toUpperCase())
: null;
}
@JSONField(serialize = false)
public CurrencyType getFormatCashFeeType() {
return cashFeeType != null ? CurrencyType.valueOf(cashFeeType
.toUpperCase()) : null;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public double getFormatCouponRefundFee() {
return couponRefundFee != null ? couponRefundFee.intValue() / 100d : 0d;
}
@@ -144,7 +156,7 @@ public class RefundRecord extends ApiResult {
*
* @return 元单位
*/
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public double getFormatTotalFee() {
return totalFee / 100d;
}
@@ -174,7 +186,7 @@ public class RefundRecord extends ApiResult {
*
* @return 元单位
*/
@JSONField(serialize = false, deserialize = false)
@JSONField(serialize = false)
public double getFormatRefundFee() {
return refundFee / 100d;
}