8000 Develop by alucardxh · Pull Request #1817 · binarywang/WxJava · GitHub
[go: up one dir, main page]

Skip to content

Develop #1817

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

Merged
merged 2 commits into from
Oct 23, 2020
Merged

Develop #1817

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
8000
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,31 @@ public interface WxCpExternalContactService {
*/
WxCpUserExternalContactInfo getContactDetail(String userId) throws WxErrorException;

/**
* 批量获取客户详情.
* <pre>
*
* 企业/第三方可通过此接口获取指定成员添加的客户信息列表。
*
* 请求方式:POST(HTTPS)
* 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/batch/get_by_user?access_token=ACCESS_TOKEN
*
* 权限说明:
*
* 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?);
8000 * 第三方/自建应用调用时,返回的跟进人follow_user仅包含应用可见范围之内的成员。
* </pre>
*
* @param userId 企业成员的userid,注意不是外部联系人的帐号
* @param cursor the cursor
* @param limit the limit
* @return wx cp user external contact batch info
* @throws WxErrorException .
*/
WxCpUserExternalContactBatchInfo getContactDetailBatch(String userId, String cursor,
Integer limit)
throws WxErrorException;

/**
* 修改客户备注信息.
* <pre>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,27 @@ public WxCpUserExternalContactInfo getContactDetail(String userId) throws WxErro
return WxCpUserExternalContactInfo.fromJson(responseContent);
}

@Override
public WxCpUserExternalContactBatchInfo getContactDetailBatch(String userId,
String cursor,
Integer limit)
throws WxErrorException {
final String url =
this.mainService
.getWxCpConfigStorage()
.getApiUrl(GET_CONTACT_DETAIL_BATCH);
JsonObject json = new JsonObject();
json.addProperty("userid", userId);
if (StringUtils.isNotBlank(cursor)) {
json.addProperty("cursor", cursor);
}
if (limit != null) {
json.addProperty("limit", limit);
}
String responseContent = this.mainService.post(url, json.toString());
return WxCpUserExternalContactBatchInfo.fromJson(responseContent);
}

@Override
public void updateRemark(WxCpUpdateRemarkRequest request) throws WxErrorException {
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(UPDATE_REMARK);
Expand Down Expand Up @@ -162,10 +183,10 @@ public WxCpUserExternalGroupChatList listGroupChat(Integer pageIndex, Integer pa
if (ArrayUtils.isNotEmpty(userIds) || ArrayUtils.isNotEmpty(partyIds)) {
JsonObject ownerFilter = new JsonObject();
if (ArrayUtils.isNotEmpty(userIds)) {
json.add("userid_list", new Gson().toJsonTree(userIds).getAsJsonArray());
ownerFilter.add("userid_list", new Gson().toJsonTree(userIds).getAsJsonArray());
}
if (ArrayUtils.isNotEmpty(partyIds)) {
json.add("partyid_list", new Gson().toJsonTree(partyIds).getAsJsonArray());
ownerFilter.add("partyid_list", new Gson().toJsonTree(partyIds).getAsJsonArray());
}
json.add("owner_filter", ownerFilter);
}
Expand Down Expand Up @@ -212,10 +233,10 @@ public WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime,
if (ArrayUtils.isNotEmpty(userIds) || ArrayUtils.isNotEmpty(partyIds)) {
JsonObject ownerFilter = new JsonObject();
if (ArrayUtils.isNotEmpty(userIds)) {
json.add("userid_list", new Gson().toJsonTree(userIds).getAsJsonArray());
ownerFilter.add("userid_list", new Gson().toJsonTree(userIds).getAsJsonArray());
}
if (ArrayUtils.isNotEmpty(partyIds)) {
json.add("partyid_list", new Gson().toJsonTree(partyIds).getAsJsonArray());
ownerFilter.add("partyid_list", new Gson().toJsonTree(partyIds).getAsJsonArray());
}
json.add("owner_filter", ownerFilter);
}
Expand Down
8000
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
package me.chanjar.weixin.cp.bean.external;

import com.google.gson.annotations.SerializedName;
import java.io.Serializable;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

/**
* <pre>
* 批量获取客户详情
* Created by Binary Wang on 2020/10/22.
* 参考文档:https://work.weixin.qq.com/api/doc/90000/90135/92994
* </pre>
*
* @author <a href="https://github.com/alucardxh">alucardxh</a>
*/
@Getter
@Setter
public class WxCpUserExternalContactBatchInfo extends WxCpBaseResp implements Serializable {
private static final long serialVersionUID = -5166048319463473186L;

@SerializedName("external_contact_list")
private List<ExternalContactInfo> externalContactList;

@SerializedName("next_cursor")
private String nextCursor;

@Getter
@Setter
public static class ExternalContactInfo {
@SerializedName("external_contact")
private ExternalContact externalContact;

@SerializedName("follow_info")
private FollowedUser followInfo;
}

@Getter
@Setter
public static class ExternalContact {
@SerializedName("external_userid")
private String externalUserId;

@SerializedName("position")
private String position;

@SerializedName("name")
private String name;

@SerializedName("avatar")
private String avatar;

@SerializedName("corp_name")
private String corpName;

@SerializedName("corp_full_name")
private String corpFullName;

@SerializedName("type")
private Integer type;

@SerializedName("gender")
private Integer gender;

@SerializedName("unionid")
private String unionId;

@SerializedName("external_profile")
private ExternalProfile externalProfile;
}

@Setter
@Getter
public static class ExternalProfile {
@SerializedName("external_attr")
private List<ExternalAttribute> externalAttrs;
}

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public static class ExternalAttribute {
@Setter
@Getter
public static class Text {
private String value;
}

@Setter
@Getter
public static class Web {
private String title;
private String url;
}

@Setter
@Getter
public static class MiniProgram {
@SerializedName("pagepath")
private String pagePath;
private String appid;
private String title;
}

private int type;

private String name;

private Text text;

private Web web;

@SerializedName("miniprogram")
private MiniProgram miniProgram;
}

@Setter
@Getter
public static class FollowedUser {
@SerializedName("userid")
private String userId;
private String remark;
private String description;
@SerializedName("createtime")
private Long createTime;
private String state;
@SerializedName("remark_company")
private String remarkCompany;
@SerializedName("remark_mobiles")
private String[] remarkMobiles;
private Tag[] tags;
@SerializedName("remark_corp_name")
private String remarkCorpName;
@SerializedName("add_way")
private String addWay;
@SerializedName("oper_userid")
private String operUserId;

}

public static WxCpUserExternalContactBatchInfo fromJson(String json) {
return WxCpGsonBuilder.create().fromJson(json, WxCpUserExternalContactBatchInfo.class);
}

@Setter
@Getter
public static class Tag {
@SerializedName("group_name")
private String groupName;
@SerializedName("tag_name")
private String tagName;
private int type;
}

}
38F0
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ public static class ExternalContact {
public static final String CLOSE_TEMP_CHAT = "/cgi-bin/externalcontact/close_temp_chat";
public static final String GET_FOLLOW_USER_LIST = "/cgi-bin/externalcontact/get_follow_user_list";
public static final String GET_CONTACT_DETAIL = "/cgi-bin/externalcontact/get?external_userid=";
public static final String GET_CONTACT_DETAIL_BATCH = "/cgi-bin/externalcontact/batch/get_by_user?";
public static final String UPDATE_REMARK = "/cgi-bin/externalcontact/remark";
public static final String LIST_EXTERNAL_CONTACT = "/cgi-bin/externalcontact/list?userid=";
public static final String LIST_UNASSIGNED_CONTACT = "/cgi-bin/externalcontact/get_unassigned_list";
Expand Down
0