mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-10-21 02:57:37 +08:00
xml代码优化
This commit is contained in:
@@ -119,7 +119,7 @@ public class WxPayRefundResult extends BaseWxPayResult implements Serializable {
|
||||
/**
|
||||
* 组装生成退款代金券信息.
|
||||
*/
|
||||
public void composeRefundCoupons() {
|
||||
private void composeRefundCoupons() {
|
||||
List<WxPayRefundCouponInfo> coupons = Lists.newArrayList();
|
||||
Integer refundCount = this.getCouponRefundCount();
|
||||
if (refundCount == null) {
|
||||
@@ -139,4 +139,10 @@ public class WxPayRefundResult extends BaseWxPayResult implements Serializable {
|
||||
|
||||
this.setRefundCoupons(coupons);
|
||||
}
|
||||
|
||||
public static WxPayRefundResult fromXML(String xml) {
|
||||
WxPayRefundResult result = BaseWxPayResult.fromXML(xml, WxPayRefundResult.class);
|
||||
result.composeRefundCoupons();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@@ -144,8 +144,7 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
|
||||
|
||||
String url = this.getPayBaseUrl() + "/secapi/pay/refund";
|
||||
String responseContent = this.post(url, request.toXML(), true);
|
||||
WxPayRefundResult result = BaseWxPayResult.fromXML(responseContent, WxPayRefundResult.class);
|
||||
result.composeRefundCoupons();
|
||||
WxPayRefundResult result = WxPayRefundResult.fromXML(responseContent);
|
||||
result.checkResult(this, request.getSignType(), true);
|
||||
return result;
|
||||
}
|
||||
|
@@ -13,11 +13,8 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
*/
|
||||
public class WxPayRefundResultTest {
|
||||
|
||||
/**
|
||||
* Test compose refund coupons.
|
||||
*/
|
||||
@Test
|
||||
public void testComposeRefundCoupons() {
|
||||
public void testFromXML() {
|
||||
/*
|
||||
该xml字符串来自于官方文档示例,稍加改造,加上代金卷
|
||||
refund_channel 是个什么鬼,官方文档只字不提
|
||||
@@ -43,8 +40,7 @@ public class WxPayRefundResultTest {
|
||||
" <refund_fee>2</refund_fee> \n" +
|
||||
"</xml>";
|
||||
|
||||
WxPayRefundResult result = WxPayRefundResult.fromXML(xmlString, WxPayRefundResult.class);
|
||||
result.composeRefundCoupons();
|
||||
WxPayRefundResult result = WxPayRefundResult.fromXML(xmlString);
|
||||
|
||||
assertThat(result.getRefundCoupons()).isNotEmpty();
|
||||
assertThat(result.getRefundCoupons().get(0).getCouponRefundId()).isEqualTo("123");
|
||||
|
Reference in New Issue
Block a user