-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
2025-08-19 tryking 增加小程序企微客服相关3个接口 查/增/删 #3681
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
92bc58b
2025-08-19 tryking 增加小程序企微客服相关3个接口 查/增/删
9682ff4
Update weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bea…
binarywang 61be63e
Update weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api…
binarywang 2ccb000
Update weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bea…
binarywang 840d985
Update weixin-java-miniapp/src/main/java/cn/binarywang/wx/miniapp/bea…
binarywang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...java-miniapp/src/main/java/cn/binarywang/wx/miniapp/api/WxMaCustomserviceWorkService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package cn.binarywang.wx.miniapp.api; | ||
|
|
||
| import cn.binarywang.wx.miniapp.bean.customservice.WxMaCustomserviceResult; | ||
| import me.chanjar.weixin.common.error.WxErrorException; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| /** | ||
| * <pre> | ||
| * 小程序 - 微信客服 相关接口 | ||
| * 负责处理 https://api.weixin.qq.com/customservice/work/** | ||
| * 文档:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/kf-work/getKfWorkBound.html | ||
| * 绑定的企业ID,需和小程序主体一致。 | ||
| * 目前仅支持绑定非个人小程序。 | ||
| * Created by tryking123 on 2025/8/18. | ||
| * </pre> | ||
| * | ||
| * @author <a href="https://github.com/tryking123">tryking123</a> | ||
| */ | ||
| public interface WxMaCustomserviceWorkService { | ||
|
|
||
| /** | ||
| * 查询小程序的微信客服绑定情况 | ||
| */ | ||
| String GET_CUSTOMSERVICE_URL = "https://api.weixin.qq.com/customservice/work/get"; | ||
| /** | ||
| * 为小程序绑定微信客服 注:此接口绑定的企业ID需完成企业认证 | ||
| */ | ||
| String BIND_CUSTOMSERVICE_URL = "https://api.weixin.qq.com/customservice/work/bind"; | ||
| /** | ||
| * 为小程序解除绑定微信客服 | ||
| */ | ||
| String UNBIND_CUSTOMSERVICE_URL = "https://api.weixin.qq.com/customservice/work/unbind"; | ||
|
|
||
| /** | ||
| * 查询小程序的微信客服绑定情况 | ||
| * | ||
| * @return 成功示例json { "errcode": 0,"entityName": "XXXXX有限公司","corpid": "wwee11111xxxxxxx","bindTime": 1694611289 } | ||
| * @throws WxErrorException | ||
| */ | ||
| WxMaCustomserviceResult getCustomservice() throws WxErrorException; | ||
|
|
||
| /** | ||
| * 绑定微信客服 | ||
| * @param corpid 企业ID,获取方式参考:https://developer.work.weixin.qq.com/document/path/90665#corpid | ||
| * @return 成功示例json { "errcode": 0 } | ||
| * @throws WxErrorException | ||
| */ | ||
| WxMaCustomserviceResult bindCustomservice(String corpid) throws WxErrorException; | ||
|
|
||
| /** | ||
| * 解除绑定微信客服 | ||
| * @param corpid 企业ID,获取方式参考:https://developer.work.weixin.qq.com/document/path/90665#corpid | ||
| * @return 成功示例json { "errcode": 0 } | ||
| * @throws WxErrorException | ||
| */ | ||
| WxMaCustomserviceResult unbindCustomservice(String corpid) throws WxErrorException; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...app/src/main/java/cn/binarywang/wx/miniapp/api/impl/WxMaCustomserviceWorkServiceImpl.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| package cn.binarywang.wx.miniapp.api.impl; | ||
|
|
||
| import cn.binarywang.wx.miniapp.api.WxMaCustomserviceWorkService; | ||
| import cn.binarywang.wx.miniapp.api.WxMaService; | ||
| import cn.binarywang.wx.miniapp.bean.customservice.WxMaCustomserviceResult; | ||
| import com.google.gson.JsonObject; | ||
| import lombok.RequiredArgsConstructor; | ||
| import me.chanjar.weixin.common.error.WxErrorException; | ||
|
|
||
|
|
||
|
|
||
| /** | ||
| * <pre> | ||
| * 小程序 - 微信客服 相关接口 | ||
| * 负责处理 https://api.weixin.qq.com/customservice/work/** | ||
| * 文档:https://developers.weixin.qq.com/miniprogram/dev/OpenApiDoc/kf-work/getKfWorkBound.html | ||
| * 绑定的企业ID,需和小程序主体一致。 | ||
| * 目前仅支持绑定非个人小程序。 | ||
| * Created by tryking123 on 2025/8/18. | ||
| * </pre> | ||
| * | ||
| * @author <a href="https://github.com/tryking123">tryking123</a> | ||
| */ | ||
| @RequiredArgsConstructor | ||
| public class WxMaCustomserviceWorkServiceImpl implements WxMaCustomserviceWorkService { | ||
| private static final String CORPID = "corpid"; | ||
|
|
||
| private final WxMaService service; | ||
|
|
||
| @Override | ||
| public WxMaCustomserviceResult getCustomservice() throws WxErrorException { | ||
| String responseContent = this.service.get(GET_CUSTOMSERVICE_URL, null); | ||
| return WxMaCustomserviceResult.fromJson(responseContent); | ||
| } | ||
|
|
||
| @Override | ||
| public WxMaCustomserviceResult bindCustomservice(String corpid) throws WxErrorException { | ||
| JsonObject paramJson = new JsonObject(); | ||
| paramJson.addProperty(CORPID, corpid); | ||
| String response = this.service.post(BIND_CUSTOMSERVICE_URL, paramJson); | ||
| return WxMaCustomserviceResult.fromJson(response); | ||
| } | ||
|
|
||
| @Override | ||
| public WxMaCustomserviceResult unbindCustomservice(String corpid) throws WxErrorException { | ||
| JsonObject paramJson = new JsonObject(); | ||
| paramJson.addProperty(CORPID, corpid); | ||
| String response = this.service.post(UNBIND_CUSTOMSERVICE_URL, paramJson); | ||
| return WxMaCustomserviceResult.fromJson(response); | ||
| } | ||
| } |
50 changes: 50 additions & 0 deletions
50
...pp/src/main/java/cn/binarywang/wx/miniapp/bean/customservice/WxMaCustomserviceResult.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,50 @@ | ||
| package cn.binarywang.wx.miniapp.bean.customservice; | ||
|
|
||
| import cn.binarywang.wx.miniapp.bean.express.WxMaExpressAccount; | ||
binarywang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| import cn.binarywang.wx.miniapp.json.WxMaGsonBuilder; | ||
| import com.fasterxml.jackson.annotation.JsonProperty; | ||
| import com.google.gson.annotations.SerializedName; | ||
| import lombok.AllArgsConstructor; | ||
| import lombok.Builder; | ||
| import lombok.Data; | ||
| import lombok.NoArgsConstructor; | ||
|
|
||
| import java.io.Serializable; | ||
| import java.util.List; | ||
|
|
||
| /** | ||
| * 小程序帐号的可选类目,其中 address / tag / title 是提交审核会用到的 | ||
| * | ||
binarywang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| * @author <a href="https://github.com/tryking123">tryking123</a> | ||
| * @since 2025/8/18 17:40 | ||
| */ | ||
| @Data | ||
| @Builder | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class WxMaCustomserviceResult implements Serializable { | ||
| private static final long serialVersionUID = 8854979405505241314L; | ||
|
|
||
| @SerializedName("errcode") | ||
| private Integer errCode; | ||
|
|
||
| /** | ||
| * 该小程序的主体名称,未绑定时不返回 | ||
| */ | ||
| @SerializedName("entityName") | ||
| private String entityName; | ||
|
|
||
| /** | ||
| * 企业ID,未绑定时不返回,未绑定时不返回 | ||
binarywang marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| */ | ||
| @SerializedName("corpid") | ||
| private String corpid; | ||
|
|
||
| /** 接受绑定时间戳,ms */ | ||
| @JsonProperty("bindTime") | ||
| private Long bindTime; | ||
|
|
||
| public static WxMaCustomserviceResult fromJson(String json) { | ||
| return WxMaGsonBuilder.create().fromJson(json, WxMaCustomserviceResult.class); | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.