Skip to content

Commit 8abb34b

Browse files
Hugo-Hobinarywang
authored andcommitted
🆕 #3184【企业微信】新增第三方组件可查询获客链接的使用详情的接口
1 parent f1a56de commit 8abb34b

File tree

4 files changed

+75
-0
lines changed

4 files changed

+75
-0
lines changed

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/WxCpExternalContactService.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1291,4 +1291,22 @@ WxMediaUploadResult uploadAttachment(String mediaType, Integer attachmentType, F
12911291
* @throws WxErrorException the wx error exception
12921292
*/
12931293
WxCpCustomerAcquisitionQuota customerAcquisitionQuota() throws WxErrorException;
1294+
1295+
1296+
/**
1297+
* 查询链接使用详情
1298+
* 服务商可通过此接口查询指定组件授权的获客链接在指定时间范围内的访问情况。
1299+
*
1300+
* 请求方式:POST(HTTPS)
1301+
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/customer_acquisition/statistic?access_token=ACCESS_TOKEN
1302+
*
1303+
* @author Hugo
1304+
* @date 2023/12/5 14:34
1305+
* @param linkId 获客链接的id
1306+
* @param startTime 统计起始时间
1307+
* @param endTime 统计结束时间
1308+
* @return 点击链接客户数和新增客户数
1309+
* @throws WxErrorException the wx error exception
1310+
*/
1311+
WxCpCustomerAcquisitionStatistic customerAcquisitionStatistic(String linkId, Date startTime, Date endTime) throws WxErrorException;
12941312
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/api/impl/WxCpExternalContactServiceImpl.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.google.gson.Gson;
44
import com.google.gson.JsonObject;
5+
import lombok.NonNull;
56
import lombok.RequiredArgsConstructor;
67
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
78
import me.chanjar.weixin.common.error.WxCpErrorMsgEnum;
@@ -817,6 +818,22 @@ public WxCpCustomerAcquisitionQuota customerAcquisitionQuota() throws WxErrorExc
817818
return WxCpCustomerAcquisitionQuota.fromJson(this.mainService.get(url, null));
818819
}
819820

821+
@Override
822+
public WxCpCustomerAcquisitionStatistic customerAcquisitionStatistic(String linkId, @NonNull Date startTime,
823+
@NonNull Date endTime) throws WxErrorException {
824+
long endTimestamp = endTime.getTime() / 1000L;
825+
long startTimestamp = startTime.getTime() / 1000L;
826+
827+
JsonObject o = new JsonObject();
828+
o.addProperty("link_id", linkId);
829+
o.addProperty("start_time", startTimestamp);
830+
o.addProperty("end_time", endTimestamp);
831+
832+
String url = this.mainService.getWxCpConfigStorage().getApiUrl(CUSTOMER_ACQUISITION_STATISTIC);
833+
return WxCpCustomerAcquisitionStatistic.fromJson(this.mainService.post(url, o));
834+
}
835+
836+
820837
@Override
821838
public WxCpGroupJoinWayResult addJoinWay(WxCpGroupJoinWayInfo wxCpGroupJoinWayInfo) throws WxErrorException {
822839
if (wxCpGroupJoinWayInfo.getJoinWay().getChatIdList() != null && wxCpGroupJoinWayInfo.getJoinWay().getChatIdList().size() > 5) {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package me.chanjar.weixin.cp.bean.external.acquisition;
2+
3+
import com.google.gson.annotations.SerializedName;
4+
import lombok.Data;
5+
import lombok.EqualsAndHashCode;
6+
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
7+
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
8+
9+
/**
10+
* 获客链接的使用详情
11+
*
12+
* @author Hugo
13+
* @date 2023/12/11 10:31
14+
*/
15+
@Data
16+
@EqualsAndHashCode(callSuper = true)
17+
public class WxCpCustomerAcquisitionStatistic extends WxCpBaseResp {
18+
private static final long serialVersionUID = -3816540677590841079L;
19+
20+
/**
21+
* 点击链接客户数
22+
*/
23+
@SerializedName("click_link_customer_cnt")
24+
private Integer clickLinkCustomerCnt;
25+
26+
/**
27+
* 新增客户数
28+
*/
29+
@SerializedName("new_customer_cnt")
30+
private Integer newCustomerCnt;
31+
32+
public static WxCpCustomerAcquisitionStatistic fromJson(String json) {
33+
return WxCpGsonBuilder.create().fromJson(json, WxCpCustomerAcquisitionStatistic.class);
34+
}
35+
36+
}

weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpApiPathConsts.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,6 +1330,10 @@ interface ExternalContact {
13301330
*/
13311331
String CUSTOMER_ACQUISITION_QUOTA = "/cgi-bin/externalcontact/customer_acquisition_quota";
13321332

1333+
/**
1334+
* 查询链接使用详情
1335+
*/
1336+
String CUSTOMER_ACQUISITION_STATISTIC = "/cgi-bin/externalcontact/customer_acquisition/statistic";
13331337
}
13341338

13351339
/**

0 commit comments

Comments
 (0)