Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat:[企业微信]新增接口-第三方组件可查询获客链接的使用详情 #3184

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1291,4 +1291,22 @@ WxMediaUploadResult uploadAttachment(String mediaType, Integer attachmentType, F
* @throws WxErrorException the wx error exception
*/
WxCpCustomerAcquisitionQuota customerAcquisitionQuota() throws WxErrorException;


/**
* 查询链接使用详情
* 服务商可通过此接口查询指定组件授权的获客链接在指定时间范围内的访问情况。
*
* 请求方式:POST(HTTPS)
* 请求地址: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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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;
Expand Down Expand Up @@ -817,6 +818,22 @@ public WxCpCustomerAcquisitionQuota customerAcquisitionQuota() throws WxErrorExc
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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -1330,6 +1330,10 @@ interface ExternalContact {
*/
String CUSTOMER_ACQUISITION_QUOTA = "/cgi-bin/externalcontact/customer_acquisition_quota";

/**
* 查询链接使用详情
*/
String CUSTOMER_ACQUISITION_STATISTIC = "/cgi-bin/externalcontact/customer_acquisition/statistic";
}

/**
Expand Down