九州仙境 v3.0.0版本的 MD5 值为:7b5ce5daab0f4a38a386ae4309157477
以下内容为反编译后的 AppService.java 源代码,内容仅作参考
package com.wechat.pay.java.service.partnerpayments.app;
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.partnerpayments.app.model.CloseOrderRequest;
import com.wechat.pay.java.service.partnerpayments.app.model.PrepayRequest;
import com.wechat.pay.java.service.partnerpayments.app.model.PrepayResponse;
import com.wechat.pay.java.service.partnerpayments.app.model.QueryOrderByIdRequest;
import com.wechat.pay.java.service.partnerpayments.app.model.QueryOrderByOutTradeNoRequest;
import com.wechat.pay.java.service.partnerpayments.app.model.Transaction;
import java.util.Objects;
public class AppService {
private final HostName hostName;
private final HttpClient httpClient;
private AppService(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 AppService build() {
return new AppService(this.httpClient, this.hostName);
}
}
public void closeOrder(CloseOrderRequest closeOrderRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/pay/partner/transactions/out-trade-no/{out_trade_no}/close".replace("{out_trade_no}", UrlEncoder.urlEncode(closeOrderRequest.getOutTradeNo()));
if (this.hostName != null) {
replace = replace.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());
this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.POST).url(replace).headers(httpHeaders).body(createRequestBody(closeOrderRequest)).build(), null);
}
public PrepayResponse prepay(PrepayRequest prepayRequest) {
String replaceFirst = this.hostName != null ? "https://api.mch.weixin.qq.com/v3/pay/partner/transactions/app".replaceFirst(HostName.API.getValue(), this.hostName.getValue()) : "https://api.mch.weixin.qq.com/v3/pay/partner/transactions/app";
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.addHeader(Constant.ACCEPT, MediaType.APPLICATION_JSON.getValue());
httpHeaders.addHeader(Constant.CONTENT_TYPE, MediaType.APPLICATION_JSON.getValue());
return (PrepayResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.POST).url(replaceFirst).headers(httpHeaders).body(createRequestBody(prepayRequest)).build(), PrepayResponse.class).getServiceResponse();
}
public Transaction queryOrderById(QueryOrderByIdRequest queryOrderByIdRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/pay/partner/transactions/id/{transaction_id}".replace("{transaction_id}", UrlEncoder.urlEncode(queryOrderByIdRequest.getTransactionId()));
QueryParameter queryParameter = new QueryParameter();
if (queryOrderByIdRequest.getSpMchid() != null) {
queryParameter.add("sp_mchid", UrlEncoder.urlEncode(queryOrderByIdRequest.getSpMchid()));
}
if (queryOrderByIdRequest.getSubMchid() != null) {
queryParameter.add("sub_mchid", UrlEncoder.urlEncode(queryOrderByIdRequest.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 (Transaction) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(str).headers(httpHeaders).build(), Transaction.class).getServiceResponse();
}
public Transaction queryOrderByOutTradeNo(QueryOrderByOutTradeNoRequest queryOrderByOutTradeNoRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/pay/partner/transactions/out-trade-no/{out_trade_no}".replace("{out_trade_no}", UrlEncoder.urlEncode(queryOrderByOutTradeNoRequest.getOutTradeNo()));
QueryParameter queryParameter = new QueryParameter();
if (queryOrderByOutTradeNoRequest.getSpMchid() != null) {
queryParameter.add("sp_mchid", UrlEncoder.urlEncode(queryOrderByOutTradeNoRequest.getSpMchid()));
}
if (queryOrderByOutTradeNoRequest.getSubMchid() != null) {
queryParameter.add("sub_mchid", UrlEncoder.urlEncode(queryOrderByOutTradeNoRequest.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 (Transaction) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(str).headers(httpHeaders).build(), Transaction.class).getServiceResponse();
}
private RequestBody createRequestBody(Object obj) {
return new JsonRequestBody.Builder().body(GsonUtil.toJson(obj)).build();
}
}