diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideService.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideService.java index 372589c82..e1427dbb6 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideService.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/WxMpGuideService.java @@ -2,6 +2,7 @@ package me.chanjar.weixin.mp.api; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.mp.bean.guide.WxMpGuideInfo; +import me.chanjar.weixin.mp.bean.guide.WxMpGuideList; /** * 微信导购助手(现在叫对话能力)接口. @@ -37,6 +38,18 @@ public interface WxMpGuideService { */ void addGuide(WxMpGuideInfo guideInfo) throws WxErrorException; + /** + * 修改顾问的昵称或头像 + *
+ * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/updateguideacct?access_token=ACCESS_TOKEN + * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/guide-account/shopping-guide.updateGuideAcct.html + *+ * + * @param guideInfo 顾问信息 + * @throws WxErrorException . + */ + void updateGuide(WxMpGuideInfo guideInfo) throws WxErrorException; + /** * 获取顾问信息 * @@ -51,4 +64,33 @@ public interface WxMpGuideService { * @throws WxErrorException . */ WxMpGuideInfo getGuide(String account, String openid) throws WxErrorException; + + /** + * 删除顾问 + * + *
+ * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/delguideacct?access_token=ACCESS_TOKEN + * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/guide-account/shopping-guide.delGuideAcct.html + *+ * + * @param account 顾问微信号(guide_account和guide_openid二选一,若同时请求,默认为guide_account) + * @param openid 顾问openid或者unionid(guide_account和guide_openid二选一) + * @throws WxErrorException . + */ + void delGuide(String account, String openid) throws WxErrorException; + + /** + * 获取服务号顾问列表 + * + *
+ * 请求地址: POST https://api.weixin.qq.com/cgi-bin/guide/getguideacctlist?access_token=ACCESS_TOKEN + * 文档地址:https://developers.weixin.qq.com/doc/offiaccount/Shopping_Guide/guide-account/shopping-guide.getGuideAcctList.html + *+ * + * @param page 分页页数,从0开始 + * @param num 每页数量 + * @return 顾问信息列表 + * @throws WxErrorException . + */ + WxMpGuideList listGuide(int page, int num) throws WxErrorException; } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideServiceImpl.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideServiceImpl.java index 6e6f71a7c..51513fbfe 100644 --- a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideServiceImpl.java +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpGuideServiceImpl.java @@ -6,6 +6,7 @@ import me.chanjar.weixin.common.util.json.GsonHelper; import me.chanjar.weixin.mp.api.WxMpGuideService; import me.chanjar.weixin.mp.api.WxMpService; import me.chanjar.weixin.mp.bean.guide.WxMpGuideInfo; +import me.chanjar.weixin.mp.bean.guide.WxMpGuideList; import me.chanjar.weixin.mp.enums.WxMpApiUrl; /** @@ -35,9 +36,31 @@ public class WxMpGuideServiceImpl implements WxMpGuideService { OPENID, guideInfo.getOpenid())); } + @Override + public void updateGuide(WxMpGuideInfo guideInfo) throws WxErrorException { + this.mpService.post(WxMpApiUrl.Guide.UPDATE_GUIDE, + GsonHelper.buildJsonObject(ACCOUNT, guideInfo.getAccount(), + "guide_headimgurl", guideInfo.getHeadImgUrl(), + "guide_nickname", guideInfo.getNickName(), + OPENID, guideInfo.getOpenid())); + + } + @Override public WxMpGuideInfo getGuide(String account, String openid) throws WxErrorException { return WxMpGuideInfo.fromJson(this.mpService.post(WxMpApiUrl.Guide.GET_GUIDE, GsonHelper.buildJsonObject(ACCOUNT, account, OPENID, openid))); } + + @Override + public void delGuide(String account, String openid) throws WxErrorException { + this.mpService.post(WxMpApiUrl.Guide.DEL_GUIDE, + GsonHelper.buildJsonObject(ACCOUNT, account, OPENID, openid)); + } + + @Override + public WxMpGuideList listGuide(int page, int num) throws WxErrorException { + return WxMpGuideList.fromJson(this.mpService.post(WxMpApiUrl.Guide.LIST_GUIDE, + GsonHelper.buildJsonObject("page", page, "num", num))); + } } diff --git a/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideList.java b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideList.java new file mode 100644 index 000000000..e550c3460 --- /dev/null +++ b/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/bean/guide/WxMpGuideList.java @@ -0,0 +1,34 @@ +package me.chanjar.weixin.mp.bean.guide; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; +import java.util.List; + +/** + * 顾问列表. + * + * @author Binary Wang + * @date 2020-10-07 + */ +@Data +public class WxMpGuideList implements Serializable { + private static final long serialVersionUID = 144044550239346216L; + + /** + * 顾问总数量 + */ + @SerializedName("total_num") + private Integer totalNum; + + /** + * 顾问列表 + */ + private List