Skip to content

Commit

Permalink
🆕 #2615 【企业微信】增加企业微信应用市场付费部分接口支持
Browse files Browse the repository at this point in the history
  • Loading branch information
MRLEILOVE authored Apr 24, 2022
1 parent 343fa11 commit 9e0a5bc
Show file tree
Hide file tree
Showing 5 changed files with 254 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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<Agent> agents;

}

@Getter
@Setter
public static class Agent implements Serializable {
Expand Down Expand Up @@ -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;

/**
* 付费状态
* <br/>
* <ul>
* <li>0-没有付费;</li>
* <li>1-限时试用;</li>
* <li>2-试用过期;</li>
* <li>3-购买期内;</li>
* <li>4-购买过期;</li>
* <li>5-不限时试用;</li>
* <li>6-购买期内,但是人数超标, 注意,超标后还可以用7天;</li>
* <li>7-购买期内,但是人数超标, 且已经超标试用7天</li>
* </ul>
*/
@SerializedName("app_status")
private Integer appStatus;

/**
* 用户上限。
* <p>特别注意, 以下情况该字段无意义,可以忽略:</p>
* <ul>
* <li>1. 固定总价购买</li>
* <li>2. app_status = 限时试用/试用过期/不限时试用</li>
* <li>3. 在第2条“app_status=不限时试用”的情况下,如果该应用的配置为“小企业无使用限制”,user_limit有效,且为限制的人数</li>
* </ul>
*/
@SerializedName("user_limit")
private Integer userLimit;

/**
* 版本到期时间, 秒级时间戳, 根据需要自行乘以1000(根据购买版本,可能是试用到期时间或付费使用到期时间)。
* <p>特别注意,以下情况该字段无意义,可以忽略:</p>
* <ul>
* <li>1. app_status = 不限时试用</li>
* </ul>
*/
@SerializedName("expired_time")
private Long expiredTime;

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public class WxCpTpPermanentCodeInfo extends WxCpBaseResp {
@SerializedName("auth_user_info")
private AuthUserInfo authUserInfo;

/**
* 企业当前生效的版本信息
*/
@SerializedName("edition_info")
private EditionInfo editionInfo;

@Getter
@Setter
Expand Down Expand Up @@ -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<Agent> agents;

}

@Getter
@Setter
public static class Agent implements Serializable {
Expand Down Expand Up @@ -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;

/**
* 付费状态
* <br/>
* <ul>
* <li>0-没有付费;</li>
* <li>1-限时试用;</li>
* <li>2-试用过期;</li>
* <li>3-购买期内;</li>
* <li>4-购买过期;</li>
* <li>5-不限时试用;</li>
* <li>6-购买期内,但是人数超标, 注意,超标后还可以用7天;</li>
* <li>7-购买期内,但是人数超标, 且已经超标试用7天</li>
* </ul>
*/
@SerializedName("app_status")
private Integer appStatus;

/**
* 用户上限。
* <p>特别注意, 以下情况该字段无意义,可以忽略:</p>
* <ul>
* <li>1. 固定总价购买</li>
* <li>2. app_status = 限时试用/试用过期/不限时试用</li>
* <li>3. 在第2条“app_status=不限时试用”的情况下,如果该应用的配置为“小企业无使用限制”,user_limit有效,且为限制的人数</li>
* </ul>
*/
@SerializedName("user_limit")
private Integer userLimit;

/**
* 版本到期时间, 秒级时间戳, 根据需要自行乘以1000(根据购买版本,可能是试用到期时间或付费使用到期时间)。
* <p>特别注意,以下情况该字段无意义,可以忽略:</p>
* <ul>
* <li>1. app_status = 不限时试用</li>
* </ul>
*/
@SerializedName("expired_time")
private Long expiredTime;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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";

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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" +
"}";

Expand All @@ -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<WxCpTpPermanentCodeInfo.Agent> editionInfoAgents = editionInfo.getAgents();
Assert.assertTrue(Objects.nonNull(editionInfoAgents) && !editionInfoAgents.isEmpty());

Assert.assertNotNull(editionInfoAgents.get(0).getExpiredTime());

}

@Test
Expand Down Expand Up @@ -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";

Expand All @@ -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<WxCpTpAuthInfo.Agent> editionInfoAgents = editionInfo.getAgents();
Assert.assertTrue(Objects.nonNull(editionInfoAgents) && !editionInfoAgents.isEmpty());

Assert.assertNotNull(editionInfoAgents.get(0).getExpiredTime());
}

@Test
Expand Down

0 comments on commit 9e0a5bc

Please sign in to comment.