mirror of
				https://gitee.com/binary/weixin-java-tools.git
				synced 2025-10-31 10:38:42 +08:00 
			
		
		
		
	🆕 #1710 企业微信增加发送新客户欢迎语接口
This commit is contained in:
		| @ -2,7 +2,8 @@ package me.chanjar.weixin.cp.api; | ||||
|  | ||||
| import lombok.NonNull; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import me.chanjar.weixin.cp.bean.*; | ||||
| import me.chanjar.weixin.cp.bean.WxCpBaseResp; | ||||
| import me.chanjar.weixin.cp.bean.external.*; | ||||
|  | ||||
| import java.util.Date; | ||||
| import java.util.List; | ||||
| @ -32,8 +33,8 @@ public interface WxCpExternalContactService { | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param info 客户联系「联系我」方式 | ||||
|    * @return | ||||
|    * @throws WxErrorException | ||||
|    * @return wx cp contact way result | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpContactWayResult addContactWay(@NonNull WxCpContactWayInfo info) throws WxErrorException; | ||||
|  | ||||
| @ -45,8 +46,8 @@ public interface WxCpExternalContactService { | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param configId 联系方式的配置id,必填 | ||||
|    * @return | ||||
|    * @throws WxErrorException | ||||
|    * @return contact way | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpContactWayInfo getContactWay(@NonNull String configId) throws WxErrorException; | ||||
|  | ||||
| @ -58,8 +59,8 @@ public interface WxCpExternalContactService { | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param info 客户联系「联系我」方式 | ||||
|    * @return | ||||
|    * @throws WxErrorException | ||||
|    * @return wx cp base resp | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpBaseResp updateContactWay(@NonNull WxCpContactWayInfo info) throws WxErrorException; | ||||
|  | ||||
| @ -71,8 +72,8 @@ public interface WxCpExternalContactService { | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param configId 企业联系方式的配置id,必填 | ||||
|    * @return | ||||
|    * @throws WxErrorException | ||||
|    * @return wx cp base resp | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpBaseResp deleteContactWay(@NonNull String configId) throws WxErrorException; | ||||
|  | ||||
| @ -85,10 +86,10 @@ public interface WxCpExternalContactService { | ||||
|    * 注意:请保证传入的企业成员和客户之间有仍然有效的临时会话, 通过<b>其他方式的添加外部联系人无法通过此接口关闭会话</b>。 | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param userId | ||||
|    * @param externalUserId | ||||
|    * @return | ||||
|    * @throws WxErrorException | ||||
|    * @param userId         the user id | ||||
|    * @param externalUserId the external user id | ||||
|    * @return wx cp base resp | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpBaseResp closeTempChat(@NonNull String userId, @NonNull String externalUserId) throws WxErrorException; | ||||
|  | ||||
| @ -103,7 +104,8 @@ public interface WxCpExternalContactService { | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param userId 外部联系人的userid | ||||
|    * @return . | ||||
|    * @return . external contact | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    * @deprecated 建议使用 {@link #getContactDetail(String)} | ||||
|    */ | ||||
|   @Deprecated | ||||
| @ -125,7 +127,7 @@ public interface WxCpExternalContactService { | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param userId 外部联系人的userid,注意不是企业成员的帐号 | ||||
|    * @return . | ||||
|    * @return . contact detail | ||||
|    * @throws WxErrorException . | ||||
|    */ | ||||
|   WxCpUserExternalContactInfo getContactDetail(String userId) throws WxErrorException; | ||||
| @ -167,21 +169,21 @@ public interface WxCpExternalContactService { | ||||
|   /** | ||||
|    * 企业和第三方可通过此接口,获取所有离职成员的客户列表,并可进一步调用离职成员的外部联系人再分配接口将这些客户重新分配给其他企业成员。 | ||||
|    * | ||||
|    * @param page | ||||
|    * @param pageSize | ||||
|    * @return | ||||
|    * @throws WxErrorException | ||||
|    * @param page     the page | ||||
|    * @param pageSize the page size | ||||
|    * @return wx cp user external unassign list | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpUserExternalUnassignList listUnassignedList(Integer page, Integer pageSize) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * 企业可通过此接口,将已离职成员的外部联系人分配给另一个成员接替联系。 | ||||
|    * | ||||
|    * @param externalUserid | ||||
|    * @param handOverUserid | ||||
|    * @param takeOverUserid | ||||
|    * @return | ||||
|    * @throws WxErrorException | ||||
|    * @param externalUserid the external userid | ||||
|    * @param handOverUserid the hand over userid | ||||
|    * @param takeOverUserid the take over userid | ||||
|    * @return wx cp base resp | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpBaseResp transferExternalContact(String externalUserid, String handOverUserid, String takeOverUserid) throws WxErrorException; | ||||
|  | ||||
| @ -192,6 +194,14 @@ public interface WxCpExternalContactService { | ||||
|    * 暂不支持第三方调用。 | ||||
|    * 微信文档:https://work.weixin.qq.com/api/doc/90000/90135/92119 | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param pageIndex the page index | ||||
|    * @param pageSize  the page size | ||||
|    * @param status    the status | ||||
|    * @param userIds   the user ids | ||||
|    * @param partyIds  the party ids | ||||
|    * @return the wx cp user external group chat list | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpUserExternalGroupChatList listGroupChat(Integer pageIndex, Integer pageSize, int status, String[] userIds, String[] partyIds) throws WxErrorException; | ||||
|  | ||||
| @ -203,9 +213,9 @@ public interface WxCpExternalContactService { | ||||
|    * 微信文档:https://work.weixin.qq.com/api/doc/90000/90135/92122 | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param chatId | ||||
|    * @return | ||||
|    * @throws WxErrorException | ||||
|    * @param chatId the chat id | ||||
|    * @return group chat | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpUserExternalGroupChatInfo getGroupChat(String chatId) throws WxErrorException; | ||||
|  | ||||
| @ -217,12 +227,12 @@ public interface WxCpExternalContactService { | ||||
|    * 第三方/自建应用调用时传入的userid和partyid要在应用的可见范围内; | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param startTime | ||||
|    * @param endTime | ||||
|    * @param userIds | ||||
|    * @param partyIds | ||||
|    * @return | ||||
|    * @throws WxErrorException | ||||
|    * @param startTime the start time | ||||
|    * @param endTime   the end time | ||||
|    * @param userIds   the user ids | ||||
|    * @param partyIds  the party ids | ||||
|    * @return user behavior statistic | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpUserExternalUserBehaviorStatistic getUserBehaviorStatistic(Date startTime, Date endTime, String[] userIds, String[] partyIds) throws WxErrorException; | ||||
|  | ||||
| @ -233,74 +243,117 @@ public interface WxCpExternalContactService { | ||||
|    * 暂不支持第三方调用。 | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param startTime | ||||
|    * @param orderBy | ||||
|    * @param orderAsc | ||||
|    * @param pageIndex | ||||
|    * @param pageSize | ||||
|    * @param userIds | ||||
|    * @param partyIds | ||||
|    * @return | ||||
|    * @throws WxErrorException | ||||
|    * @param startTime the start time | ||||
|    * @param orderBy   the order by | ||||
|    * @param orderAsc  the order asc | ||||
|    * @param pageIndex the page index | ||||
|    * @param pageSize  the page size | ||||
|    * @param userIds   the user ids | ||||
|    * @param partyIds  the party ids | ||||
|    * @return group chat statistic | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpUserExternalGroupChatStatistic getGroupChatStatistic(Date startTime, Integer orderBy, Integer orderAsc, Integer pageIndex, Integer pageSize, String[] userIds, String[] partyIds) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * 添加企业群发消息任务 | ||||
|    * 企业可通过此接口添加企业群发消息的任务并通知客服人员发送给相关客户或客户群。(注:企业微信终端需升级到2.7.5版本及以上) | ||||
|    * 注意:调用该接口并不会直接发送消息给客户/客户群,需要相关的客服人员操作以后才会实际发送(客服人员的企业微信需要升级到2.7.5及以上版本) | ||||
|    * 同一个企业每个自然月内仅可针对一个客户/客户群发送4条消息,超过限制的用户将会被忽略。 | ||||
|    * <p> | ||||
|    * 请求方式: POST(HTTP) | ||||
|    * <p> | ||||
|    * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/add_msg_template?access_token=ACCESS_TOKEN | ||||
|    * <p> | ||||
|    * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/92135 | ||||
|    * | ||||
|    * @param wxCpMsgTemplate the wx cp msg template | ||||
|    * @return the wx cp msg template add result | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpMsgTemplateAddResult addMsgTemplate(WxCpMsgTemplate wxCpMsgTemplate) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * 发送新客户欢迎语 | ||||
|    * <pre> | ||||
|    * 企业微信在向企业推送添加外部联系人事件时,会额外返回一个welcome_code,企业以此为凭据调用接口,即可通过成员向新添加的客户发送个性化的欢迎语。 | ||||
|    * 为了保证用户体验以及避免滥用,企业仅可在收到相关事件后20秒内调用,且只可调用一次。 | ||||
|    * 如果企业已经在管理端为相关成员配置了可用的欢迎语,则推送添加外部联系人事件时不会返回welcome_code。 | ||||
|    * 每次添加新客户时可能有多个企业自建应用/第三方应用收到带有welcome_code的回调事件,但仅有最先调用的可以发送成功。后续调用将返回41051(externaluser has started chatting)错误,请用户根据实际使用需求,合理设置应用可见范围,避免冲突。 | ||||
|    * 请求方式: POST(HTTP) | ||||
|    * | ||||
|    * 请求地址:https://qyapi.weixin.qq.com/cgi-bin/externalcontact/send_welcome_msg?access_token=ACCESS_TOKEN | ||||
|    * | ||||
|    * 文档地址:https://work.weixin.qq.com/api/doc/90000/90135/92137 | ||||
|    * </pre> | ||||
|    * | ||||
|    * @param msg . | ||||
|    * @throws WxErrorException . | ||||
|    */ | ||||
|   void sendWelcomeMsg(WxCpWelcomeMsg msg) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 企业可通过此接口获取企业客户标签详情。 | ||||
|    * </pre> | ||||
|    * @param tagId | ||||
|    * @return | ||||
|    * | ||||
|    * @param tagId the tag id | ||||
|    * @return corp tag list | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpUserExternalTagGroupList getCorpTagList(String [] tagId) throws WxErrorException; | ||||
|  | ||||
|   WxCpUserExternalTagGroupList getCorpTagList(String[] tagId) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 企业可通过此接口向客户标签库中添加新的标签组和标签,每个企业最多可配置3000个企业标签。 | ||||
|    * 暂不支持第三方调用。 | ||||
|    * </pre> | ||||
|    * @param tagGroup | ||||
|    * @return | ||||
|    * | ||||
|    * @param tagGroup the tag group | ||||
|    * @return wx cp user external tag group info | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpUserExternalTagGroupInfo addCorpTag(WxCpUserExternalTagGroupInfo tagGroup)throws WxErrorException; | ||||
|   WxCpUserExternalTagGroupInfo addCorpTag(WxCpUserExternalTagGroupInfo tagGroup) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 企业可通过此接口编辑客户标签/标签组的名称或次序值。 | ||||
|    * 暂不支持第三方调用。 | ||||
|    * </pre> | ||||
|    * @param id | ||||
|    * @param name | ||||
|    * @param order | ||||
|    * @return | ||||
|    * | ||||
|    * @param id    the id | ||||
|    * @param name  the name | ||||
|    * @param order the order | ||||
|    * @return wx cp base resp | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpBaseResp  editCorpTag(String id,String name,Integer order)throws WxErrorException; | ||||
|   WxCpBaseResp editCorpTag(String id, String name, Integer order) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 企业可通过此接口删除客户标签库中的标签,或删除整个标签组。 | ||||
|    * 暂不支持第三方调用。 | ||||
|    * </pre> | ||||
|    * @param tagId | ||||
|    * @param groupId | ||||
|    * @return | ||||
|    * | ||||
|    * @param tagId   the tag id | ||||
|    * @param groupId the group id | ||||
|    * @return wx cp base resp | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpBaseResp  delCorpTag(String [] tagId,String[] groupId)throws WxErrorException; | ||||
|   WxCpBaseResp delCorpTag(String[] tagId, String[] groupId) throws WxErrorException; | ||||
|  | ||||
|   /** | ||||
|    * <pre> | ||||
|    * 企业可通过此接口为指定成员的客户添加上由企业统一配置的标签。 | ||||
|    * https://work.weixin.qq.com/api/doc/90000/90135/92117 | ||||
|    * </pre> | ||||
|    * @param userid | ||||
|    * @param externalUserid | ||||
|    * @param addTag | ||||
|    * @param removeTag | ||||
|    * @return | ||||
|    * | ||||
|    * @param userid         the userid | ||||
|    * @param externalUserid the external userid | ||||
|    * @param addTag         the add tag | ||||
|    * @param removeTag      the remove tag | ||||
|    * @return wx cp base resp | ||||
|    * @throws WxErrorException the wx error exception | ||||
|    */ | ||||
|   WxCpBaseResp  markTag(String userid,String externalUserid,String[] addTag,String [] removeTag)throws WxErrorException; | ||||
|   WxCpBaseResp markTag(String userid, String externalUserid, String[] addTag, String[] removeTag) throws WxErrorException; | ||||
| } | ||||
|  | ||||
| @ -3,7 +3,7 @@ package me.chanjar.weixin.cp.api; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import me.chanjar.weixin.cp.bean.WxCpInviteResult; | ||||
| import me.chanjar.weixin.cp.bean.WxCpUser; | ||||
| import me.chanjar.weixin.cp.bean.WxCpUserExternalContactInfo; | ||||
| import me.chanjar.weixin.cp.bean.external.WxCpUserExternalContactInfo; | ||||
|  | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| @ -9,6 +9,7 @@ import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import me.chanjar.weixin.cp.api.WxCpExternalContactService; | ||||
| import me.chanjar.weixin.cp.api.WxCpService; | ||||
| import me.chanjar.weixin.cp.bean.*; | ||||
| import me.chanjar.weixin.cp.bean.external.*; | ||||
| import org.apache.commons.lang3.ArrayUtils; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
|  | ||||
| @ -223,6 +224,12 @@ public class WxCpExternalContactServiceImpl implements WxCpExternalContactServic | ||||
|     return WxCpMsgTemplateAddResult.fromJson(result); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public void sendWelcomeMsg(WxCpWelcomeMsg msg) throws WxErrorException { | ||||
|     final String url = this.mainService.getWxCpConfigStorage().getApiUrl(SEND_WELCOME_MSG); | ||||
|     this.mainService.post(url, msg.toJson()); | ||||
|   } | ||||
|  | ||||
|   @Override | ||||
|   public WxCpUserExternalTagGroupList getCorpTagList(String[] tagId) throws WxErrorException { | ||||
|     JsonObject json = new JsonObject(); | ||||
|  | ||||
| @ -10,7 +10,7 @@ import me.chanjar.weixin.cp.api.WxCpService; | ||||
| import me.chanjar.weixin.cp.api.WxCpUserService; | ||||
| import me.chanjar.weixin.cp.bean.WxCpInviteResult; | ||||
| import me.chanjar.weixin.cp.bean.WxCpUser; | ||||
| import me.chanjar.weixin.cp.bean.WxCpUserExternalContactInfo; | ||||
| import me.chanjar.weixin.cp.bean.external.WxCpUserExternalContactInfo; | ||||
| import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| @ -1,4 +1,4 @@ | ||||
| package me.chanjar.weixin.cp.bean; | ||||
| package me.chanjar.weixin.cp.bean.external; | ||||
| 
 | ||||
| import com.google.gson.annotations.JsonAdapter; | ||||
| import com.google.gson.annotations.SerializedName; | ||||
| @ -1,7 +1,8 @@ | ||||
| package me.chanjar.weixin.cp.bean; | ||||
| package me.chanjar.weixin.cp.bean.external; | ||||
| 
 | ||||
| import com.google.gson.annotations.SerializedName; | ||||
| import lombok.Data; | ||||
| import me.chanjar.weixin.cp.bean.WxCpBaseResp; | ||||
| import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | ||||
| 
 | ||||
| /** | ||||
| @ -1,10 +1,14 @@ | ||||
| package me.chanjar.weixin.cp.bean; | ||||
| package me.chanjar.weixin.cp.bean.external; | ||||
| 
 | ||||
| import com.google.gson.annotations.SerializedName; | ||||
| import lombok.AllArgsConstructor; | ||||
| import lombok.Builder; | ||||
| import lombok.Data; | ||||
| import lombok.NoArgsConstructor; | ||||
| import me.chanjar.weixin.cp.bean.external.msg.Image; | ||||
| import me.chanjar.weixin.cp.bean.external.msg.Link; | ||||
| import me.chanjar.weixin.cp.bean.external.msg.MiniProgram; | ||||
| import me.chanjar.weixin.cp.bean.external.msg.Text; | ||||
| import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | ||||
| 
 | ||||
| import java.io.Serializable; | ||||
| @ -14,6 +18,8 @@ import java.util.List; | ||||
|  * 企业群发消息任务 | ||||
|  * <p> | ||||
|  * Created by songfan on 2020/7/14. | ||||
|  * | ||||
|  * @author songfan | ||||
|  */ | ||||
| @Data | ||||
| @Builder | ||||
| @ -36,7 +42,7 @@ public class WxCpMsgTemplate implements Serializable { | ||||
| 
 | ||||
|   private Link link; | ||||
| 
 | ||||
|   private Miniprogram miniprogram; | ||||
|   private MiniProgram miniprogram; | ||||
| 
 | ||||
|   public static WxCpMsgTemplate fromJson(String json) { | ||||
|     return WxCpGsonBuilder.create().fromJson(json, WxCpMsgTemplate.class); | ||||
| @ -46,36 +52,4 @@ public class WxCpMsgTemplate implements Serializable { | ||||
|     return WxCpGsonBuilder.create().toJson(this); | ||||
|   } | ||||
| 
 | ||||
|   @Data | ||||
|   public class Text { | ||||
|     private String content; | ||||
|   } | ||||
| 
 | ||||
|   @Data | ||||
|   public class Image { | ||||
| 
 | ||||
|     @SerializedName("media_id") | ||||
|     private String mediaId; | ||||
| 
 | ||||
|     @SerializedName("pic_url") | ||||
|     private String picUrl; | ||||
|   } | ||||
| 
 | ||||
|   @Data | ||||
|   public class Link { | ||||
|     private String title; | ||||
|     @SerializedName("picurl") | ||||
|     private String picUrl; | ||||
|     private String desc; | ||||
|     private String url; | ||||
|   } | ||||
| 
 | ||||
|   @Data | ||||
|   public class Miniprogram { | ||||
|     private String title; | ||||
|     @SerializedName("pic_media_id") | ||||
|     private String picMediaId; | ||||
|     private String appid; | ||||
|     private String page; | ||||
|   } | ||||
| } | ||||
| @ -1,4 +1,4 @@ | ||||
| package me.chanjar.weixin.cp.bean; | ||||
| package me.chanjar.weixin.cp.bean.external; | ||||
| 
 | ||||
| import com.google.gson.annotations.SerializedName; | ||||
| import lombok.Data; | ||||
| @ -9,6 +9,8 @@ import java.util.List; | ||||
| 
 | ||||
| /** | ||||
|  * Created by songfan on 2020/7/14. | ||||
|  * | ||||
|  * @author songfan | ||||
|  */ | ||||
| @Data | ||||
| public class WxCpMsgTemplateAddResult implements Serializable { | ||||
| @ -1,4 +1,4 @@ | ||||
| package me.chanjar.weixin.cp.bean; | ||||
| package me.chanjar.weixin.cp.bean.external; | ||||
| 
 | ||||
| import com.google.gson.annotations.SerializedName; | ||||
| import lombok.*; | ||||
| @ -1,4 +1,4 @@ | ||||
| package me.chanjar.weixin.cp.bean; | ||||
| package me.chanjar.weixin.cp.bean.external; | ||||
| 
 | ||||
| import com.google.gson.annotations.Expose; | ||||
| import com.google.gson.annotations.SerializedName; | ||||
| @ -1,8 +1,9 @@ | ||||
| package me.chanjar.weixin.cp.bean; | ||||
| 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; | ||||
| @ -13,7 +14,7 @@ import java.util.List; | ||||
|  */ | ||||
| @Getter | ||||
| @Setter | ||||
| public class WxCpUserExternalGroupChatInfo extends WxCpBaseResp{ | ||||
| public class WxCpUserExternalGroupChatInfo extends WxCpBaseResp { | ||||
| 
 | ||||
|   @SerializedName("group_chat") | ||||
|   private GroupChat groupChat; | ||||
| @ -1,8 +1,9 @@ | ||||
| package me.chanjar.weixin.cp.bean; | ||||
| 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; | ||||
| @ -1,10 +1,12 @@ | ||||
| package me.chanjar.weixin.cp.bean; | ||||
| 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.io.Serializable; | ||||
| import java.util.List; | ||||
| 
 | ||||
| /** | ||||
| @ -15,73 +17,76 @@ import java.util.List; | ||||
|  */ | ||||
| @Getter | ||||
| @Setter | ||||
| public class WxCpUserExternalGroupChatStatistic extends WxCpBaseResp{ | ||||
| public class WxCpUserExternalGroupChatStatistic extends WxCpBaseResp implements Serializable { | ||||
|   private static final long serialVersionUID = -3548998672207956622L; | ||||
| 
 | ||||
|   @SerializedName("total") | ||||
|   int total; | ||||
|   private int total; | ||||
| 
 | ||||
|   @SerializedName("next_offset") | ||||
|   int nextOffset; | ||||
|   private int nextOffset; | ||||
| 
 | ||||
|   @SerializedName("items") | ||||
|   List<StatisticItem> itemList; | ||||
|   private List<StatisticItem> itemList; | ||||
| 
 | ||||
|   @Getter | ||||
|   @Setter | ||||
|   public static class StatisticItem { | ||||
|   public static class StatisticItem implements Serializable { | ||||
|     private static final long serialVersionUID = -7272935708787587856L; | ||||
| 
 | ||||
|     @SerializedName("owner") | ||||
|     String owner; | ||||
|     private String owner; | ||||
| 
 | ||||
|     @SerializedName("data") | ||||
|     ItemData itemData; | ||||
|     private ItemData itemData; | ||||
|   } | ||||
| 
 | ||||
|   @Getter | ||||
|   @Setter | ||||
|   public static class ItemData { | ||||
|   public static class ItemData implements Serializable { | ||||
|     private static final long serialVersionUID = 354382008606856587L; | ||||
| 
 | ||||
|     /** | ||||
|      * 新增客户群数量 | ||||
|      */ | ||||
|     @SerializedName("new_chat_cnt") | ||||
|     int newChatCnt; | ||||
|     private int newChatCnt; | ||||
| 
 | ||||
|     /** | ||||
|      * 截至当天客户群总数量 | ||||
|      */ | ||||
|     @SerializedName("chat_total") | ||||
|     int chatTotal; | ||||
|     private int chatTotal; | ||||
| 
 | ||||
|     /** | ||||
|      * 截至当天有发过消息的客户群数量 | ||||
|      */ | ||||
|     @SerializedName("chat_has_msg") | ||||
|     int chatHasMsg; | ||||
|     private int chatHasMsg; | ||||
| 
 | ||||
|     /** | ||||
|      * 客户群新增群人数。 | ||||
|      */ | ||||
|     @SerializedName("new_member_cnt") | ||||
|     int newMemberCnt; | ||||
|     private int newMemberCnt; | ||||
| 
 | ||||
|     /** | ||||
|      * 截至当天客户群总人数 | ||||
|      */ | ||||
|     @SerializedName("member_total") | ||||
|     int memberTotal; | ||||
|     private int memberTotal; | ||||
| 
 | ||||
|     /** | ||||
|      * 截至当天有发过消息的群成员数 | ||||
|      */ | ||||
|     @SerializedName("member_has_msg") | ||||
|     int memberHasMsg; | ||||
|     private int memberHasMsg; | ||||
| 
 | ||||
|     /** | ||||
|      * 截至当天客户群消息总数 | ||||
|      */ | ||||
|     @SerializedName("msg_total") | ||||
|     int msgTotal; | ||||
|     private int msgTotal; | ||||
|   } | ||||
| 
 | ||||
|   public static WxCpUserExternalGroupChatStatistic fromJson(String json) { | ||||
| @ -1,9 +1,10 @@ | ||||
| package me.chanjar.weixin.cp.bean; | ||||
| package me.chanjar.weixin.cp.bean.external; | ||||
| 
 | ||||
| import com.google.gson.annotations.SerializedName; | ||||
| import lombok.Getter; | ||||
| import lombok.Setter; | ||||
| import me.chanjar.weixin.common.util.json.WxGsonBuilder; | ||||
| import me.chanjar.weixin.cp.bean.WxCpBaseResp; | ||||
| import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | ||||
| 
 | ||||
| import java.util.List; | ||||
| @ -1,9 +1,10 @@ | ||||
| package me.chanjar.weixin.cp.bean; | ||||
| package me.chanjar.weixin.cp.bean.external; | ||||
| 
 | ||||
| import com.google.gson.annotations.SerializedName; | ||||
| import lombok.Getter; | ||||
| import lombok.Setter; | ||||
| import me.chanjar.weixin.common.util.json.WxGsonBuilder; | ||||
| import me.chanjar.weixin.cp.bean.WxCpBaseResp; | ||||
| import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | ||||
| 
 | ||||
| import java.util.List; | ||||
| @ -1,8 +1,9 @@ | ||||
| package me.chanjar.weixin.cp.bean; | ||||
| 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; | ||||
| @ -14,7 +15,7 @@ import java.util.List; | ||||
|  */ | ||||
| @Getter | ||||
| @Setter | ||||
| public class WxCpUserExternalUnassignList extends WxCpBaseResp{ | ||||
| public class WxCpUserExternalUnassignList extends WxCpBaseResp { | ||||
| 
 | ||||
|   @SerializedName("info") | ||||
|   private List<UnassignInfo> unassignInfos; | ||||
| @ -1,8 +1,9 @@ | ||||
| package me.chanjar.weixin.cp.bean; | ||||
| 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; | ||||
| @ -1,4 +1,4 @@ | ||||
| package me.chanjar.weixin.cp.bean; | ||||
| package me.chanjar.weixin.cp.bean.external; | ||||
| 
 | ||||
| import com.google.gson.annotations.Expose; | ||||
| import com.google.gson.annotations.SerializedName; | ||||
							
								
								
									
										40
									
								
								weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpWelcomeMsg.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/WxCpWelcomeMsg.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,40 @@ | ||||
| package me.chanjar.weixin.cp.bean.external; | ||||
|  | ||||
| import com.google.gson.annotations.SerializedName; | ||||
| import lombok.*; | ||||
| import me.chanjar.weixin.cp.bean.external.msg.Image; | ||||
| import me.chanjar.weixin.cp.bean.external.msg.Link; | ||||
| import me.chanjar.weixin.cp.bean.external.msg.MiniProgram; | ||||
| import me.chanjar.weixin.cp.bean.external.msg.Text; | ||||
| import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder; | ||||
|  | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
|  * 新客户欢迎语. | ||||
|  * | ||||
|  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
|  * @date 2020-08-16 | ||||
|  */ | ||||
| @Data | ||||
| @Builder | ||||
| @NoArgsConstructor | ||||
| @AllArgsConstructor | ||||
| public class WxCpWelcomeMsg implements Serializable { | ||||
|   private static final long serialVersionUID = 4170843890468921757L; | ||||
|  | ||||
|   @SerializedName("welcome_code") | ||||
|   private String welcomeCode; | ||||
|  | ||||
|   private Text text; | ||||
|  | ||||
|   private Image image; | ||||
|  | ||||
|   private Link link; | ||||
|  | ||||
|   private MiniProgram miniprogram; | ||||
|  | ||||
|   public String toJson() { | ||||
|     return WxCpGsonBuilder.create().toJson(this); | ||||
|   } | ||||
| } | ||||
							
								
								
									
										23
									
								
								weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Image.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Image.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| package me.chanjar.weixin.cp.bean.external.msg; | ||||
|  | ||||
| import com.google.gson.annotations.SerializedName; | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
|  * 图片消息. | ||||
|  * | ||||
|  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
|  * @date 2020-08-16 | ||||
|  */ | ||||
| @Data | ||||
| public class Image implements Serializable { | ||||
|   private static final long serialVersionUID = -606286372867787121L; | ||||
|  | ||||
|   @SerializedName("media_id") | ||||
|   private String mediaId; | ||||
|  | ||||
|   @SerializedName("pic_url") | ||||
|   private String picUrl; | ||||
| } | ||||
							
								
								
									
										22
									
								
								weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Link.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Link.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,22 @@ | ||||
| package me.chanjar.weixin.cp.bean.external.msg; | ||||
|  | ||||
| import com.google.gson.annotations.SerializedName; | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
|  * 图文消息. | ||||
|  * | ||||
|  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
|  * @date 2020-08-16 | ||||
|  */ | ||||
| @Data | ||||
| public class Link implements Serializable { | ||||
|   private static final long serialVersionUID = -8041816740881163875L; | ||||
|   private String title; | ||||
|   @SerializedName("picurl") | ||||
|   private String picUrl; | ||||
|   private String desc; | ||||
|   private String url; | ||||
| } | ||||
							
								
								
									
										23
									
								
								weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/MiniProgram.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										23
									
								
								weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/MiniProgram.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,23 @@ | ||||
| package me.chanjar.weixin.cp.bean.external.msg; | ||||
|  | ||||
| import com.google.gson.annotations.SerializedName; | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
|  * 小程序消息. | ||||
|  * | ||||
|  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
|  * @date 2020-08-16 | ||||
|  */ | ||||
| @Data | ||||
| public class MiniProgram implements Serializable { | ||||
|   private static final long serialVersionUID = 4242074162638170679L; | ||||
|  | ||||
|   private String title; | ||||
|   @SerializedName("pic_media_id") | ||||
|   private String picMediaId; | ||||
|   private String appid; | ||||
|   private String page; | ||||
| } | ||||
							
								
								
									
										17
									
								
								weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Text.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/external/msg/Text.java
									
									
									
									
										vendored
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | ||||
| package me.chanjar.weixin.cp.bean.external.msg; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.io.Serializable; | ||||
|  | ||||
| /** | ||||
|  * 消息文本消息. | ||||
|  * | ||||
|  * @author <a href="https://github.com/binarywang">Binary Wang</a> | ||||
|  * @date 2020-08-16 | ||||
|  */ | ||||
| @Data | ||||
| public class Text implements Serializable { | ||||
|   private static final long serialVersionUID = 6608288753719551600L; | ||||
|   private String content; | ||||
| } | ||||
| @ -17,9 +17,11 @@ import java.util.concurrent.locks.ReentrantLock; | ||||
|  *    使用说明:本实现仅供参考,并不完整. | ||||
|  *    比如为减少项目依赖,未加入redis分布式锁的实现,如有需要请自行实现。 | ||||
|  * </pre> | ||||
|  * @deprecated 不建议使用,如有需要,请自行改造实现,加入到自己的项目中并引用 | ||||
|  * | ||||
|  * @author gaigeshen | ||||
|  */ | ||||
| @Deprecated | ||||
| public class WxCpRedisConfigImpl implements WxCpConfigStorage { | ||||
|   private static final String ACCESS_TOKEN_KEY = "WX_CP_ACCESS_TOKEN"; | ||||
|   private static final String ACCESS_TOKEN_EXPIRES_TIME_KEY = "WX_CP_ACCESS_TOKEN_EXPIRES_TIME"; | ||||
|  | ||||
| @ -132,6 +132,7 @@ public final class WxCpApiPathConsts { | ||||
|     public static final String LIST_USER_BEHAVIOR_DATA = "/cgi-bin/externalcontact/get_user_behavior_data"; | ||||
|     public static final String LIST_GROUP_CHAT_DATA = "/cgi-bin/externalcontact/groupchat/statistic"; | ||||
|     public static final String ADD_MSG_TEMPLATE = "/cgi-bin/externalcontact/add_msg_template"; | ||||
|     public static final String SEND_WELCOME_MSG = "/cgi-bin/externalcontact/send_welcome_msg"; | ||||
|  | ||||
|     public static final String GET_CORP_TAG_LIST = "/cgi-bin/externalcontact/get_corp_tag_list"; | ||||
|     public static final String ADD_CORP_TAG = "/cgi-bin/externalcontact/add_corp_tag"; | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| package me.chanjar.weixin.cp.util.json; | ||||
|  | ||||
| import com.google.gson.*; | ||||
| import me.chanjar.weixin.cp.bean.WxCpContactWayInfo; | ||||
| import me.chanjar.weixin.cp.bean.external.WxCpContactWayInfo; | ||||
| import org.apache.commons.lang3.StringUtils; | ||||
|  | ||||
| import java.lang.reflect.Type; | ||||
|  | ||||
| @ -5,7 +5,8 @@ import com.google.inject.Inject; | ||||
| import me.chanjar.weixin.common.error.WxErrorException; | ||||
| import me.chanjar.weixin.cp.api.ApiTestModule; | ||||
| import me.chanjar.weixin.cp.api.WxCpService; | ||||
| import me.chanjar.weixin.cp.bean.*; | ||||
| import me.chanjar.weixin.cp.bean.WxCpBaseResp; | ||||
| import me.chanjar.weixin.cp.bean.external.*; | ||||
| import org.apache.commons.lang3.time.DateFormatUtils; | ||||
| import org.testng.annotations.Guice; | ||||
| import org.testng.annotations.Test; | ||||
| @ -22,7 +23,7 @@ public class WxCpExternalContactServiceImplTest { | ||||
|   private WxCpService wxCpService; | ||||
|   @Inject | ||||
|   protected ApiTestModule.WxXmlCpInMemoryConfigStorage configStorage; | ||||
|   private String userId = "someone" + System.currentTimeMillis(); | ||||
|   private final String userId = "someone" + System.currentTimeMillis(); | ||||
|  | ||||
|   @Test | ||||
|   public void testGetExternalContact() throws WxErrorException { | ||||
| @ -111,7 +112,7 @@ public class WxCpExternalContactServiceImplTest { | ||||
|  | ||||
|   @Test | ||||
|   public void testGetCorpTagList() throws WxErrorException { | ||||
|     String tag[]={}; | ||||
|     String[] tag = {}; | ||||
|     WxCpUserExternalTagGroupList result = this.wxCpService.getExternalContactService().getCorpTagList(null); | ||||
|     System.out.println(result); | ||||
|     assertNotNull(result); | ||||
| @ -121,7 +122,7 @@ public class WxCpExternalContactServiceImplTest { | ||||
|   public void testAddCorpTag() throws WxErrorException { | ||||
|  | ||||
|     List<WxCpUserExternalTagGroupInfo.Tag> list = new ArrayList<>(); | ||||
|     WxCpUserExternalTagGroupInfo.Tag  tag = new  WxCpUserExternalTagGroupInfo.Tag(); | ||||
|     WxCpUserExternalTagGroupInfo.Tag tag = new WxCpUserExternalTagGroupInfo.Tag(); | ||||
|     tag.setName("测试标签20"); | ||||
|     tag.setOrder(1); | ||||
|     list.add(tag); | ||||
| @ -151,10 +152,10 @@ public class WxCpExternalContactServiceImplTest { | ||||
|   @Test | ||||
|   public void testDelCorpTag() throws WxErrorException { | ||||
|  | ||||
|     String tagId[] = {}; | ||||
|     String groupId[] = {"et2omCCwAAM3WzL00QpK9xARab3HGkAg"}; | ||||
|     String[] tagId = {}; | ||||
|     String[] groupId = {"et2omCCwAAM3WzL00QpK9xARab3HGkAg"}; | ||||
|  | ||||
|     WxCpBaseResp result = this.wxCpService.getExternalContactService().delCorpTag(tagId,groupId); | ||||
|     WxCpBaseResp result = this.wxCpService.getExternalContactService().delCorpTag(tagId, groupId); | ||||
|  | ||||
|     System.out.println(result); | ||||
|     assertNotNull(result); | ||||
| @ -163,15 +164,57 @@ public class WxCpExternalContactServiceImplTest { | ||||
|   @Test | ||||
|   public void testMarkTag() throws WxErrorException { | ||||
|  | ||||
|     String userid="HuangXiaoMing"; | ||||
|     String externalUserid="wo2omCCwAAzR0Rt1omz-90o_XJkPGXIQ"; | ||||
|     String addTag[] = {"et2omCCwAAzdcSK-RV80YS9sbpCXlNlQ"}; | ||||
|     String removeTag[] = {}; | ||||
|     String userid = "HuangXiaoMing"; | ||||
|     String externalUserid = "wo2omCCwAAzR0Rt1omz-90o_XJkPGXIQ"; | ||||
|     String[] addTag = {"et2omCCwAAzdcSK-RV80YS9sbpCXlNlQ"}; | ||||
|     String[] removeTag = {}; | ||||
|  | ||||
|     WxCpBaseResp result = this.wxCpService.getExternalContactService().markTag(userid,externalUserid,addTag,removeTag); | ||||
|     WxCpBaseResp result = this.wxCpService.getExternalContactService().markTag(userid, externalUserid, addTag, removeTag); | ||||
|  | ||||
|     System.out.println(result); | ||||
|     assertNotNull(result); | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void testDeleteContactWay() { | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void testListFollowers() { | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void testListUnassignedList() { | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void testTransferExternalContact() { | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void testListGroupChat() { | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void testGetGroupChat() { | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void testGetUserBehaviorStatistic() { | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void testGetGroupChatStatistic() { | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void testAddMsgTemplate() { | ||||
|   } | ||||
|  | ||||
|   @Test | ||||
|   public void testSendWelcomeMsg() throws WxErrorException { | ||||
|     this.wxCpService.getExternalContactService().sendWelcomeMsg(WxCpWelcomeMsg.builder() | ||||
|       .welcomeCode("abc") | ||||
|       .build()); | ||||
|   } | ||||
| } | ||||
|  | ||||
| @ -2,6 +2,7 @@ package me.chanjar.weixin.cp.bean; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| import me.chanjar.weixin.cp.bean.external.WxCpUserExternalContactInfo; | ||||
| import org.testng.annotations.*; | ||||
|  | ||||
| import static org.assertj.core.api.Assertions.assertThat; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Binary Wang
					Binary Wang