49
49
import com .github .binarywang .wxpay .bean .request .WxPayUnifiedOrderRequest ;
50
50
import com .github .binarywang .wxpay .bean .result .BaseWxPayResult ;
51
51
import com .github .binarywang .wxpay .bean .result .WxPayAuthcode2OpenidResult ;
52
- import com .github .binarywang .wxpay .bean .result .WxPayBillBaseResult ;
53
52
import com .github .binarywang .wxpay .bean .result .WxPayBillResult ;
54
53
import com .github .binarywang .wxpay .bean .result .WxPayCommonResult ;
55
54
import com .github .binarywang .wxpay .bean .result .WxPayFundFlowBaseResult ;
91
90
public abstract class BaseWxPayServiceImpl implements WxPayService {
92
91
private static final String PAY_BASE_URL = "https://api.mch.weixin.qq.com" ;
93
92
private static final String TOTAL_FUND_COUNT = "资金流水总笔数" ;
94
- private static final String TOTAL_DEAL_COUNT = "总交易单数" ;
95
93
96
94
/**
97
95
* The Log.
@@ -554,10 +552,10 @@ private WxPayBillResult handleBill(String billType, String responseContent) {
554
552
return null ;
555
553
}
556
554
557
- return this . handleAllBill (responseContent );
555
+ return WxPayBillResult . fromRawBillResultString (responseContent );
558
556
}
559
557
560
- private String handleGzipBill (String url , String requestStr ) throws WxPayException {
558
+ private String handleGzipBill (String url , String requestStr ) {
561
559
try {
562
560
byte [] responseBytes = this .postForBytes (url , requestStr , false );
563
561
Path tempDirectory = Files .createTempDirectory ("bill" );
@@ -581,80 +579,6 @@ private String handleGzipBill(String url, String requestStr) throws WxPayExcepti
581
579
return null ;
582
580
}
583
581
584
- private WxPayBillResult handleAllBill (String responseContent ) {
585
- WxPayBillResult wxPayBillResult = new WxPayBillResult ();
586
-
587
- String listStr = "" ;
588
- String objStr = "" ;
589
- if (responseContent .contains (TOTAL_DEAL_COUNT )) {
590
- listStr = responseContent .substring (0 , responseContent .indexOf (TOTAL_DEAL_COUNT ));
591
- objStr = responseContent .substring (responseContent .indexOf (TOTAL_DEAL_COUNT ));
592
- }
593
-
594
- /*
595
- * 交易时间:2017-04-06 01:00:02 公众账号ID: 商户号: 子商户号:0 设备号:WEB 微信订单号: 商户订单号:2017040519091071873216 用户标识: 交易类型:NATIVE
596
- * 交易状态:REFUND 付款银行:CFT 货币种类:CNY 总金额:0.00 企业红包金额:0.00 微信退款单号: 商户退款单号:20170406010000933 退款金额:0.01 企业红包退款金额:0.00
597
- * 退款类型:ORIGINAL 退款状态:SUCCESS 商品名称: 商户数据包: 手续费:0.00000 费率 :0.60%
598
- * 参考以上格式进行取值
599
- */
600
- List <WxPayBillBaseResult > wxPayBillBaseResultLst = new LinkedList <>();
601
- // 去空格
602
- String newStr = listStr .replaceAll ("," , " " );
603
- // 数据分组
604
- String [] tempStr = newStr .split ("`" );
605
- // 分组标题
606
- String [] t = tempStr [0 ].split (" " );
607
- // 计算循环次数
608
- int j = tempStr .length / t .length ;
609
- // 纪录数组下标
610
- int k = 1 ;
611
- for (int i = 0 ; i < j ; i ++) {
612
- WxPayBillBaseResult wxPayBillBaseResult = new WxPayBillBaseResult ();
613
-
614
- wxPayBillBaseResult .setTradeTime (tempStr [k ].trim ());
615
- wxPayBillBaseResult .setAppId (tempStr [k + 1 ].trim ());
616
- wxPayBillBaseResult .setMchId (tempStr [k + 2 ].trim ());
617
- wxPayBillBaseResult .setSubMchId (tempStr [k + 3 ].trim ());
618
- wxPayBillBaseResult .setDeviceInfo (tempStr [k + 4 ].trim ());
619
- wxPayBillBaseResult .setTransactionId (tempStr [k + 5 ].trim ());
620
- wxPayBillBaseResult .setOutTradeNo (tempStr [k + 6 ].trim ());
621
- wxPayBillBaseResult .setOpenId (tempStr [k + 7 ].trim ());
622
- wxPayBillBaseResult .setTradeType (tempStr [k + 8 ].trim ());
623
- wxPayBillBaseResult .setTradeState (tempStr [k + 9 ].trim ());
624
- wxPayBillBaseResult .setBankType (tempStr [k + 10 ].trim ());
625
- wxPayBillBaseResult .setFeeType (tempStr [k + 11 ].trim ());
626
- wxPayBillBaseResult .setTotalFee (tempStr [k + 12 ].trim ());
627
- wxPayBillBaseResult .setCouponFee (tempStr [k + 13 ].trim ());
628
- wxPayBillBaseResult .setRefundId (tempStr [k + 14 ].trim ());
629
- wxPayBillBaseResult .setOutRefundNo (tempStr [k + 15 ].trim ());
630
- wxPayBillBaseResult .setSettlementRefundFee (tempStr [k + 16 ].trim ());
631
- wxPayBillBaseResult .setCouponRefundFee (tempStr [k + 17 ].trim ());
632
- wxPayBillBaseResult .setRefundChannel (tempStr [k + 18 ].trim ());
633
- wxPayBillBaseResult .setRefundState (tempStr [k + 19 ].trim ());
634
- wxPayBillBaseResult .setBody (tempStr [k + 20 ].trim ());
635
- wxPayBillBaseResult .setAttach (tempStr [k + 21 ].trim ());
636
- wxPayBillBaseResult .setPoundage (tempStr [k + 22 ].trim ());
637
- wxPayBillBaseResult .setPoundageRate (tempStr [k + 23 ].trim ());
638
- wxPayBillBaseResultLst .add (wxPayBillBaseResult );
639
- k += t .length ;
640
- }
641
- wxPayBillResult .setWxPayBillBaseResultLst (wxPayBillBaseResultLst );
642
-
643
- /*
644
- * 总交易单数,总交易额,总退款金额,总代金券或立减优惠退款金额,手续费总金额 `2,`0.02,`0.0,`0.0,`0
645
- * 参考以上格式进行取值
646
- */
647
- String totalStr = objStr .replaceAll ("," , " " );
648
- String [] totalTempStr = totalStr .split ("`" );
649
- wxPayBillResult .setTotalRecord (totalTempStr [1 ]);
650
- wxPayBillResult .setTotalFee (totalTempStr [2 ]);
651
- wxPayBillResult .setTotalRefundFee (totalTempStr [3 ]);
652
- wxPayBillResult .setTotalCouponFee (totalTempStr [4 ]);
653
- wxPayBillResult .setTotalPoundageFee (totalTempStr [5 ]);
654
-
655
- return wxPayBillResult ;
656
- }
657
-
658
582
@ Override
659
583
public WxPayFundFlowResult downloadFundFlow (String billDate , String accountType , String tarType ) throws WxPayException {
660
584
0 commit comments