1
1
package com .github .binarywang .wxpay .bean .result ;
2
2
3
3
import com .github .binarywang .wxpay .constant .WxPayConstants ;
4
- import org .testng .Assert ;
5
4
import org .testng .annotations .Test ;
6
5
6
+ import static org .testng .Assert .assertEquals ;
7
+ import static org .testng .Assert .assertNull ;
8
+
7
9
/**
8
10
* @author m8cool
9
11
*/
10
12
public class WxPayBillResultTest {
11
-
12
- public static final String PAY_BILL_RESULT_ALL_CONTENT = "交易时间,公众账号ID,商户号,特约商户号,设备号,微信订单号,商户订单号,用户标识,交易类型,交易状态,付款银行,货币种类,应结订单金额,代金券金额,微信退款单号,商户退款单号,退款金额,充值券退款金额,退款类型,退款状态,商品名称,商户数据包,手续费,费率,订单金额,申请退款金额,费率备注\n " +
13
+ private static final String PAY_BILL_RESULT_ALL_CONTENT = "交易时间,公众账号ID,商户号,特约商户号,设备号,微信订单号,商户订单号,用户标识,交易类型,交易状态,付款银行,货币种类,应结订单金额,代金券金额,微信退款单号,商户退款单号,退款金额,充值券退款金额,退款类型,退款状态,商品名称,商户数据包,手续费,费率,订单金额,申请退款金额,费率备注\n " +
13
14
"`2019-07-25 08:35:41,`WWWW,`XXXXXXXX,`0,`,`XXXXXXXXXXXXX,`XXXXXXXXXX,`XXXXXXXXXXX,`JSAPI,`SUCCESS,`PSBC_DEBIT,`CNY,`6.00,`0.00,`0,`0,`0.00,`0.00,`,`,`XXXXXX,`XXXXXXX,`0.04000,`0.60%,`6.00,`0.00,`\n " +
14
15
"总交易单数,应结订单总金额,退款总金额,充值券退款总金额,手续费总金额,订单总金额,申请退款总金额\n " +
15
16
"`48,`5.76,`1.42,`0.00,`0.01000,`5.76,`1.42\n " ;
16
- public static final String PAY_BILL_RESULT_SUCCESS_CONTENT = "交易时间,公众账号ID,商户号,特约商户号,设备号,微信订单号,商户订单号,用户标识,交易类型,交易状态,付款银行,货币种类,应结订单金额,代金券金额,商品名称,商户数据包,手续费,费率,订单金额,费率备注\n " +
17
+ private static final String PAY_BILL_RESULT_ALL_CONTENT_1 = "交易时间,公众账号ID,商户号,子商户号,设备号,微信订单号,商户订单号,用户标识,交易类型,交易状态,付款银行,货币种类,总金额,代金券或立减优惠金额,微信退款单号,商户退款单号,退款金额,代金券或立减优惠退款金额,退款类型,退款状态,商品名称,商户数据包,手续费,费率\n " +
18
+ "`2014-11-10 16:33:45,`wx2421b1c4370ec43b,`10000100,`0,`1000,`1001690740201411100005734289,`1415640626,`085e9858e3ba5186aafcbaed1,`MICROPAY,`SUCCESS,`OTHERS,`CNY,`0.01,`0.0,`0,`0,`0,`0,`,`,`被扫支付测试,`订单额外描述,`0,`0.60%\n " +
19
+ "`2014-11-10 16:46:14,`wx2421b1c4370ec43b,`10000100,`0,`1000,`1002780740201411100005729794,`1415635270,`085e9858e90ca40c0b5aee463,`MICROPAY,`SUCCESS,`OTHERS,`CNY,`0.01,`0.0,`0,`0,`0,`0,`,`,`被扫支付测试,`订单额外描述,`0,`0.60%\n " +
20
+ "总交易单数,总交易额,总退款金额,总代金券或立减优惠退款金额,手续费总金额\n " +
21
+ "`2,`0.02,`0.0,`0.0,`0" ;
22
+
23
+ private static final String PAY_BILL_RESULT_SUCCESS_CONTENT = "交易时间,公众账号ID,商户号,特约商户号,设备号,微信订单号,商户订单号,用户标识,交易类型,交易状态,付款银行,货币种类,应结订单金额,代金券金额,商品名称,商户数据包,手续费,费率,订单金额,费率备注\n " +
17
24
"`2019-07-23 18:46:41,`XXXX,`XXX,`XXX,`,`XXX,`XXX,`XXX,`JSAPI,`SUCCESS,`CFT,`CNY,`0.01,`0.00,`XXX,`XXXX,`0.00000,`0.60%,`0.01,`\n " +
18
25
"总交易单数,应结订单总金额,退款总金额,充值券退款总金额,手续费总金额,订单总金额,申请退款总金额\n " +
19
26
"`31,`3.05,`0.00,`0.00,`0.02000,`3.05,`0.00" ;
20
- public static final String PAY_BILL_RESULT_REFUND_CONTENT = "交易时间,公众账号ID,商户号,特约商户号,设备号,微信订单号,商户订单号,用户标识,交易类型,交易状态,付款银行,货币种类,应结订单金额,代金券金额,退款申请时间,退款成功时间,微信退款单号,商户退款单号,退款金额,充值券退款金额,退款类型,退款状态,商品名称,商户数据包,手续费,费率,订单金额,申请退款金额,费率备注\n " +
27
+ private static final String PAY_BILL_RESULT_REFUND_CONTENT = "交易时间,公众账号ID,商户号,特约商户号,设备号,微信订单号,商户订单号,用户标识,交易类型,交易状态,付款银行,货币种类,应结订单金额,代金券金额,退款申请时间,退款成功时间,微信退款单号,商户退款单号,退款金额,充值券退款金额,退款类型,退款状态,商品名称,商户数据包,手续费,费率,订单金额,申请退款金额,费率备注\n " +
21
28
"`2019-07-23 20:53:36,`xxx,`xxx,`xxx,`,`xxx,`xxxx,`xxxxx,`JSAPI,`REFUND,`CFT,`CNY,`0.00,`0.00,`2019-07-23 20:53:36,`2019-07-23 20:53:40,`xxxx,`xxx,`0.01,`0.00,`ORIGINAL,`SUCCESS,`xxxx,`xxxx,`0.00000,`0.60%,`0.00,`0.01,`\n " +
22
29
"总交易单数,应结订单总金额,退款总金额,充值券退款总金额,手续费总金额,订单总金额,申请退款总金额\n " +
23
30
"`4,`0.00,`2.02,`0.00,`-0.02000,`0.00,`2.02" ;
24
31
32
+
25
33
/**
26
34
* 测试微信返回类型为ALL时,解析结果是否正确
27
35
*/
28
36
@ Test
29
37
public void testFromRawBillResultStringAll () {
30
38
WxPayBillResult result = WxPayBillResult .fromRawBillResultString (PAY_BILL_RESULT_ALL_CONTENT , WxPayConstants .BillType .ALL );
31
39
32
- Assert .assertEquals (result .getTotalRecord (), "48" );
33
- Assert .assertEquals (result .getTotalFee (), "5.76" );
34
- Assert .assertEquals (result .getTotalRefundFee (), "1.42" );
35
- Assert .assertEquals (result .getTotalCouponFee (), "0.00" );
36
- Assert .assertEquals (result .getTotalPoundageFee (), "0.01000" );
37
- Assert .assertEquals (result .getTotalAmount (), "5.76" );
38
- Assert .assertEquals (result .getTotalAppliedRefundFee (), "1.42" );
39
- Assert .assertEquals (result .getBillInfoList ().get (0 ).getTotalAmount (), "6.00" );
40
- Assert .assertEquals (result .getBillInfoList ().get (0 ).getAppliedRefundAmount (), "0.00" );
41
- Assert .assertEquals (result .getBillInfoList ().get (0 ).getFeeRemark (), "" );
40
+ assertEquals (result .getTotalRecord (), "48" );
41
+ assertEquals (result .getTotalFee (), "5.76" );
42
+ assertEquals (result .getTotalRefundFee (), "1.42" );
43
+ assertEquals (result .getTotalCouponFee (), "0.00" );
44
+ assertEquals (result .getTotalPoundageFee (), "0.01000" );
45
+ assertEquals (result .getTotalAmount (), "5.76" );
46
+ assertEquals (result .getTotalAppliedRefundFee (), "1.42" );
47
+ assertEquals (result .getBillInfoList ().get (0 ).getTotalAmount (), "6.00" );
48
+ assertEquals (result .getBillInfoList ().get (0 ).getAppliedRefundAmount (), "0.00" );
49
+ assertEquals (result .getBillInfoList ().get (0 ).getFeeRemark (), "" );
50
+
51
+ result = WxPayBillResult .fromRawBillResultString (PAY_BILL_RESULT_ALL_CONTENT_1 , WxPayConstants .BillType .ALL );
42
52
53
+ assertEquals (result .getTotalRecord (), "2" );
54
+ assertEquals (result .getTotalFee (), "0.02" );
55
+ assertEquals (result .getTotalRefundFee (), "0.0" );
56
+ assertEquals (result .getTotalCouponFee (), "0.0" );
57
+ assertEquals (result .getTotalPoundageFee (), "0" );
58
+ assertNull (result .getTotalAmount ());
59
+ assertNull (result .getTotalAppliedRefundFee ());
60
+ assertNull (result .getBillInfoList ().get (0 ).getTotalAmount ());
61
+ assertNull (result .getBillInfoList ().get (0 ).getAppliedRefundAmount ());
62
+ assertNull (result .getBillInfoList ().get (0 ).getFeeRemark ());
43
63
44
64
}
45
65
@@ -50,15 +70,15 @@ public void testFromRawBillResultStringAll() {
50
70
public void testFromRawBillResultStringSuccess () {
51
71
WxPayBillResult result = WxPayBillResult .fromRawBillResultString (PAY_BILL_RESULT_SUCCESS_CONTENT , WxPayConstants .BillType .SUCCESS );
52
72
53
- Assert . assertEquals (result .getTotalRecord (), "31" );
54
- Assert . assertEquals (result .getTotalFee (), "3.05" );
55
- Assert . assertEquals (result .getTotalRefundFee (), "0.00" );
56
- Assert . assertEquals (result .getTotalCouponFee (), "0.00" );
57
- Assert . assertEquals (result .getTotalPoundageFee (), "0.02000" );
58
- Assert . assertEquals (result .getTotalAmount (), "3.05" );
59
- Assert . assertEquals (result .getTotalAppliedRefundFee (), "0.00" );
60
- Assert . assertEquals (result .getBillInfoList ().get (0 ).getTotalAmount (), "0.01" );
61
- Assert . assertEquals (result .getBillInfoList ().get (0 ).getFeeRemark (), "" );
73
+ assertEquals (result .getTotalRecord (), "31" );
74
+ assertEquals (result .getTotalFee (), "3.05" );
75
+ assertEquals (result .getTotalRefundFee (), "0.00" );
76
+ assertEquals (result .getTotalCouponFee (), "0.00" );
77
+ assertEquals (result .getTotalPoundageFee (), "0.02000" );
78
+ assertEquals (result .getTotalAmount (), "3.05" );
79
+ assertEquals (result .getTotalAppliedRefundFee (), "0.00" );
80
+ assertEquals (result .getBillInfoList ().get (0 ).getTotalAmount (), "0.01" );
81
+ assertEquals (result .getBillInfoList ().get (0 ).getFeeRemark (), "" );
62
82
63
83
}
64
84
}
0 commit comments