9
9
import com .google .gson .GsonBuilder ;
10
10
import lombok .RequiredArgsConstructor ;
11
11
import lombok .extern .slf4j .Slf4j ;
12
+ import org .apache .commons .lang3 .StringUtils ;
12
13
13
14
/**
14
15
* @author glz
@@ -24,26 +25,30 @@ public class MerchantTransferServiceImpl implements MerchantTransferService {
24
25
25
26
@ Override
26
27
public TransferCreateResult createTransfer (TransferCreateRequest request ) throws WxPayException {
27
- request .setAppid (this .wxPayService .getConfig ().getAppId ());
28
+ if (StringUtils .isEmpty (request .getAppid ())) {
29
+ request .setAppid (this .wxPayService .getConfig ().getAppId ());
30
+ }
31
+
28
32
String url = String .format ("%s/v3/transfer/batches" , this .wxPayService .getPayBaseUrl ());
29
33
RsaCryptoUtil .encryptFields (request , this .wxPayService .getConfig ().getVerifier ().getValidCertificate ());
30
34
31
- String response = wxPayService .postV3WithWechatpaySerial (url ,GSON .toJson (request ));
35
+ String response = wxPayService .postV3WithWechatpaySerial (url , GSON .toJson (request ));
32
36
return GSON .fromJson (response , TransferCreateResult .class );
33
37
}
34
38
35
39
@ Override
36
40
public BatchesQueryResult queryWxBatches (WxBatchesQueryRequest request ) throws WxPayException {
37
- String url = String .format ("%s/v3/transfer/batches/batch-id/%s?need_query_detail=%b" , this .wxPayService .getPayBaseUrl (), request .getBatchId (), request .getNeedQueryDetail ());
41
+ String url = String .format ("%s/v3/transfer/batches/batch-id/%s?need_query_detail=%b" ,
42
+ this .wxPayService .getPayBaseUrl (), request .getBatchId (), request .getNeedQueryDetail ());
38
43
39
- if (request .getOffset ()!= null ){
40
- url = String .format ("%s&offset=%d" ,url ,request .getOffset ());
44
+ if (request .getOffset () != null ) {
45
+ url = String .format ("%s&offset=%d" , url , request .getOffset ());
41
46
}
42
- if (request .getLimit ()!= null ){
43
- url = String .format ("%s&limit=%d" ,url ,request .getLimit ());
47
+ if (request .getLimit () != null ) {
48
+ url = String .format ("%s&limit=%d" , url , request .getLimit ());
44
49
}
45
- if (request .getDetailStatus ()!= null && request .getDetailStatus ().length ()!= 0 ) {
46
- url = String .format ("%s&detail_status=%s" ,url ,request .getDetailStatus ());
50
+ if (request .getDetailStatus () != null && request .getDetailStatus ().length () != 0 ) {
51
+ url = String .format ("%s&detail_status=%s" , url , request .getDetailStatus ());
47
52
}
48
53
49
54
String response = wxPayService .getV3 (url );
@@ -52,23 +57,25 @@ public BatchesQueryResult queryWxBatches(WxBatchesQueryRequest request) throws W
52
57
53
58
@ Override
54
59
public DetailsQueryResult queryWxDetails (WxDetailsQueryRequest request ) throws WxPayException {
55
- String url = String .format ("%s/v3/transfer/batches/batch-id/%s/details/detail-id/%s" ,this .wxPayService .getPayBaseUrl (),request .getBatchId (),request .getDetailId ());
60
+ String url = String .format ("%s/v3/transfer/batches/batch-id/%s/details/detail-id/%s" ,
61
+ this .wxPayService .getPayBaseUrl (), request .getBatchId (), request .getDetailId ());
56
62
String response = wxPayService .getV3 (url );
57
63
return GSON .fromJson (response , DetailsQueryResult .class );
58
64
}
59
65
60
66
@ Override
61
67
public BatchesQueryResult queryMerchantBatches (MerchantBatchesQueryRequest request ) throws WxPayException {
62
- String url = String .format ("%s/v3/transfer/batches/out-batch-no/%s?need_query_detail=%b" , this .wxPayService .getPayBaseUrl (), request .getOutBatchNo (),request .getNeedQueryDetail ());
68
+ String url = String .format ("%s/v3/transfer/batches/out-batch-no/%s?need_query_detail=%b" ,
69
+ this .wxPayService .getPayBaseUrl (), request .getOutBatchNo (), request .getNeedQueryDetail ());
63
70
64
- if (request .getOffset ()!= null ){
65
- url = String .format ("%s&offset=%d" ,url ,request .getOffset ());
71
+ if (request .getOffset () != null ) {
72
+ url = String .format ("%s&offset=%d" , url , request .getOffset ());
66
73
}
67
- if (request .getLimit ()!= null ){
68
- url = String .format ("%s&limit=%d" ,url ,request .getLimit ());
74
+ if (request .getLimit () != null ) {
75
+ url = String .format ("%s&limit=%d" , url , request .getLimit ());
69
76
}
70
- if (request .getDetailStatus ()!= null && request .getDetailStatus ().length ()!= 0 ) {
71
- url = String .format ("%s&detail_status=%s" ,url ,request .getDetailStatus ());
77
+ if (request .getDetailStatus () != null && request .getDetailStatus ().length () != 0 ) {
78
+ url = String .format ("%s&detail_status=%s" , url , request .getDetailStatus ());
72
79
}
73
80
74
81
String response = wxPayService .getV3 (url );
@@ -77,38 +84,40 @@ public BatchesQueryResult queryMerchantBatches(MerchantBatchesQueryRequest reque
77
84
78
85
@ Override
79
86
public DetailsQueryResult queryMerchantDetails (MerchantDetailsQueryRequest request ) throws WxPayException {
80
- String url = String .format ("%s/v3/transfer/batches/out-batch-no/%s/details/out-detail-no/%s" ,this .wxPayService .getPayBaseUrl (),request .getOutBatchNo (),request .getOutDetailNo ());
87
+ String url = String .format ("%s/v3/transfer/batches/out-batch-no/%s/details/out-detail-no/%s" ,
88
+ this .wxPayService .getPayBaseUrl (), request .getOutBatchNo (), request .getOutDetailNo ());
81
89
String response = wxPayService .getV3 (url );
82
90
return GSON .fromJson (response , DetailsQueryResult .class );
83
91
}
84
92
85
93
@ Override
86
94
public ElectronicBillResult applyElectronicBill (ElectronicBillApplyRequest request ) throws WxPayException {
87
- String url = String .format ("%s/v3/transfer/bill-receipt" ,this .wxPayService .getPayBaseUrl ());
88
- String response = wxPayService .postV3 (url ,GSON .toJson (request ));
95
+ String url = String .format ("%s/v3/transfer/bill-receipt" , this .wxPayService .getPayBaseUrl ());
96
+ String response = wxPayService .postV3 (url , GSON .toJson (request ));
89
97
return GSON .fromJson (response , ElectronicBillResult .class );
90
98
}
91
99
92
100
@ Override
93
101
public ElectronicBillResult queryElectronicBill (String outBatchNo ) throws WxPayException {
94
- String url = String .format ("%s/v3/transfer/bill-receipt/%s" ,this .wxPayService .getPayBaseUrl (),outBatchNo );
102
+ String url = String .format ("%s/v3/transfer/bill-receipt/%s" , this .wxPayService .getPayBaseUrl (), outBatchNo );
95
103
String response = wxPayService .getV3 (url );
96
104
return GSON .fromJson (response , ElectronicBillResult .class );
97
105
}
98
106
99
107
@ Override
100
108
public DetailElectronicBillResult applyDetailElectronicBill (DetailElectronicBillRequest request ) throws WxPayException {
101
- String url = String .format ("%s/v3/transfer-detail/electronic-receipts" ,this .wxPayService .getPayBaseUrl ());
102
- String response = wxPayService .postV3 (url ,GSON .toJson (request ));
109
+ String url = String .format ("%s/v3/transfer-detail/electronic-receipts" , this .wxPayService .getPayBaseUrl ());
110
+ String response = wxPayService .postV3 (url , GSON .toJson (request ));
103
111
return GSON .fromJson (response , DetailElectronicBillResult .class );
104
112
}
105
113
106
114
@ Override
107
115
public DetailElectronicBillResult queryDetailElectronicBill (DetailElectronicBillRequest request ) throws WxPayException {
108
- String url = String .format ("%s/v3/transfer-detail/electronic-receipts?accept_type=%s&out_detail_no=%s" , this .wxPayService .getPayBaseUrl (), request .getAcceptType (),request .getOutDetailNo ());
116
+ String url = String .format ("%s/v3/transfer-detail/electronic-receipts?accept_type=%s&out_detail_no=%s" ,
117
+ this .wxPayService .getPayBaseUrl (), request .getAcceptType (), request .getOutDetailNo ());
109
118
110
- if ( request . getOutBatchNo ()!= null && request .getOutBatchNo (). length ()!= 0 ) {
111
- url = String .format ("%s&out_batch_no=%s" ,url ,request .getOutBatchNo ());
119
+ if ( StringUtils . isNotEmpty ( request .getOutBatchNo ())) {
120
+ url = String .format ("%s&out_batch_no=%s" , url , request .getOutBatchNo ());
112
121
}
113
122
114
123
String response = wxPayService .getV3 (url );
0 commit comments