@Test public void composeRefundRecords() throws Exception { String xmlString = "<xml>\n" + " <appid><![CDATA[wx2421b1c4370ec43b]]></appid>\n" + " <mch_id><![CDATA[10000100]]></mch_id>\n" + " <nonce_str><![CDATA[TeqClE3i0mvn3DrK]]></nonce_str>\n" + " <out_refund_no_0><![CDATA[1415701182]]></out_refund_no_0>\n" + " <out_trade_no><![CDATA[1415757673]]></out_trade_no>\n" + " <refund_count>1</refund_count>\n" + " <refund_fee_0>1</refund_fee_0>\n" + " <refund_id_0><![CDATA[2008450740201411110000174436]]></refund_id_0>\n" + " <refund_status_0><![CDATA[PROCESSING]]></refund_status_0>\n" + " <result_code><![CDATA[SUCCESS]]></result_code>\n" + " <return_code><![CDATA[SUCCESS]]></return_code>\n" + " <return_msg><![CDATA[OK]]></return_msg>\n" + " <sign><![CDATA[1F2841558E233C33ABA71A961D27561C]]></sign>\n" + " <transaction_id><![CDATA[1008450740201411110005820873]]></transaction_id>\n" + "</xml>"; WxPayRefundQueryResult result = WxPayRefundQueryResult.fromXML(xmlString, WxPayRefundQueryResult.class); result.composeRefundRecords(); Assert.assertNotNull(result.getRefundRecords()); Assert.assertEquals(result.getRefundRecords().size(), 1); Assert.assertEquals(result.getRefundRecords().get(0).getRefundId(), "2008450740201411110000174436"); Assert.assertEquals(result.getRefundRecords().get(0).getRefundFee().intValue(), 1); Assert.assertEquals(result.getRefundRecords().get(0).getOutRefundNo(), "1415701182"); Assert.assertEquals(result.getRefundRecords().get(0).getRefundStatus(), "PROCESSING"); }
public void composeRefundRecords() { if (this.refundCount != null && this.refundCount > 0) { this.refundRecords = Lists.newArrayList(); for (int i = 0; i < this.refundCount; i++) { RefundRecord refundRecord = new RefundRecord(); this.refundRecords.add(refundRecord); refundRecord.setOutRefundNo(this.getXmlValue("xml/out_refund_no_" + i)); refundRecord.setRefundId(this.getXmlValue("xml/refund_id_" + i)); refundRecord.setRefundChannel(this.getXmlValue("xml/refund_channel_" + i)); refundRecord.setRefundFee(this.getXmlValueAsInt("xml/refund_fee_" + i)); refundRecord.setSettlementRefundFee(this.getXmlValueAsInt("xml/settlement_refund_fee_" + i)); refundRecord.setCouponRefundFee(this.getXmlValueAsInt("xml/coupon_refund_fee_" + i)); refundRecord.setCouponRefundCount(this.getXmlValueAsInt("xml/coupon_refund_count_" + i)); refundRecord.setRefundStatus(this.getXmlValue("xml/refund_status_" + i)); refundRecord.setRefundRecvAccount(this.getXmlValue("xml/refund_recv_accout_" + i)); refundRecord.setRefundSuccessTime(this.getXmlValue("xml/refund_success_time_" + i)); if (refundRecord.getCouponRefundCount() == null || refundRecord.getCouponRefundCount() == 0) { continue; } List<WxPayRefundCouponInfo> coupons = Lists.newArrayList(); for (int j = 0; j < refundRecord.getCouponRefundCount(); j++) { coupons.add( new WxPayRefundCouponInfo( this.getXmlValue("xml/coupon_refund_id_" + i + "_" + j), this.getXmlValueAsInt("xml/coupon_refund_fee_" + i + "_" + j), this.getXmlValue("xml/coupon_type_" + i + "_" + j) ) ); } refundRecord.setRefundCoupons(coupons); } } }
WxPayRefundQueryResult extends BaseWxPayResult { public void composeRefundRecords() { if (this.refundCount != null && this.refundCount > 0) { this.refundRecords = Lists.newArrayList(); for (int i = 0; i < this.refundCount; i++) { RefundRecord refundRecord = new RefundRecord(); this.refundRecords.add(refundRecord); refundRecord.setOutRefundNo(this.getXmlValue("xml/out_refund_no_" + i)); refundRecord.setRefundId(this.getXmlValue("xml/refund_id_" + i)); refundRecord.setRefundChannel(this.getXmlValue("xml/refund_channel_" + i)); refundRecord.setRefundFee(this.getXmlValueAsInt("xml/refund_fee_" + i)); refundRecord.setSettlementRefundFee(this.getXmlValueAsInt("xml/settlement_refund_fee_" + i)); refundRecord.setCouponRefundFee(this.getXmlValueAsInt("xml/coupon_refund_fee_" + i)); refundRecord.setCouponRefundCount(this.getXmlValueAsInt("xml/coupon_refund_count_" + i)); refundRecord.setRefundStatus(this.getXmlValue("xml/refund_status_" + i)); refundRecord.setRefundRecvAccount(this.getXmlValue("xml/refund_recv_accout_" + i)); refundRecord.setRefundSuccessTime(this.getXmlValue("xml/refund_success_time_" + i)); if (refundRecord.getCouponRefundCount() == null || refundRecord.getCouponRefundCount() == 0) { continue; } List<WxPayRefundCouponInfo> coupons = Lists.newArrayList(); for (int j = 0; j < refundRecord.getCouponRefundCount(); j++) { coupons.add( new WxPayRefundCouponInfo( this.getXmlValue("xml/coupon_refund_id_" + i + "_" + j), this.getXmlValueAsInt("xml/coupon_refund_fee_" + i + "_" + j), this.getXmlValue("xml/coupon_type_" + i + "_" + j) ) ); } refundRecord.setRefundCoupons(coupons); } } } }
WxPayRefundQueryResult extends BaseWxPayResult { public void composeRefundRecords() { if (this.refundCount != null && this.refundCount > 0) { this.refundRecords = Lists.newArrayList(); for (int i = 0; i < this.refundCount; i++) { RefundRecord refundRecord = new RefundRecord(); this.refundRecords.add(refundRecord); refundRecord.setOutRefundNo(this.getXmlValue("xml/out_refund_no_" + i)); refundRecord.setRefundId(this.getXmlValue("xml/refund_id_" + i)); refundRecord.setRefundChannel(this.getXmlValue("xml/refund_channel_" + i)); refundRecord.setRefundFee(this.getXmlValueAsInt("xml/refund_fee_" + i)); refundRecord.setSettlementRefundFee(this.getXmlValueAsInt("xml/settlement_refund_fee_" + i)); refundRecord.setCouponRefundFee(this.getXmlValueAsInt("xml/coupon_refund_fee_" + i)); refundRecord.setCouponRefundCount(this.getXmlValueAsInt("xml/coupon_refund_count_" + i)); refundRecord.setRefundStatus(this.getXmlValue("xml/refund_status_" + i)); refundRecord.setRefundRecvAccount(this.getXmlValue("xml/refund_recv_accout_" + i)); refundRecord.setRefundSuccessTime(this.getXmlValue("xml/refund_success_time_" + i)); if (refundRecord.getCouponRefundCount() == null || refundRecord.getCouponRefundCount() == 0) { continue; } List<WxPayRefundCouponInfo> coupons = Lists.newArrayList(); for (int j = 0; j < refundRecord.getCouponRefundCount(); j++) { coupons.add( new WxPayRefundCouponInfo( this.getXmlValue("xml/coupon_refund_id_" + i + "_" + j), this.getXmlValueAsInt("xml/coupon_refund_fee_" + i + "_" + j), this.getXmlValue("xml/coupon_type_" + i + "_" + j) ) ); } refundRecord.setRefundCoupons(coupons); } } }  }
WxPayRefundQueryResult extends BaseWxPayResult { public void composeRefundRecords() { if (this.refundCount != null && this.refundCount > 0) { this.refundRecords = Lists.newArrayList(); for (int i = 0; i < this.refundCount; i++) { RefundRecord refundRecord = new RefundRecord(); this.refundRecords.add(refundRecord); refundRecord.setOutRefundNo(this.getXmlValue("xml/out_refund_no_" + i)); refundRecord.setRefundId(this.getXmlValue("xml/refund_id_" + i)); refundRecord.setRefundChannel(this.getXmlValue("xml/refund_channel_" + i)); refundRecord.setRefundFee(this.getXmlValueAsInt("xml/refund_fee_" + i)); refundRecord.setSettlementRefundFee(this.getXmlValueAsInt("xml/settlement_refund_fee_" + i)); refundRecord.setCouponRefundFee(this.getXmlValueAsInt("xml/coupon_refund_fee_" + i)); refundRecord.setCouponRefundCount(this.getXmlValueAsInt("xml/coupon_refund_count_" + i)); refundRecord.setRefundStatus(this.getXmlValue("xml/refund_status_" + i)); refundRecord.setRefundRecvAccount(this.getXmlValue("xml/refund_recv_accout_" + i)); refundRecord.setRefundSuccessTime(this.getXmlValue("xml/refund_success_time_" + i)); if (refundRecord.getCouponRefundCount() == null || refundRecord.getCouponRefundCount() == 0) { continue; } List<WxPayRefundCouponInfo> coupons = Lists.newArrayList(); for (int j = 0; j < refundRecord.getCouponRefundCount(); j++) { coupons.add( new WxPayRefundCouponInfo( this.getXmlValue("xml/coupon_refund_id_" + i + "_" + j), this.getXmlValueAsInt("xml/coupon_refund_fee_" + i + "_" + j), this.getXmlValue("xml/coupon_type_" + i + "_" + j) ) ); } refundRecord.setRefundCoupons(coupons); } } }  void composeRefundRecords(); }
WxPayRefundQueryResult extends BaseWxPayResult { public void composeRefundRecords() { if (this.refundCount != null && this.refundCount > 0) { this.refundRecords = Lists.newArrayList(); for (int i = 0; i < this.refundCount; i++) { RefundRecord refundRecord = new RefundRecord(); this.refundRecords.add(refundRecord); refundRecord.setOutRefundNo(this.getXmlValue("xml/out_refund_no_" + i)); refundRecord.setRefundId(this.getXmlValue("xml/refund_id_" + i)); refundRecord.setRefundChannel(this.getXmlValue("xml/refund_channel_" + i)); refundRecord.setRefundFee(this.getXmlValueAsInt("xml/refund_fee_" + i)); refundRecord.setSettlementRefundFee(this.getXmlValueAsInt("xml/settlement_refund_fee_" + i)); refundRecord.setCouponRefundFee(this.getXmlValueAsInt("xml/coupon_refund_fee_" + i)); refundRecord.setCouponRefundCount(this.getXmlValueAsInt("xml/coupon_refund_count_" + i)); refundRecord.setRefundStatus(this.getXmlValue("xml/refund_status_" + i)); refundRecord.setRefundRecvAccount(this.getXmlValue("xml/refund_recv_accout_" + i)); refundRecord.setRefundSuccessTime(this.getXmlValue("xml/refund_success_time_" + i)); if (refundRecord.getCouponRefundCount() == null || refundRecord.getCouponRefundCount() == 0) { continue; } List<WxPayRefundCouponInfo> coupons = Lists.newArrayList(); for (int j = 0; j < refundRecord.getCouponRefundCount(); j++) { coupons.add( new WxPayRefundCouponInfo( this.getXmlValue("xml/coupon_refund_id_" + i + "_" + j), this.getXmlValueAsInt("xml/coupon_refund_fee_" + i + "_" + j), this.getXmlValue("xml/coupon_type_" + i + "_" + j) ) ); } refundRecord.setRefundCoupons(coupons); } } }  void composeRefundRecords();  }