1
0
mirror of synced 2025-12-12 17:54:20 +08:00

🆕 #3184【企业微信】新增第三方组件可查询获客链接的使用详情的接口

This commit is contained in:
Hugo-Ho
2023-12-13 19:43:19 +08:00
committed by Binary Wang
parent f1a56deb1f
commit 8abb34b172
4 changed files with 75 additions and 0 deletions

View File

@@ -1291,4 +1291,22 @@ public interface WxCpExternalContactService {
* @throws WxErrorException the wx error exception
*/
WxCpCustomerAcquisitionQuota customerAcquisitionQuota() throws WxErrorException;
/**
* 查询链接使用详情
* 服务商可通过此接口查询指定组件授权的获客链接在指定时间范围内的访问情况。
*
* 请求方式POSTHTTPS
* 请求地址https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/statistic?access_token=ACCESS_TOKEN
*
* @author Hugo
* @date 2023/12/5 14:34
* @param linkId 获客链接的id
* @param startTime 统计起始时间
* @param endTime 统计结束时间
* @return 点击链接客户数和新增客户数
* @throws WxErrorException the wx error exception
*/
WxCpCustomerAcquisitionStatistic customerAcquisitionStatistic(String linkId, Date startTime, Date endTime) throws WxErrorException;
}

View File

@@ -2,6 +2,7 @@ package me.chanjar.weixin.cp.api.impl;
import com.google.gson.Gson;
import com.google.gson.JsonObject;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
import me.chanjar.weixin.common.error.WxCpErrorMsgEnum;
@@ -817,6 +818,22 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic
return WxCpCustomerAcquisitionQuota.fromJson(this.mainService.get(url, null));
}
@Override
public WxCpCustomerAcquisitionStatistic customerAcquisitionStatistic(String linkId, @NonNull Date startTime,
@NonNull Date endTime) throws WxErrorException {
long endTimestamp = endTime.getTime() / 1000L;
long startTimestamp = startTime.getTime() / 1000L;
JsonObject o = new JsonObject();
o.addProperty("link_id", linkId);
o.addProperty("start_time", startTimestamp);
o.addProperty("end_time", endTimestamp);
String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_STATISTIC);
return WxCpCustomerAcquisitionStatistic.fromJson(this.mainService.post(url, o));
}
@Override
public WxCpGroupJoinWayResult addJoinWay(WxCpGroupJoinWayInfo wxCpGroupJoinWayInfo) throws WxErrorException {
if (wxCpGroupJoinWayInfo.getJoinWay().getChatIdList() != null && wxCpGroupJoinWayInfo.getJoinWay().getChatIdList().size() > 5) {

View File

@@ -0,0 +1,36 @@
package me.chanjar.weixin.cp.bean.external.acquisition;
import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
/**
* 获客链接的使用详情
*
* @author Hugo
* @date 2023/12/11 10:31
*/
@Data
@EqualsAndHashCode(callSuper = true)
public class WxCpCustomerAcquisitionStatistic extends WxCpBaseResp {
private static final long serialVersionUID = -3816540677590841079L;
/**
* 点击链接客户数
*/
@SerializedName("click_link_customer_cnt")
private Integer clickLinkCustomerCnt;
/**
* 新增客户数
*/
@SerializedName("new_customer_cnt")
private Integer newCustomerCnt;
public static WxCpCustomerAcquisitionStatistic fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpCustomerAcquisitionStatistic.class);
}
}

View File

@@ -1330,6 +1330,10 @@ public interface WxCpApiPathConsts {
*/
String CUSTOMER_ACQUISITION_QUOTA = "/cgi-bin/externalcontact/customer_acquisition_quota";
/**
* 查询链接使用详情
*/
String CUSTOMER_ACQUISITION_STATISTIC = "/cgi-bin/externalcontact/customer_acquisition/statistic";
}
/**