From 4ce392ddbafbcce5709bf5daadee6e56c10db5be Mon Sep 17 00:00:00 2001 From: Ven <43876593+alienzyl@users.noreply.github.com> Date: Sun, 25 Jun 2023 11:49:47 +0800 Subject: [PATCH] =?UTF-8?q?:new:=20#3064=20=E3=80=90=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E3=80=91=E5=A2=9E=E5=8A=A0=E8=8E=B7=E5=AE=A2?= =?UTF-8?q?=E5=8A=A9=E6=89=8B=E7=9B=B8=E5=85=B3=E7=9A=84=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cp/api/WxCpExternalContactService.java | 114 ++++++++++++++++++ .../impl/WxCpExternalContactServiceImpl.java | 58 +++++++++ .../WxCpCustomerAcquisitionCreateResult.java | 23 ++++ .../WxCpCustomerAcquisitionCustomerList.java | 68 +++++++++++ .../WxCpCustomerAcquisitionInfo.java | 103 ++++++++++++++++ .../WxCpCustomerAcquisitionList.java | 39 ++++++ .../WxCpCustomerAcquisitionQuota.java | 35 ++++++ .../WxCpCustomerAcquisitionRequest.java | 38 ++++++ .../weixin/cp/constant/WxCpApiPathConsts.java | 30 ++++- 9 files changed, 507 insertions(+), 1 deletion(-) create mode 100644 weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionCreateResult.java create mode 100644 weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionCustomerList.java create mode 100644 weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionInfo.java create mode 100644 weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionList.java create mode 100644 weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionQuota.java create mode 100644 weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionRequest.java diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java index 3f85502d5..2e8ca3f15 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java @@ -4,6 +4,7 @@ import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.external.*; +import me.chanjar.weixin.cp.bean.external.acquisition.*; import me.chanjar.weixin.cp.bean.external.contact.*; import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRule; import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleAddRequest; @@ -1144,4 +1145,117 @@ public interface WxCpExternalContactService { */ void deleteProductAlbum(String productId) throws WxErrorException; + /** + *
+ * 获取获客链接列表 + * 企业可通过此接口获取当前仍然有效的获客链接。 + * 请求方式:POST(HTTPS) + * 请求地址: + * 接口地址 + * + * 文档地址 + *+ * @param limit 商品id + * @param cursor 商品id + * @return 获客链接列表 + * @throws WxErrorException the wx error exception + */ + WxCpCustomerAcquisitionList customerAcquisitionLinkList(Integer limit, String cursor) throws WxErrorException; + + /** + *
+ * 获取获客链接详情 + * 企业可通过此接口根据获客链接id获取链接配置详情。。 + * 请求方式:POST(HTTPS) + * 请求地址: + * 接口地址 + * + * 文档地址 + *+ * @param linkId 获客链接ID + * @return 获客链接详情 + * @throws WxErrorException the wx error exception + */ + WxCpCustomerAcquisitionInfo customerAcquisitionLinkGet(String linkId) throws WxErrorException; + + /** + *
+ * 创建获客链接 + * 企业可通过此接口创建新的获客链接。 + * 请求方式:POST(HTTPS) + * 请求地址: + * 接口地址 + * 文档地址 + *+ * + * @param wxCpCustomerAcquisitionRequest 创建链接请求 + * @return 创建链接详情 + * @throws WxErrorException the wx error exception + */ + WxCpCustomerAcquisitionCreateResult customerAcquisitionLinkCreate(WxCpCustomerAcquisitionRequest wxCpCustomerAcquisitionRequest) throws WxErrorException; + + /** + *
+ * 编辑获客链接 + * 企业可通过此接口编辑获客链接,修改获客链接的关联范围或修改获客链接的名称。 + * 请求方式:POST(HTTPS) + * 请求地址: + * 接口地址 + * 文档地址 + *+ * + * @param wxCpCustomerAcquisitionRequest 编辑链接请求 + * @return 编辑链接详情 + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp customerAcquisitionUpdate(WxCpCustomerAcquisitionRequest wxCpCustomerAcquisitionRequest) throws WxErrorException; + + /** + *
+ * 删除获客链接 + * 企业可通过此接口删除获客链接,删除后的获客链接将无法继续使用。 + * 请求方式:POST(HTTPS) + * 请求地址: + * 接口地址 + * 文档地址 + *+ * + * @param linkId 获客链接的id + * @return 删除结果 + * @throws WxErrorException the wx error exception + */ + WxCpBaseResp customerAcquisitionLinkDelete(String linkId) throws WxErrorException; + + /** + *
+ * 获取获客客户列表 + * 企业可通过此接口获取到由指定的获客链接添加的客户列表。 + * 请求方式:POST(HTTPS) + * 请求地址: + * 接口地址 + * 文档地址 + *+ * + * @param linkId 获客链接id + * @param limit 返回的最大记录数,整型,最大值1000 + * @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填 + * @return 由获客链接添加的客户信息列表 + * @throws WxErrorException the wx error exception + */ + WxCpCustomerAcquisitionCustomerList customerAcquisitionCustomer(String linkId, Integer limit, String cursor) throws WxErrorException; + + /** + *
+ * 查询剩余使用量 + * 企业可通过此接口查询当前剩余的使用量。 + * 请求方式:GET(HTTPS) + * 请求地址: + * 接口地址 + * 文档地址 + *+ * + * @return 剩余使用量 + * @throws WxErrorException the wx error exception + */ + WxCpCustomerAcquisitionQuota customerAcquisitionQuota() throws WxErrorException; } diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java index 67dd76811..fbaf977a8 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java @@ -16,6 +16,7 @@ import me.chanjar.weixin.cp.api.WxCpExternalContactService; import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.bean.WxCpBaseResp; import me.chanjar.weixin.cp.bean.external.*; +import me.chanjar.weixin.cp.bean.external.acquisition.*; import me.chanjar.weixin.cp.bean.external.contact.*; import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRule; import me.chanjar.weixin.cp.bean.external.interceptrule.WxCpInterceptRuleAddRequest; @@ -741,6 +742,63 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic this.mainService.post(url, o.toString()); } + @Override + public WxCpCustomerAcquisitionList customerAcquisitionLinkList(Integer limit, String cursor) throws WxErrorException { + JsonObject o = new JsonObject(); + o.addProperty("limit", limit); + o.addProperty("cursor", cursor); + + String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_LINK_LIST); + return WxCpCustomerAcquisitionList.fromJson(this.mainService.post(url, o)); + } + + @Override + public WxCpCustomerAcquisitionInfo customerAcquisitionLinkGet(String linkId) throws WxErrorException { + JsonObject o = new JsonObject(); + o.addProperty("link_id", linkId); + + String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_LINK_GET); + return WxCpCustomerAcquisitionInfo.fromJson(this.mainService.post(url, o)); + } + + @Override + public WxCpCustomerAcquisitionCreateResult customerAcquisitionLinkCreate(WxCpCustomerAcquisitionRequest wxCpCustomerAcquisitionRequest) throws WxErrorException { + String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_LINK_CREATE); + return WxCpCustomerAcquisitionCreateResult.fromJson(this.mainService.post(url, wxCpCustomerAcquisitionRequest.toJson())); + } + + @Override + public WxCpBaseResp customerAcquisitionUpdate(WxCpCustomerAcquisitionRequest wxCpCustomerAcquisitionRequest) throws WxErrorException { + String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_LINK_UPDATE); + return WxCpBaseResp.fromJson(this.mainService.post(url, wxCpCustomerAcquisitionRequest.toJson())); + } + + @Override + public WxCpBaseResp customerAcquisitionLinkDelete(String linkId) throws WxErrorException { + JsonObject o = new JsonObject(); + o.addProperty("link_id", linkId); + + String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_LINK_DELETE); + return WxCpBaseResp.fromJson(this.mainService.post(url, o)); + } + + @Override + public WxCpCustomerAcquisitionCustomerList customerAcquisitionCustomer(String linkId, Integer limit, String cursor) throws WxErrorException { + JsonObject o = new JsonObject(); + o.addProperty("link_id", linkId); + o.addProperty("limit", limit); + o.addProperty("cursor", cursor); + + String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_CUSTOMER); + return WxCpCustomerAcquisitionCustomerList.fromJson(this.mainService.post(url, o)); + } + + @Override + public WxCpCustomerAcquisitionQuota customerAcquisitionQuota() throws WxErrorException { + String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_QUOTA); + return WxCpCustomerAcquisitionQuota.fromJson(this.mainService.get(url, null)); + } + @Override public WxCpGroupJoinWayResult addJoinWay(WxCpGroupJoinWayInfo wxCpGroupJoinWayInfo) throws WxErrorException { if (wxCpGroupJoinWayInfo.getJoinWay().getChatIdList() != null && wxCpGroupJoinWayInfo.getJoinWay().getChatIdList().size() > 5) { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionCreateResult.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionCreateResult.java new file mode 100644 index 000000000..58739275f --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionCreateResult.java @@ -0,0 +1,23 @@ +package me.chanjar.weixin.cp.bean.external.acquisition; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.cp.bean.WxCpBaseResp; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +/** + * 创建获客助手链接结果 + * + * @author alien_zyl + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class WxCpCustomerAcquisitionCreateResult extends WxCpBaseResp { + private static final long serialVersionUID = -6301164294371861558L; + + private WxCpCustomerAcquisitionInfo.Link link; + + public static WxCpCustomerAcquisitionCreateResult fromJson(String json) { + return WxCpGsonBuilder.create().fromJson(json, WxCpCustomerAcquisitionCreateResult.class); + } +} diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionCustomerList.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionCustomerList.java new file mode 100644 index 000000000..728fde894 --- /dev/null +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/acquisition/WxCpCustomerAcquisitionCustomerList.java @@ -0,0 +1,68 @@ +package me.chanjar.weixin.cp.bean.external.acquisition; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 获取由获客链接添加的客户信息结果 + * + * @author alien_zyl + */ +@Data +public class WxCpCustomerAcquisitionCustomerList { + + @SerializedName("customer_list") + private List