From 37ae6807e6e5ca7b6880780973527002045c15bd Mon Sep 17 00:00:00 2001 From: Binary Wang Date: Wed, 27 Jan 2021 21:19:44 +0800 Subject: [PATCH] =?UTF-8?q?:new:=20=E3=80=90=E5=85=AC=E4=BC=97=E5=8F=B7?= =?UTF-8?q?=E3=80=91=E5=A2=9E=E5=8A=A0=E8=BF=94=E5=9B=9E=E5=93=8D=E5=BA=94?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E5=AE=8C=E6=95=B4=E5=86=85=E5=AE=B9=E7=9A=84?= =?UTF-8?q?=E5=AE=A2=E6=9C=8D=E6=B6=88=E6=81=AF=E5=8F=91=E9=80=81=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/cp/tp/service/WxCpTpService.java | 2 +- .../weixin/mp/api/WxMpKefuService.java | 48 +++++++++++++++++-- .../mp/api/impl/WxMpKefuServiceImpl.java | 9 ++-- 3 files changed, 52 insertions(+), 7 deletions(-) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpService.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpService.java index 62178550e..83b1c0892 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpService.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/tp/service/WxCpTpService.java @@ -267,7 +267,7 @@ public interface WxCpTpService { * 获取WxMpConfigStorage 对象. * * @return WxMpConfigStorage wx cp tp config storage - * @Deprecated storage应该在service内部使用,提供这个接口,容易破坏这个封装 + * @deprecated storage应该在service内部使用,提供这个接口,容易破坏这个封装 */ @Deprecated WxCpTpConfigStorage getWxCpTpConfigStorage(); diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java index 3404f5fe2..fdce7833f 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpKefuService.java @@ -25,14 +25,29 @@ public interface WxMpKefuService { /** *
    * 发送客服消息
-   * 详情请见: 发送客服消息
+   * 详情请见: 发送客服消息
    * 接口url格式:https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
    * 
* + * @param message the message + * @return the boolean * @throws WxErrorException 异常 */ boolean sendKefuMessage(WxMpKefuMessage message) throws WxErrorException; + /** + *
+   * 发送客服消息
+   * 详情请见: 发送客服消息
+   * 接口url格式:https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token=ACCESS_TOKEN
+   * 
+ * + * @param message the message + * @return the response + * @throws WxErrorException 异常 + */ + String sendKefuMessageWithResponse(WxMpKefuMessage message) throws WxErrorException; + //*******************客服管理接口***********************// /** @@ -42,6 +57,7 @@ public interface WxMpKefuService { * 接口url格式:https://api.weixin.qq.com/cgi-bin/customservice/getkflist?access_token=ACCESS_TOKEN * * + * @return the wx mp kf list * @throws WxErrorException 异常 */ WxMpKfList kfList() throws WxErrorException; @@ -53,6 +69,7 @@ public interface WxMpKefuService { * 接口url格式:https://api.weixin.qq.com/cgi-bin/customservice/getonlinekflist?access_token=ACCESS_TOKEN * * + * @return the wx mp kf online list * @throws WxErrorException 异常 */ WxMpKfOnlineList kfOnlineList() throws WxErrorException; @@ -64,6 +81,8 @@ public interface WxMpKefuService { * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/add?access_token=ACCESS_TOKEN * * + * @param request the request + * @return the boolean * @throws WxErrorException 异常 */ boolean kfAccountAdd(WxMpKfAccountRequest request) throws WxErrorException; @@ -74,6 +93,10 @@ public interface WxMpKefuService { * 详情请见:客服管理 * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/update?access_token=ACCESS_TOKEN * + * + * @param request the request + * @return the boolean + * @throws WxErrorException the wx error exception */ boolean kfAccountUpdate(WxMpKfAccountRequest request) throws WxErrorException; @@ -84,6 +107,8 @@ public interface WxMpKefuService { * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/inviteworker?access_token=ACCESS_TOKEN * * + * @param request the request + * @return the boolean * @throws WxErrorException 异常 */ boolean kfAccountInviteWorker(WxMpKfAccountRequest request) throws WxErrorException; @@ -95,6 +120,9 @@ public interface WxMpKefuService { * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/uploadheadimg?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT * * + * @param kfAccount the kf account + * @param imgFile the img file + * @return the boolean * @throws WxErrorException 异常 */ boolean kfAccountUploadHeadImg(String kfAccount, File imgFile) throws WxErrorException; @@ -106,6 +134,8 @@ public interface WxMpKefuService { * 接口url格式:https://api.weixin.qq.com/customservice/kfaccount/del?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT * * + * @param kfAccount the kf account + * @return the boolean * @throws WxErrorException 异常 */ boolean kfAccountDel(String kfAccount) throws WxErrorException; @@ -120,6 +150,9 @@ public interface WxMpKefuService { * 接口url格式: https://api.weixin.qq.com/customservice/kfsession/create?access_token=ACCESS_TOKEN * * + * @param openid the openid + * @param kfAccount the kf account + * @return the boolean * @throws WxErrorException 异常 */ boolean kfSessionCreate(String openid, String kfAccount) throws WxErrorException; @@ -132,6 +165,9 @@ public interface WxMpKefuService { * 接口url格式: https://api.weixin.qq.com/customservice/kfsession/close?access_token=ACCESS_TOKEN * * + * @param openid the openid + * @param kfAccount the kf account + * @return the boolean * @throws WxErrorException 异常 */ boolean kfSessionClose(String openid, String kfAccount) throws WxErrorException; @@ -144,6 +180,8 @@ public interface WxMpKefuService { * 接口url格式: https://api.weixin.qq.com/customservice/kfsession/getsession?access_token=ACCESS_TOKEN&openid=OPENID * * + * @param openid the openid + * @return the wx mp kf session get result * @throws WxErrorException 异常 */ WxMpKfSessionGetResult kfSessionGet(String openid) throws WxErrorException; @@ -156,6 +194,8 @@ public interface WxMpKefuService { * 接口url格式: https://api.weixin.qq.com/customservice/kfsession/getsessionlist?access_token=ACCESS_TOKEN&kf_account=KFACCOUNT * * + * @param kfAccount the kf account + * @return the wx mp kf session list * @throws WxErrorException 异常 */ WxMpKfSessionList kfSessionList(String kfAccount) throws WxErrorException; @@ -168,6 +208,7 @@ public interface WxMpKefuService { * 接口url格式: https://api.weixin.qq.com/customservice/kfsession/getwaitcase?access_token=ACCESS_TOKEN * * + * @return the wx mp kf session wait case list * @throws WxErrorException 异常 */ WxMpKfSessionWaitCaseList kfSessionGetWaitCase() throws WxErrorException; @@ -186,7 +227,7 @@ public interface WxMpKefuService { * @param endTime 结束时间 * @param msgId 消息id顺序从小到大,从1开始 * @param number 每次获取条数,最多10000条 - * @return 聊天记录对象 + * @return 聊天记录对象 wx mp kf msg list * @throws WxErrorException 异常 */ WxMpKfMsgList kfMsgList(Date startTime, Date endTime, Long msgId, Integer number) throws WxErrorException; @@ -201,7 +242,7 @@ public interface WxMpKefuService { * * @param startTime 起始时间 * @param endTime 结束时间 - * @return 聊天记录对象 + * @return 聊天记录对象 wx mp kf msg list * @throws WxErrorException 异常 */ WxMpKfMsgList kfMsgList(Date startTime, Date endTime) throws WxErrorException; @@ -222,6 +263,7 @@ public interface WxMpKefuService { * * @param openid 用户id * @param command "Typing":对用户下发“正在输入"状态 "CancelTyping":取消对用户的”正在输入"状态 + * @return the boolean * @throws WxErrorException 异常 */ boolean sendKfTypingState(String openid, String command) throws WxErrorException; diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImpl.java index 1ed957aae..cde4df5b6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpKefuServiceImpl.java @@ -4,7 +4,6 @@ import com.google.gson.JsonObject; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import me.chanjar.weixin.common.bean.result.WxMediaUploadResult; -import me.chanjar.weixin.common.error.WxError; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.util.http.MediaUploadRequestExecutor; import me.chanjar.weixin.mp.api.WxMpKefuService; @@ -29,8 +28,12 @@ public class WxMpKefuServiceImpl implements WxMpKefuService { @Override public boolean sendKefuMessage(WxMpKefuMessage message) throws WxErrorException { - String responseContent = this.wxMpService.post(MESSAGE_CUSTOM_SEND, message.toJson()); - return responseContent != null; + return this.sendKefuMessageWithResponse(message) != null; + } + + @Override + public String sendKefuMessageWithResponse(WxMpKefuMessage message) throws WxErrorException { + return this.wxMpService.post(MESSAGE_CUSTOM_SEND, message.toJson()); } @Override