Skip to content

Commit

Permalink
🆕 #3016 【企业微信】增加获取客户数据统计接待人员明细数据的接口,并修复获取企业汇总数据接口返回值问题
Browse files Browse the repository at this point in the history
  • Loading branch information
MsThink authored May 16, 2023
1 parent 9d6faa0 commit fe91a81
Show file tree
Hide file tree
Showing 7 changed files with 244 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,22 @@ WxCpKfCustomerBatchGetResp customerBatchGet(List<String> externalUserIdList)
*/
WxCpKfGetCorpStatisticResp getCorpStatistic(WxCpKfGetCorpStatisticRequest request) throws WxErrorException;

/**
* <pre>
* 获取「客户数据统计」接待人员明细数据
* 通过此接口,可获取接入人工会话数、咨询会话数等与接待人员相关的统计信息
* 请求方式:POST(HTTPS)
* 请求地址:
* <a href="https://qyapi.weixin.qq.com/cgi-bin/kf/get_servicer_statistic?access_token=ACCESS_TOKEN">https://qyapi.weixin.qq.com/cgi-bin/kf/get_servicer_statistic?access_token=ACCESS_TOKEN</a>
* 文档地址:
* <a href="https://developer.work.weixin.qq.com/document/path/95490">https://developer.work.weixin.qq.com/document/path/95490</a>
* <pre>
* @param request 查询参数
* @return 客户数据统计 -企业汇总数据
* @throws WxErrorException the wx error exception
*/
WxCpKfGetServicerStatisticResp getServicerStatistic(WxCpKfGetServicerStatisticRequest request) throws WxErrorException;

// 「升级服务」配置

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,4 +271,11 @@ public WxCpKfGetCorpStatisticResp getCorpStatistic(WxCpKfGetCorpStatisticRequest
return WxCpKfGetCorpStatisticResp.fromJson(responseContent);
}

@Override
public WxCpKfGetServicerStatisticResp getServicerStatistic(WxCpKfGetServicerStatisticRequest request) throws WxErrorException {
String url = cpService.getWxCpConfigStorage().getApiUrl(GET_SERVICER_STATISTIC);
String responseContent = cpService.post(url, GSON.toJson(request));
return WxCpKfGetServicerStatisticResp.fromJson(responseContent);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static class Statistic {
/**
* 咨询客户数。在会话中发送过消息的客户数量,若客户多次咨询只计算一个客户
*/
@SerializedName("user_cnt")
@SerializedName("customer_cnt")
private Integer customerCnt;

/**
Expand All @@ -79,21 +79,27 @@ public static class Statistic {
/**
* 智能回复会话数。客户发过消息并分配给智能助手的咨询会话数。通过API发消息或者开启智能回复功能会将客户分配给智能助手
*/
@SerializedName("ai_transfer_rate")
@SerializedName("ai_session_reply_cnt")
private Integer aiSessionReplyCnt;

/**
* 转人工率。一个自然日内,客户给智能助手发消息的会话中,转人工的会话的占比。
*/
@SerializedName("ai_transfer_rate")
private Integer aiTransferRate;
private Float aiTransferRate;

/**
* 知识命中率。一个自然日内,客户给智能助手发送的消息中,命中知识库的占比。只有在开启了智能回复原生功能并配置了知识库的情况下,才会产生该项统计数据。当api
* 托管了会话分配,智能回复原生功能失效。若不返回,代表没有向配置知识库的智能接待助手发送消息,该项无法计算
*/
@SerializedName("ai_knowledge_hit_rate")
private Integer aiKnowledgeHitRate;
private Float aiKnowledgeHitRate;

/**
* 被拒收消息的客户数。被接待人员设置了“不再接收消息”的客户数
*/
@SerializedName("msg_rejected_customer_cnt")
private Integer msgRejectedCustomerCnt;
}

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package me.chanjar.weixin.cp.bean.kf;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
* 获取「客户数据统计」接待人员明细数据
*
* @author MsThink created on 2023/5/13
*/
@NoArgsConstructor
@Data
public class WxCpKfGetServicerStatisticRequest {
/**
* 客服帐号ID
*/
@SerializedName("open_kfid")
private String openKfId;

/**
* 接待人员的userid。第三方应用为密文userid,即open_userid
*/
@SerializedName("servicer_userid")
private String servicerUserid;

/**
* 起始日期的时间戳,填这一天的0时0分0秒(否则系统自动处理为当天的0分0秒)。取值范围:昨天至前180天
*/
@SerializedName("start_time")
private Long startTime;
/**
* 结束日期的时间戳,填这一天的0时0分0秒(否则系统自动处理为当天的0分0秒)。取值范围:昨天至前180天
*/
@SerializedName("end_time")
private Long endTime;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
package me.chanjar.weixin.cp.bean.kf;

import com.google.gson.annotations.SerializedName;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

import java.util.List;

/**
* 获取「客户数据统计」接待人员明细数据
*
* @author MsThink created on 2023/5/13
*/
@EqualsAndHashCode(callSuper = true)
@NoArgsConstructor
@Data
public class WxCpKfGetServicerStatisticResp extends WxCpBaseResp {
/**
* 统计数据列表
*/
@SerializedName("statistic_list")
private List<WxCpKfGetServicerStatisticResp.StatisticList> statisticList;

/**
* The type Statistic list.
*/
@NoArgsConstructor
@Data
public static class StatisticList {
/**
* 数据统计日期,为当日0点的时间戳
*/
@SerializedName("stat_time")
private Long statTime;

/**
* 一天的统计数据。若当天未产生任何下列统计数据或统计数据还未计算完成则不会返回此项
*/
@SerializedName("statistic")
private WxCpKfGetServicerStatisticResp.Statistic statistic;
}

/**
* The type Statistic.
*/
@NoArgsConstructor
@Data
public static class Statistic {

/**
* 接入人工会话数。客户发过消息并分配给接待人员的咨询会话数
*/
@SerializedName("session_cnt")
private Integer sessionCnt;

/**
* 咨询客户数。在会话中发送过消息且接入了人工会话的客户数量,若客户多次咨询只计算一个客户
*/
@SerializedName("customer_cnt")
private Integer customerCnt;

/**
* 咨询消息总数。客户在会话中发送的消息的数量
*/
@SerializedName("customer_msg_cnt")
private Integer customerMsgCnt;

/**
* 人工回复率。一个自然日内,客户给接待人员发消息的会话中,接待人员回复了的会话的占比。若数据项不返回,代表没有给接待人员发送消息的客户,此项无法计算。
*/
@SerializedName("reply_rate")
private Float replyRate;

/**
* 平均首次响应时长,单位:秒。一个自然日内,客户给接待人员发送的第一条消息至接待人员回复之间的时长,为首次响应时长。所有的首次回复总时长/已回复的咨询会话数,
* 即为平均首次响应时长 。若数据项不返回,代表没有给接待人员发送消息的客户,此项无法计算
*/
@SerializedName("first_reply_average_sec")
private Float firstReplyAverageSec;

/**
* 满意度评价发送数。当api托管了会话分配,满意度原生功能失效,满意度评价发送数为0
*/
@SerializedName("satisfaction_investgate_cnt")
private Integer satisfactionInvestgateCnt;

/**
* 满意度参评率 。当api托管了会话分配,满意度原生功能失效。若数据项不返回,代表没有发送满意度评价,此项无法计算
*/
@SerializedName("satisfaction_participation_rate")
private Float satisfactionParticipationRate;

/**
* “满意”评价占比 。在客户参评的满意度评价中,评价是“满意”的占比。当api托管了会话分配,满意度原生功能失效。若数据项不返回,代表没有客户参评的满意度评价,此项无法计算
*/
@SerializedName("satisfied_rate")
private Float satisfiedRate;

/**
* “一般”评价占比 。在客户参评的满意度评价中,评价是“一般”的占比。当api托管了会话分配,满意度原生功能失效。若数据项不返回,代表没有客户参评的满意度评价,此项无法计算
*/
@SerializedName("middling_rate")
private Float middlingRate;

/**
* “不满意”评价占比。在客户参评的满意度评价中,评价是“不满意”的占比。当api托管了会话分配,满意度原生功能失效。若数据项不返回,代表没有客户参评的满意度评价,此项无法计算
*/
@SerializedName("dissatisfied_rate")
private Float dissatisfiedRate;

/**
* 升级服务客户数。通过「升级服务」功能成功添加专员或加入客户群的客户数,若同一个客户添加多个专员或客户群,只计算一个客户。在2022年3月10日以后才会有对应统计数据
*/
@SerializedName("upgrade_service_customer_cnt")
private Integer upgradeServiceCustomerCnt;

/**
* 专员服务邀请数。接待人员通过「升级服务-专员服务」向客户发送服务专员名片的次数。在2022年3月10日以后才会有对应统计数据
*/
@SerializedName("upgrade_service_member_invite_cnt")
private Integer upgradeServiceMemberInviteCnt;

/**
* 添加专员的客户数 。客户成功添加专员为好友的数量,若同一个客户添加多个专员,则计算多个客户数。在2022年3月10日以后才会有对应统计数据
*/
@SerializedName("upgrade_service_member_customer_cnt")
private Integer upgradeServiceMemberCustomerCnt;

/**
* 客户群服务邀请数。接待人员通过「升级服务-客户群服务」向客户发送客户群二维码的次数。在2022年3月10日以后才会有对应统计数据
*/
@SerializedName("upgrade_service_groupchat_invite_cnt")
private Integer upgradeServiceGroupchatInviteCnt;

/**
* 加入客户群的客户数。客户成功加入客户群的数量,若同一个客户加多个客户群,则计算多个客户数。在2022年3月10日以后才会有对应统计数据
*/
@SerializedName("upgrade_service_groupchat_customer_cnt")
private Integer upgradeServiceGroupchatCustomerCnt;

/**
* 被拒收消息的客户数。被接待人员设置了“不再接收消息”的客户数
*/
@SerializedName("msg_rejected_customer_cnt")
private Integer msgRejectedCustomerCnt;
}
/**
* From json wx cp kf get servicer statistic resp.
*
* @param json the json
* @return the wx cp kf get servicer statistic resp
*/
public static WxCpKfGetServicerStatisticResp fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpKfGetServicerStatisticResp.class);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1364,6 +1364,12 @@ interface Kf {
* The constant GET_CORP_STATISTIC.
*/
String GET_CORP_STATISTIC = "/cgi-bin/kf/get_corp_statistic";

/**
* The constant GET_SERVICER_STATISTIC.
*/
String GET_SERVICER_STATISTIC = "/cgi-bin/kf/get_servicer_statistic";

/**
* The constant CUSTOMER_GET_UPGRADE_SERVICE_CONFIG.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,15 @@ public WxCpKfGetCorpStatisticResp.StatisticList deserialize(JsonElement jsonElem
JsonElement statistic = asJsonObject.get("statistic");
if (GsonHelper.isNotNull(statistic)) {
WxCpKfGetCorpStatisticResp.Statistic statisticObj = new WxCpKfGetCorpStatisticResp.Statistic();
statisticObj.setSessionCnt(statistic.getAsJsonObject().get("session_cnt").getAsInt());
statisticObj.setCustomerCnt(statistic.getAsJsonObject().get("customer_cnt").getAsInt());
statisticObj.setCustomerMsgCnt(statistic.getAsJsonObject().get("customer_msg_cnt").getAsInt());
statisticObj.setUpgradeServiceCustomerCnt(statistic.getAsJsonObject().get("upgrade_service_customer_cnt").getAsInt());
statisticObj.setAiTransferRate(statistic.getAsJsonObject().get("ai_transfer_rate").getAsInt());
statisticObj.setAiKnowledgeHitRate(statistic.getAsJsonObject().get("ai_knowledge_hit_rate").getAsInt());
statisticObj.setSessionCnt(GsonHelper.isNull(statistic.getAsJsonObject().get("session_cnt")) ? null : statistic.getAsJsonObject().get("session_cnt").getAsInt());
statisticObj.setCustomerCnt(GsonHelper.isNull(statistic.getAsJsonObject().get("customer_cnt")) ? null : statistic.getAsJsonObject().get("customer_cnt").getAsInt());
statisticObj.setCustomerMsgCnt(GsonHelper.isNull(statistic.getAsJsonObject().get("customer_msg_cnt")) ? null : statistic.getAsJsonObject().get("customer_msg_cnt").getAsInt());
statisticObj.setUpgradeServiceCustomerCnt(GsonHelper.isNull(statistic.getAsJsonObject().get("upgrade_service_customer_cnt")) ? null : statistic.getAsJsonObject().get("upgrade_service_customer_cnt").getAsInt());
statisticObj.setAiSessionReplyCnt(GsonHelper.isNull(statistic.getAsJsonObject().get("ai_session_reply_cnt")) ? null : statistic.getAsJsonObject().get("ai_session_reply_cnt").getAsInt());
statisticObj.setAiTransferRate(GsonHelper.isNull(statistic.getAsJsonObject().get("ai_transfer_rate")) ? null : statistic.getAsJsonObject().get("ai_transfer_rate").getAsFloat());
statisticObj.setAiKnowledgeHitRate(GsonHelper.isNull(statistic.getAsJsonObject().get("ai_knowledge_hit_rate")) ? null : statistic.getAsJsonObject().get("ai_knowledge_hit_rate").getAsFloat());
statisticObj.setMsgRejectedCustomerCnt(GsonHelper.isNull(statistic.getAsJsonObject().get("msg_rejected_customer_cnt")) ? null : statistic.getAsJsonObject().get("msg_rejected_customer_cnt").getAsInt());
statisticList.setStatistic(statisticObj);
}
return statisticList;
}
Expand Down

0 comments on commit fe91a81

Please sign in to comment.