Skip to content

Commit 4c03373

Browse files
committed
支付结果通知类优化
1 parent 5986fbb commit 4c03373

File tree

2 files changed

+58
-7
lines changed

2 files changed

+58
-7
lines changed

weixin-java-pay/src/main/java/com/github/binarywang/wxpay/bean/WxPayOrderNotifyCoupon.java

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
package com.github.binarywang.wxpay.bean;
22

3-
import com.thoughtworks.xstream.annotations.XStreamAlias;
43
import org.apache.commons.lang3.builder.ToStringBuilder;
54
import org.apache.commons.lang3.builder.ToStringStyle;
65

@@ -12,16 +11,10 @@
1211
* 支付异步通知代金券详细
1312
*/
1413
public class WxPayOrderNotifyCoupon implements Serializable {
15-
/**
16-
* @fields serialVersionUID
17-
*/
1814
private static final long serialVersionUID = -4165343733538156097L;
1915

20-
@XStreamAlias("coupon_id")
2116
private String couponId;
22-
@XStreamAlias("coupon_type")
2317
private String couponType;
24-
@XStreamAlias("coupon_fee")
2518
private Integer couponFee;
2619

2720
public String getCouponId() {
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.github.binarywang.wxpay.bean.result;
2+
3+
import org.testng.*;
4+
import org.testng.annotations.*;
5+
6+
/**
7+
* <pre>
8+
* Created by Binary Wang on 2017-6-15.
9+
* @author <a href="https://github.com/binarywang">Binary Wang</a>
10+
* </pre>
11+
*/
12+
public class WxPayOrderNotifyResultTest {
13+
@Test
14+
public void testFromXML() throws Exception {
15+
String xmlString = "<xml>\n" +
16+
" <appid><![CDATA[wx2421b1c4370ec43b]]></appid>\n" +
17+
" <attach><![CDATA[支付测试]]></attach>\n" +
18+
" <bank_type><![CDATA[CFT]]></bank_type>\n" +
19+
" <fee_type><![CDATA[CNY]]></fee_type>\n" +
20+
" <is_subscribe><![CDATA[Y]]></is_subscribe>\n" +
21+
" <mch_id><![CDATA[10000100]]></mch_id>\n" +
22+
" <nonce_str><![CDATA[5d2b6c2a8db53831f7eda20af46e531c]]></nonce_str>\n" +
23+
" <openid><![CDATA[oUpF8uMEb4qRXf22hE3X68TekukE]]></openid>\n" +
24+
" <out_trade_no><![CDATA[1409811653]]></out_trade_no>\n" +
25+
" <result_code><![CDATA[SUCCESS]]></result_code>\n" +
26+
" <return_code><![CDATA[SUCCESS]]></return_code>\n" +
27+
" <sign><![CDATA[B552ED6B279343CB493C5DD0D78AB241]]></sign>\n" +
28+
" <sub_mch_id><![CDATA[10000100]]></sub_mch_id>\n" +
29+
" <time_end><![CDATA[20140903131540]]></time_end>\n" +
30+
" <total_fee>1</total_fee>\n" +
31+
" <trade_type><![CDATA[JSAPI]]></trade_type>\n" +
32+
" <transaction_id><![CDATA[1004400740201409030005092168]]></transaction_id>\n" +
33+
" <coupon_count>2</coupon_count>\n" +
34+
" <coupon_type_0><![CDATA[CASH]]></coupon_type_0>\n" +
35+
" <coupon_id_0>10000</coupon_id_0>\n" +
36+
" <coupon_fee_0>100</coupon_fee_0>\n" +
37+
" <coupon_type_1><![CDATA[NO_CASH]]></coupon_type_1>\n" +
38+
" <coupon_id_1>10001</coupon_id_1>\n" +
39+
" <coupon_fee_1>200</coupon_fee_1>\n" +
40+
"</xml>";
41+
42+
WxPayOrderNotifyResult result = WxPayOrderNotifyResult.fromXML(xmlString);
43+
44+
Assert.assertEquals(result.getCouponCount().intValue(), 2);
45+
Assert.assertNotNull(result.getCouponList());
46+
Assert.assertEquals(result.getCouponList().size(), 2);
47+
48+
Assert.assertEquals(result.getCouponList().get(0).getCouponFee().intValue(), 100);
49+
Assert.assertEquals(result.getCouponList().get(1).getCouponFee().intValue(), 200);
50+
51+
Assert.assertEquals(result.getCouponList().get(0).getCouponType(), "CASH");
52+
Assert.assertEquals(result.getCouponList().get(1).getCouponType(), "NO_CASH");
53+
54+
Assert.assertEquals(result.getCouponList().get(0).getCouponId(), "10000");
55+
Assert.assertEquals(result.getCouponList().get(1).getCouponId(), "10001");
56+
}
57+
58+
}

0 commit comments

Comments
 (0)