From d2fbb51b680bc98840150e66f18938ca925c15a5 Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Tue, 19 Sep 2017 10:19:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E4=B8=80=E4=B8=AA=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E7=9A=84=E7=B1=BB=E5=B1=9E=E6=80=A7=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bean/result/WxPayBillBaseResult.java | 30 ++++++++++++------- .../wxpay/bean/result/WxPayBillResult.java | 11 +++++-- .../impl/WxPayServiceAbstractImpl.java | 2 +- .../impl/WxPayServiceAbstractImplTest.java | 24 +++++++++++---- 4 files changed, 47 insertions(+), 20 deletions(-) diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java index e469ff45..de585364 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillBaseResult.java @@ -1,14 +1,22 @@ package com.github.binarywang.wxpay.bean.result; +import me.chanjar.weixin.common.util.ToStringUtils; + import java.io.Serializable; +/** + * 交易时间:2017-04-06 01:00:02 公众账号ID: 商户号: 子商户号:0 设备号:WEB 微信订单号: 商户订单号:2017040519091071873216 用户标识: 交易类型:NATIVE + * 交易状态:REFUND 付款银行:CFT 货币种类:CNY 总金额:0.00 企业红包金额:0.00 微信退款单号: 商户退款单号:20170406010000933 退款金额:0.01 企业红包退款金额:0.00 + * 退款类型:ORIGINAL 退款状态:SUCCESS 商品名称: 商户数据包: 手续费:0.00000 费率 :0.60% + */ public class WxPayBillBaseResult implements Serializable { - /* - * 交易时间:2017-04-06 01:00:02 公众账号ID: 商户号: 子商户号:0 设备号:WEB 微信订单号: 商户订单号:2017040519091071873216 用户标识: 交易类型:NATIVE - * 交易状态:REFUND 付款银行:CFT 货币种类:CNY 总金额:0.00 企业红包金额:0.00 微信退款单号: 商户退款单号:20170406010000933 退款金额:0.01 企业红包退款金额:0.00 - * 退款类型:ORIGINAL 退款状态:SUCCESS 商品名称: 商户数据包: 手续费:0.00000 费率 :0.60% - */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 2226245109137435453L; + + @Override + public String toString() { + return ToStringUtils.toSimpleString(this); + } + /** * 交易时间 */ @@ -32,7 +40,7 @@ public class WxPayBillBaseResult implements Serializable { /** * 微信订单号 */ - private String transationId; + private String transactionId; /** * 商户订单号 */ @@ -150,12 +158,12 @@ public class WxPayBillBaseResult implements Serializable { this.deviceInfo = deviceInfo; } - public String getTransationId() { - return transationId; + public String getTransactionId() { + return transactionId; } - public void setTransationId(String transationId) { - this.transationId = transationId; + public void setTransactionId(String transactionId) { + this.transactionId = transactionId; } public String getOutTradeNo() { diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java index a7fb25be..f699a42b 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/result/WxPayBillResult.java @@ -1,14 +1,21 @@ package com.github.binarywang.wxpay.bean.result; +import me.chanjar.weixin.common.util.ToStringUtils; + import java.io.Serializable; import java.util.List; public class WxPayBillResult implements Serializable { + private static final long serialVersionUID = -7687458652694204070L; + + @Override + public String toString() { + return ToStringUtils.toSimpleString(this); + } + /** * 对账返回对象 */ - private static final long serialVersionUID = 1L; - private List wxPayBillBaseResultLst; /** * 总交易单数 diff --git a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java index e77d3e1f..ae855d5b 100644 --- a/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java +++ b/weixin-java-pay/src/main/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImpl.java @@ -446,7 +446,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { wxPayBillBaseResult.setMchId(tempStr[k + 2].trim()); wxPayBillBaseResult.setSubMchId(tempStr[k + 3].trim()); wxPayBillBaseResult.setDeviceInfo(tempStr[k + 4].trim()); - wxPayBillBaseResult.setTransationId(tempStr[k + 5].trim()); + wxPayBillBaseResult.setTransactionId(tempStr[k + 5].trim()); wxPayBillBaseResult.setOutTradeNo(tempStr[k + 6].trim()); wxPayBillBaseResult.setOpenId(tempStr[k + 7].trim()); wxPayBillBaseResult.setTradeType(tempStr[k + 8].trim()); diff --git a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java index 2fc53544..afea13d8 100644 --- a/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java +++ b/weixin-java-pay/src/test/java/com/github/binarywang/wxpay/service/impl/WxPayServiceAbstractImplTest.java @@ -15,8 +15,7 @@ import com.github.binarywang.wxpay.testbase.XmlWxPayConfig; import com.google.inject.Inject; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.annotations.Guice; -import org.testng.annotations.Test; +import org.testng.annotations.*; import java.nio.file.Files; import java.nio.file.Path; @@ -90,11 +89,24 @@ public class WxPayServiceAbstractImplTest { this.logger.info(this.payService.closeOrder("11212121").toString()); } + @DataProvider + public Object[][] billingData() { + return new Object[][]{ +// {"20170831", BillType.ALL, null, "deviceInfo"}, + {"20170831", BillType.SUCCESS, null, "deviceInfo"} + }; + } + + @Test(dataProvider = "billingData") + public void testDownloadBill(String billDate, String billType, + String tarType, String deviceInfo) throws Exception { + WxPayBillResult billResult = this.payService.downloadBill(billDate, billType, tarType, deviceInfo); + assertNotNull(billResult); + this.logger.info(billResult.toString()); + } + @Test - public void testDownloadBill() throws Exception { - WxPayBillResult wxPayBillResult = this.payService.downloadBill("20170831", BillType.ALL, null, "1111111"); - //前一天没有账单记录返回null - assertNotNull(wxPayBillResult); + public void testDownloadBill_withNoParams() throws Exception { //必填字段为空时,抛出异常 this.payService.downloadBill("", "", "", null); }