mirror of
https://github.com/dromara/payment-spring-boot.git
synced 2026-03-13 21:33:41 +08:00
feat: 实现经营能力接口
- 支付即服务,适用于服务商和直连商户 - 点金计划,适用于服务商
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -710,7 +710,64 @@ public enum WechatPayV3Type {
|
||||
*
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
SPEC_MCH_SUB_SETTLEMENT(HttpMethod.GET, "%s/v3/apply4sub/sub_merchants/{sub_mchid}/settlement");
|
||||
SPEC_MCH_SUB_SETTLEMENT(HttpMethod.GET, "%s/v3/apply4sub/sub_merchants/{sub_mchid}/settlement"),
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* 经营能力-支付即服务-服务人员注册API.
|
||||
*
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
SMART_GUIDES(HttpMethod.POST, "%s/v3/smartguide/guides"),
|
||||
/**
|
||||
* 经营能力-支付即服务-服务人员分配API.
|
||||
*
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
SMART_GUIDES_ASSIGN(HttpMethod.POST, "%s/v3/smartguide/guides/{guide_id}/assign"),
|
||||
/**
|
||||
* 经营能力-支付即服务-服务人员查询API.
|
||||
*
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
SMART_GUIDES_GET(HttpMethod.GET, "%s/v3/smartguide/guides"),
|
||||
/**
|
||||
* 经营能力-支付即服务-服务人员查询API.
|
||||
*
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
SMART_GUIDES_MODIFY(HttpMethod.PATCH, "%s/v3/smartguide/guides/{guide_id}"),
|
||||
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
/**
|
||||
* 经营能力-点金计划-点金计划管理API.
|
||||
*
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
GOLD_PLAN_CHANGE(HttpMethod.POST, "%s/v3/goldplan/merchants/changegoldplanstatus"),
|
||||
/**
|
||||
* 经营能力-点金计划-商家小票管理API.
|
||||
*
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
GOLD_PLAN_CHANGE_CUSTOM(HttpMethod.POST, "%s/v3/goldplan/merchants/changecustompagestatus"),
|
||||
/**
|
||||
* 经营能力-点金计划-同业过滤标签管理API.
|
||||
*
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
GOLD_PLAN_FILTER(HttpMethod.POST, "%s/v3/goldplan/merchants/set-advertising-industry-filter"),
|
||||
/**
|
||||
* 经营能力-点金计划-开通广告展示API.
|
||||
*
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
GOLD_PLAN_ADV_OPEN(HttpMethod.POST, "%s/v3/goldplan/merchants/open-advertising-show"),
|
||||
/**
|
||||
* 经营能力-点金计划-关闭广告展示API.
|
||||
*
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
GOLD_PLAN_ADV_CLOSE(HttpMethod.POST, "%s/v3/goldplan/merchants/close-advertising-show"),
|
||||
;
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -158,7 +158,8 @@ public abstract class AbstractApi {
|
||||
*/
|
||||
protected RequestEntity<?> Post(URI uri, Object params) {
|
||||
try {
|
||||
return RequestEntity.post(uri).header("Pay-TenantId", tenantId)
|
||||
return RequestEntity.post(uri)
|
||||
.header("Pay-TenantId", tenantId)
|
||||
.body(mapper.writeValueAsString(params));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new PayException("wechat app pay json failed");
|
||||
@@ -191,7 +192,8 @@ public abstract class AbstractApi {
|
||||
* @return the request entity
|
||||
*/
|
||||
protected RequestEntity<?> Get(URI uri) {
|
||||
return RequestEntity.get(uri).header("Pay-TenantId", tenantId)
|
||||
return RequestEntity.get(uri)
|
||||
.header("Pay-TenantId", tenantId)
|
||||
.build();
|
||||
}
|
||||
|
||||
@@ -210,7 +212,7 @@ public abstract class AbstractApi {
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建Post请求对象.
|
||||
* 构建Patch请求对象.
|
||||
*
|
||||
* @param uri the uri
|
||||
* @param params the params
|
||||
@@ -218,7 +220,27 @@ public abstract class AbstractApi {
|
||||
*/
|
||||
protected RequestEntity<?> Patch(URI uri, Object params) {
|
||||
try {
|
||||
return RequestEntity.patch(uri).header("Pay-TenantId", tenantId)
|
||||
return RequestEntity.patch(uri)
|
||||
.header("Pay-TenantId", tenantId)
|
||||
.body(mapper.writeValueAsString(params));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new PayException("wechat app pay json failed");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建Patch请求对象.
|
||||
*
|
||||
* @param uri the uri
|
||||
* @param params the params
|
||||
* @param httpHeaders the http headers
|
||||
* @return the request entity
|
||||
*/
|
||||
protected RequestEntity<?> Patch(URI uri, Object params, HttpHeaders httpHeaders) {
|
||||
try {
|
||||
return RequestEntity.patch(uri)
|
||||
.header("Pay-TenantId", tenantId)
|
||||
.headers(httpHeaders)
|
||||
.body(mapper.writeValueAsString(params));
|
||||
} catch (JsonProcessingException e) {
|
||||
throw new PayException("wechat app pay json failed");
|
||||
@@ -230,7 +252,7 @@ public abstract class AbstractApi {
|
||||
*
|
||||
* @param link the link
|
||||
* @return 对账单内容 ,有可能为空字符 “”
|
||||
* @see AbstractApi#billResource(String) AbstractApi#billResource(String)AbstractApi#billResource(String)AbstractApi#billResource(String)
|
||||
* @see AbstractApi#billResource(String) AbstractApi#billResource(String)AbstractApi#billResource(String)AbstractApi#billResource(String)AbstractApi#billResource(String)AbstractApi#billResource(String)
|
||||
*/
|
||||
protected String billCsvDownload(String link) {
|
||||
return this.client().withType(WechatPayV3Type.FILE_DOWNLOAD, link)
|
||||
@@ -349,7 +371,7 @@ public abstract class AbstractApi {
|
||||
/**
|
||||
* 调用{@code /v3/billdownload/file}直接下载为文件.
|
||||
*
|
||||
* @param downloadUrl 格式为 {@code https://api.mch.weixin.qq.com/v3/billdownload/file?token=xxx}
|
||||
* @param downloadUrl 格式为 {@code https://api.mch.weixin.qq.com/v3/billdownload/file?token=xxx}
|
||||
* @param filename 文件名称包含扩展名
|
||||
* @return the response entity
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,11 @@ import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.springframework.http.*;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.http.converter.HttpMessageConverter;
|
||||
import org.springframework.http.converter.xml.MappingJackson2XmlHttpMessageConverter;
|
||||
import org.springframework.util.AlternativeJdkIdGenerator;
|
||||
@@ -54,7 +58,11 @@ import java.security.cert.CertificateFactory;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -315,6 +323,29 @@ public class SignatureProvider {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 对响应的敏感字段进行解密
|
||||
*
|
||||
* @param message the message
|
||||
* @param tenantId the tenant id
|
||||
* @return encrypt message
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
public String decryptResponseMessage(String message, String tenantId) {
|
||||
try {
|
||||
WechatMetaBean wechatMetaBean = wechatMetaContainer.getWechatMeta(tenantId);
|
||||
PrivateKey privateKey = wechatMetaBean.getKeyPair().getPrivate();
|
||||
Cipher cipher = Cipher.getInstance("RSA/ECB/OAEPWithSHA-1AndMGF1Padding", BC_PROVIDER);
|
||||
cipher.init(Cipher.DECRYPT_MODE,privateKey);
|
||||
byte[] data = Base64Utils.decodeFromString(message);
|
||||
byte[] cipherData = cipher.doFinal(data);
|
||||
return new String(cipherData,StandardCharsets.UTF_8);
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new PayException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get certificate x 509 wechat certificate info.
|
||||
*
|
||||
|
||||
@@ -230,17 +230,37 @@ public class WechatApiProvider {
|
||||
* @param tenantId the tenant id
|
||||
* @return wechat partner special mch api
|
||||
*/
|
||||
public WechatPartnerSpecialMchApi partnerSpecialMchApi(String tenantId){
|
||||
public WechatPartnerSpecialMchApi partnerSpecialMchApi(String tenantId) {
|
||||
return new WechatPartnerSpecialMchApi(wechatPayClient, tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务商或者直连商户-经营能力-支付即服务
|
||||
*
|
||||
* @param tenantId the tenant id
|
||||
* @return wechat smart guide api
|
||||
*/
|
||||
public WechatSmartGuideApi smartGuideApi(String tenantId) {
|
||||
return new WechatSmartGuideApi(wechatPayClient, tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务商-经营能力-点金计划
|
||||
*
|
||||
* @param tenantId the tenant id
|
||||
* @return the wechat gold plan api
|
||||
*/
|
||||
public WechatGoldPlanApi goldPlanApi(String tenantId) {
|
||||
return new WechatGoldPlanApi(wechatPayClient, tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 其它能力-媒体上传
|
||||
*
|
||||
* @param tenantId the tenant id
|
||||
* @return the wechat media api
|
||||
*/
|
||||
public WechatMediaApi mediaApi(String tenantId){
|
||||
public WechatMediaApi mediaApi(String tenantId) {
|
||||
return new WechatMediaApi(wechatPayClient, tenantId);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* Website:
|
||||
* https://felord.cn
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.felord.payment.wechat.v3;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.WeChatServer;
|
||||
import cn.felord.payment.wechat.enumeration.WechatPayV3Type;
|
||||
import cn.felord.payment.wechat.v3.model.goldplan.GoldPlanChangeParams;
|
||||
import cn.felord.payment.wechat.v3.model.goldplan.GoldPlanAdvertisingParams;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Collections;
|
||||
|
||||
/**
|
||||
* 经营能力-点金计划
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
public class WechatGoldPlanApi extends AbstractApi {
|
||||
/**
|
||||
* Instantiates a new Abstract api.
|
||||
*
|
||||
* @param wechatPayClient the wechat pay client
|
||||
* @param tenantId the tenant id
|
||||
*/
|
||||
public WechatGoldPlanApi(WechatPayClient wechatPayClient, String tenantId) {
|
||||
super(wechatPayClient, tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 点金计划管理API
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> change(GoldPlanChangeParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.GOLD_PLAN_CHANGE, params)
|
||||
.function((wechatPayV3Type, goldPlanChangeParams) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
return Post(uri, goldPlanChangeParams);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 商家小票管理API
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> changeCustom(GoldPlanChangeParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.GOLD_PLAN_CHANGE_CUSTOM, params)
|
||||
.function((wechatPayV3Type, goldPlanChangeParams) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
return Post(uri, goldPlanChangeParams);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 同业过滤标签管理API
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> filter(GoldPlanAdvertisingParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.GOLD_PLAN_CHANGE_CUSTOM, params)
|
||||
.function((wechatPayV3Type, goldPlanChangeParams) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
return Post(uri, goldPlanChangeParams);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 开通广告展示API
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> openAdv(GoldPlanAdvertisingParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.GOLD_PLAN_ADV_OPEN, params)
|
||||
.function((wechatPayV3Type, goldPlanChangeParams) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
return Post(uri, goldPlanChangeParams);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭广告展示API
|
||||
*
|
||||
* @param subMchid the sub mchid
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> closeAdv(String subMchid) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.GOLD_PLAN_ADV_CLOSE, subMchid)
|
||||
.function((wechatPayV3Type, id) -> {
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
return Post(uri, Collections.singletonMap("sub_mchid",id));
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -0,0 +1,196 @@
|
||||
/*
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* Website:
|
||||
* https://felord.cn
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.felord.payment.wechat.v3;
|
||||
|
||||
import cn.felord.payment.wechat.enumeration.WeChatServer;
|
||||
import cn.felord.payment.wechat.enumeration.WechatPayV3Type;
|
||||
import cn.felord.payment.wechat.v3.model.smartguide.PartnerAssignParams;
|
||||
import cn.felord.payment.wechat.v3.model.smartguide.PartnerSmartGuidesParams;
|
||||
import cn.felord.payment.wechat.v3.model.smartguide.PartnerSmartGuidesQueryParams;
|
||||
import cn.felord.payment.wechat.v3.model.smartguide.SmartGuidesModifyParams;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.RequestEntity;
|
||||
import org.springframework.util.LinkedMultiValueMap;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.web.util.UriComponentsBuilder;
|
||||
|
||||
import java.net.URI;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 微信V3服务商或者直连商户-经营能力-支付即服务
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
public class WechatSmartGuideApi extends AbstractApi {
|
||||
/**
|
||||
* Instantiates a new Abstract api.
|
||||
*
|
||||
* @param wechatPayClient the wechat pay client
|
||||
* @param tenantId the tenant id
|
||||
*/
|
||||
public WechatSmartGuideApi(WechatPayClient wechatPayClient, String tenantId) {
|
||||
super(wechatPayClient, tenantId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务人员注册API
|
||||
* <p>
|
||||
* 用于开发者为商户注册服务人员使用。
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> register(PartnerSmartGuidesParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.SMART_GUIDES, params)
|
||||
.function((wechatPayV3Type, smartGuidesParams) -> {
|
||||
SignatureProvider signatureProvider = this.client().signatureProvider();
|
||||
X509WechatCertificateInfo certificate = signatureProvider.getCertificate(this.wechatMetaBean().getTenantId());
|
||||
final X509Certificate x509Certificate = certificate.getX509Certificate();
|
||||
smartGuidesParams.setName(signatureProvider.encryptRequestMessage(smartGuidesParams.getName(), x509Certificate));
|
||||
smartGuidesParams.setMobile(signatureProvider.encryptRequestMessage(smartGuidesParams.getMobile(), x509Certificate));
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.add("Wechatpay-Serial", certificate.getWechatPaySerial());
|
||||
return Post(uri, smartGuidesParams, httpHeaders);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务人员分配API
|
||||
* <p>
|
||||
* 用于开发者在顾客下单后为顾客分配服务人员使用。
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> assign(PartnerAssignParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.SMART_GUIDES_ASSIGN, params)
|
||||
.function((wechatPayV3Type, assignParams) -> {
|
||||
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.expand(assignParams.getGuideId())
|
||||
.toUri();
|
||||
Map<String, String> map = new HashMap<>(2);
|
||||
map.put("sub_mchid", assignParams.getSubMchid());
|
||||
map.put("out_trade_no", assignParams.getOutTradeNo());
|
||||
return Post(uri, map);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务人员分配API
|
||||
* <p>
|
||||
* 用于开发者在顾客下单后为顾客分配服务人员使用。
|
||||
* <p>
|
||||
* 成功返回后请自行使用{@link SignatureProvider#decryptResponseMessage(String, String)}解密敏感字段。
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> query(PartnerSmartGuidesQueryParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.SMART_GUIDES_GET, params)
|
||||
.function((wechatPayV3Type, smartGuidesQueryParams) -> {
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.add("Pay-TenantId",this.tenantId());
|
||||
MultiValueMap<String, String> queryParams = new LinkedMultiValueMap<>();
|
||||
String subMchid = smartGuidesQueryParams.getSubMchid();
|
||||
if (subMchid != null) {
|
||||
queryParams.add("sub_mchid", subMchid);
|
||||
}
|
||||
queryParams.add("store_id", String.valueOf(smartGuidesQueryParams.getStoreId()));
|
||||
String userid = smartGuidesQueryParams.getUserid();
|
||||
if (userid != null) {
|
||||
queryParams.add("userid", userid);
|
||||
}
|
||||
String mobile = smartGuidesQueryParams.getMobile();
|
||||
if (mobile != null) {
|
||||
SignatureProvider signatureProvider = this.client().signatureProvider();
|
||||
X509WechatCertificateInfo certificate = signatureProvider.getCertificate(this.wechatMetaBean().getTenantId());
|
||||
final X509Certificate x509Certificate = certificate.getX509Certificate();
|
||||
queryParams.add("mobile", signatureProvider.encryptRequestMessage(mobile, x509Certificate));
|
||||
httpHeaders.add("Wechatpay-Serial", certificate.getWechatPaySerial());
|
||||
}
|
||||
String workId = smartGuidesQueryParams.getWorkId();
|
||||
if (workId != null) {
|
||||
queryParams.add("work_id", workId);
|
||||
}
|
||||
Integer offset = smartGuidesQueryParams.getOffset();
|
||||
if (offset != null) {
|
||||
queryParams.add("offset", String.valueOf(offset));
|
||||
}
|
||||
Integer limit = smartGuidesQueryParams.getLimit();
|
||||
if (limit != null) {
|
||||
queryParams.add("limit", String.valueOf(limit));
|
||||
}
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||
.queryParams(queryParams)
|
||||
.build()
|
||||
.toUri();
|
||||
return RequestEntity.get(uri).headers(httpHeaders)
|
||||
.build();
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务人员信息更新API
|
||||
*
|
||||
* @param params the params
|
||||
* @return the wechat response entity
|
||||
*/
|
||||
public WechatResponseEntity<ObjectNode> modify(SmartGuidesModifyParams params) {
|
||||
WechatResponseEntity<ObjectNode> wechatResponseEntity = new WechatResponseEntity<>();
|
||||
this.client().withType(WechatPayV3Type.SMART_GUIDES_MODIFY, params)
|
||||
.function((wechatPayV3Type, smartGuidesParams) -> {
|
||||
SignatureProvider signatureProvider = this.client().signatureProvider();
|
||||
X509WechatCertificateInfo certificate = signatureProvider.getCertificate(this.wechatMetaBean().getTenantId());
|
||||
final X509Certificate x509Certificate = certificate.getX509Certificate();
|
||||
smartGuidesParams.setName(signatureProvider.encryptRequestMessage(smartGuidesParams.getName(), x509Certificate));
|
||||
smartGuidesParams.setMobile(signatureProvider.encryptRequestMessage(smartGuidesParams.getMobile(), x509Certificate));
|
||||
URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA))
|
||||
.build()
|
||||
.toUri();
|
||||
HttpHeaders httpHeaders = new HttpHeaders();
|
||||
httpHeaders.add("Wechatpay-Serial", certificate.getWechatPaySerial());
|
||||
return Patch(uri, smartGuidesParams, httpHeaders);
|
||||
})
|
||||
.consumer(wechatResponseEntity::convert)
|
||||
.request();
|
||||
return wechatResponseEntity;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* Website:
|
||||
* https://felord.cn
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.felord.payment.wechat.v3.model.goldplan;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 同业过滤标签管理和开通广告展示API参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class GoldPlanAdvertisingParams {
|
||||
private String subMchid;
|
||||
private List<String> advertisingIndustryFilters;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* Website:
|
||||
* https://felord.cn
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.felord.payment.wechat.v3.model.goldplan;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 点金计划管理和商家小票管理API参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class GoldPlanChangeParams {
|
||||
private String subMchid;
|
||||
private OperationType operationType;
|
||||
|
||||
|
||||
/**
|
||||
* The enum Operation type.
|
||||
*/
|
||||
public enum OperationType{
|
||||
/**
|
||||
* 表示开通
|
||||
*/
|
||||
OPEN,
|
||||
/**
|
||||
* 表示关闭
|
||||
*/
|
||||
CLOSE
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* Website:
|
||||
* https://felord.cn
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.felord.payment.wechat.v3.model.smartguide;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 服务人员分配API参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class AssignParams {
|
||||
private String guideId;
|
||||
private String outTradeNo;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* Website:
|
||||
* https://felord.cn
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.felord.payment.wechat.v3.model.smartguide;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 服务人员分配API参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class PartnerAssignParams extends AssignParams {
|
||||
private String subMchid;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* Website:
|
||||
* https://felord.cn
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.felord.payment.wechat.v3.model.smartguide;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 服务人员注册API参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class PartnerSmartGuidesParams extends SmartGuidesParams {
|
||||
private String subMchid;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* Website:
|
||||
* https://felord.cn
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.felord.payment.wechat.v3.model.smartguide;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* 服务人员查询API参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class PartnerSmartGuidesQueryParams extends SmartGuidesQueryParams {
|
||||
private String subMchid;
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* Website:
|
||||
* https://felord.cn
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package cn.felord.payment.wechat.v3.model.smartguide;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 服务人员信息更新API参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class SmartGuidesModifyParams {
|
||||
private String guideId;
|
||||
private String name;
|
||||
private String mobile;
|
||||
private String qrCode;
|
||||
private String avatar;
|
||||
private String groupQrcode;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package cn.felord.payment.wechat.v3.model.smartguide;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 服务人员注册API参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class SmartGuidesParams {
|
||||
|
||||
private String corpid;
|
||||
private Integer storeId;
|
||||
private String userid;
|
||||
private String name;
|
||||
private String mobile;
|
||||
private String qrCode;
|
||||
private String avatar;
|
||||
private String groupQrcode;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package cn.felord.payment.wechat.v3.model.smartguide;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 服务人员查询API参数
|
||||
*
|
||||
* @author felord.cn
|
||||
* @since 1.0.14.RELEASE
|
||||
*/
|
||||
@Data
|
||||
public class SmartGuidesQueryParams {
|
||||
|
||||
private Integer storeId;
|
||||
private String userid;
|
||||
private String mobile;
|
||||
private String workId;
|
||||
private Integer limit;
|
||||
private Integer offset;
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019-2021 felord.cn
|
||||
* Copyright 2019-2022 felord.cn
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
|
||||
Reference in New Issue
Block a user