package com.cyksj.service.corp;

import cn.hutool.json.JSONObject;
import com.cyksj.dto.CorpOauth2UserInfo;
import com.cyksj.model.kf.*;
import com.cyksj.model.request.corp.CorpFollowContact;
import com.cyksj.model.request.corp.CorpGroupConfig;
import com.cyksj.model.request.corp.CorpMsgTemplate;
import com.cyksj.model.request.corp.CorpXmlMessage;
import com.cyksj.model.request.corp.link.WxCpLinkAdd;
import com.cyksj.model.request.corp.link.WxCpLinkAddResp;
import com.cyksj.model.request.corp.link.WxCpLinkUpd;
import com.cyksj.model.request.corp.message.WxCorpAgentMessage;
import com.cyksj.model.response.corp.*;

import java.util.List;
import java.util.Set;

/*
 *项目名: netflix
 *文件名: WxCorpOps
 *创建者: JavaZou
 *创建时间:2022/10/13 16:27
 */
public interface WxCorpOps {
	/**
	 * 获取客户详情
	 *
	 * @param corpId
	 * @param userId
	 * @return
	 */
	CorpExternalContactInfo getExternalContact(String corpId, String userId) throws Exception;

	/**
	 * 通过企业微信id 获取access_token
	 *
	 * @param corpId
	 * @return
	 * @throws Exception
	 */
	String getAccessToken(String corpId) throws Exception;

	/**
	 * 通过企业微信id 获取消息accessstoken
	 * @param corpId
	 */
	String getMsgAccessToken(String corpId) throws Exception;

	/**
	 * 获取企业标签库
	 *
	 * @author chan
	 * @date 2022-03-24 下午2:30
	 */
	CorpUserExternalTagGroupList getCorpTagList(String corpId, List<String> tagIds, List<String> groupIds) throws Exception;

	/**
	 * 获取配置客户功能成员列表
	 */
	List<String> getFollowUserList(String corpId) throws Exception;

	/**
	 * 客户联系功能的成员列表
	 */
	CorpUserInfo getFollowUser(String corpId, String userId) throws Exception;

	/**
	 * 获取客户列表
	 */
	List<String> listExternalContacts(String corpId, String userId) throws Exception;

	/**
	 * 获取授权链接
	 */
	String createUrl(String corpId, String state);

	/**
	 * 获取成员信息
	 */
	CorpOauth2UserInfo getUserInfo(String corpId, String code) throws Exception;

	/**
	 * 企业微信获取js_ticket
	 */
	String getJsTicket(String corpId) throws Exception;

	/**
	 * 企业微信获取应用js_ticket
	 */
	String getAgentJsTicket(String corpId, String agentId) throws Exception;

	String getCorpChatGroups(String corpId,String config) throws Exception;

	String setGroupsConfig(List<String> chatIds) throws Exception;

	String getGroupsDetail(String chatId) throws Exception;

	/**
	 * 添加企业客户标签
	 *
	 * @author chan
	 * @date 2022-03-24 下午5:12
	 */
	CorpUserExternalTagGroupInfo addCorpTag(CorpUserExternalTagGroupInfo tagGroup, String corpId) throws Exception;

	/**
	 * 编辑企业客户标签
	 * @author chan
	 * @date 2022-03-24 下午5:54
	 */
	CorpBaseResult editCorpTag(JSONObject params) throws Exception;

	/**
	 * 删除企业客户标签
	 * @author chan
	 * @date 2022-03-24 下午6:05
	 */
	CorpBaseResult delCorpTag(String[] tagIds, String[] groupIds) throws Exception;

	/**
	 * 编辑客户标签
	 * @author chan
	 * @date 2022-03-25 上午9:43
	 */
	CorpBaseResult markTag(String userId, String followId, String[] tags, String[] removeTags) throws Exception;

	/**
	 * 企业群发消息
	 * @author chan
	 * @date 2022-03-16 下午3:08
	 */
	CorpMsgTemplateAddResult addMsgTemplate(String corpId, CorpMsgTemplate msgTemplate)throws Exception;

	/**
	 * 上传附件
	 */
	String getMediaIdByFileName(String msgType,String url,String corpId);

	/**
	 * 提醒群发
	 */
	CorpBaseResult remindBulkTask(String msgid, String corpId) throws Exception;

	/**
	 * 获取标签组下所有标签
	 */
	List<CorpUserExternalTagGroupInfo.TagGroup> getAllCorpTagByGroupsId(String groupId,String corpId) throws Exception;

	void updateGroupsConfig(CorpGroupConfig config) throws Exception;

	/**
	 * 联系客服配置
	 */
	String corpFollowContactConfig(CorpFollowContact corpFollowContact) throws Exception;

	/**
	 * 更新客服配置
	 */
	void updateCorpFollowContactConfig(CorpFollowContact corpFollowContact) throws Exception;

	void sendAgentMessage(String corpId, WxCorpAgentMessage agentMessage) throws Exception;

	/**
	 * 获取客户群列表
	 */
	CorpGroupChatListDetail getGroupChatList(String corpId, String cursor, Integer limit) throws Exception;

	/**
	 * 获取客户群详情
	 */
	CorpGroupChatDetail getCorpGroupChatDetail(String corpId, CorpXmlMessage message) throws Exception;

	/**
	 *  新增获客助手链接
	 */
	WxCpLinkAddResp customerAcquisitionCreateLink(String corpId, WxCpLinkAdd wxCpLinkAdd) throws Exception;

	/**
	 * 编辑获客助手链接
	 */
	WxCpLinkAddResp customerAcquisitionUpdateLink(String corpId, WxCpLinkUpd wxCpLinkUpd) throws Exception;

	/**
	 * 删除获客链接
	 */
	WxCpLinkAddResp customerAcquisitionDeleteLink(String corpId, WxCpLinkUpd wxCpLinkUpd) throws Exception;

	/**
	 * 获取会话内容存档开启成员列表
	 */
	List<String> getPermitUserList(String corpId, String type) throws Exception;

	/**
	 * 添加客服帐号，并可设置客服名称和头像
	 */
	WxCpKfAccountAddResp addAccount(String corpId, WxCpKfAccountAdd add) throws Exception;

	/**
	 * 删除已有的客服帐号
	 *
	 * @param del 要删除的客服帐号
	 */
	void delAccount(String corpId, WxCpKfAccountDel del) throws Exception;

	/**
	 * 修改已有的客服帐号，可修改客服名称和头像。
	 *
	 * @param upd 新的客服账号信息
	 */
	void updAccount(String corpId, WxCpKfAccountUpd upd) throws Exception;

	/**
	 * 读取消息
	 */
	WxCpKfMsgListResp syncMsg(String corpId, String cursor, String token, Integer limit, String openKfId) throws Exception;

	/**
	 * 客服发送消息
	 */
	WxCpKfMsgSendResp sendMsgOnEvent(String corpId, WxCorpKfMsgSendRequest request) throws Exception;

	/**
	 * 获取客服账号接待人员
	 */
	CorpKfServicerResp getKfServicerList(String corpId,String openKfId) throws Exception;

	void moveWaitingQueue(String corpId, String openKfId, String externalUserId) throws Exception;

	/**
	 * 变更微信客服会话状态
	 */
	void transCorpKfSessionToServicer(String toUserName, String openKfId, String userid, String externalUserId, Integer serviceState) throws Exception;

	/**
	 * 发送满意度调查msg
	 */
	void sendSatisfactionMsg(String msgid, String openKfId, String externalUserId, String msgCode) throws Exception;

	CorpKfUserInfo getCorpKfUserInfo(String externalUserid) throws Exception;

	/**
	 * 获取微信客服账号链接
	 */
	String getCorpKfUrl(String openKfId, String scene) throws Exception;

	/**
	 * 删除接待人员
	 */
	void delCorpKfServicer(String openKfId, List<String> delDutyFollowId) throws Exception;

	/**
	 * 添加接待人员
	 */
	void addCorpKfServicer(String openKfId, Set<String> dutyFollowIds) throws Exception;

	/**
	 * 发送文本消息
	 */
	void sendTextMsg(String corpId, WxCorpKfMsgSendRequest wxCpKfMsgSendRequest) throws Exception;

	ServiceStateResponse getCorpKfSessionStatus(String corpId, String openKfId, String externalUserid) throws Exception;

	/**
	 * 获取素材
	 */
	String getMedia(String corpId, String mediaId) throws Exception;

	String generateTempCorpFollowCode(CorpFollowContact corpFollowContact) throws Exception;
}
