| @@ -1,14 +1,22 @@ | |||||
| package com.github.binarywang.wxpay.bean.result; | package com.github.binarywang.wxpay.bean.result; | ||||
| import me.chanjar.weixin.common.util.ToStringUtils; | |||||
| import java.io.Serializable; | 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 { | 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; | 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() { | public String getOutTradeNo() { | ||||
| @@ -1,14 +1,21 @@ | |||||
| package com.github.binarywang.wxpay.bean.result; | package com.github.binarywang.wxpay.bean.result; | ||||
| import me.chanjar.weixin.common.util.ToStringUtils; | |||||
| import java.io.Serializable; | import java.io.Serializable; | ||||
| import java.util.List; | import java.util.List; | ||||
| public class WxPayBillResult implements Serializable { | 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<WxPayBillBaseResult> wxPayBillBaseResultLst; | private List<WxPayBillBaseResult> wxPayBillBaseResultLst; | ||||
| /** | /** | ||||
| * 总交易单数 | * 总交易单数 | ||||
| @@ -446,7 +446,7 @@ public abstract class WxPayServiceAbstractImpl implements WxPayService { | |||||
| wxPayBillBaseResult.setMchId(tempStr[k + 2].trim()); | wxPayBillBaseResult.setMchId(tempStr[k + 2].trim()); | ||||
| wxPayBillBaseResult.setSubMchId(tempStr[k + 3].trim()); | wxPayBillBaseResult.setSubMchId(tempStr[k + 3].trim()); | ||||
| wxPayBillBaseResult.setDeviceInfo(tempStr[k + 4].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.setOutTradeNo(tempStr[k + 6].trim()); | ||||
| wxPayBillBaseResult.setOpenId(tempStr[k + 7].trim()); | wxPayBillBaseResult.setOpenId(tempStr[k + 7].trim()); | ||||
| wxPayBillBaseResult.setTradeType(tempStr[k + 8].trim()); | wxPayBillBaseResult.setTradeType(tempStr[k + 8].trim()); | ||||
| @@ -15,8 +15,7 @@ import com.github.binarywang.wxpay.testbase.XmlWxPayConfig; | |||||
| import com.google.inject.Inject; | import com.google.inject.Inject; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | 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.Files; | ||||
| import java.nio.file.Path; | import java.nio.file.Path; | ||||
| @@ -90,11 +89,24 @@ public class WxPayServiceAbstractImplTest { | |||||
| this.logger.info(this.payService.closeOrder("11212121").toString()); | 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 | @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); | this.payService.downloadBill("", "", "", null); | ||||
| } | } | ||||