Skip to content

Commit

Permalink
Merge branch 'develop' of github.com:Wechat-Group/WxJava into develop
Browse files Browse the repository at this point in the history
* 'develop' of github.com:Wechat-Group/WxJava:
  ⬆️ Bump jetty-server from 9.4.38.v20210224 to 9.4.41.v20210516 (Wechat-Group#2164)
  🆕 Wechat-Group#2163 【开放平台】增加查询小程序可回退版本的接口
  🐛 Wechat-Group#2148 【企业微信】修复互联企业消息推送接口返回字段问题
  🆕 Wechat-Group#2161 【公众号】微信推送消息类增加群发接口事件相关字段
  🆕 Wechat-Group#2150 【企业微信】补充完善部分客户联系接口,以及服务商模式外部联系人openid转换接口
  🎨 Wechat-Group#2155 【企业微信】发送新客户欢迎语接口增加对视频类型的支持,同时修复结构不正确的问题
  • Loading branch information
ParkerJX committed Jun 25, 2021
2 parents 4f5bc71 + b6d4b5e commit d6501e8
Show file tree
Hide file tree
Showing 27 changed files with 1,111 additions and 210 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<httpclient.version>4.5.13</httpclient.version>
<jetty.version>9.4.38.v20210224</jetty.version>
<jetty.version>9.4.41.v20210516</jetty.version>
</properties>

<dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ public static class MassMsgStatus {
public static final String ERR_20013 = "err(20013)";
public static final String ERR_22000 = "err(22000)";
public static final String ERR_21000 = "err(21000)";
public static final String ERR_30001 = "err(30001)";
public static final String ERR_30002 = "err(30002)";
public static final String ERR_30003 = "err(30003)";
public static final String ERR_40001 = "err(40001)";
public static final String ERR_40002 = "err(40002)";


/**
* 群发反馈消息代码所对应的文字描述.
Expand All @@ -174,6 +180,11 @@ public static class MassMsgStatus {
STATUS_DESC.put(ERR_20013, "涉嫌版权");
STATUS_DESC.put(ERR_22000, "涉嫌互推_互相宣传");
STATUS_DESC.put(ERR_21000, "涉嫌其他");
STATUS_DESC.put(ERR_30001, "原创校验出现系统错误且用户选择了被判为转载就不群发");
STATUS_DESC.put(ERR_30002, "原创校验被判定为不能群发");
STATUS_DESC.put(ERR_30003, "原创校验被判定为转载文且用户选择了被判为转载就不群发");
STATUS_DESC.put(ERR_40001, "管理员拒绝");
STATUS_DESC.put(ERR_40002, "管理员30分钟内无响应,超时");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import me.chanjar.weixin.cp.bean.external.*;
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactBatchInfo;
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo;
import org.jetbrains.annotations.NotNull;

import java.util.Date;
import java.util.List;
Expand Down Expand Up @@ -134,6 +135,14 @@ public interface WxCpExternalContactService {
*/
WxCpExternalContactInfo getContactDetail(String userId) throws WxErrorException;

/**
* 企业和服务商可通过此接口,将微信外部联系人的userid转为微信openid,用于调用支付相关接口。暂不支持企业微信外部联系人(ExternalUserid为wo开头)的userid转openid。
* @param externalUserid 微信外部联系人的userid
* @return 该企业的外部联系人openid
* @throws WxErrorException .
*/
String convertToOpenid(String externalUserid) throws WxErrorException;

/**
* 批量获取客户详情.
* <pre>
Expand Down Expand Up @@ -225,9 +234,85 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String userId, String cursor,
* @param takeOverUserid the take over userid
* @return wx cp base resp
* @throws WxErrorException the wx error exception
* @deprecated 此后续将不再更新维护,建议使用 {@link #transferCustomer(WxCpUserTransferCustomerReq)}
*/
@Deprecated
WxCpBaseResp transferExternalContact(String externalUserid, String handOverUserid, String takeOverUserid) throws WxErrorException;

/**
* 企业可通过此接口,转接在职成员的客户给其他成员。
* <per>
* external_userid必须是handover_userid的客户(即配置了客户联系功能的成员所添加的联系人)。
* 在职成员的每位客户最多被分配2次。客户被转接成功后,将有90个自然日的服务关系保护期,保护期内的客户无法再次被分配。
*
* 权限说明:
* * 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。
* 第三方应用需拥有“企业客户权限->客户联系->在职继承”权限
* 接替成员必须在此第三方应用或自建应用的可见范围内。
* 接替成员需要配置了客户联系功能。
* 接替成员需要在企业微信激活且已经过实名认证。
* </per>
* @param req 转接在职成员的客户给其他成员请求实体
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
WxCpUserTransferCustomerResp transferCustomer(WxCpUserTransferCustomerReq req) throws WxErrorException;

/**
* 企业和第三方可通过此接口查询在职成员的客户转接情况。
* <per>
* 权限说明:
*
* 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。
* 第三方应用需拥有“企业客户权限->客户联系->在职继承”权限
* 接替成员必须在此第三方应用或自建应用的可见范围内。
* </per>
* @param handOverUserid 原添加成员的userid
* @param takeOverUserid 接替成员的userid
* @param cursor 分页查询的cursor,每个分页返回的数据不会超过1000条;不填或为空表示获取第一个分页;
* @return 客户转接接口实体
* @throws WxErrorException the wx error exception
*/
WxCpUserTransferResultResp transferResult(@NotNull String handOverUserid, @NotNull String takeOverUserid, String cursor) throws WxErrorException;

/**
* 企业可通过此接口,分配离职成员的客户给其他成员。
* <per>
* handover_userid必须是已离职用户。
* external_userid必须是handover_userid的客户(即配置了客户联系功能的成员所添加的联系人)。
* 在职成员的每位客户最多被分配2次。客户被转接成功后,将有90个自然日的服务关系保护期,保护期内的客户无法再次被分配。
*
* 权限说明:
*
* 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。
* 第三方应用需拥有“企业客户权限->客户联系->离职分配”权限
* 接替成员必须在此第三方应用或自建应用的可见范围内。
* 接替成员需要配置了客户联系功能。
* 接替成员需要在企业微信激活且已经过实名认证。
* </per>
* @param req 转接在职成员的客户给其他成员请求实体
* @return wx cp base resp
* @throws WxErrorException the wx error exception
*/
WxCpUserTransferCustomerResp resignedTransferCustomer(WxCpUserTransferCustomerReq req) throws WxErrorException;

/**
* 企业和第三方可通过此接口查询离职成员的客户分配情况。
* <per>
* 权限说明:
*
* 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。
* 第三方应用需拥有“企业客户权限->客户联系->在职继承”权限
* 接替成员必须在此第三方应用或自建应用的可见范围内。
* </per>
* @param handOverUserid 原添加成员的userid
* @param takeOverUserid 接替成员的userid
* @param cursor 分页查询的cursor,每个分页返回的数据不会超过1000条;不填或为空表示获取第一个分页;
* @return 客户转接接口实体
* @throws WxErrorException the wx error exception
*/
WxCpUserTransferResultResp resignedTransferResult(@NotNull String handOverUserid, @NotNull String takeOverUserid, String cursor) throws WxErrorException;

/**
* <pre>
* 该接口用于获取配置过客户群管理的客户群列表。
Expand Down Expand Up @@ -260,6 +345,32 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String userId, String cursor,
*/
WxCpUserExternalGroupChatInfo getGroupChat(String chatId) throws WxErrorException;

/**
*
* 企业可通过此接口,将已离职成员为群主的群,分配给另一个客服成员。
*
* <per>
* 注意::
*
* 群主离职了的客户群,才可继承
* 继承给的新群主,必须是配置了客户联系功能的成员
* 继承给的新群主,必须有设置实名
* 继承给的新群主,必须有激活企业微信
* 同一个人的群,限制每天最多分配300个给新群主
*
* 权限说明:
*
* 企业需要使用“客户联系”secret或配置到“可调用应用”列表中的自建应用secret所获取的accesstoken来调用(accesstoken如何获取?)。
* 第三方应用需拥有“企业客户权限->客户联系->分配离职成员的客户群”权限
* 对于第三方/自建应用,群主必须在应用的可见范围。
* </per>
* @param chatIds 需要转群主的客户群ID列表。取值范围: 1 ~ 100
* @param newOwner 新群主ID
* @return 分配结果,主要是分配失败的群列表
* @throws WxErrorException the wx error exception
*/
WxCpUserExternalGroupChatTransferResp transferGroupChat(String[] chatIds, String newOwner) throws WxErrorException;

/**
* <pre>
* 企业可通过此接口获取成员联系客户的数据,包括发起申请数、新增客户数、聊天数、发送消息数和删除/拉黑成员的客户数等指标。
Expand Down Expand Up @@ -397,4 +508,6 @@ WxCpExternalContactBatchInfo getContactDetailBatch(String userId, String cursor,
* @throws WxErrorException the wx error exception
*/
WxCpBaseResp markTag(String userid, String externalUserid, String[] addTag, String[] removeTag) throws WxErrorException;


}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package me.chanjar.weixin.cp.api;

import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendStatistics;
import me.chanjar.weixin.cp.bean.message.*;

/**
* 消息推送接口.
Expand Down Expand Up @@ -52,5 +49,5 @@ public interface WxCpMessageService {
* @return the wx cp message send result
* @throws WxErrorException the wx error exception
*/
WxCpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException;
WxCpLinkedCorpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
import me.chanjar.weixin.common.error.WxCpErrorMsgEnum;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.common.error.WxRuntimeException;
import me.chanjar.weixin.common.util.BeanUtils;
import me.chanjar.weixin.common.util.json.GsonParser;
import me.chanjar.weixin.cp.api.WxCpExternalContactService;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
Expand All @@ -15,6 +17,7 @@
import me.chanjar.weixin.cp.bean.external.contact.WxCpExternalContactInfo;
import org.apache.commons.lang3.ArrayUtils;
import org.apache.commons.lang3.StringUtils;
import org.jetbrains.annotations.NotNull;

import java.util.Collections;
import java.util.Date;
Expand Down Expand Up @@ -106,6 +109,16 @@ public WxCpExternalContactInfo getContactDetail(String userId) throws WxErrorExc
return WxCpExternalContactInfo.fromJson(responseContent);
}

@Override
public String convertToOpenid(@NotNull String externalUserId) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("external_userid", externalUserId);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(CONVERT_TO_OPENID);
String responseContent = this.mainService.post(url, json.toString());
JsonObject tmpJson = GsonParser.parse(responseContent);
return tmpJson.get("openid").getAsString();
}

@Override
public WxCpExternalContactBatchInfo getContactDetailBatch(String userId,
String cursor,
Expand Down Expand Up @@ -176,6 +189,44 @@ public WxCpBaseResp transferExternalContact(String externalUserid, String handOv
return WxCpBaseResp.fromJson(result);
}

@Override
public WxCpUserTransferCustomerResp transferCustomer(WxCpUserTransferCustomerReq req) throws WxErrorException {
BeanUtils.checkRequiredFields(req);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(TRANSFER_CUSTOMER);
final String result = this.mainService.post(url, req.toJson());
return WxCpUserTransferCustomerResp.fromJson(result);
}

@Override
public WxCpUserTransferResultResp transferResult(@NotNull String handOverUserid, @NotNull String takeOverUserid, String cursor) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("cursor", cursor);
json.addProperty("handover_userid", handOverUserid);
json.addProperty("takeover_userid", takeOverUserid);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(TRANSFER_RESULT);
final String result = this.mainService.post(url, json.toString());
return WxCpUserTransferResultResp.fromJson(result);
}

@Override
public WxCpUserTransferCustomerResp resignedTransferCustomer(WxCpUserTransferCustomerReq req) throws WxErrorException {
BeanUtils.checkRequiredFields(req);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(RESIGNED_TRANSFER_CUSTOMER);
final String result = this.mainService.post(url, req.toJson());
return WxCpUserTransferCustomerResp.fromJson(result);
}

@Override
public WxCpUserTransferResultResp resignedTransferResult(@NotNull String handOverUserid, @NotNull String takeOverUserid, String cursor) throws WxErrorException {
JsonObject json = new JsonObject();
json.addProperty("cursor", cursor);
json.addProperty("handover_userid", handOverUserid);
json.addProperty("takeover_userid", takeOverUserid);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(RESIGNED_TRANSFER_RESULT);
final String result = this.mainService.post(url, json.toString());
return WxCpUserTransferResultResp.fromJson(result);
}

@Override
public WxCpUserExternalGroupChatList listGroupChat(Integer pageIndex, Integer pageSize, int status, String[] userIds, String[] partyIds) throws WxErrorException {
JsonObject json = new JsonObject();
Expand Down Expand Up @@ -206,6 +257,18 @@ public WxCpUserExternalGroupChatInfo getGroupChat(String chatId) throws WxErrorE
return WxCpUserExternalGroupChatInfo.fromJson(result);
}

@Override
public WxCpUserExternalGroupChatTransferResp transferGroupChat(String[] chatIds, String newOwner) throws WxErrorException {
JsonObject json = new JsonObject();
if (ArrayUtils.isNotEmpty(chatIds)) {
json.add("chat_id_list", new Gson().toJsonTree(chatIds).getAsJsonArray());
}
json.addProperty("new_owner", newOwner);
final String url = this.mainService.getWxCpConfigStorage().getApiUrl(GROUP_CHAT_TRANSFER);
final String result = this.mainService.post(url, json.toString());
return WxCpUserExternalGroupChatTransferResp.fromJson(result);
}

@Override
public WxCpUserExternalUserBehaviorStatistic getUserBehaviorStatistic(Date startTime, Date endTime, String[] userIds, String[] partyIds) throws WxErrorException {
JsonObject json = new JsonObject();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,7 @@
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpMessageService;
import me.chanjar.weixin.cp.api.WxCpService;
import me.chanjar.weixin.cp.bean.message.WxCpLinkedCorpMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessage;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendResult;
import me.chanjar.weixin.cp.bean.message.WxCpMessageSendStatistics;
import me.chanjar.weixin.cp.bean.message.*;
import me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Message;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

Expand Down Expand Up @@ -40,13 +37,13 @@ public WxCpMessageSendStatistics getStatistics(int timeType) throws WxErrorExcep
}

@Override
public WxCpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException {
public WxCpLinkedCorpMessageSendResult sendLinkedCorpMessage(WxCpLinkedCorpMessage message) throws WxErrorException {
Integer agentId = message.getAgentId();
if (null == agentId) {
message.setAgentId(this.cpService.getWxCpConfigStorage().getAgentId());
}

return WxCpMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage()
return WxCpLinkedCorpMessageSendResult.fromJson(this.cpService.post(this.cpService.getWxCpConfigStorage()
.getApiUrl(Message.LINKEDCORP_MESSAGE_SEND), message.toJson()));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
package me.chanjar.weixin.cp.bean.external;

import com.google.gson.annotations.SerializedName;
import lombok.Getter;
import lombok.Setter;
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;

import java.util.List;

/**
* 分配离职成员的客户群结果
* @author pg
* @date 2021年6月21日
*/
@Getter
@Setter
public class WxCpUserExternalGroupChatTransferResp extends WxCpBaseResp {
private static final long serialVersionUID = -943124579487821819L;
/**
* 没有成功继承的群列表
*/
@SerializedName("failed_chat_list")
private List<GroupChatFailedTransfer> failedChatList;

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

public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}

@Getter
@Setter
public static class GroupChatFailedTransfer extends WxCpBaseResp {
private static final long serialVersionUID = -5836775099634587239L;
/**
* 没能成功继承的群ID
*/
private String chatId;

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

public String toJson() {
return WxCpGsonBuilder.create().toJson(this);
}
}
}
Loading

0 comments on commit d6501e8

Please sign in to comment.