From 806274445e9eb412ba0628654f410b1c0ba241e5 Mon Sep 17 00:00:00 2001 From: jinyu Date: Mon, 12 Dec 2016 23:04:56 +0800 Subject: [PATCH] =?UTF-8?q?=E9=80=80=E6=AC=BE=E6=8E=A5=E5=8F=A3=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E9=80=80=E6=AC=BE=E8=B5=84=E9=87=91=E6=9D=A5=E6=BA=90?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/com/foxinmy/weixin4j/api/PayApi.java | 13 +++++++++++-- .../foxinmy/weixin4j/payment/WeixinPayProxy.java | 9 ++++++--- .../com/foxinmy/weixin4j/base/test/PayTest.java | 2 +- 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/PayApi.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/PayApi.java index 539d948a..8583da5f 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/PayApi.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/api/PayApi.java @@ -39,6 +39,7 @@ import com.foxinmy.weixin4j.type.IdType; import com.foxinmy.weixin4j.type.SignType; import com.foxinmy.weixin4j.type.TradeType; import com.foxinmy.weixin4j.type.mch.BillType; +import com.foxinmy.weixin4j.type.mch.RefundAccountType; import com.foxinmy.weixin4j.util.Consts; import com.foxinmy.weixin4j.util.DateUtil; import com.foxinmy.weixin4j.util.DigestUtil; @@ -453,6 +454,8 @@ public class PayApi extends MchApi { * 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY * @param opUserId * 操作员帐号, 默认为商户号 + * @param refundAccountType + * 退款资金来源,默认使用未结算资金退款:REFUND_SOURCE_UNSETTLED_FUNDS * @return 退款申请结果 * @see com.foxinmy.weixin4j.payment.mch.RefundResult * @see map = createBaseRequestMap(idQuery); map.put("out_refund_no", outRefundNo); @@ -478,7 +482,11 @@ public class PayApi extends MchApi { if (refundFeeType == null) { refundFeeType = CurrencyType.CNY; } + if (refundAccountType == null) { + refundAccountType = RefundAccountType.REFUND_SOURCE_UNSETTLED_FUNDS; + } map.put("refund_fee_type", refundFeeType.name()); + map.put("refund_account", refundAccountType.name()); map.put("sign", weixinSignature.sign(map)); String param = XmlStream.map2xml(map); response = getWeixinSSLExecutor().post( @@ -501,7 +509,8 @@ public class PayApi extends MchApi { */ public RefundResult applyRefund(IdQuery idQuery, String outRefundNo, double totalFee) throws WeixinException { - return applyRefund(idQuery, outRefundNo, totalFee, totalFee, null, null); + return applyRefund(idQuery, outRefundNo, totalFee, totalFee, null, + null, null); } /** diff --git a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/WeixinPayProxy.java b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/WeixinPayProxy.java index 93c512a0..10041ec8 100644 --- a/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/WeixinPayProxy.java +++ b/weixin4j-base/src/main/java/com/foxinmy/weixin4j/payment/WeixinPayProxy.java @@ -40,6 +40,7 @@ import com.foxinmy.weixin4j.type.CurrencyType; import com.foxinmy.weixin4j.type.CustomsCity; import com.foxinmy.weixin4j.type.IdQuery; import com.foxinmy.weixin4j.type.mch.BillType; +import com.foxinmy.weixin4j.type.mch.RefundAccountType; import com.foxinmy.weixin4j.util.Weixin4jConfigUtil; /** @@ -443,7 +444,8 @@ public class WeixinPayProxy { * 货币类型,符合ISO 4217标准的三位字母代码,默认人民币:CNY * @param opUserId * 操作员帐号, 默认为商户号 - * + * @param refundAccountType + * 退款资金来源,默认使用未结算资金退款:REFUND_SOURCE_UNSETTLED_FUNDS * @return 退款申请结果 * @see com.foxinmy.weixin4j.payment.mch.RefundResult * @see com.foxinmy.weixin4j.api.PayApi @@ -455,9 +457,10 @@ public class WeixinPayProxy { */ public RefundResult applyRefund(IdQuery idQuery, String outRefundNo, double totalFee, double refundFee, CurrencyType refundFeeType, - String opUserId) throws WeixinException { + String opUserId, RefundAccountType refundAccountType) + throws WeixinException { return payApi.applyRefund(idQuery, outRefundNo, totalFee, refundFee, - refundFeeType, opUserId); + refundFeeType, opUserId, refundAccountType); } /** diff --git a/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/PayTest.java b/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/PayTest.java index 126b1f51..0b5f3e16 100644 --- a/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/PayTest.java +++ b/weixin4j-base/src/test/java/com/foxinmy/weixin4j/base/test/PayTest.java @@ -99,7 +99,7 @@ public class PayTest { IdQuery idQuery = new IdQuery("TT_1427183696238", IdType.TRADENO); RefundResult result = PAY.applyRefund(idQuery, "TT_R" + System.currentTimeMillis(), 0.01d, 0.01d, null, - "10020674"); + "10020674", null); Assert.assertEquals(Consts.SUCCESS, result.getReturnCode()); Assert.assertEquals(Consts.SUCCESS, result.getResultCode()); System.err.println(result);