九州仙境 v3.0.0版本的 MD5 值为:7b5ce5daab0f4a38a386ae4309157477
以下内容为反编译后的 RefundService.java 源代码,内容仅作参考
package com.wechat.pay.java.service.refund;
import com.wechat.pay.java.core.Config;
import com.wechat.pay.java.core.http.Constant;
import com.wechat.pay.java.core.http.DefaultHttpClientBuilder;
import com.wechat.pay.java.core.http.HostName;
import com.wechat.pay.java.core.http.HttpClient;
import com.wechat.pay.java.core.http.HttpHeaders;
import com.wechat.pay.java.core.http.HttpMethod;
import com.wechat.pay.java.core.http.HttpRequest;
import com.wechat.pay.java.core.http.JsonRequestBody;
import com.wechat.pay.java.core.http.MediaType;
import com.wechat.pay.java.core.http.QueryParameter;
import com.wechat.pay.java.core.http.RequestBody;
import com.wechat.pay.java.core.http.UrlEncoder;
import com.wechat.pay.java.core.util.GsonUtil;
import com.wechat.pay.java.service.refund.model.CreateRequest;
import com.wechat.pay.java.service.refund.model.QueryByOutRefundNoRequest;
import com.wechat.pay.java.service.refund.model.Refund;
import java.util.Objects;
public class RefundService {
private final HostName hostName;
private final HttpClient httpClient;
private RefundService(HttpClient httpClient, HostName hostName) {
this.httpClient = (HttpClient) Objects.requireNonNull(httpClient);
this.hostName = hostName;
}
public static class Builder {
private HostName hostName;
private HttpClient httpClient;
public Builder config(Config config) {
this.httpClient = new DefaultHttpClientBuilder().config(config).build();
return this;
}
public Builder hostName(HostName hostName) {
this.hostName = hostName;
return this;
}
public Builder httpClient(HttpClient httpClient) {
this.httpClient = httpClient;
return this;
}
public RefundService build() {
return new RefundService(this.httpClient, this.hostName);
}
}
public Refund create(CreateRequest createRequest) {
String replaceFirst = this.hostName != null ? "https://api.mch.weixin.qq.com/v3/refund/domestic/refunds".replaceFirst(HostName.API.getValue(), this.hostName.getValue()) : "https://api.mch.weixin.qq.com/v3/refund/domestic/refunds";
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.addHeader(Constant.ACCEPT, MediaType.APPLICATION_JSON.getValue());
httpHeaders.addHeader(Constant.CONTENT_TYPE, MediaType.APPLICATION_JSON.getValue());
return (Refund) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.POST).url(replaceFirst).headers(httpHeaders).body(createRequestBody(createRequest)).build(), Refund.class).getServiceResponse();
}
public Refund queryByOutRefundNo(QueryByOutRefundNoRequest queryByOutRefundNoRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/refund/domestic/refunds/{out_refund_no}".replace("{out_refund_no}", UrlEncoder.urlEncode(queryByOutRefundNoRequest.getOutRefundNo()));
QueryParameter queryParameter = new QueryParameter();
if (queryByOutRefundNoRequest.getSubMchid() != null) {
queryParameter.add("sub_mchid", UrlEncoder.urlEncode(queryByOutRefundNoRequest.getSubMchid()));
}
String str = replace + queryParameter.getQueryStr();
if (this.hostName != null) {
str = str.replaceFirst(HostName.API.getValue(), this.hostName.getValue());
}
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.addHeader(Constant.ACCEPT, MediaType.APPLICATION_JSON.getValue());
httpHeaders.addHeader(Constant.CONTENT_TYPE, MediaType.APPLICATION_JSON.getValue());
return (Refund) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(str).headers(httpHeaders).build(), Refund.class).getServiceResponse();
}
private RequestBody createRequestBody(Object obj) {
return new JsonRequestBody.Builder().body(GsonUtil.toJson(obj)).build();
}
}