2323import org .slf4j .LoggerFactory ;
2424
2525import java .io .File ;
26- import java .util .HashMap ;
27- import java .util .LinkedList ;
28- import java .util .List ;
29- import java .util .Map ;
26+ import java .util .*;
27+
28+ import static com .github .binarywang .wxpay .constant .WxPayConstants .QUERY_COMMENT_DATE_FORMAT ;
3029
3130/**
3231 * <pre>
@@ -237,7 +236,7 @@ public <T> T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException
237236 configMap .put ("appid" , appId );
238237
239238 payResult = WxPayAppOrderResult .newBuilder ()
240- .sign (SignUtils .createSign (configMap , this .getConfig ().getMchKey ()))
239+ .sign (SignUtils .createSign (configMap , this .getConfig ().getMchKey (), null ))
241240 .prepayId (prepayId )
242241 .partnerId (partnerId )
243242 .appId (appId )
@@ -256,7 +255,7 @@ public <T> T createOrder(WxPayUnifiedOrderRequest request) throws WxPayException
256255 .signType (SignType .MD5 )
257256 .build ();
258257 ((WxPayMpOrderResult ) payResult )
259- .setPaySign (SignUtils .createSign (payResult , this .getConfig ().getMchKey ()));
258+ .setPaySign (SignUtils .createSign (payResult , this .getConfig ().getMchKey (), null ));
260259 break ;
261260 }
262261 }
@@ -303,7 +302,7 @@ public Map<String, String> getPayInfo(WxPayUnifiedOrderRequest request) throws W
303302 configMap .put ("noncestr" , nonceStr );
304303 configMap .put ("appid" , appId );
305304 // 此map用于客户端与微信服务器交互
306- payInfo .put ("sign" , SignUtils .createSign (configMap , this .getConfig ().getMchKey ()));
305+ payInfo .put ("sign" , SignUtils .createSign (configMap , this .getConfig ().getMchKey (), null ));
307306 payInfo .put ("prepayId" , prepayId );
308307 payInfo .put ("partnerId" , partnerId );
309308 payInfo .put ("appId" , appId );
@@ -317,7 +316,7 @@ public Map<String, String> getPayInfo(WxPayUnifiedOrderRequest request) throws W
317316 payInfo .put ("nonceStr" , nonceStr );
318317 payInfo .put ("package" , "prepay_id=" + prepayId );
319318 payInfo .put ("signType" , SignType .MD5 );
320- payInfo .put ("paySign" , SignUtils .createSign (payInfo , this .getConfig ().getMchKey ()));
319+ payInfo .put ("paySign" , SignUtils .createSign (payInfo , this .getConfig ().getMchKey (), null ));
321320 }
322321
323322 return payInfo ;
@@ -364,7 +363,7 @@ public String createScanPayQrcodeMode1(String productId) {
364363 params .put ("time_stamp" , String .valueOf (System .currentTimeMillis () / 1000 ));//这里需要秒,10位数字
365364 params .put ("nonce_str" , String .valueOf (System .currentTimeMillis ()));
366365
367- String sign = SignUtils .createSign (params , this .getConfig ().getMchKey ());
366+ String sign = SignUtils .createSign (params , this .getConfig ().getMchKey (), null );
368367 params .put ("sign" , sign );
369368
370369 for (String key : params .keySet ()) {
@@ -411,15 +410,13 @@ public WxPayBillResult downloadBill(String billDate, String billType, String tar
411410 String url = this .getPayBaseUrl () + "/pay/downloadbill" ;
412411 String responseContent = this .post (url , request .toXML (), false );
413412 if (responseContent .startsWith ("<" )) {
414- WxPayCommonResult result = WxPayBaseResult .fromXML (responseContent , WxPayCommonResult .class );
415- result .checkResult (this );
416- return null ;
413+ throw WxPayException .from (WxPayBaseResult .fromXML (responseContent , WxPayCommonResult .class ));
417414 } else {
418- return billInformationDeal (responseContent );
415+ return this . handleBillInformation (responseContent );
419416 }
420417 }
421418
422- private WxPayBillResult billInformationDeal (String responseContent ) {
419+ private WxPayBillResult handleBillInformation (String responseContent ) {
423420 WxPayBillResult wxPayBillResult = new WxPayBillResult ();
424421
425422 String listStr = "" ;
@@ -597,4 +594,25 @@ public WxPayApiData getWxApiData() {
597594 wxApiData .remove ();
598595 }
599596 }
597+
598+ @ Override
599+ public String queryComment (Date beginDate , Date endDate , Integer offset , Integer limit ) throws WxPayException {
600+ WxPayQueryCommentRequest request = new WxPayQueryCommentRequest ();
601+ request .setBeginTime (QUERY_COMMENT_DATE_FORMAT .format (beginDate ));
602+ request .setEndTime (QUERY_COMMENT_DATE_FORMAT .format (endDate ));
603+ request .setOffset (offset );
604+ request .setLimit (limit );
605+ request .setSignType (SignType .HMAC_SHA256 );
606+
607+ request .checkAndSign (this .getConfig ());
608+
609+ String url = this .getPayBaseUrl () + "/billcommentsp/batchquerycomment" ;
610+
611+ String responseContent = this .post (url , request .toXML (), true );
612+ if (responseContent .startsWith ("<" )) {
613+ throw WxPayException .from (WxPayBaseResult .fromXML (responseContent , WxPayCommonResult .class ));
614+ }
615+
616+ return responseContent ;
617+ }
600618}
0 commit comments