22
33import com .google .common .collect .Lists ;
44import com .thoughtworks .xstream .annotations .XStreamAlias ;
5+ import io .restassured .path .xml .XmlPath ;
56
67import java .util .List ;
78
1718 * <li>示例值
1819 * <li>描述
1920 * </pre>
21+ *
2022 * @author <a href="https://github.com/binarywang">binarywang(Binary Wang)</a>
2123 */
2224@ XStreamAlias ("xml" )
@@ -179,75 +181,6 @@ public class WxPayOrderQueryResult extends WxPayBaseResult {
179181 private Integer couponCount ;
180182
181183 private List <Coupon > coupons ;
182-
183- public static class Coupon {
184- /**
185- * <pre>代金券类型
186- * coupon_type_$n
187- * 否
188- * String
189- * CASH
190- * <li>CASH--充值代金券
191- * <li>NO_CASH---非充值代金券
192- * 订单使用代金券时有返回(取值:CASH、NO_CASH)。$n为下标,从0开始编号,举例:coupon_type_$0
193- * </pre>
194- */
195- private String couponType ;
196-
197- /**
198- * <pre>代金券ID
199- * coupon_id_$n
200- * 否
201- * String(20)
202- * 10000
203- * 代金券ID, $n为下标,从0开始编号
204- * </pre>
205- */
206- private String couponId ;
207-
208- /**
209- * <pre>单个代金券支付金额
210- * coupon_fee_$n
211- * 否
212- * Int
213- * 100
214- * 单个代金券支付金额, $n为下标,从0开始编号
215- * </pre>
216- */
217- private Integer couponFee ;
218-
219- public Coupon (String couponType , String couponId , Integer couponFee ) {
220- this .couponType = couponType ;
221- this .couponId = couponId ;
222- this .couponFee = couponFee ;
223- }
224-
225- public String getCouponType () {
226- return this .couponType ;
227- }
228-
229- public void setCouponType (String couponType ) {
230- this .couponType = couponType ;
231- }
232-
233- public String getCouponId () {
234- return this .couponId ;
235- }
236-
237- public void setCouponId (String couponId ) {
238- this .couponId = couponId ;
239- }
240-
241- public Integer getCouponFee () {
242- return this .couponFee ;
243- }
244-
245- public void setCouponFee (Integer couponFee ) {
246- this .couponFee = couponFee ;
247- }
248-
249- }
250-
251184 /**
252185 * <pre>微信支付订单号
253186 * transaction_id
@@ -259,7 +192,6 @@ public void setCouponFee(Integer couponFee) {
259192 */
260193 @ XStreamAlias ("transaction_id" )
261194 private String transactionId ;
262-
263195 /**
264196 * <pre>商户订单号
265197 * out_trade_no
@@ -271,7 +203,6 @@ public void setCouponFee(Integer couponFee) {
271203 */
272204 @ XStreamAlias ("out_trade_no" )
273205 private String outTradeNo ;
274-
275206 /**
276207 * <pre>附加数据
277208 * attach
@@ -283,7 +214,6 @@ public void setCouponFee(Integer couponFee) {
283214 */
284215 @ XStreamAlias ("attach" )
285216 private String attach ;
286-
287217 /**
288218 * <pre>支付完成时间
289219 * time_end
@@ -295,7 +225,6 @@ public void setCouponFee(Integer couponFee) {
295225 */
296226 @ XStreamAlias ("time_end" )
297227 private String timeEnd ;
298-
299228 /**
300229 * <pre>交易状态描述
301230 * trade_state_desc
@@ -460,10 +389,86 @@ public void setTradeStateDesc(String tradeStateDesc) {
460389 this .tradeStateDesc = tradeStateDesc ;
461390 }
462391
463- public void composeCoupons (String xmlString ){
464- if (this .couponCount != null && this .couponCount > 0 ){
392+ /**
393+ * 通过xml组装coupons属性内容
394+ */
395+ public void composeCoupons () {
396+ if (this .couponCount != null && this .couponCount > 0 ) {
465397 this .coupons = Lists .newArrayList ();
466- //TODO 暂时待实现
398+ XmlPath xmlPath = new XmlPath (this .getXmlString ());
399+ for (int i = 0 ; i < this .couponCount ; i ++){
400+ this .coupons .add (new Coupon (this .getXmlValueIfExists (xmlPath , "xml.coupon_type_" + i , String .class ),
401+ this .getXmlValueIfExists (xmlPath , "xml.coupon_id_" + i , String .class ),
402+ this .getXmlValueIfExists (xmlPath , "xml.coupon_fee_" + i , Integer .class )));
403+ }
404+ }
405+ }
406+
407+ public static class Coupon {
408+ /**
409+ * <pre>代金券类型
410+ * coupon_type_$n
411+ * 否
412+ * String
413+ * CASH
414+ * <li>CASH--充值代金券
415+ * <li>NO_CASH---非充值代金券
416+ * 订单使用代金券时有返回(取值:CASH、NO_CASH)。$n为下标,从0开始编号,举例:coupon_type_$0
417+ * </pre>
418+ */
419+ private String couponType ;
420+
421+ /**
422+ * <pre>代金券ID
423+ * coupon_id_$n
424+ * 否
425+ * String(20)
426+ * 10000
427+ * 代金券ID, $n为下标,从0开始编号
428+ * </pre>
429+ */
430+ private String couponId ;
431+
432+ /**
433+ * <pre>单个代金券支付金额
434+ * coupon_fee_$n
435+ * 否
436+ * Int
437+ * 100
438+ * 单个代金券支付金额, $n为下标,从0开始编号
439+ * </pre>
440+ */
441+ private Integer couponFee ;
442+
443+ public Coupon (String couponType , String couponId , Integer couponFee ) {
444+ this .couponType = couponType ;
445+ this .couponId = couponId ;
446+ this .couponFee = couponFee ;
447+ }
448+
449+ public String getCouponType () {
450+ return this .couponType ;
451+ }
452+
453+ public void setCouponType (String couponType ) {
454+ this .couponType = couponType ;
467455 }
456+
457+ public String getCouponId () {
458+ return this .couponId ;
459+ }
460+
461+ public void setCouponId (String couponId ) {
462+ this .couponId = couponId ;
463+ }
464+
465+ public Integer getCouponFee () {
466+ return this .couponFee ;
467+ }
468+
469+ public void setCouponFee (Integer couponFee ) {
470+ this .couponFee = couponFee ;
471+ }
472+
468473 }
469474}
0 commit comments