13
13
import com .github .binarywang .wxpay .bean .request .*;
14
14
import com .github .binarywang .wxpay .bean .result .*;
15
15
import com .github .binarywang .wxpay .config .WxPayConfig ;
16
- import com .github .binarywang .wxpay .constant .WxPayConstants .BillType ;
17
16
import com .github .binarywang .wxpay .constant .WxPayConstants .SignType ;
18
17
import com .github .binarywang .wxpay .constant .WxPayConstants .TradeType ;
19
18
import com .github .binarywang .wxpay .exception .WxPayException ;
20
19
import com .github .binarywang .wxpay .service .EntPayService ;
21
20
import com .github .binarywang .wxpay .service .ProfitSharingService ;
21
+ import com .github .binarywang .wxpay .service .RedpackService ;
22
22
import com .github .binarywang .wxpay .service .WxPayService ;
23
23
import com .github .binarywang .wxpay .util .SignUtils ;
24
24
import com .google .common .base .Joiner ;
@@ -61,6 +61,8 @@ public abstract class BaseWxPayServiceImpl implements WxPayService {
61
61
62
62
private EntPayService entPayService = new EntPayServiceImpl (this );
63
63
private ProfitSharingService profitSharingService = new ProfitSharingServiceImpl (this );
64
+ private RedpackService redpackService = new RedpackServiceImpl (this );
65
+
64
66
/**
65
67
* The Config.
66
68
*/
@@ -76,6 +78,11 @@ public ProfitSharingService getProfitSharingService() {
76
78
return profitSharingService ;
77
79
}
78
80
81
+ @ Override
82
+ public RedpackService getRedpackService () {
83
+ return this .redpackService ;
84
+ }
85
+
79
86
@ Override
80
87
public void setEntPayService (EntPayService entPayService ) {
81
88
this .entPayService = entPayService ;
@@ -182,51 +189,25 @@ public WxScanPayNotifyResult parseScanPayNotifyResult(String xmlData) throws WxP
182
189
183
190
}
184
191
185
- @ Override
186
- public WxPaySendMiniProgramRedpackResult sendMiniProgramRedpack (WxPaySendMiniProgramRedpackRequest request )
187
- throws WxPayException {
188
- request .checkAndSign (this .getConfig ());
189
- String url = this .getPayBaseUrl () + "/mmpaymkttransfers/sendminiprogramhb" ;
190
- String responseContent = this .post (url , request .toXML (), true );
191
-
192
- WxPaySendMiniProgramRedpackResult result = BaseWxPayResult .fromXML (responseContent , WxPaySendMiniProgramRedpackResult .class );
193
- result .checkResult (this , request .getSignType (), true );
194
- return result ;
195
- }
192
+ @ Override
193
+ public WxPaySendMiniProgramRedpackResult sendMiniProgramRedpack (WxPaySendMiniProgramRedpackRequest request )
194
+ throws WxPayException {
195
+ return this .redpackService .sendMiniProgramRedpack (request );
196
+ }
196
197
197
- @ Override
198
+ @ Override
198
199
public WxPaySendRedpackResult sendRedpack (WxPaySendRedpackRequest request ) throws WxPayException {
199
- request .checkAndSign (this .getConfig ());
200
-
201
- String url = this .getPayBaseUrl () + "/mmpaymkttransfers/sendredpack" ;
202
- if (request .getAmtType () != null ) {
203
- //裂变红包
204
- url = this .getPayBaseUrl () + "/mmpaymkttransfers/sendgroupredpack" ;
205
- }
206
-
207
- String responseContent = this .post (url , request .toXML (), true );
208
- final WxPaySendRedpackResult result = BaseWxPayResult .fromXML (responseContent , WxPaySendRedpackResult .class );
209
- result .checkResult (this , request .getSignType (), true );
210
- return result ;
200
+ return this .redpackService .sendRedpack (request );
211
201
}
212
202
213
203
@ Override
214
204
public WxPayRedpackQueryResult queryRedpack (String mchBillNo ) throws WxPayException {
215
- WxPayRedpackQueryRequest request = new WxPayRedpackQueryRequest ();
216
- request .setMchBillNo (mchBillNo );
217
- return this .queryRedpack (request );
205
+ return this .redpackService .queryRedpack (mchBillNo );
218
206
}
219
207
220
208
@ Override
221
209
public WxPayRedpackQueryResult queryRedpack (WxPayRedpackQueryRequest request ) throws WxPayException {
222
- request .setBillType (BillType .MCHT );
223
- request .checkAndSign (this .getConfig ());
224
-
225
- String url = this .getPayBaseUrl () + "/mmpaymkttransfers/gethbinfo" ;
226
- String responseContent = this .post (url , request .toXML (), true );
227
- WxPayRedpackQueryResult result = BaseWxPayResult .fromXML (responseContent , WxPayRedpackQueryResult .class );
228
- result .checkResult (this , request .getSignType (), true );
229
- return result ;
210
+ return this .redpackService .queryRedpack (request );
230
211
}
231
212
232
213
@ Override
0 commit comments