九州仙境 v3.0.0版本的 MD5 值为:7b5ce5daab0f4a38a386ae4309157477
以下内容为反编译后的 LovefeastService.java 源代码,内容仅作参考
package com.wechat.pay.java.service.lovefeast;
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.lovefeast.model.BrandEntity;
import com.wechat.pay.java.service.lovefeast.model.GetBrandRequest;
import com.wechat.pay.java.service.lovefeast.model.GetByUserRequest;
import com.wechat.pay.java.service.lovefeast.model.ListByUserRequest;
import com.wechat.pay.java.service.lovefeast.model.OrdersEntity;
import com.wechat.pay.java.service.lovefeast.model.OrdersListByUserResponse;
import java.util.Objects;
public class LovefeastService {
private final HostName hostName;
private final HttpClient httpClient;
private LovefeastService(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 LovefeastService build() {
return new LovefeastService(this.httpClient, this.hostName);
}
}
public BrandEntity getBrand(GetBrandRequest getBrandRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/lovefeast/brands/{brand_id}".replace("{brand_id}", UrlEncoder.urlEncode(getBrandRequest.getBrandId().toString()));
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());
return (BrandEntity) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(replace).headers(httpHeaders).build(), BrandEntity.class).getServiceResponse();
}
public OrdersEntity getByUser(GetByUserRequest getByUserRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/lovefeast/users/{openid}/orders/out-trade-no/{out_trade_no}".replace("{openid}", UrlEncoder.urlEncode(getByUserRequest.getOpenid())).replace("{out_trade_no}", UrlEncoder.urlEncode(getByUserRequest.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());
return (OrdersEntity) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(replace).headers(httpHeaders).build(), OrdersEntity.class).getServiceResponse();
}
public OrdersListByUserResponse listByUser(ListByUserRequest listByUserRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/lovefeast/users/{openid}/orders/brand-id/{brand_id}".replace("{openid}", UrlEncoder.urlEncode(listByUserRequest.getOpenid())).replace("{brand_id}", UrlEncoder.urlEncode(listByUserRequest.getBrandId().toString()));
QueryParameter queryParameter = new QueryParameter();
if (listByUserRequest.getLimit() != null) {
queryParameter.add("limit", UrlEncoder.urlEncode(listByUserRequest.getLimit().toString()));
}
if (listByUserRequest.getOffset() != null) {
queryParameter.add("offset", UrlEncoder.urlEncode(listByUserRequest.getOffset().toString()));
}
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 (OrdersListByUserResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(str).headers(httpHeaders).build(), OrdersListByUserResponse.class).getServiceResponse();
}
private RequestBody createRequestBody(Object obj) {
return new JsonRequestBody.Builder().body(GsonUtil.toJson(obj)).build();
}
}