From 7f7c0a3765661779ea3f28bfc1d2b9bee3f32a1a Mon Sep 17 00:00:00 2001 From: Nobody Date: Mon, 19 Sep 2022 20:00:16 +0800 Subject: [PATCH] =?UTF-8?q?:new:=20#2815=E3=80=90=E5=BC=80=E6=94=BE?= =?UTF-8?q?=E5=B9=B3=E5=8F=B0=E3=80=91=E6=9F=A5=E8=AF=A2=E5=85=AC=E4=BC=97?= =?UTF-8?q?=E5=8F=B7/=E5=B0=8F=E7=A8=8B=E5=BA=8F=E6=98=AF=E5=90=A6?= =?UTF-8?q?=E7=BB=91=E5=AE=9Aopen=E5=AE=9E=E7=8E=B0=20&&=20=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=8E=88=E6=9D=83=E7=94=A8=E6=88=B7=E8=B5=84=E6=96=99?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E4=BA=8B=E4=BB=B6=E5=B8=B8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chanjar/weixin/common/api/WxConsts.java | 16 ++++++++++++ .../open/api/WxOpenComponentService.java | 15 +++++++++++ .../api/impl/WxOpenComponentServiceImpl.java | 6 +++++ .../open/bean/result/WxOpenHaveResult.java | 25 +++++++++++++++++++ .../impl/WxOpenComponentServiceImplTest.java | 6 +++++ 5 files changed, 68 insertions(+) create mode 100644 weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenHaveResult.java diff --git a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java index 5bef9f28a..e88aa1957 100644 --- a/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java +++ b/weixin-java-common/src/main/java/me/chanjar/weixin/common/api/WxConsts.java @@ -309,7 +309,23 @@ public class WxConsts { */ public static final String LOCATION_SELECT = "location_select"; + /** + * 授权用户资料变更事件 + * 1、 当部分用户的资料存在风险时,平台会对用户资料进行清理,并通过消息推送服务器通知最近30天授权过的公众号开发者,我们建议开发者留意响应该事件,及时主动更新或清理用户的头像及昵称,降低风险。 + * 2、 当用户撤回授权信息时,平台会通过消息推送服务器通知给公众号开发者,请开发者注意及时删除用户信息。 + */ + public static final String USER_INFO_MODIFIED = "user_info_modified"; + + /** + * 用户撤回授权事件 + */ + public static final String USER_AUTHORIZATION_REVOKE = "user_authorization_revoke"; + + /** + * 群发模板回调事件 + */ public static final String TEMPLATE_SEND_JOB_FINISH = "TEMPLATESENDJOBFINISH"; + /** * 微信小店 订单付款通知. */ diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java index 6c31c4921..64e40d3f3 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/WxOpenComponentService.java @@ -115,6 +115,11 @@ public interface WxOpenComponentService { */ String GET_OPEN_URL = "https://api.weixin.qq.com/cgi-bin/open/get"; + /** + * 查询公众号/小程序是否绑定 open 帐号 + */ + String HAVE_OPEN_URL = "https://api.weixin.qq.com/cgi-bin/open/have"; + /** * 快速创建小程序接口. */ @@ -575,6 +580,16 @@ public interface WxOpenComponentService { */ WxOpenGetResult getOpenAccount(String appId, String appIdType) throws WxErrorException; + /** + * https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/getbindopeninfo.html + * 查询公众号/小程序是否绑定 open 帐号 + * + * @return 是否绑定 open 帐号,true表示绑定;false表示未绑定任何 open 帐号 + * @throws WxErrorException the wx error exception + */ + WxOpenHaveResult haveOpen() throws WxErrorException; + + /** * https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=21538208049W8uwq&token=&lang=zh_CN * 第三方平台快速创建小程序. diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java index 9589a9843..96bcb4ea2 100644 --- a/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImpl.java @@ -607,6 +607,12 @@ public class WxOpenComponentServiceImpl implements WxOpenComponentService { return WxOpenGetResult.fromJson(json); } + @Override + public WxOpenHaveResult haveOpen() throws WxErrorException { + String json = post(GET_OPEN_URL, null); + return WxOpenHaveResult.fromJson(json); + } + @Override public WxOpenResult fastRegisterWeapp(String name, String code, String codeType, String legalPersonaWechat, String legalPersonaName, String componentPhone) throws WxErrorException { diff --git a/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenHaveResult.java b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenHaveResult.java new file mode 100644 index 000000000..5db81c7b1 --- /dev/null +++ b/weixin-java-open/src/main/java/me/chanjar/weixin/open/bean/result/WxOpenHaveResult.java @@ -0,0 +1,25 @@ +package me.chanjar.weixin.open.bean.result; + +import com.google.gson.annotations.SerializedName; +import lombok.Data; +import lombok.EqualsAndHashCode; +import me.chanjar.weixin.common.util.json.WxGsonBuilder; + +import java.io.Serializable; + +/** + * 该 API 用于查询公众号或小程序是否绑定的开放平台帐号。 + * 文档地址:https://developers.weixin.qq.com/doc/oplatform/Third-party_Platforms/2.0/api/Mini_Program_Basic_Info/getbindopeninfo.html + */ +@Data +@EqualsAndHashCode(callSuper = false) +public class WxOpenHaveResult extends WxOpenResult implements Serializable { + + @SerializedName("have_open") + private Boolean haveOpen; + + public static WxOpenHaveResult fromJson(String json) { + return WxGsonBuilder.create().fromJson(json, WxOpenHaveResult.class); + } + +} diff --git a/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImplTest.java b/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImplTest.java index 85fdac4b6..dd8a9f1c4 100644 --- a/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImplTest.java +++ b/weixin-java-open/src/test/java/me/chanjar/weixin/open/api/impl/WxOpenComponentServiceImplTest.java @@ -3,6 +3,7 @@ package me.chanjar.weixin.open.api.impl; import com.google.inject.Inject; import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.open.api.WxOpenComponentService; +import me.chanjar.weixin.open.bean.result.WxOpenHaveResult; import me.chanjar.weixin.open.bean.result.WxOpenResult; import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvRequest; import me.chanjar.weixin.open.bean.tcb.ShareCloudBaseEnvResponse; @@ -166,6 +167,11 @@ public class WxOpenComponentServiceImplTest { @Test public void testGetOpenAccount() { } + @Test + public void testHaveOpen() throws WxErrorException { + WxOpenHaveResult wxOpenHaveResult = wxOpenComponentService.haveOpen(); + Assert.assertNotNull(wxOpenHaveResult); + } @Test public void testFastRegisterWeapp() {