weixin4j-base:主要调整退款相关类与官网一致

This commit is contained in:
jinyu 2016-07-22 13:07:14 +08:00
parent 57669927a7
commit 42a3fc357e
26 changed files with 523 additions and 473 deletions

View File

@ -731,4 +731,8 @@
* 2016-07-21
+ 新增MessageConverter
+ weixin4j-base:新增MessageConverter
* 2016-07-22
+ weixin4j-base:主要调整退款相关类与官网一致

View File

@ -729,10 +729,10 @@ public class PayApi extends MchApi {
* @throws WeixinException
* @see <a href=
* "http://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_8">
* 接口测试上报API</a>
* 交易保障</a>
*/
@SuppressWarnings("unchecked")
public XmlResult interfaceReport(String interfaceUrl, int executeTime,
public XmlResult reportInterface(String interfaceUrl, int executeTime,
String outTradeNo, String ip, Date time, XmlResult returnXml)
throws WeixinException {
Map<String, String> map = createBaseRequestMap(null);

View File

@ -97,7 +97,7 @@ public class MimeType implements Serializable {
}
/**
* reference of apache Spring Web
* reference of Spring Web
*/
public boolean includes(MimeType other) {
if (other == null) {

View File

@ -12,8 +12,7 @@ import com.foxinmy.weixin4j.http.MimeType;
* @className MessageConverter
* @author jinyu
* @date Jul 20, 2016
* @since JDK 1.8
* @see
* @since JDK 1.6
*/
public interface MessageConverter {
/**

View File

@ -1,5 +1,7 @@
package com.foxinmy.weixin4j.http.message;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
@ -18,10 +20,22 @@ import com.alibaba.fastjson.annotation.JSONField;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class XmlResult extends ApiResult {
public class XmlResult implements Serializable {
private static final long serialVersionUID = -6185313616955051150L;
/**
* 调用接口返回码通信标识
*/
@XmlElement(name = "return_code")
@JSONField(name = "return_code")
private String returnCode;
/**
* 调用接口返回消息,如非 ,为错误原因 可能为空
*/
@XmlElement(name = "return_msg")
@JSONField(name = "return_msg")
private String returnMsg;
/**
* 业务结果SUCCESS/FAIL 非空
*/
@ -42,10 +56,12 @@ public class XmlResult extends ApiResult {
private String errCodeDes;
protected XmlResult() {
// jaxb required
}
public XmlResult(String returnCode, String returnMsg) {
super(returnCode, returnMsg);
this.returnCode = returnCode;
this.returnMsg = returnMsg;
}
public String getResultCode() {
@ -60,6 +76,14 @@ public class XmlResult extends ApiResult {
return errCodeDes;
}
public String getReturnCode() {
return returnCode;
}
public String getReturnMsg() {
return returnMsg;
}
public void setResultCode(String resultCode) {
this.resultCode = resultCode;
}
@ -74,6 +98,8 @@ public class XmlResult extends ApiResult {
@Override
public String toString() {
return super.toString() + ", resultCode=" + resultCode + ", errCode=" + errCode + ", errCodeDes=" + errCodeDes;
return "returnCode=" + returnCode + ", returnMsg=" + returnMsg
+ ", resultCode=" + resultCode + ", errCode=" + errCode
+ ", errCodeDes=" + errCodeDes;
}
}

View File

@ -114,7 +114,7 @@ public class WeixinRequestExecutor {
if (XmlMessageConverter.GLOBAL.canConvert(XmlResult.class, response)) {
try {
XmlResult xmlResult = XmlMessageConverter.GLOBAL.convert(XmlResult.class, response);
if (!SUCCESS_CODE.contains(xmlResult.getResultCode())) {
if (!SUCCESS_CODE.contains(String.format(",%s,", xmlResult.getResultCode().toLowerCase()))) {
throw new WeixinException(xmlResult.getErrCode(), xmlResult.getErrCodeDes());
}
} catch (IOException e) {

View File

@ -821,7 +821,7 @@
</error>
<error>
<code>60008</code>
<text>部门名称已存在</text>
<text>部门ID或者部门名称已存在</text>
</error>
<error>
<code>60009</code>

View File

@ -624,10 +624,10 @@ public class WeixinPayProxy {
* 接口测试上报API</a>
* @throws WeixinException
*/
public XmlResult interfaceReport(String interfaceUrl, int executeTime,
public XmlResult reportInterface(String interfaceUrl, int executeTime,
String outTradeNo, String ip, Date time, XmlResult returnXml)
throws WeixinException {
return payApi.interfaceReport(interfaceUrl, executeTime, outTradeNo,
return payApi.reportInterface(interfaceUrl, executeTime, outTradeNo,
ip, time, returnXml);
}

View File

@ -0,0 +1,96 @@
package com.foxinmy.weixin4j.payment.coupon;
import java.io.Serializable;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.type.CouponType;
/**
* 订单代金券信息
*
* @className OrderCouponInfo
* @author jinyu(foxinmy@gmail.com)
* @date 2015年3月24日
* @since JDK 1.6
* @see
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class OrderCouponInfo implements Serializable {
private static final long serialVersionUID = -8744999305258786901L;
/**
* 代金券或立减优惠批次ID
*/
@XmlElement(name = "coupon_batch_id")
@JSONField(name = "coupon_batch_id")
private String couponBatchId;
/**
* 代金券类型
*
* @see com.foxinmy.weixin4j.type.CouponType
*/
@XmlElement(name = "coupon_type")
@JSONField(name = "coupon_type")
private String couponType;
/**
* 代金券或立减优惠ID
*/
@XmlElement(name = "coupon_id")
@JSONField(name = "coupon_id")
private String couponId;
/**
* 单个代金券或立减优惠支付金额
*/
@XmlElement(name = "coupon_fee")
@JSONField(name = "coupon_fee")
private Integer couponFee;
protected OrderCouponInfo() {
// jaxb requried
}
public String getCouponBatchId() {
return couponBatchId;
}
public String getCouponType() {
return couponType;
}
@JSONField(serialize = false)
public CouponType getFormatCouponType() {
return couponType != null ? CouponType
.valueOf(couponType.toUpperCase()) : null;
}
public String getCouponId() {
return couponId;
}
public Integer getCouponFee() {
return couponFee;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatCouponFee() {
return couponFee != null ? couponFee.doubleValue() / 100d : 0d;
}
@Override
public String toString() {
return "couponBatchId=" + couponBatchId + ", couponType=" + couponType
+ ", couponId=" + couponId + ", couponFee=" + couponFee;
}
}

View File

@ -10,9 +10,9 @@ import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
/**
* 代金券信息(订单,退款中体现)
* 退款代金券信息
*
* @className CouponInfo
* @className RefundCouponInfo
* @author jinyu(foxinmy@gmail.com)
* @date 2015年3月24日
* @since JDK 1.6
@ -20,31 +20,31 @@ import com.alibaba.fastjson.annotation.JSONField;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class CouponInfo implements Serializable {
public class RefundCouponInfo implements Serializable {
private static final long serialVersionUID = -8744999305258786901L;
/**
* 代金券或立减优惠批次ID
*/
@XmlElement(name = "coupon_batch_id")
@JSONField(name = "coupon_batch_id")
@XmlElement(name = "coupon_refund_batch_id")
@JSONField(name = "coupon_refund_batch_id")
private String couponBatchId;
/**
* 代金券或立减优惠ID
* 退款代金券ID
*/
@XmlElement(name = "coupon_id")
@JSONField(name = "coupon_id")
@XmlElement(name = "coupon_refund_id")
@JSONField(name = "coupon_refund_id")
private String couponId;
/**
* 单个代金券或立减优惠支付金额
*/
@XmlElement(name = "coupon_fee")
@JSONField(name = "coupon_fee")
@XmlElement(name = "coupon_refund_fee")
@JSONField(name = "coupon_refund_fee")
private Integer couponFee;
public CouponInfo() {
protected RefundCouponInfo() {
// jaxb requried
}
public String getCouponBatchId() {
@ -69,10 +69,6 @@ public class CouponInfo implements Serializable {
return couponFee != null ? couponFee.doubleValue() / 100d : 0d;
}
public void setCouponId(String couponId) {
this.couponId = couponId;
}
@Override
public String toString() {
return "couponBatchId=" + couponBatchId + ", couponId=" + couponId

View File

@ -0,0 +1,126 @@
package com.foxinmy.weixin4j.payment.mch;
import javax.xml.bind.annotation.XmlElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.type.CurrencyType;
/**
* 商户平台交易结果
*
* @className MerchantTradeResult
* @author jinyu(foxinmy@gmail.com)
* @date 2016年7月21日
* @since JDK 1.7
* @see
*/
public class MerchantTradeResult extends MerchantResult {
private static final long serialVersionUID = 4205906286092873877L;
/**
* 微信支付订单号
*/
@XmlElement(name = "transaction_id")
@JSONField(name = "transaction_id")
private String transactionId;
/**
* 商户订单号
*/
@XmlElement(name = "out_trade_no")
@JSONField(name = "out_trade_no")
private String outTradeNo;
/**
* 订单总金额,单位为分
*/
@XmlElement(name = "total_fee")
@JSONField(name = "total_fee")
private Integer totalFee;
/**
* 应结订单金额,单位为分:应结订单金额=订单金额-非充值代金券金额应结订单金额<=订单金额
*/
@XmlElement(name = "settlement_total_fee")
@JSONField(name = "settlement_total_fee")
private Integer settlementTotalFee;
/**
* 货币类型,符合 ISO 4217 标准的三位字母代码,默认人民币:CNY
*
* @see com.foxinmy.weixin4j.mp.type.CurrencyType
*/
@XmlElement(name = "fee_type")
@JSONField(name = "fee_type")
private String feeType;
/**
* 现金支付金额
*/
@XmlElement(name = "cash_fee")
@JSONField(name = "cash_fee")
private Integer cashFee;
public Integer getCashFee() {
return cashFee;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatCashFee() {
return cashFee != null ? cashFee / 100d : 0d;
}
public Integer getTotalFee() {
return totalFee;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatTotalFee() {
return totalFee != null ? totalFee / 100d : 0d;
}
@JSONField(serialize = false)
public CurrencyType getFormatFeeType() {
return feeType != null ? CurrencyType.valueOf(feeType.toUpperCase())
: null;
}
public String getFeeType() {
return feeType;
}
public String getTransactionId() {
return transactionId;
}
public String getOutTradeNo() {
return outTradeNo;
}
public Integer getSettlementTotalFee() {
return settlementTotalFee;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatSettlementTotalFee() {
return settlementTotalFee != null ? settlementTotalFee / 100d : 0d;
}
@Override
public String toString() {
return "transactionId=" + transactionId + ", outTradeNo=" + outTradeNo
+ ", totalFee=" + totalFee + ", cashFee=" + cashFee
+ ", feeType=" + feeType + ", settlementTotalFee="
+ settlementTotalFee + ", " + super.toString();
}
}

View File

@ -45,8 +45,7 @@ public class NativePayResponse extends MerchantResult {
* @throws WeixinPayException
*/
public NativePayResponse(String returnMsg, String resultMsg) {
super.setReturnMsg(returnMsg);
super.setReturnCode(Consts.FAIL);
super(Consts.FAIL, returnMsg);
super.setErrCodeDes(resultMsg);
super.setResultCode(Consts.FAIL);
}
@ -61,7 +60,7 @@ public class NativePayResponse extends MerchantResult {
* @throws WeixinPayException
*/
public NativePayResponse(WeixinPayAccount weixinAccount, String prepayId) {
super.setReturnCode(Consts.SUCCESS);
super(Consts.SUCCESS, "OK");
this.setResultCode(Consts.SUCCESS);
this.setMchId(weixinAccount.getMchId());
this.setAppId(weixinAccount.getId());

View File

@ -9,7 +9,7 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.payment.coupon.CouponInfo;
import com.foxinmy.weixin4j.payment.coupon.OrderCouponInfo;
import com.foxinmy.weixin4j.type.BankType;
import com.foxinmy.weixin4j.type.CurrencyType;
import com.foxinmy.weixin4j.type.TradeState;
@ -28,7 +28,7 @@ import com.foxinmy.weixin4j.xml.ListsuffixResult;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Order extends MerchantResult {
public class Order extends MerchantTradeResult {
private static final long serialVersionUID = 5636828325595317079L;
/**
@ -65,14 +65,17 @@ public class Order extends MerchantResult {
@XmlElement(name = "bank_type")
@JSONField(name = "bank_type")
private String bankType;
/**
* 订单总金额,单位为分
* 现金支付货币类型,符合 ISO 4217 标准的三位字母代码,默认人民币:CNY
*
* @see com.foxinmy.weixin4j.mp.type.CurrencyType
*/
@XmlElement(name = "total_fee")
@JSONField(name = "total_fee")
private Integer totalFee;
@XmlElement(name = "cash_fee_type")
@JSONField(name = "cash_fee_type")
private String cashFeeType;
/**
* 现金券支付金额<=订单总金 ,订单总金额-现金券金额 现金支付金额
* 代金券金额:代金券金额<=订单金额订单金额-代金券金额=现金支付金额
*/
@XmlElement(name = "coupon_fee")
@JSONField(name = "coupon_fee")
@ -87,33 +90,7 @@ public class Order extends MerchantResult {
* 代金券信息 验证签名有点麻烦
*/
@ListsuffixResult
private List<CouponInfo> couponList;
/**
* 现金支付金额
*/
@XmlElement(name = "cash_fee")
@JSONField(name = "cash_fee")
private Integer cashFee;
/**
* 货币类型,符合 ISO 4217 标准的三位字母代码,默认人民币:CNY
*
* @see com.foxinmy.weixin4j.mp.type.CurrencyType
*/
@XmlElement(name = "fee_type")
@JSONField(name = "fee_type")
private String feeType;
/**
* 微信支付订单号
*/
@XmlElement(name = "transaction_id")
@JSONField(name = "transaction_id")
private String transactionId;
/**
* 商户订单号
*/
@XmlElement(name = "out_trade_no")
@JSONField(name = "out_trade_no")
private String outTradeNo;
private List<OrderCouponInfo> couponList;
/**
* 商家数据包
*/
@ -183,20 +160,6 @@ public class Order extends MerchantResult {
: null;
}
public Integer getTotalFee() {
return totalFee;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatTotalFee() {
return totalFee != null ? totalFee / 100d : 0d;
}
public Integer getCouponFee() {
return couponFee;
}
@ -215,26 +178,6 @@ public class Order extends MerchantResult {
return couponCount;
}
public Integer getCashFee() {
return cashFee;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatCashFee() {
return cashFee != null ? cashFee / 100d : 0d;
}
@JSONField(serialize = false)
public CurrencyType getFormatFeeType() {
return feeType != null ? CurrencyType.valueOf(feeType.toUpperCase())
: null;
}
public String getTradeState() {
return tradeState;
}
@ -243,18 +186,6 @@ public class Order extends MerchantResult {
return tradeType;
}
public String getFeeType() {
return feeType;
}
public String getTransactionId() {
return transactionId;
}
public String getOutTradeNo() {
return outTradeNo;
}
public String getAttach() {
return attach;
}
@ -272,11 +203,11 @@ public class Order extends MerchantResult {
return tradeStateDesc;
}
public List<CouponInfo> getCouponList() {
public List<OrderCouponInfo> getCouponList() {
return couponList;
}
public void setCouponList(List<CouponInfo> couponList) {
public void setCouponList(List<OrderCouponInfo> couponList) {
this.couponList = couponList;
}
@ -293,19 +224,25 @@ public class Order extends MerchantResult {
return subIsSubscribe != null && subIsSubscribe.equalsIgnoreCase("y");
}
public String getCashFeeType() {
return cashFeeType;
}
@JSONField(serialize = false)
public CurrencyType getFormatCashFeeType() {
return cashFeeType != null ? CurrencyType.valueOf(cashFeeType
.toUpperCase()) : null;
}
@Override
public String toString() {
return "Order [tradeState=" + tradeState + ", openId=" + openId
+ ", isSubscribe=" + isSubscribe + ", tradeType=" + tradeType
+ ", bankType=" + bankType + ", feeType=" + feeType
+ ", transactionId=" + transactionId + ", outTradeNo="
+ outTradeNo + ", attach=" + attach + ", timeEnd=" + timeEnd
+ ", totalFee=" + getFormatTotalFee() + ", couponFee="
+ getFormatCouponFee() + ", couponCount=" + couponCount
+ ", couponList=" + couponList + ", cashFee="
+ getFormatCashFee() + ", timeEnd=" + getFormatTimeEnd()
+ ", tradeStateDesc=" + tradeStateDesc + ", subOpenId="
+ subOpenId + ", subIsSubscribe=" + subIsSubscribe
+ super.toString() + "]";
+ ", bankType=" + bankType + ", cashFeeType=" + cashFeeType
+ ", couponFee=" + couponFee + ", couponCount=" + couponCount
+ ", couponList=" + couponList + ", attach=" + attach
+ ", timeEnd=" + timeEnd + ", tradeStateDesc=" + tradeStateDesc
+ ", subOpenId=" + subOpenId + ", subIsSubscribe="
+ subIsSubscribe + ", " + super.toString() + "]";
}
}

View File

@ -1,5 +1,6 @@
package com.foxinmy.weixin4j.payment.mch;
import java.io.Serializable;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
@ -8,26 +9,28 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.payment.coupon.CouponInfo;
import com.foxinmy.weixin4j.type.CurrencyType;
import com.foxinmy.weixin4j.payment.coupon.RefundCouponInfo;
import com.foxinmy.weixin4j.type.CouponType;
import com.foxinmy.weixin4j.type.RefundChannel;
import com.foxinmy.weixin4j.type.RefundStatus;
import com.foxinmy.weixin4j.xml.ListsuffixResult;
/**
* V3退款详细
* 退款详细
*
* @className RefundDetail
* @author jinyu(foxinmy@gmail.com)
* @date 2014年11月6
* @date 2016年7月21
* @since JDK 1.6
* @see
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class RefundDetail extends MerchantResult {
public class RefundDetail implements Serializable {
private static final long serialVersionUID = 1402738803019986864L;
private static final long serialVersionUID = -3687863914168618620L;
protected RefundDetail() {
// jaxb required
}
/**
* 商户退款单号
@ -53,56 +56,6 @@ public class RefundDetail extends MerchantResult {
@XmlElement(name = "refund_fee")
@JSONField(name = "refund_fee")
private int refundFee;
/**
* 退款货币种类
*
* @see com.foxinmy.weixin4j.mp.type.CurrencyType
*/
@XmlElement(name = "refund_fee_type")
@JSONField(name = "refund_fee_type")
private String refundFeeType;
/**
* 订单总金额
*/
@XmlElement(name = "total_fee")
@JSONField(name = "total_fee")
private int totalFee;
/**
* 订单金额货币种类
*
* @see com.foxinmy.weixin4j.mp.type.CurrencyType
*/
@XmlElement(name = "fee_type")
@JSONField(name = "fee_type")
private String feeType;
/**
* 现金支付金额
*/
@XmlElement(name = "cash_fee")
@JSONField(name = "cash_fee")
private int cashFee;
/**
* 现金支付货币种类
*
* @see com.foxinmy.weixin4j.mp.type.CurrencyType
*/
@XmlElement(name = "cash_fee_type")
@JSONField(name = "cash_fee_type")
private String cashFeeType;
/**
* 现金退款金额
*/
@XmlElement(name = "cash_refund_fee")
@JSONField(name = "cash_refund_fee")
private Integer cashRefundFee;
/**
* 现金退款货币类型
*
* @see com.foxinmy.weixin4j.mp.type.CurrencyType
*/
@XmlElement(name = "cash_refund_fee_type")
@JSONField(name = "cash_refund_fee_type")
private String cashRefundFeeType;
/**
* 退款状态
*/
@ -110,30 +63,44 @@ public class RefundDetail extends MerchantResult {
@JSONField(name = "refund_status")
private String refundStatus;
/**
* 现金券退款金额<=退款金额,退款金额-现金券退款金额为现金
* 退款金额退款金额=申请退款金额-非充值代金券退款金额退款金额<=申请退款金额
*/
@XmlElement(name = "settlement_refund_fee")
@JSONField(name = "settlement_refund_fee")
private Integer settlementRefundFee;
/**
* 代金券退款金额代金券退款金额<=退款金额退款金额-代金券或立减优惠退款金额为现金
*/
@XmlElement(name = "coupon_refund_fee")
@JSONField(name = "coupon_refund_fee")
private Integer couponRefundFee;
/**
* 代金券或立减优惠使用数量 <font
* color="red">微信支付文档上写的coupon_count,而实际测试拿到的是coupon_refund_count,做个记号
* </font>
* 代金券或立减优惠使用数量
*/
@XmlElement(name = "coupon_refund_count")
@JSONField(name = "coupon_refund_count")
private Integer couponRefundCount;
/**
* 代金券信息
* 代金券类型
*
* @see com.foxinmy.weixin4j.payment.coupon.CouponInfo
* @see com.foxinmy.weixin4j.type.CouponType
*/
@XmlElement(name = "coupon_type")
@JSONField(name = "coupon_type")
private String couponType;
/**
* 退款入账账户取当前退款单的退款入账方 1退回银行卡 {银行名称}{卡类型}{卡尾号} 2退回支付用户零钱: 支付用户零钱
*/
@XmlElement(name = "refund_recv_accout")
@JSONField(name = "refund_recv_accout")
private String refundRecvAccout;
/**
* 退款代金券信息
*
* @see com.foxinmy.weixin4j.payment.coupon.RefundCouponInfo
*/
@ListsuffixResult
private List<CouponInfo> couponList;
protected RefundDetail() {
// jaxb required
}
private List<RefundCouponInfo> couponList;
public String getOutRefundNo() {
return outRefundNo;
@ -157,26 +124,6 @@ public class RefundDetail extends MerchantResult {
return refundFee;
}
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(serialize = false)
public double getFormatRefundFee() {
return refundFee / 100d;
}
public String getRefundStatus() {
return refundStatus;
}
@ -187,6 +134,28 @@ public class RefundDetail extends MerchantResult {
.toUpperCase()) : null;
}
public List<RefundCouponInfo> getCouponList() {
return couponList;
}
public void setCouponList(List<RefundCouponInfo> couponList) {
this.couponList = couponList;
}
public Integer getSettlementRefundFee() {
return settlementRefundFee;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatSettlementRefundFee() {
return settlementRefundFee != null ? settlementRefundFee / 100d : 0d;
}
public Integer getCouponRefundFee() {
return couponRefundFee;
}
@ -198,105 +167,36 @@ public class RefundDetail extends MerchantResult {
*/
@JSONField(serialize = false)
public double getFormatCouponRefundFee() {
return couponRefundFee != null ? couponRefundFee.intValue() / 100d : 0d;
}
public String getRefundFeeType() {
return refundFeeType;
}
@JSONField(serialize = false)
public CurrencyType getFormatRefundFeeType() {
return refundFeeType != null ? CurrencyType.valueOf(refundFeeType
.toUpperCase()) : null;
}
public int getTotalFee() {
return totalFee;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatTotalFee() {
return totalFee / 100d;
}
public int getCashFee() {
return cashFee;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatCashFee() {
return cashFee / 100d;
}
public String getCashFeeType() {
return cashFeeType;
}
@JSONField(serialize = false)
public CurrencyType getFormatCashFeeType() {
return cashFeeType != null ? CurrencyType.valueOf(cashFeeType
.toUpperCase()) : null;
}
public Integer getCashRefundFee() {
return cashRefundFee;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatCashRefundFee() {
return cashRefundFee != null ? cashRefundFee.intValue() / 100d : 0d;
}
public String getCashRefundFeeType() {
return cashRefundFeeType;
}
@JSONField(serialize = false)
public CurrencyType getFormatCashRefundFeeType() {
return cashRefundFeeType != null ? CurrencyType
.valueOf(cashRefundFeeType.toUpperCase()) : null;
return couponRefundFee != null ? couponRefundFee / 100d : 0d;
}
public Integer getCouponRefundCount() {
return couponRefundCount;
}
public List<CouponInfo> getCouponList() {
return couponList;
public String getCouponType() {
return couponType;
}
public void setCouponList(List<CouponInfo> couponList) {
this.couponList = couponList;
@JSONField(serialize = false)
public CouponType getFormatCouponType() {
return couponType != null ? CouponType
.valueOf(couponType.toUpperCase()) : null;
}
public String getRefundRecvAccout() {
return refundRecvAccout;
}
@Override
public String toString() {
return "RefundDetail [outRefundNo=" + outRefundNo + ", refundId="
+ refundId + ", refundChannel=" + refundChannel
+ ", refundFee=" + getFormatRefundFee() + ", refundFeeType="
+ refundFeeType + ", totalFee=" + getFormatTotalFee()
+ ", feeType=" + feeType + ", cashFee=" + getFormatCashFee()
+ ", cashFeeType=" + cashFeeType + ", cashRefundFee="
+ getFormatCashRefundFee() + ", cashRefundFeeType="
+ cashRefundFeeType + ", refundStatus=" + refundStatus
+ ", couponRefundFee=" + getFormatCouponRefundFee()
+ ", couponRefundCount=" + couponRefundCount + ", couponList="
+ couponList + ", " + super.toString() + "]";
+ ", refundFee=" + refundFee + ", refundStatus=" + refundStatus
+ ", settlementRefundFee=" + settlementRefundFee
+ ", couponRefundFee=" + couponRefundFee
+ ", couponRefundCount=" + couponRefundCount + ", couponType="
+ couponType + ", refundRecvAccout=" + refundRecvAccout
+ ", couponList=" + couponList + "]";
}
}

View File

@ -8,11 +8,10 @@ import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.type.CurrencyType;
import com.foxinmy.weixin4j.xml.ListsuffixResult;
/**
* V3退款记录
* 退款记录
*
* @className RefundRecord
* @author jinyu(foxinmy@gmail.com)
@ -21,162 +20,37 @@ import com.foxinmy.weixin4j.xml.ListsuffixResult;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class RefundRecord extends MerchantResult {
public class RefundRecord extends MerchantTradeResult {
private static final long serialVersionUID = -2971132874939642721L;
/**
* 微信订单号
*/
@XmlElement(name = "transaction_id")
@JSONField(name = "transaction_id")
private String transactionId;
/**
* 商户订单号
*/
@XmlElement(name = "out_trade_no")
@JSONField(name = "out_trade_no")
private String outTradeNo;
/**
* 订单总金额
*/
@XmlElement(name = "total_fee")
@JSONField(name = "total_fee")
private int totalFee;
/**
* 订单金额货币种类
*
* @see com.foxinmy.weixin4j.mp.type.CurrencyType
*/
@XmlElement(name = "fee_type")
@JSONField(name = "fee_type")
private String feeType;
/**
* 现金支付金额
*/
@XmlElement(name = "cash_fee")
@JSONField(name = "cash_fee")
private int cashFee;
/**
* 现金支付金额货币种类
*
* @see com.foxinmy.weixin4j.mp.type.CurrencyType
*/
@XmlElement(name = "cash_fee_type")
@JSONField(name = "cash_fee_type")
private String cashFeeType;
/**
* 退款总金额
*/
@XmlElement(name = "refund_fee")
@JSONField(name = "refund_fee")
private int refundFee;
/**
* 代金券或立减优惠退款金额=订单金额-现金退款金额注意满立减金额不会退回
*/
@XmlElement(name = "coupon_refund_fee")
@JSONField(name = "coupon_refund_fee")
private Integer couponRefundFee;
/**
* 退款笔数
*/
@XmlElement(name = "refund_count")
@JSONField(name = "refund_count")
private int refundCount;
/**
* 退款总金额,单位为分,可以做部分退款
*/
@XmlElement(name = "refund_fee")
@JSONField(name = "refund_fee")
private int refundFee;
/**
* 退款详情
*
* @see com.foxinmy.weixin4j.payment.mch.RefundDetail
* @see RefundDetail
*/
@ListsuffixResult({ "^out_refund_no(_\\d)$", "^refund_.*(_\\d)$" })
@ListsuffixResult({ ".*(_\\d)$" })
private List<RefundDetail> refundList;
protected RefundRecord() {
// jaxb required
}
public String getTransactionId() {
return transactionId;
}
public String getOutTradeNo() {
return outTradeNo;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatCashFee() {
return cashFee / 100d;
}
public int getCashFee() {
return cashFee;
}
public String getFeeType() {
return feeType;
}
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)
public double getFormatCouponRefundFee() {
return couponRefundFee != null ? couponRefundFee.intValue() / 100d : 0d;
}
public Integer getCouponRefundFee() {
return couponRefundFee;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatTotalFee() {
return totalFee / 100d;
}
public int getTotalFee() {
return totalFee;
}
public int getRefundCount() {
return refundCount;
}
public List<RefundDetail> getRefundList() {
return refundList;
}
public void setRefundList(List<RefundDetail> refundList) {
this.refundList = refundList;
}
public int getRefundFee() {
return refundFee;
}
@ -191,14 +65,18 @@ public class RefundRecord extends MerchantResult {
return refundFee / 100d;
}
public List<RefundDetail> getRefundList() {
return refundList;
}
public void setRefundList(List<RefundDetail> refundList) {
this.refundList = refundList;
}
@Override
public String toString() {
return "RefundRecord [transactionId=" + transactionId + ", outTradeNo="
+ outTradeNo + ", totalFee=" + getFormatTotalFee()
+ ", feeType=" + feeType + ", cashFee=" + getFormatCashFee()
+ ", cashFeeType=" + cashFeeType + ", refundFee="
+ getFormatRefundFee() + ", couponRefundFee="
+ getFormatCouponRefundFee() + ", refundCount=" + refundCount
+ ", refundList=" + refundList + ", " + super.toString() + "]";
return "RefundRecord [refundCount=" + refundCount + ", refundFee="
+ refundFee + ", refundList=" + refundList + ", "
+ super.toString() + "]";
}
}

View File

@ -1,14 +1,18 @@
package com.foxinmy.weixin4j.payment.mch;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import com.alibaba.fastjson.annotation.JSONField;
import com.foxinmy.weixin4j.type.RefundChannel;
import com.foxinmy.weixin4j.xml.ListsuffixResult;
/**
* V3退款申请结果
* 退款申请结果
*
* @className RefundResult
* @author jinyu(foxinmy@gmail.com)
@ -18,38 +22,108 @@ import com.alibaba.fastjson.annotation.JSONField;
*/
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class RefundResult extends RefundDetail {
public class RefundResult extends MerchantTradeResult {
private static final long serialVersionUID = -3687863914168618620L;
/**
* 微信订单号
* 商户退款单号
*/
@XmlElement(name = "transaction_id")
@JSONField(name = "transaction_id")
private String transactionId;
@XmlElement(name = "out_refund_no")
@JSONField(name = "out_refund_no")
private String outRefundNo;
/**
* 商户系统内部的订单号
* 微信退款单号
*/
@XmlElement(name = "out_trade_no")
@JSONField(name = "out_trade_no")
private String outTradeNo;
@XmlElement(name = "refund_id")
@JSONField(name = "refund_id")
private String refundId;
/**
* 退款渠道:ORIGINAL原路退款,默认 BALANCE退回到余额
*/
@XmlElement(name = "refund_channel")
@JSONField(name = "refund_channel")
private String refundChannel;
/**
* 退款总金额,单位为分,可以做部分退款
*/
@XmlElement(name = "refund_fee")
@JSONField(name = "refund_fee")
private int refundFee;
/**
* 现金退款金额
*/
@XmlElement(name = "cash_refund_fee")
@JSONField(name = "cash_refund_fee")
private Integer cashRefundFee;
/**
* 退款详情
*
* @see RefundDetail
*/
@ListsuffixResult({ ".*(_\\d)$" })
private List<RefundDetail> refundList;
protected RefundResult() {
// jaxb required
}
public String getTransactionId() {
return transactionId;
public String getOutRefundNo() {
return outRefundNo;
}
public String getOutTradeNo() {
return outTradeNo;
public String getRefundId() {
return refundId;
}
public String getRefundChannel() {
return refundChannel;
}
@JSONField(serialize = false)
public RefundChannel getFormatRefundChannel() {
return refundChannel != null ? RefundChannel.valueOf(refundChannel
.toUpperCase()) : null;
}
public int getRefundFee() {
return refundFee;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatRefundFee() {
return refundFee / 100d;
}
public Integer getCashRefundFee() {
return cashRefundFee;
}
/**
* <font color="red">调用接口获取单位为分,get方法转换为元方便使用</font>
*
* @return 元单位
*/
@JSONField(serialize = false)
public double getFormatCashRefundFee() {
return cashRefundFee != null ? cashRefundFee.intValue() / 100d : 0d;
}
public List<RefundDetail> getRefundList() {
return refundList;
}
@Override
public String toString() {
return "RefundResult [transactionId=" + transactionId + ", outTradeNo="
+ outTradeNo + ", " + super.toString() + "]";
return "RefundResult [" + super.toString() + ", outRefundNo="
+ outRefundNo + ", refundId=" + refundId + ", refundChannel="
+ refundChannel + ", refundFee=" + refundFee
+ ", cashRefundFee=" + cashRefundFee + ", refundList="
+ refundList + "]";
}
}

View File

@ -21,7 +21,16 @@ public enum CouponType {
/**
* 门槛叠加
*/
THRESHOLD_PLUS(3);
THRESHOLD_PLUS(3),
/**
* 充值代金券
*/
CASH(-1),
/**
* 非充值代金券
*/
NO_CASH(-2);
private int val;
CouponType(int val) {

View File

@ -34,7 +34,7 @@ import com.foxinmy.weixin4j.type.TradeType;
* @className PayTest
* @author jinyu(foxinmy@gmail.com)
* @date 2016年1月30日
* @since JDK 1.7
* @since JDK 1.6
* @see
*/
public class PayTest {
@ -50,11 +50,11 @@ public class PayTest {
/**
* 商户证书文件
*/
protected File caFile = new File("商户证书:*.p12");
protected File caFile = new File("*.p12");
@Test
public void queryOrder() throws WeixinException {
Order order = PAY.queryOrder(new IdQuery("BY2016010800025",
Order order = PAY.queryOrder(new IdQuery("201601131632321",
IdType.TRADENO));
System.err.println(order);
String sign = order.getSign();
@ -70,7 +70,6 @@ public class PayTest {
RefundRecord record = PAY.queryRefund(new IdQuery("TT_1427183696238",
IdType.TRADENO));
System.err.println(record);
// 这里的验证签名需要把details循环拼接
String sign = record.getSign();
record.setSign(null);
String valiSign = SIGNATURE.sign(record);
@ -139,7 +138,7 @@ public class PayTest {
}
@Test
public void interfaceReport() throws WeixinException {
public void reportInterface() throws WeixinException {
String interfaceUrl = "https://api.mch.weixin.qq.com/pay/unifiedorder";
int executeTime = 2500;
String outTradeNo = null;
@ -147,7 +146,7 @@ public class PayTest {
Date time = new Date();
XmlResult returnXml = new XmlResult("SUCCESS", "");
returnXml.setResultCode("SUCCESS");
returnXml = PAY.interfaceReport(interfaceUrl, executeTime, outTradeNo,
returnXml = PAY.reportInterface(interfaceUrl, executeTime, outTradeNo,
ip, time, returnXml);
System.err.println(returnXml);
}

View File

@ -33,6 +33,8 @@ weixin4j-mp
* UserApi `用户管理API`
* TagApi `用户标签管理API`
* ComponentApi `第三方组件API`
[如何使用](https://github.com/foxinmy/weixin4j/wiki)

View File

@ -220,7 +220,7 @@ public class OauthApi extends MpApi {
}
/**
* 请求CODE
* 微信开放平台oauth授权:请求CODE
*
* @param redirectUri
* 重定向地址 域名与审核时填写的授权域名一致

View File

@ -24,4 +24,6 @@
* UserApi `用户管理API`
* TagApi `用户标签管理API`
* TagApi `用户标签管理API`
* ComponentApi `第三方组件API`

View File

@ -9,7 +9,7 @@ import com.foxinmy.weixin4j.token.TokenCreator;
import com.foxinmy.weixin4j.token.TokenManager;
/**
* 微信开平台应用组件预授权码创建
* 微信开平台应用组件预授权码创建
*
* @className WeixinComponentPreCodeCreator
* @author jinyu(foxinmy@gmail.com)

View File

@ -9,7 +9,7 @@ import com.foxinmy.weixin4j.token.TicketManager;
import com.foxinmy.weixin4j.token.TokenCreator;
/**
* 微信开平台应用组件凭证创建
* 微信开平台应用组件凭证创建
*
* @className WeixinComponentTokenCreator
* @author jinyu(foxinmy@gmail.com)

View File

@ -37,7 +37,7 @@ public class WeixinTokenComponentCreator extends TokenCreator {
@Override
public String key0() {
return String.format("mp_token_suite_%s_%s",
return String.format("mp_token_component_%s_%s",
perTicketManager.getThirdId(), perTicketManager.getAuthAppId());
}

View File

@ -56,7 +56,10 @@ public class TemplateMessage implements Serializable {
private final static String TAIL_KEY = "remark";
private final static String DEFAULT_COLOR = "#173177";
public TemplateMessage(String toUser, String templateId, String url) {
@JSONCreator
public TemplateMessage(@JSONField(name = "toUser") String toUser,
@JSONField(name = "templateId") String templateId,
@JSONField(name = "url") String url) {
this.toUser = toUser;
this.templateId = templateId;
this.url = url;

View File

@ -35,7 +35,7 @@ public class NotifyTest extends TokenTest {
@Test
public void text() throws WeixinException {
NotifyMessage notify = new NotifyMessage(0, new Text("content"));
NotifyMessage notify = new NotifyMessage(40, new Text("content"));
System.out.println(notifyApi.sendNotifyMessage(notify));
}