mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2026-02-18 14:16:25 +08:00
添加多客服中客服管理的6个接口
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
package me.chanjar.weixin.mp.api;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Binary Wang
|
||||
*
|
||||
*/
|
||||
|
||||
public interface WxMpBaseChildService {
|
||||
/**
|
||||
* 设置WxMpService对象
|
||||
* @return
|
||||
*/
|
||||
void setWxMpService(WxMpService wxMpService);
|
||||
}
|
||||
@@ -0,0 +1,73 @@
|
||||
package me.chanjar.weixin.mp.api;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.mp.bean.customerservice.request.WxMpKfAccountRequest;
|
||||
import me.chanjar.weixin.mp.bean.customerservice.result.WxMpKfList;
|
||||
import me.chanjar.weixin.mp.bean.customerservice.result.WxMpKfOnlineList;
|
||||
|
||||
/**
|
||||
* 客服接口 ,
|
||||
* 命名采用kefu拼音的原因是:
|
||||
* 其英文CustomerService如果再加上Service后缀显得有点啰嗦,
|
||||
* 如果不加又显得表意不完整
|
||||
* @author Binary Wang
|
||||
*
|
||||
*/
|
||||
public interface WxMpKefuService extends WxMpBaseChildService {
|
||||
/**
|
||||
* <pre>
|
||||
* 获取客服基本信息
|
||||
* 详情请见:<a href="http://mp.weixin.qq.com/wiki/18/749901f4e123170fb8a4d447ae6040ba.html">客服管理</a>
|
||||
* https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token=ACCESS_TOKEN
|
||||
* </pre>
|
||||
*/
|
||||
WxMpKfList kfList() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 获取在线客服接待信息
|
||||
* 详情请见:<a href="http://mp.weixin.qq.com/wiki/18/749901f4e123170fb8a4d447ae6040ba.html">客服管理</a>
|
||||
* https://api.weixin.qq.com/cgi-bin/customservice/getonlinekflist?access_token=ACCESS_TOKEN
|
||||
* </pre>
|
||||
*/
|
||||
WxMpKfOnlineList kfOnlineList() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 添加客服账号
|
||||
* 详情请见:<a href="http://mp.weixin.qq.com/wiki/18/749901f4e123170fb8a4d447ae6040ba.html">客服管理</a>
|
||||
* https://api.weixin.qq.com/customservice/kfaccount/add?access_token=ACCESS_TOKEN
|
||||
* </pre>
|
||||
*/
|
||||
boolean kfAccountAdd(WxMpKfAccountRequest request) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 设置客服信息(更新)
|
||||
* 详情请见:<a href="http://mp.weixin.qq.com/wiki/18/749901f4e123170fb8a4d447ae6040ba.html">客服管理</a>
|
||||
* https://api.weixin.qq.com/customservice/kfaccount/update?access_token=ACCESS_TOKEN
|
||||
* </pre>
|
||||
*/
|
||||
boolean kfAccountUpdate(WxMpKfAccountRequest request) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 上传客服头像
|
||||
* 详情请见:<a href="http://mp.weixin.qq.com/wiki/18/749901f4e123170fb8a4d447ae6040ba.html">客服管理</a>
|
||||
* http://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT
|
||||
* </pre>
|
||||
*/
|
||||
|
||||
boolean kfAccountUploadHeadImg(String kfAccount, File imgFile) throws WxErrorException;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 删除客服账号
|
||||
* 详情请见:<a href="http://mp.weixin.qq.com/wiki/18/749901f4e123170fb8a4d447ae6040ba.html">客服管理</a>
|
||||
* https://api.weixin.qq.com/customservice/kfaccount/del?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT
|
||||
* </pre>
|
||||
*/
|
||||
boolean kfAccountDel(String kfAccount) throws WxErrorException;
|
||||
}
|
||||
@@ -1,14 +1,5 @@
|
||||
package me.chanjar.weixin.mp.api;
|
||||
|
||||
import me.chanjar.weixin.common.bean.WxCardApiSignature;
|
||||
import me.chanjar.weixin.common.bean.WxMenu;
|
||||
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.http.RequestExecutor;
|
||||
import me.chanjar.weixin.mp.bean.*;
|
||||
import me.chanjar.weixin.mp.bean.result.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -17,6 +8,47 @@ import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import me.chanjar.weixin.common.bean.WxCardApiSignature;
|
||||
import me.chanjar.weixin.common.bean.WxJsapiSignature;
|
||||
import me.chanjar.weixin.common.bean.WxMenu;
|
||||
import me.chanjar.weixin.common.bean.result.WxMediaUploadResult;
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.http.RequestExecutor;
|
||||
import me.chanjar.weixin.mp.bean.WxMpCustomMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpGroup;
|
||||
import me.chanjar.weixin.mp.bean.WxMpIndustry;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassGroupMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassNews;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassOpenIdsMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassPreviewMessage;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMassVideo;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMaterial;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMaterialArticleUpdate;
|
||||
import me.chanjar.weixin.mp.bean.WxMpMaterialNews;
|
||||
import me.chanjar.weixin.mp.bean.WxMpSemanticQuery;
|
||||
import me.chanjar.weixin.mp.bean.WxMpTemplateMessage;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMediaImgUploadResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpCardResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpMassSendResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpMassUploadResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialCountResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialFileBatchGetResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialNewsBatchGetResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialUploadResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpMaterialVideoInfoResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpOAuth2AccessToken;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpPayCallback;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpPayRefundResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpPayResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpPrepayIdResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpQrCodeTicket;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpSemanticQueryResult;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUser;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUserCumulate;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUserList;
|
||||
import me.chanjar.weixin.mp.bean.result.WxMpUserSummary;
|
||||
import me.chanjar.weixin.mp.bean.result.WxRedpackResult;
|
||||
|
||||
/**
|
||||
* 微信API的Service
|
||||
*/
|
||||
@@ -1001,4 +1033,11 @@ public interface WxMpService {
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxMpIndustry getIndustry() throws WxErrorException;
|
||||
|
||||
/**
|
||||
* 返回客服接口方法实现类,以方便调用个其各种接口
|
||||
* @return WxMpKefuService
|
||||
*/
|
||||
WxMpKefuService getKefuService();
|
||||
|
||||
}
|
||||
|
||||
@@ -74,6 +74,8 @@ public class WxMpServiceImpl implements WxMpService {
|
||||
protected final Object globalCardApiTicketRefreshLock = new Object();
|
||||
|
||||
protected WxMpConfigStorage wxMpConfigStorage;
|
||||
|
||||
protected WxMpKefuService kefuService;
|
||||
|
||||
protected CloseableHttpClient httpClient;
|
||||
|
||||
@@ -1369,4 +1371,14 @@ public class WxMpServiceImpl implements WxMpService {
|
||||
String responseContent = execute(new SimpleGetRequestExecutor(), url, null);
|
||||
return WxMpIndustry.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpKefuService getKefuService() {
|
||||
return this.kefuService;
|
||||
}
|
||||
|
||||
public void setCustomerService(WxMpKefuService kefuService) {
|
||||
this.kefuService = kefuService;
|
||||
this.kefuService.setWxMpService(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package me.chanjar.weixin.mp.api.impl;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import me.chanjar.weixin.common.exception.WxErrorException;
|
||||
import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.SimpleGetRequestExecutor;
|
||||
import me.chanjar.weixin.common.util.http.SimplePostRequestExecutor;
|
||||
import me.chanjar.weixin.mp.api.WxMpKefuService;
|
||||
import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.bean.customerservice.request.WxMpKfAccountRequest;
|
||||
import me.chanjar.weixin.mp.bean.customerservice.result.WxMpKfList;
|
||||
import me.chanjar.weixin.mp.bean.customerservice.result.WxMpKfOnlineList;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Binary Wang
|
||||
*
|
||||
*/
|
||||
public class WxMpKefuServiceImpl implements WxMpKefuService {
|
||||
private WxMpService wxMpService;
|
||||
|
||||
@Override
|
||||
public void setWxMpService(WxMpService wxMpService) {
|
||||
this.wxMpService = wxMpService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpKfList kfList() throws WxErrorException {
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/customservice/getkflist";
|
||||
String responseContent = this.wxMpService.execute(
|
||||
new SimpleGetRequestExecutor(), url, null);
|
||||
return WxMpKfList.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxMpKfOnlineList kfOnlineList() throws WxErrorException {
|
||||
String url = "https://api.weixin.qq.com/cgi-bin/customservice/getonlinekflist";
|
||||
String responseContent = this.wxMpService.execute(
|
||||
new SimpleGetRequestExecutor(), url, null);
|
||||
return WxMpKfOnlineList.fromJson(responseContent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean kfAccountAdd(WxMpKfAccountRequest request) throws WxErrorException {
|
||||
String url = "https://api.weixin.qq.com/customservice/kfaccount/add";
|
||||
this.wxMpService.execute(new SimplePostRequestExecutor(), url, request.toJson());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean kfAccountUpdate(WxMpKfAccountRequest request) throws WxErrorException {
|
||||
String url = "https://api.weixin.qq.com/customservice/kfaccount/update";
|
||||
this.wxMpService.execute(new SimplePostRequestExecutor(), url, request.toJson());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean kfAccountUploadHeadImg(String kfAccount, File imgFile) throws WxErrorException {
|
||||
String url = "https://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?kf_account=" + kfAccount ;
|
||||
this.wxMpService.execute(new MediaUploadRequestExecutor(), url, imgFile);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean kfAccountDel(String kfAccount) throws WxErrorException {
|
||||
String url = "https://api.weixin.qq.com/customservice/kfaccount/del?kf_account=" + kfAccount;
|
||||
this.wxMpService.execute(new SimpleGetRequestExecutor(), url, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user