九州世界 v1.0版本的 MD5 值为:7e82e48b69a4c36d0bdfb2a8d382d05d
以下内容为反编译后的 MerchantExclusiveCouponService.java 源代码,内容仅作参考
package com.wechat.pay.java.service.merchantexclusivecoupon;
import com.alipay.sdk.m.p0.c;
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.merchantexclusivecoupon.model.AssociateTradeInfoRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.AssociateTradeInfoResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.CouponCodeInfoRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.CouponCodeInfoResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.CouponCodeListResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.CouponEntity;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.CouponListResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.CouponSendGovCardResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.CreateBusiFavorStockRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.CreateBusiFavorStockResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.DeactivateCouponRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.DeactivateCouponResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.DeleteCouponCodeRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.DeleteCouponCodeResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.DisassociateTradeInfoRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.DisassociateTradeInfoResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.GetCouponNotifyRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.GetCouponNotifyResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.ListCouponsByFilterRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.ModifyBudgetRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.ModifyBudgetResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.ModifyStockInfoRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.PayReceiptInfoRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.PayReceiptListRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.QueryCouponCodeListRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.QueryCouponRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.QueryStockRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.ReturnCouponRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.ReturnCouponResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.ReturnReceiptInfoRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.SendCouponRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.SendCouponResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.SendGovCardRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.SetCouponNotifyRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.SetCouponNotifyResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.StockGetResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.SubsidyPayReceipt;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.SubsidyPayReceiptListResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.SubsidyPayRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.SubsidyReturnReceipt;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.SubsidyReturnRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.UploadCouponCodeRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.UploadCouponCodeResponse;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.UseCouponRequest;
import com.wechat.pay.java.service.merchantexclusivecoupon.model.UseCouponResponse;
import java.util.Objects;
public class MerchantExclusiveCouponService {
private final HostName hostName;
private final HttpClient httpClient;
private MerchantExclusiveCouponService(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 MerchantExclusiveCouponService build() {
return new MerchantExclusiveCouponService(this.httpClient, this.hostName);
}
}
public CouponCodeInfoResponse couponCodeInfo(CouponCodeInfoRequest couponCodeInfoRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/marketing/busifavor/stocks/{stock_id}/couponcodes/{coupon_code}".replace("{stock_id}", UrlEncoder.urlEncode(couponCodeInfoRequest.getStockId())).replace("{coupon_code}", UrlEncoder.urlEncode(couponCodeInfoRequest.getCouponCode()));
QueryParameter queryParameter = new QueryParameter();
if (couponCodeInfoRequest.getAppid() != null) {
queryParameter.add(c.d, UrlEncoder.urlEncode(couponCodeInfoRequest.getAppid()));
}
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 (CouponCodeInfoResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(str).headers(httpHeaders).build(), CouponCodeInfoResponse.class).getServiceResponse();
}
public CreateBusiFavorStockResponse createBusifavorStock(CreateBusiFavorStockRequest createBusiFavorStockRequest) {
String replaceFirst = this.hostName != null ? "https://api.mch.weixin.qq.com/v3/marketing/busifavor/stocks".replaceFirst(HostName.API.getValue(), this.hostName.getValue()) : "https://api.mch.weixin.qq.com/v3/marketing/busifavor/stocks";
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.addHeader(Constant.ACCEPT, MediaType.APPLICATION_JSON.getValue());
httpHeaders.addHeader(Constant.CONTENT_TYPE, MediaType.APPLICATION_JSON.getValue());
return (CreateBusiFavorStockResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.POST).url(replaceFirst).headers(httpHeaders).body(createRequestBody(createBusiFavorStockRequest)).build(), CreateBusiFavorStockResponse.class).getServiceResponse();
}
public DeleteCouponCodeResponse deleteCouponCode(DeleteCouponCodeRequest deleteCouponCodeRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/marketing/busifavor/stocks/{stock_id}/couponcodes/{coupon_code}".replace("{stock_id}", UrlEncoder.urlEncode(deleteCouponCodeRequest.getStockId())).replace("{coupon_code}", UrlEncoder.urlEncode(deleteCouponCodeRequest.getCouponCode()));
QueryParameter queryParameter = new QueryParameter();
if (deleteCouponCodeRequest.getDeleteRequestNo() != null) {
queryParameter.add("delete_request_no", UrlEncoder.urlEncode(deleteCouponCodeRequest.getDeleteRequestNo()));
}
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 (DeleteCouponCodeResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.DELETE).url(str).headers(httpHeaders).build(), DeleteCouponCodeResponse.class).getServiceResponse();
}
public ModifyBudgetResponse modifyBudget(ModifyBudgetRequest modifyBudgetRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/marketing/busifavor/stocks/{stock_id}/budget".replace("{stock_id}", UrlEncoder.urlEncode(modifyBudgetRequest.getStockId()));
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 (ModifyBudgetResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.PATCH).url(replace).headers(httpHeaders).body(createRequestBody(modifyBudgetRequest)).build(), ModifyBudgetResponse.class).getServiceResponse();
}
public void modifyStockInfo(ModifyStockInfoRequest modifyStockInfoRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/marketing/busifavor/stocks/{stock_id}".replace("{stock_id}", UrlEncoder.urlEncode(modifyStockInfoRequest.getStockId()));
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.PATCH).url(replace).headers(httpHeaders).body(createRequestBody(modifyStockInfoRequest)).build(), null);
}
public CouponCodeListResponse queryCouponCodeList(QueryCouponCodeListRequest queryCouponCodeListRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/marketing/busifavor/stocks/{stock_id}/couponcodes".replace("{stock_id}", UrlEncoder.urlEncode(queryCouponCodeListRequest.getStockId()));
QueryParameter queryParameter = new QueryParameter();
if (queryCouponCodeListRequest.getLimit() != null) {
queryParameter.add("limit", UrlEncoder.urlEncode(queryCouponCodeListRequest.getLimit().toString()));
}
if (queryCouponCodeListRequest.getOffset() != null) {
queryParameter.add("offset", UrlEncoder.urlEncode(queryCouponCodeListRequest.getOffset().toString()));
}
if (queryCouponCodeListRequest.getAppid() != null) {
queryParameter.add(c.d, UrlEncoder.urlEncode(queryCouponCodeListRequest.getAppid()));
}
if (queryCouponCodeListRequest.getStatus() != null) {
queryParameter.add("status", UrlEncoder.urlEncode(queryCouponCodeListRequest.getStatus().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 (CouponCodeListResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(str).headers(httpHeaders).build(), CouponCodeListResponse.class).getServiceResponse();
}
public StockGetResponse queryStock(QueryStockRequest queryStockRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/marketing/busifavor/stocks/{stock_id}".replace("{stock_id}", UrlEncoder.urlEncode(queryStockRequest.getStockId()));
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 (StockGetResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(replace).headers(httpHeaders).build(), StockGetResponse.class).getServiceResponse();
}
public UploadCouponCodeResponse uploadCouponCode(UploadCouponCodeRequest uploadCouponCodeRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/marketing/busifavor/stocks/{stock_id}/couponcodes".replace("{stock_id}", UrlEncoder.urlEncode(uploadCouponCodeRequest.getStockId()));
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 (UploadCouponCodeResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.POST).url(replace).headers(httpHeaders).body(createRequestBody(uploadCouponCodeRequest)).build(), UploadCouponCodeResponse.class).getServiceResponse();
}
public GetCouponNotifyResponse getCouponNotify(GetCouponNotifyRequest getCouponNotifyRequest) {
QueryParameter queryParameter = new QueryParameter();
if (getCouponNotifyRequest.getMchid() != null) {
queryParameter.add("mchid", UrlEncoder.urlEncode(getCouponNotifyRequest.getMchid()));
}
String str = "https://api.mch.weixin.qq.com/v3/marketing/busifavor/callbacks" + 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 (GetCouponNotifyResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(str).headers(httpHeaders).build(), GetCouponNotifyResponse.class).getServiceResponse();
}
public SetCouponNotifyResponse setCouponNotify(SetCouponNotifyRequest setCouponNotifyRequest) {
String replaceFirst = this.hostName != null ? "https://api.mch.weixin.qq.com/v3/marketing/busifavor/callbacks".replaceFirst(HostName.API.getValue(), this.hostName.getValue()) : "https://api.mch.weixin.qq.com/v3/marketing/busifavor/callbacks";
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.addHeader(Constant.ACCEPT, MediaType.APPLICATION_JSON.getValue());
httpHeaders.addHeader(Constant.CONTENT_TYPE, MediaType.APPLICATION_JSON.getValue());
return (SetCouponNotifyResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.POST).url(replaceFirst).headers(httpHeaders).body(createRequestBody(setCouponNotifyRequest)).build(), SetCouponNotifyResponse.class).getServiceResponse();
}
public AssociateTradeInfoResponse associateTradeInfo(AssociateTradeInfoRequest associateTradeInfoRequest) {
String replaceFirst = this.hostName != null ? "https://api.mch.weixin.qq.com/v3/marketing/busifavor/coupons/associate".replaceFirst(HostName.API.getValue(), this.hostName.getValue()) : "https://api.mch.weixin.qq.com/v3/marketing/busifavor/coupons/associate";
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.addHeader(Constant.ACCEPT, MediaType.APPLICATION_JSON.getValue());
httpHeaders.addHeader(Constant.CONTENT_TYPE, MediaType.APPLICATION_JSON.getValue());
return (AssociateTradeInfoResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.POST).url(replaceFirst).headers(httpHeaders).body(createRequestBody(associateTradeInfoRequest)).build(), AssociateTradeInfoResponse.class).getServiceResponse();
}
public DeactivateCouponResponse deactivateCoupon(DeactivateCouponRequest deactivateCouponRequest) {
String replaceFirst = this.hostName != null ? "https://api.mch.weixin.qq.com/v3/marketing/busifavor/coupons/deactivate".replaceFirst(HostName.API.getValue(), this.hostName.getValue()) : "https://api.mch.weixin.qq.com/v3/marketing/busifavor/coupons/deactivate";
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.addHeader(Constant.ACCEPT, MediaType.APPLICATION_JSON.getValue());
httpHeaders.addHeader(Constant.CONTENT_TYPE, MediaType.APPLICATION_JSON.getValue());
return (DeactivateCouponResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.POST).url(replaceFirst).headers(httpHeaders).body(createRequestBody(deactivateCouponRequest)).build(), DeactivateCouponResponse.class).getServiceResponse();
}
public DisassociateTradeInfoResponse disassociateTradeInfo(DisassociateTradeInfoRequest disassociateTradeInfoRequest) {
String replaceFirst = this.hostName != null ? "https://api.mch.weixin.qq.com/v3/marketing/busifavor/coupons/disassociate".replaceFirst(HostName.API.getValue(), this.hostName.getValue()) : "https://api.mch.weixin.qq.com/v3/marketing/busifavor/coupons/disassociate";
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.addHeader(Constant.ACCEPT, MediaType.APPLICATION_JSON.getValue());
httpHeaders.addHeader(Constant.CONTENT_TYPE, MediaType.APPLICATION_JSON.getValue());
return (DisassociateTradeInfoResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.POST).url(replaceFirst).headers(httpHeaders).body(createRequestBody(disassociateTradeInfoRequest)).build(), DisassociateTradeInfoResponse.class).getServiceResponse();
}
public CouponListResponse listCouponsByFilter(ListCouponsByFilterRequest listCouponsByFilterRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/marketing/busifavor/users/{openid}/coupons".replace("{openid}", UrlEncoder.urlEncode(listCouponsByFilterRequest.getOpenid()));
QueryParameter queryParameter = new QueryParameter();
if (listCouponsByFilterRequest.getAppid() != null) {
queryParameter.add(c.d, UrlEncoder.urlEncode(listCouponsByFilterRequest.getAppid()));
}
if (listCouponsByFilterRequest.getStockId() != null) {
queryParameter.add("stock_id", UrlEncoder.urlEncode(listCouponsByFilterRequest.getStockId()));
}
if (listCouponsByFilterRequest.getCreatorMerchant() != null) {
queryParameter.add("creator_merchant", UrlEncoder.urlEncode(listCouponsByFilterRequest.getCreatorMerchant()));
}
if (listCouponsByFilterRequest.getBelongMerchant() != null) {
queryParameter.add("belong_merchant", UrlEncoder.urlEncode(listCouponsByFilterRequest.getBelongMerchant()));
}
if (listCouponsByFilterRequest.getSenderMerchant() != null) {
queryParameter.add("sender_merchant", UrlEncoder.urlEncode(listCouponsByFilterRequest.getSenderMerchant()));
}
if (listCouponsByFilterRequest.getOffset() != null) {
queryParameter.add("offset", UrlEncoder.urlEncode(listCouponsByFilterRequest.getOffset().toString()));
}
if (listCouponsByFilterRequest.getLimit() != null) {
queryParameter.add("limit", UrlEncoder.urlEncode(listCouponsByFilterRequest.getLimit().toString()));
}
if (listCouponsByFilterRequest.getCouponState() != null) {
queryParameter.add("coupon_state", UrlEncoder.urlEncode(listCouponsByFilterRequest.getCouponState().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 (CouponListResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(str).headers(httpHeaders).build(), CouponListResponse.class).getServiceResponse();
}
public CouponEntity queryCoupon(QueryCouponRequest queryCouponRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/marketing/busifavor/users/{openid}/coupons/{coupon_code}/appids/{appid}".replace("{coupon_code}", UrlEncoder.urlEncode(queryCouponRequest.getCouponCode())).replace("{appid}", UrlEncoder.urlEncode(queryCouponRequest.getAppid())).replace("{openid}", UrlEncoder.urlEncode(queryCouponRequest.getOpenid()));
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 (CouponEntity) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(replace).headers(httpHeaders).build(), CouponEntity.class).getServiceResponse();
}
public ReturnCouponResponse returnCoupon(ReturnCouponRequest returnCouponRequest) {
String replaceFirst = this.hostName != null ? "https://api.mch.weixin.qq.com/v3/marketing/busifavor/coupons/return".replaceFirst(HostName.API.getValue(), this.hostName.getValue()) : "https://api.mch.weixin.qq.com/v3/marketing/busifavor/coupons/return";
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.addHeader(Constant.ACCEPT, MediaType.APPLICATION_JSON.getValue());
httpHeaders.addHeader(Constant.CONTENT_TYPE, MediaType.APPLICATION_JSON.getValue());
return (ReturnCouponResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.POST).url(replaceFirst).headers(httpHeaders).body(createRequestBody(returnCouponRequest)).build(), ReturnCouponResponse.class).getServiceResponse();
}
public SendCouponResponse sendCoupon(SendCouponRequest sendCouponRequest) {
String replaceFirst = this.hostName != null ? "https://api.mch.weixin.qq.com/v3/marketing/busifavor/coupons/send".replaceFirst(HostName.API.getValue(), this.hostName.getValue()) : "https://api.mch.weixin.qq.com/v3/marketing/busifavor/coupons/send";
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.addHeader(Constant.ACCEPT, MediaType.APPLICATION_JSON.getValue());
httpHeaders.addHeader(Constant.CONTENT_TYPE, MediaType.APPLICATION_JSON.getValue());
return (SendCouponResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.POST).url(replaceFirst).headers(httpHeaders).body(createRequestBody(sendCouponRequest)).build(), SendCouponResponse.class).getServiceResponse();
}
public CouponSendGovCardResponse sendGovCard(SendGovCardRequest sendGovCardRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/marketing/busifavor/coupons/{card_id}/send".replace("{card_id}", UrlEncoder.urlEncode(sendGovCardRequest.getCardId()));
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 (CouponSendGovCardResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.POST).url(replace).headers(httpHeaders).body(createRequestBody(sendGovCardRequest)).build(), CouponSendGovCardResponse.class).getServiceResponse();
}
public UseCouponResponse useCoupon(UseCouponRequest useCouponRequest) {
String replaceFirst = this.hostName != null ? "https://api.mch.weixin.qq.com/v3/marketing/busifavor/coupons/use".replaceFirst(HostName.API.getValue(), this.hostName.getValue()) : "https://api.mch.weixin.qq.com/v3/marketing/busifavor/coupons/use";
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.addHeader(Constant.ACCEPT, MediaType.APPLICATION_JSON.getValue());
httpHeaders.addHeader(Constant.CONTENT_TYPE, MediaType.APPLICATION_JSON.getValue());
return (UseCouponResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.POST).url(replaceFirst).headers(httpHeaders).body(createRequestBody(useCouponRequest)).build(), UseCouponResponse.class).getServiceResponse();
}
public SubsidyPayReceipt payReceiptInfo(PayReceiptInfoRequest payReceiptInfoRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/marketing/busifavor/subsidy/pay-receipts/{subsidy_receipt_id}".replace("{subsidy_receipt_id}", UrlEncoder.urlEncode(payReceiptInfoRequest.getSubsidyReceiptId()));
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 (SubsidyPayReceipt) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(replace).headers(httpHeaders).build(), SubsidyPayReceipt.class).getServiceResponse();
}
public SubsidyPayReceiptListResponse payReceiptList(PayReceiptListRequest payReceiptListRequest) {
QueryParameter queryParameter = new QueryParameter();
if (payReceiptListRequest.getStockId() != null) {
queryParameter.add("stock_id", UrlEncoder.urlEncode(payReceiptListRequest.getStockId()));
}
if (payReceiptListRequest.getCouponCode() != null) {
queryParameter.add("coupon_code", UrlEncoder.urlEncode(payReceiptListRequest.getCouponCode()));
}
if (payReceiptListRequest.getOutSubsidyNo() != null) {
queryParameter.add("out_subsidy_no", UrlEncoder.urlEncode(payReceiptListRequest.getOutSubsidyNo()));
}
String str = "https://api.mch.weixin.qq.com/v3/marketing/busifavor/subsidy/pay-receipts" + 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 (SubsidyPayReceiptListResponse) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(str).headers(httpHeaders).build(), SubsidyPayReceiptListResponse.class).getServiceResponse();
}
public SubsidyReturnReceipt returnReceiptInfo(ReturnReceiptInfoRequest returnReceiptInfoRequest) {
String replace = "https://api.mch.weixin.qq.com/v3/marketing/busifavor/subsidy/return-receipts/{subsidy_return_receipt_id}".replace("{subsidy_return_receipt_id}", UrlEncoder.urlEncode(returnReceiptInfoRequest.getSubsidyReturnReceiptId()));
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 (SubsidyReturnReceipt) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.GET).url(replace).headers(httpHeaders).build(), SubsidyReturnReceipt.class).getServiceResponse();
}
public SubsidyPayReceipt subsidyPay(SubsidyPayRequest subsidyPayRequest) {
String replaceFirst = this.hostName != null ? "https://api.mch.weixin.qq.com/v3/marketing/busifavor/subsidy/pay-receipts".replaceFirst(HostName.API.getValue(), this.hostName.getValue()) : "https://api.mch.weixin.qq.com/v3/marketing/busifavor/subsidy/pay-receipts";
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.addHeader(Constant.ACCEPT, MediaType.APPLICATION_JSON.getValue());
httpHeaders.addHeader(Constant.CONTENT_TYPE, MediaType.APPLICATION_JSON.getValue());
return (SubsidyPayReceipt) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.POST).url(replaceFirst).headers(httpHeaders).body(createRequestBody(subsidyPayRequest)).build(), SubsidyPayReceipt.class).getServiceResponse();
}
public SubsidyReturnReceipt subsidyReturn(SubsidyReturnRequest subsidyReturnRequest) {
String replaceFirst = this.hostName != null ? "https://api.mch.weixin.qq.com/v3/marketing/busifavor/subsidy/return-receipts".replaceFirst(HostName.API.getValue(), this.hostName.getValue()) : "https://api.mch.weixin.qq.com/v3/marketing/busifavor/subsidy/return-receipts";
HttpHeaders httpHeaders = new HttpHeaders();
httpHeaders.addHeader(Constant.ACCEPT, MediaType.APPLICATION_JSON.getValue());
httpHeaders.addHeader(Constant.CONTENT_TYPE, MediaType.APPLICATION_JSON.getValue());
return (SubsidyReturnReceipt) this.httpClient.execute(new HttpRequest.Builder().httpMethod(HttpMethod.POST).url(replaceFirst).headers(httpHeaders).body(createRequestBody(subsidyReturnRequest)).build(), SubsidyReturnReceipt.class).getServiceResponse();
}
private RequestBody createRequestBody(Object obj) {
return new JsonRequestBody.Builder().body(GsonUtil.toJson(obj)).build();
}
}