From 9e0a5bcc787ad9f38a15952289ad89524e83f339 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=8D=E6=95=B2=E4=BB=A3=E7=A0=81=E7=9A=84=E6=94=BB?= =?UTF-8?q?=E5=9F=8E=E7=8B=AE?= <191789784@qq.com> Date: Sun, 24 Apr 2022 12:44:42 +0800 Subject: [PATCH] =?UTF-8?q?:new:=20#2615=20=E3=80=90=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E3=80=91=E5=A2=9E=E5=8A=A0=E4=BC=81=E4=B8=9A?= =?UTF-8?q?=E5=BE=AE=E4=BF=A1=E5=BA=94=E7=94=A8=E5=B8=82=E5=9C=BA=E4=BB=98?= =?UTF-8?q?=E8=B4=B9=E9=83=A8=E5=88=86=E6=8E=A5=E5=8F=A3=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../weixin/cp/bean/WxCpTpAuthInfo.java | 74 +++++++++++++++++++ .../cp/bean/WxCpTpPermanentCodeInfo.java | 71 ++++++++++++++++++ .../cp/bean/message/WxCpTpXmlMessage.java | 20 +++++ .../weixin/cp/constant/WxCpTpConsts.java | 25 +++++++ .../impl/BaseWxCpTpServiceImplTest.java | 64 ++++++++++++++++ 5 files changed, 254 insertions(+) diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAuthInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAuthInfo.java index 9ca4971754..8249cd50bd 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAuthInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpAuthInfo.java @@ -36,6 +36,13 @@ public class WxCpTpAuthInfo extends WxCpBaseResp { @SerializedName("auth_info") private AuthInfo authInfo; + + /** + * 企业当前生效的版本信息 + */ + @SerializedName("edition_info") + private EditionInfo editionInfo; + @Getter @Setter public static class DealerCorpInfo extends WxCpBaseResp { @@ -128,6 +135,22 @@ public static class AuthInfo implements Serializable { } + /** + * 企业当前生效的版本信息 + */ + @Getter + @Setter + public static class EditionInfo implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + /** + * 授权的应用信息,注意是一个数组,但仅旧的多应用套件授权时会返回多个agent,对新的单应用授权,永远只返回一个agent + */ + @SerializedName("agent") + private List agents; + + } + @Getter @Setter public static class Agent implements Serializable { @@ -170,6 +193,57 @@ public static class Agent implements Serializable { @SerializedName("privilege") private Privilege privilege; + /** + * 版本id + */ + @SerializedName("edition_id") + private String editionId; + + /** + * 版本名称 + */ + @SerializedName("edition_name") + private String editionName; + + /** + * 付费状态 + *
+ * + */ + @SerializedName("app_status") + private Integer appStatus; + + /** + * 用户上限。 + *

特别注意, 以下情况该字段无意义,可以忽略:

+ * + */ + @SerializedName("user_limit") + private Integer userLimit; + + /** + * 版本到期时间, 秒级时间戳, 根据需要自行乘以1000(根据购买版本,可能是试用到期时间或付费使用到期时间)。 + *

特别注意,以下情况该字段无意义,可以忽略:

+ * + */ + @SerializedName("expired_time") + private Long expiredTime; + } /** diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpPermanentCodeInfo.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpPermanentCodeInfo.java index 9774f6230b..7a22310ee6 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpPermanentCodeInfo.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/WxCpTpPermanentCodeInfo.java @@ -46,6 +46,11 @@ public class WxCpTpPermanentCodeInfo extends WxCpBaseResp { @SerializedName("auth_user_info") private AuthUserInfo authUserInfo; + /** + * 企业当前生效的版本信息 + */ + @SerializedName("edition_info") + private EditionInfo editionInfo; @Getter @Setter @@ -127,6 +132,22 @@ public static class AuthInfo implements Serializable { } + /** + * 企业当前生效的版本信息 + */ + @Getter + @Setter + public static class EditionInfo implements Serializable { + private static final long serialVersionUID = -5028321625140879571L; + + /** + * 授权的应用信息,注意是一个数组,但仅旧的多应用套件授权时会返回多个agent,对新的单应用授权,永远只返回一个agent + */ + @SerializedName("agent") + private List agents; + + } + @Getter @Setter public static class Agent implements Serializable { @@ -169,6 +190,56 @@ public static class Agent implements Serializable { @SerializedName("privilege") private Privilege privilege; + /** + * 版本id + */ + @SerializedName("edition_id") + private String editionId; + + /** + * 版本名称 + */ + @SerializedName("edition_name") + private String editionName; + + /** + * 付费状态 + *
+ * + */ + @SerializedName("app_status") + private Integer appStatus; + + /** + * 用户上限。 + *

特别注意, 以下情况该字段无意义,可以忽略:

+ * + */ + @SerializedName("user_limit") + private Integer userLimit; + + /** + * 版本到期时间, 秒级时间戳, 根据需要自行乘以1000(根据购买版本,可能是试用到期时间或付费使用到期时间)。 + *

特别注意,以下情况该字段无意义,可以忽略:

+ * + */ + @SerializedName("expired_time") + private Long expiredTime; } /** diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpTpXmlMessage.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpTpXmlMessage.java index 5796735948..87f8332dcf 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpTpXmlMessage.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/bean/message/WxCpTpXmlMessage.java @@ -314,6 +314,26 @@ public class WxCpTpXmlMessage implements Serializable { @XStreamConverter(value = XStreamCDataConverter.class) private String taskId; + @XStreamAlias("PaidCorpId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String paidCorpId; + + @XStreamAlias("OrderId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String orderId; + + @XStreamAlias("OperatorId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String operatorId; + + @XStreamAlias("OldOrderId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String oldOrderId; + + @XStreamAlias("NewOrderId") + @XStreamConverter(value = XStreamCDataConverter.class) + private String newOrderId; + @Data @XStreamAlias("ContactSync") public static class ContactSync implements Serializable { diff --git a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpTpConsts.java b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpTpConsts.java index 40270270cf..aed02d92f0 100644 --- a/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpTpConsts.java +++ b/weixin-java-cp/src/main/java/me/chanjar/weixin/cp/constant/WxCpTpConsts.java @@ -47,6 +47,31 @@ public static class InfoType { */ public static final String CHANGE_EXTERNAL_CONTACT = "change_external_contact"; + /** + * 下单成功通知 + */ + public static final String OPEN_ORDER = "open_order"; + + /** + * 改单通知 + */ + public static final String CHANGE_ORDER = "change_order"; + + /** + * 支付成功通知 + */ + public static final String PAY_FOR_APP_SUCCESS = "pay_for_app_success"; + + /** + * 退款通知 + */ + public static final String REFUND = "refund"; + + /** + * 付费版本变更通知 + */ + public static final String CHANGE_EDITION = "change_editon"; + } } diff --git a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImplTest.java b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImplTest.java index 26ca567c12..d181fac105 100644 --- a/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImplTest.java +++ b/weixin-java-cp/src/test/java/me/chanjar/weixin/cp/tp/service/impl/BaseWxCpTpServiceImplTest.java @@ -12,6 +12,9 @@ import org.testng.Assert; import org.testng.annotations.Test; +import java.util.List; +import java.util.Objects; + import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_AUTH_INFO; import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_PERMANENT_CODE; import static org.assertj.core.api.Assertions.assertThat; @@ -179,6 +182,28 @@ public void testGetPermanentCodeInfo() throws WxErrorException { " \"userid\": \"yuanqixun\", \n" + " \"name\": \"袁启勋\", \n" + " \"avatar\": \"http://wework.qpic.cn/bizmail/ZYqy8EswiaFyPnk7gy7eiafoicz3TL35f4bAvCf2eSe6RVYSK7aPDFxcw/0\"\n" + + " },\n" + + " \"edition_info\":\n" + + " {\n" + + " \"agent\" :\n" + + " [\n" + + " {\n" + + " \"agentid\":1,\n" + + " \"edition_id\":\"RLS65535\",\n" + + " \"edition_name\":\"协同版\",\n" + + " \"app_status\":3,\n" + + " \"user_limit\":200,\n" + + " \"expired_time\":1541990791\n" + + " },\n" + + " {\n" + + " \"agentid\":1,\n" + + " \"edition_id\":\"RLS65535\",\n" + + " \"edition_name\":\"协同版\",\n" + + " \"app_status\":3,\n" + + " \"user_limit\":200,\n" + + " \"expired_time\":1541990791\n" + + " }\n" + + " ]\n" + " }\n" + "}"; @@ -192,6 +217,15 @@ public void testGetPermanentCodeInfo() throws WxErrorException { assertThat(tpPermanentCodeInfo.getAuthInfo().getAgents().get(0).getAgentId()).isEqualTo(1000012); Assert.assertNotNull(tpPermanentCodeInfo.getAuthInfo().getAgents().get(0).getSquareLogoUrl()); Assert.assertNotNull(tpPermanentCodeInfo.getAuthCorpInfo().getCorpSquareLogoUrl()); + + final WxCpTpPermanentCodeInfo.EditionInfo editionInfo = tpPermanentCodeInfo.getEditionInfo(); + Assert.assertNotNull(editionInfo); + + final List editionInfoAgents = editionInfo.getAgents(); + Assert.assertTrue(Objects.nonNull(editionInfoAgents) && !editionInfoAgents.isEmpty()); + + Assert.assertNotNull(editionInfoAgents.get(0).getExpiredTime()); + } @Test @@ -250,6 +284,28 @@ public void testGetAuthInfo() throws WxErrorException { " \"appid\":5\n" + " }\n" + " ]\n" + + " },\n" + + " \"edition_info\":\n" + + " {\n" + + " \"agent\" :\n" + + " [\n" + + " {\n" + + " \"agentid\":1,\n" + + " \"edition_id\":\"RLS65535\",\n" + + " \"edition_name\":\"协同版\",\n" + + " \"app_status\":3,\n" + + " \"user_limit\":200,\n" + + " \"expired_time\":1541990791\n" + + " },\n" + + " {\n" + + " \"agentid\":1,\n" + + " \"edition_id\":\"RLS65535\",\n" + + " \"edition_name\":\"协同版\",\n" + + " \"app_status\":3,\n" + + " \"user_limit\":200,\n" + + " \"expired_time\":1541990791\n" + + " }\n" + + " ]\n" + " }\n" + "}\n"; @@ -263,6 +319,14 @@ public void testGetAuthInfo() throws WxErrorException { Mockito.doReturn(returnJson).when(tpService).post(configStorage.getApiUrl(GET_AUTH_INFO), jsonObject.toString()); WxCpTpAuthInfo authInfo = tpService.getAuthInfo(authCorpId, permanentCode); Assert.assertNotNull(authInfo.getAuthCorpInfo().getCorpId()); + + final WxCpTpAuthInfo.EditionInfo editionInfo = authInfo.getEditionInfo(); + Assert.assertNotNull(editionInfo); + + final List editionInfoAgents = editionInfo.getAgents(); + Assert.assertTrue(Objects.nonNull(editionInfoAgents) && !editionInfoAgents.isEmpty()); + + Assert.assertNotNull(editionInfoAgents.get(0).getExpiredTime()); } @Test