mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +08:00
🆕 #2718【企业微信】增加接口调用许可相关接口
This commit is contained in:
parent
4fd6693c56
commit
a12fa55601
@ -0,0 +1,32 @@
|
||||
package me.chanjar.weixin.cp.bean.license;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
|
||||
/**
|
||||
* 订单账号信息
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 14:04
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WxCpTpLicenseAccount extends WxCpTpLicenseBaseAccount {
|
||||
private static final long serialVersionUID = 8225061160406054730L;
|
||||
|
||||
/**
|
||||
* 激活码
|
||||
*/
|
||||
@SerializedName("active_code")
|
||||
private String activeCode;
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package me.chanjar.weixin.cp.bean.license;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 11:54
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WxCpTpLicenseAccountCount implements Serializable {
|
||||
private static final long serialVersionUID = 8521389670723004989L;
|
||||
|
||||
@SerializedName("base_count")
|
||||
private Integer baseCount;
|
||||
@SerializedName("external_contact_count")
|
||||
private Integer externalContactCount;
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package me.chanjar.weixin.cp.bean.license;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Totoro
|
||||
* @date 2022-6-27 11:22:53
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WxCpTpLicenseAccountDuration implements Serializable {
|
||||
private static final long serialVersionUID = 7960912263908286975L;
|
||||
|
||||
private Integer months;
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package me.chanjar.weixin.cp.bean.license;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Totoro
|
||||
* @date 2022-6-27 16:26:35
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WxCpTpLicenseActiveAccount implements Serializable {
|
||||
private static final long serialVersionUID = -2382681430861137803L;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String userid;
|
||||
|
||||
/**
|
||||
* 激活码
|
||||
*/
|
||||
@SerializedName("active_code")
|
||||
private String activeCode;
|
||||
|
||||
/**
|
||||
* 激活状态 0为成功
|
||||
* 此值在请求激活时无需传入
|
||||
*/
|
||||
@SerializedName("errcode")
|
||||
private Integer errCode;
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package me.chanjar.weixin.cp.bean.license;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* 激活码信息
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95553
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 14:34
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WxCpTpLicenseActiveCodeInfo extends WxCpTpLicenseBaseAccount {
|
||||
private static final long serialVersionUID = 7696395903786956694L;
|
||||
|
||||
@SerializedName("active_code")
|
||||
private String activeCode;
|
||||
|
||||
private Integer status;
|
||||
|
||||
@SerializedName("create_time")
|
||||
private Long createTime;
|
||||
|
||||
@SerializedName("active_time")
|
||||
private Long activeTime;
|
||||
|
||||
@SerializedName("expire_time")
|
||||
private Long expireTime;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package me.chanjar.weixin.cp.bean.license;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 许可证账号基础类
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 14:39
|
||||
*/
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WxCpTpLicenseBaseAccount implements Serializable {
|
||||
private static final long serialVersionUID = 7075253491688740047L;
|
||||
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
private String userid;
|
||||
|
||||
/**
|
||||
* 类型
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package me.chanjar.weixin.cp.bean.license;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 15:21
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WxCpTpLicenseCorpAccount extends WxCpTpLicenseBaseAccount {
|
||||
|
||||
private static final long serialVersionUID = -5856054486686123753L;
|
||||
|
||||
@SerializedName("active_time")
|
||||
private Long activeTime;
|
||||
|
||||
@SerializedName("expire_time")
|
||||
private Long expireTime;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package me.chanjar.weixin.cp.bean.license;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.experimental.SuperBuilder;
|
||||
|
||||
/**
|
||||
* @author Totoro
|
||||
* @date 2022-6-27 15:35:30
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@SuperBuilder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WxCpTpLicenseInvalidAccount extends WxCpTpLicenseBaseAccount {
|
||||
private static final long serialVersionUID = -3706481243147500720L;
|
||||
|
||||
@SerializedName("errcode")
|
||||
private Integer errorCode;
|
||||
@SerializedName("errmsg")
|
||||
private String errMsg;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package me.chanjar.weixin.cp.bean.license;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 详细的订单信息
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95648
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 11:38
|
||||
*/
|
||||
@Data
|
||||
public class WxCpTpLicenseOrder implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4094302825442292644L;
|
||||
|
||||
@SerializedName("order_id")
|
||||
private String orderId;
|
||||
|
||||
@SerializedName("order_type")
|
||||
private Integer orderType;
|
||||
|
||||
@SerializedName("order_status")
|
||||
private Integer orderStatus;
|
||||
|
||||
@SerializedName("corpid")
|
||||
private String corpId;
|
||||
|
||||
@SerializedName("price")
|
||||
private Long price;
|
||||
|
||||
@SerializedName("account_count")
|
||||
private WxCpTpLicenseAccountCount accountCount;
|
||||
|
||||
@SerializedName("account_duration")
|
||||
private WxCpTpLicenseAccountDuration accountDuration;
|
||||
|
||||
@SerializedName("create_time")
|
||||
private Long createTime;
|
||||
|
||||
@SerializedName("pay_time")
|
||||
private Long payTime;
|
||||
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package me.chanjar.weixin.cp.bean.license;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 11:38
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WxCpTpLicenseSimpleOrder implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -4094302825442292644L;
|
||||
|
||||
@SerializedName("order_id")
|
||||
private String orderId;
|
||||
@SerializedName("order_type")
|
||||
private Integer orderType;
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package me.chanjar.weixin.cp.bean.license;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 基础的信息
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 15:50
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WxCpTpLicenseTransfer implements Serializable {
|
||||
private static final long serialVersionUID = -5194757640985570778L;
|
||||
|
||||
|
||||
/**
|
||||
* 转移成员加密的userid
|
||||
*/
|
||||
@SerializedName("handover_userid")
|
||||
private String handoverUserId;
|
||||
|
||||
/**
|
||||
* 接收成员加密的userid
|
||||
*/
|
||||
@SerializedName("takeover_userid")
|
||||
private String takeoverUserId;
|
||||
|
||||
/**
|
||||
* 基础成功标识符,在请求继承的时候无需传入该参数,参数为企业微信返回
|
||||
* 0为成功
|
||||
*/
|
||||
@SerializedName("errcode")
|
||||
private Integer errCode;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package me.chanjar.weixin.cp.bean.license.account;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseActiveCodeInfo;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 某个企业成员的激活情况
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95555
|
||||
* @author Totoro
|
||||
* @date 2022-6-27 14:51:19
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class WxCpTpLicenseActiveInfoByUserResp extends WxCpBaseResp {
|
||||
private static final long serialVersionUID = -5172901191911873330L;
|
||||
|
||||
|
||||
@SerializedName("active_status")
|
||||
private Integer activeStatus;
|
||||
|
||||
@SerializedName("active_info_list")
|
||||
private List<WxCpTpLicenseActiveCodeInfo> activeInfoList;
|
||||
|
||||
|
||||
public static WxCpTpLicenseActiveInfoByUserResp fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseActiveInfoByUserResp.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package me.chanjar.weixin.cp.bean.license.account;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseActiveAccount;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 批量激活帐号结果
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95553
|
||||
* @author Totoro
|
||||
* @date 2022-6-27 16:19:21
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class WxCpTpLicenseBatchActiveResultResp extends WxCpBaseResp {
|
||||
|
||||
private static final long serialVersionUID = 8799524570217687659L;
|
||||
|
||||
@SerializedName("active_result")
|
||||
private List<WxCpTpLicenseActiveAccount> activeResults;
|
||||
|
||||
|
||||
|
||||
|
||||
public static WxCpTpLicenseBatchActiveResultResp fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseBatchActiveResultResp.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package me.chanjar.weixin.cp.bean.license.account;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseActiveCodeInfo;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 批量查询的激活码详情
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95553
|
||||
* @author Totoro
|
||||
* @date 2022-6-27 14:51:19
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class WxCpTpLicenseBatchCodeInfoResp extends WxCpBaseResp {
|
||||
private static final long serialVersionUID = 1327038464020790843L;
|
||||
|
||||
@SerializedName("active_info_list")
|
||||
private List<WxCpTpLicenseActiveCodeInfo> activeCodeInfoList;
|
||||
|
||||
@SerializedName("invalid_active_code_list")
|
||||
private List<String> invalidActiveCodeList;
|
||||
|
||||
|
||||
public static WxCpTpLicenseBatchCodeInfoResp fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseBatchCodeInfoResp.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package me.chanjar.weixin.cp.bean.license.account;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseTransfer;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 基础结果返回信息
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95673
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 15:49
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class WxCpTpLicenseBatchTransferResp extends WxCpBaseResp {
|
||||
private static final long serialVersionUID = 5443977430756597486L;
|
||||
|
||||
@SerializedName("transfer_result")
|
||||
private List<WxCpTpLicenseTransfer> transferResult;
|
||||
|
||||
public static WxCpTpLicenseBatchTransferResp fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseBatchTransferResp.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package me.chanjar.weixin.cp.bean.license.account;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseActiveCodeInfo;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
/**
|
||||
* 查询的激活码详情
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95553
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 14:28
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class WxCpTpLicenseCodeInfoResp extends WxCpBaseResp {
|
||||
private static final long serialVersionUID = 8058798194938243361L;
|
||||
|
||||
@SerializedName("active_info")
|
||||
private WxCpTpLicenseActiveCodeInfo activeCodeInfo;
|
||||
|
||||
|
||||
public static WxCpTpLicenseCodeInfoResp fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseCodeInfoResp.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package me.chanjar.weixin.cp.bean.license.account;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseCorpAccount;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 企业的帐号列表(已激活)
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95544
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 15:15
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class WxCpTpLicenseCorpAccountListResp extends WxCpBaseResp {
|
||||
private static final long serialVersionUID = -7976008813041959375L;
|
||||
|
||||
@SerializedName("next_cursor")
|
||||
private String nextCursor;
|
||||
|
||||
@SerializedName("has_more")
|
||||
private Integer hasMore;
|
||||
|
||||
@SerializedName("account_list")
|
||||
private List<WxCpTpLicenseCorpAccount> orderList;
|
||||
|
||||
|
||||
public static WxCpTpLicenseCorpAccountListResp fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseCorpAccountListResp.class);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package me.chanjar.weixin.cp.bean.license.order;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
/**
|
||||
* 订单创建结果
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95644
|
||||
* @author Totoro
|
||||
* @date 2022-6-27 11:26:36
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class WxCpTpLicenseCreateOrderResp extends WxCpBaseResp {
|
||||
private static final long serialVersionUID = 6644560301282598903L;
|
||||
|
||||
@SerializedName("order_id")
|
||||
private String orderId;
|
||||
|
||||
|
||||
public static WxCpTpLicenseCreateOrderResp fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseCreateOrderResp.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package me.chanjar.weixin.cp.bean.license.order;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseAccountCount;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseAccountDuration;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 下单购买帐号
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95644
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 10:52
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WxCpTpLicenseNewOrderRequest implements Serializable {
|
||||
private static final long serialVersionUID = 6644560301282598903L;
|
||||
|
||||
/**
|
||||
* 企业ID
|
||||
*/
|
||||
@SerializedName("corpid")
|
||||
private String corpId;
|
||||
|
||||
/**
|
||||
* 购买者ID
|
||||
*/
|
||||
@SerializedName("buyer_userid")
|
||||
private String buyerUserId;
|
||||
|
||||
/**
|
||||
* 账号个数
|
||||
*/
|
||||
@SerializedName("account_count")
|
||||
private WxCpTpLicenseAccountCount accountCount;
|
||||
|
||||
/**
|
||||
* 购买市场
|
||||
*/
|
||||
@SerializedName("account_duration")
|
||||
private WxCpTpLicenseAccountDuration accountDuration;
|
||||
|
||||
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package me.chanjar.weixin.cp.bean.license.order;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseAccount;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 获取订单中的帐号列表
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95649
|
||||
* @author Totoro
|
||||
* @date 2022-6-27 14:14:40
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WxCpTpLicenseOrderAccountListResp extends WxCpBaseResp {
|
||||
private static final long serialVersionUID = 470154227651487230L;
|
||||
|
||||
@SerializedName("next_cursor")
|
||||
private String nextCursor;
|
||||
|
||||
@SerializedName("has_more")
|
||||
private Integer hasMore;
|
||||
|
||||
@SerializedName("account_list")
|
||||
private List<WxCpTpLicenseAccount> accountList;
|
||||
|
||||
|
||||
public static WxCpTpLicenseOrderAccountListResp fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseOrderAccountListResp.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package me.chanjar.weixin.cp.bean.license.order;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseOrder;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
/**
|
||||
* 订单详情结果
|
||||
* 文档:https://developer.work.weixin.qq.com/document/path/95648
|
||||
* @author Totoro
|
||||
* @date 2022/06/27 11:56:03
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class WxCpTpLicenseOrderInfoResp extends WxCpBaseResp {
|
||||
|
||||
private static final long serialVersionUID = 7000171280773370910L;
|
||||
|
||||
private WxCpTpLicenseOrder order;
|
||||
|
||||
|
||||
public static WxCpTpLicenseOrderInfoResp fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseOrderInfoResp.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package me.chanjar.weixin.cp.bean.license.order;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseSimpleOrder;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 获取订单列表详情
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95647
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 11:39
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class WxCpTpLicenseOrderListResp extends WxCpBaseResp {
|
||||
private static final long serialVersionUID = 1878909432164961275L;
|
||||
|
||||
@SerializedName("next_cursor")
|
||||
private String nextCursor;
|
||||
|
||||
@SerializedName("has_more")
|
||||
private Integer hasMore;
|
||||
|
||||
@SerializedName("order_list")
|
||||
private List<WxCpTpLicenseSimpleOrder> orderList;
|
||||
|
||||
|
||||
public static WxCpTpLicenseOrderListResp fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseOrderListResp.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,49 @@
|
||||
package me.chanjar.weixin.cp.bean.license.order;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseBaseAccount;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 创建下单续期帐号任务
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95646
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 11:12
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WxCpTpLicenseRenewOrderJobRequest implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 8074896339359557034L;
|
||||
/**
|
||||
* 对应的企业ID
|
||||
*/
|
||||
@SerializedName("corpid")
|
||||
private String corpId;
|
||||
/**
|
||||
* 续费的用户UserId
|
||||
*/
|
||||
@SerializedName("account_list")
|
||||
private List<WxCpTpLicenseBaseAccount> accountList;
|
||||
/**
|
||||
* 任务id,若不传则默认创建一个新任务。若指定第一次调用后拿到jobid,可以通过该接口将jobid关联多个userid
|
||||
*/
|
||||
@SerializedName("jobid")
|
||||
private String jobId;
|
||||
|
||||
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package me.chanjar.weixin.cp.bean.license.order;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseInvalidAccount;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 创建下单购买帐号任务返回结果
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95646
|
||||
* @author Totoro
|
||||
* @date 2022-6-27 11:15:20
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class WxCpTpLicenseRenewOrderJobResp extends WxCpBaseResp {
|
||||
|
||||
private static final long serialVersionUID = -4469875729545594102L;
|
||||
/**
|
||||
* 任务ID
|
||||
*/
|
||||
@SerializedName("jobid")
|
||||
private String jobId;
|
||||
/**
|
||||
* 有效的续费账号列表
|
||||
*/
|
||||
@SerializedName("invalid_account_list")
|
||||
private List<WxCpTpLicenseInvalidAccount> invalidAccountList;
|
||||
|
||||
|
||||
|
||||
public static WxCpTpLicenseRenewOrderJobResp fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpLicenseRenewOrderJobResp.class);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package me.chanjar.weixin.cp.bean.license.order;
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseAccountDuration;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 续期帐号订单
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95646
|
||||
* @author Totoro
|
||||
* @date 2022-6-27 11:21:51
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class WxCpTpLicenseRenewOrderRequest implements Serializable {
|
||||
private static final long serialVersionUID = 8709132346969663049L;
|
||||
|
||||
@SerializedName("buyer_userid")
|
||||
private String buyerUserId;
|
||||
@SerializedName("jobid")
|
||||
private String jobId;
|
||||
@SerializedName("account_duration")
|
||||
private WxCpTpLicenseAccountDuration accountDuration;
|
||||
|
||||
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -271,6 +271,22 @@ public interface WxCpApiPathConsts {
|
||||
|
||||
}
|
||||
|
||||
interface License {
|
||||
String CREATE_NEW_ORDER = "/cgi-bin/license/create_new_order";
|
||||
String CREATE_RENEW_ORDER_JOB = "/cgi-bin/license/create_renew_order_job";
|
||||
String SUBMIT_ORDER_JOB = "/cgi-bin/license/submit_order_job";
|
||||
String LIST_ORDER = "/cgi-bin/license/list_order";
|
||||
String GET_ORDER = "/cgi-bin/license/get_order";
|
||||
String LIST_ORDER_ACCOUNT = "/cgi-bin/license/list_order_account";
|
||||
String ACTIVE_ACCOUNT = "/cgi-bin/license/active_account";
|
||||
String BATCH_ACTIVE_ACCOUNT = "/cgi-bin/license/batch_active_account";
|
||||
String GET_ACTIVE_INFO_BY_CODE = "/cgi-bin/license/get_active_info_by_code";
|
||||
String BATCH_GET_ACTIVE_INFO_BY_CODE = "/cgi-bin/license/batch_get_active_info_by_code";
|
||||
String LIST_ACTIVED_ACCOUNT = "/cgi-bin/license/list_actived_account";
|
||||
String GET_ACTIVE_INFO_BY_USER = "/cgi-bin/license/get_active_info_by_user";
|
||||
String BATCH_TRANSFER_LICENSE = "/cgi-bin/license/batch_transfer_license";
|
||||
}
|
||||
|
||||
interface User {
|
||||
String USER_AUTHENTICATE = "/cgi-bin/user/authsucc?userid=";
|
||||
String USER_CREATE = "/cgi-bin/user/create";
|
||||
|
@ -72,6 +72,23 @@ public class WxCpTpConsts {
|
||||
*/
|
||||
public static final String CHANGE_EDITION = "change_editon";
|
||||
|
||||
|
||||
/**
|
||||
* 接口许可失效通知
|
||||
*/
|
||||
public static final String UNLICENSED_NOTIFY = "unlicensed_notify";
|
||||
|
||||
/**
|
||||
* 支付成功通知
|
||||
*/
|
||||
public static final String LICENSE_PAY_SUCCESS = "license_pay_success";
|
||||
|
||||
/**
|
||||
* 退款结果通知
|
||||
*/
|
||||
public static final String LICENSE_REFUND = "license_refund";
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,212 @@
|
||||
package me.chanjar.weixin.cp.tp.service;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseActiveAccount;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseTransfer;
|
||||
import me.chanjar.weixin.cp.bean.license.account.*;
|
||||
import me.chanjar.weixin.cp.bean.license.order.*;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <pre>
|
||||
* 服务商接口调用许可相关接口
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95652
|
||||
* </pre>
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 10:57
|
||||
*/
|
||||
public interface WxCpTpLicenseService {
|
||||
|
||||
|
||||
/**
|
||||
* 下单购买帐号
|
||||
* 服务商下单为企业购买新的帐号,可以同时购买基础帐号与互通帐号。
|
||||
* 下单之后,需要到服务商管理端发起支付,支付完成之后,订单才能生效。
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95644
|
||||
* @param licenseNewOrderRequest 订单信息
|
||||
* @return 订单ID
|
||||
* @throws WxErrorException;
|
||||
*/
|
||||
WxCpTpLicenseCreateOrderResp createNewOrder(WxCpTpLicenseNewOrderRequest licenseNewOrderRequest) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 创建下单续期帐号任务
|
||||
* <pre>
|
||||
* 可以下单为一批已激活帐号的成员续期,续期下单分为两个步骤:
|
||||
* 传入userid列表创建一个任务,创建之后,可以往同一个任务继续追加待续期的userid列表;
|
||||
* 根据步骤1得到的jobid提交订单。
|
||||
* </pre>
|
||||
* @param licenseRenewOrderJobRequest 续费订单信息
|
||||
* @return 返回JobId
|
||||
* @throws WxErrorException;
|
||||
*/
|
||||
WxCpTpLicenseRenewOrderJobResp createRenewOrderJob(WxCpTpLicenseRenewOrderJobRequest licenseRenewOrderJobRequest) throws WxErrorException;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 提交续期订单
|
||||
* 创建续期任务之后,需要调用该接口,以提交订单任务。
|
||||
* 注意,提交之后,需要到服务商管理端发起支付,支付完成之后,订单才能生效。
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95646
|
||||
* @param licenseRenewOrderRequest 订单信息
|
||||
* @return 订单ID
|
||||
* @throws WxErrorException;
|
||||
*/
|
||||
WxCpTpLicenseCreateOrderResp submitRenewOrder(WxCpTpLicenseRenewOrderRequest licenseRenewOrderRequest) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 获取订单列表
|
||||
* 服务商查询自己某段时间内的平台能力服务订单列表
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95647
|
||||
* @param corpId 企业ID
|
||||
* @param startTime 开始时间,下单时间。可不填。但是不能单独指定该字段,start_time跟end_time必须同时指定。
|
||||
* @param endTime 结束时间,下单时间。起始时间跟结束时间不能超过31天。可不填。但是不能单独指定该字段,start_time跟end_time必须同时指定。
|
||||
* @param cursor 用于分页查询的游标,字符串类型,由上一次调用返回,首次调用可不填
|
||||
* @param limit 返回的最大记录数,整型,最大值1000,默认值500
|
||||
* @return 订单列表
|
||||
* @throws WxErrorException;
|
||||
*/
|
||||
WxCpTpLicenseOrderListResp getOrderList(String corpId, Date startTime, Date endTime, String cursor, int limit) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 获取订单详情
|
||||
* 查询某个订单的详情,包括订单的状态、基础帐号个数、互通帐号个数、帐号购买时长等。
|
||||
* 注意,该接口不返回订单中的帐号激活码列表或者续期的帐号成员列表,请调用获取订单中的帐号列表接口以获取帐号列表。
|
||||
* @param orderId 订单ID
|
||||
* @return 单条订单信息
|
||||
* @throws WxErrorException;
|
||||
*/
|
||||
WxCpTpLicenseOrderInfoResp getOrderInfo(String orderId) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 查询指定订单下的平台能力服务帐号列表。
|
||||
* 若为购买帐号的订单或者存量企业的版本付费迁移订单,则返回帐号激活码列表;
|
||||
* 若为续期帐号的订单,则返回续期帐号的成员列表。注意,若是购买帐号的订单,
|
||||
* 则仅订单支付完成时,系统才会生成帐号,故支付完成之前,该接口不会返回帐号激活码。
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95649
|
||||
* @param orderId 订单ID
|
||||
* @param limit 大小
|
||||
* @param cursor 分页游标
|
||||
* @return 订单账号列表
|
||||
* @throws WxErrorException;
|
||||
*/
|
||||
WxCpTpLicenseOrderAccountListResp getOrderAccountList(String orderId, int limit, String cursor) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 激活帐号
|
||||
* 下单购买帐号并支付完成之后,先调用获取订单中的帐号列表接口获取到帐号激活码,
|
||||
* 然后可以调用该接口将激活码绑定到某个企业员工,以对其激活相应的平台服务能力。
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95553
|
||||
* @param code 激活码
|
||||
* @param corpId 企业ID
|
||||
* @param userId 用户ID
|
||||
* @return 激活结果
|
||||
* @throws WxErrorException;
|
||||
*/
|
||||
WxCpBaseResp activeCode(String code, String corpId, String userId) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 批量激活帐号
|
||||
* 可在一次请求里为一个企业的多个成员激活许可帐号,便于服务商批量化处理。
|
||||
* 一个userid允许激活一个基础帐号以及一个互通帐号。
|
||||
* 单次激活的员工数量不超过1000
|
||||
* @param corpId 企业ID
|
||||
* @param activeAccountList 激活列表
|
||||
* @return 激活结果
|
||||
* @throws WxErrorException;
|
||||
*/
|
||||
WxCpTpLicenseBatchActiveResultResp batchActiveCode(String corpId, List<WxCpTpLicenseActiveAccount> activeAccountList) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 获取激活码详情
|
||||
* 查询某个帐号激活码的状态以及激活绑定情况。
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95552
|
||||
* @param code 激活码
|
||||
* @param corpId 企业ID
|
||||
* @return 激活码信息
|
||||
* @throws WxErrorException;
|
||||
*/
|
||||
WxCpTpLicenseCodeInfoResp getActiveInfoByCode(String code, String corpId) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 获取激活码详情
|
||||
* 查询某个帐号激活码的状态以及激活绑定情况。
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95552
|
||||
* @param codes 激活码
|
||||
* @param corpId 企业ID
|
||||
* @return 激活码信息
|
||||
* @throws WxErrorException;
|
||||
*/
|
||||
WxCpTpLicenseBatchCodeInfoResp batchGetActiveInfoByCode(Collection<String> codes, String corpId) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 获取企业的帐号列表
|
||||
* 查询指定企业下的平台能力服务帐号列表。
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95544
|
||||
* @param corpId 企业ID
|
||||
* @param limit 大小
|
||||
* @param cursor 游标
|
||||
* @return 已激活列表
|
||||
* @throws WxErrorException
|
||||
*/
|
||||
WxCpTpLicenseCorpAccountListResp getCorpAccountList(String corpId, int limit, String cursor) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 获取成员的激活详情
|
||||
* 查询某个企业成员的激活情况。
|
||||
* 文档地址:https://developer.work.weixin.qq.com/document/path/95555
|
||||
* @param corpId 企业ID
|
||||
* @param userId 用户ID
|
||||
* @return 激活情况
|
||||
* @throws WxErrorException;
|
||||
*/
|
||||
WxCpTpLicenseActiveInfoByUserResp getActiveInfoByUser(String corpId, String userId) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 帐号继承
|
||||
* 在企业员工离职或者工作范围的有变更时,允许将其许可帐号继承给其他员工。
|
||||
* @param corpId 企业ID
|
||||
* @param transferList 转移列表
|
||||
* @return 转移结果
|
||||
* @throws WxErrorException;
|
||||
*/
|
||||
WxCpTpLicenseBatchTransferResp batchTransferLicense(String corpId, List<WxCpTpLicenseTransfer> transferList) throws WxErrorException;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -474,6 +474,21 @@ public interface WxCpTpService {
|
||||
*/
|
||||
void setWxCpTpUserService(WxCpTpUserService wxCpTpUserService);
|
||||
|
||||
/**
|
||||
* set license service
|
||||
*
|
||||
* @param wxCpTpLicenseService the oa service
|
||||
*/
|
||||
void setWxCpTpLicenseService(WxCpTpLicenseService wxCpTpLicenseService);
|
||||
|
||||
|
||||
/**
|
||||
* get license service
|
||||
*
|
||||
* @return getCpTPLicenseService wx cp tp license service
|
||||
*/
|
||||
WxCpTpLicenseService getWxCpTpLicenseService();
|
||||
|
||||
/**
|
||||
* 获取应用的管理员列表
|
||||
*
|
||||
|
@ -50,6 +50,7 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ
|
||||
private WxCpTpUserService wxCpTpUserService = new WxCpTpUserServiceImpl(this);
|
||||
private WxCpTpOrderService wxCpTpOrderService = new WxCpTpOrderServiceImpl(this);
|
||||
private WxCpTpEditionService wxCpTpEditionService = new WxCpTpEditionServiceImpl(this);
|
||||
private WxCpTpLicenseService wxCpTpLicenseService = new WxCpTpLicenseServiceImpl(this);
|
||||
|
||||
/**
|
||||
* 全局的是否正在刷新access token的锁.
|
||||
@ -547,6 +548,18 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ
|
||||
this.wxCpTpOAService = wxCpTpOAService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public WxCpTpLicenseService getWxCpTpLicenseService() {
|
||||
return wxCpTpLicenseService;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setWxCpTpLicenseService(WxCpTpLicenseService wxCpTpLicenseService) {
|
||||
this.wxCpTpLicenseService = wxCpTpLicenseService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWxCpTpUserService(WxCpTpUserService wxCpTpUserService) {
|
||||
this.wxCpTpUserService = wxCpTpUserService;
|
||||
|
@ -0,0 +1,193 @@
|
||||
package me.chanjar.weixin.cp.tp.service.impl;
|
||||
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonPrimitive;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseActiveAccount;
|
||||
import me.chanjar.weixin.cp.bean.license.WxCpTpLicenseTransfer;
|
||||
import me.chanjar.weixin.cp.bean.license.account.*;
|
||||
import me.chanjar.weixin.cp.bean.license.order.*;
|
||||
import me.chanjar.weixin.cp.config.WxCpTpConfigStorage;
|
||||
import me.chanjar.weixin.cp.tp.service.WxCpTpLicenseService;
|
||||
import me.chanjar.weixin.cp.tp.service.WxCpTpService;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.License.*;
|
||||
|
||||
/**
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 11:03
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class WxCpTpLicenseServiceImpl implements WxCpTpLicenseService {
|
||||
|
||||
private final WxCpTpService mainService;
|
||||
|
||||
@Override
|
||||
public WxCpTpLicenseCreateOrderResp createNewOrder(WxCpTpLicenseNewOrderRequest licenseNewOrderRequest) throws WxErrorException {
|
||||
String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(CREATE_NEW_ORDER) +
|
||||
getProviderAccessToken(), licenseNewOrderRequest.toJson());
|
||||
return WxCpTpLicenseCreateOrderResp.fromJson(resultText);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public WxCpTpLicenseRenewOrderJobResp createRenewOrderJob(WxCpTpLicenseRenewOrderJobRequest licenseRenewOrderJobRequest) throws WxErrorException {
|
||||
String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(CREATE_RENEW_ORDER_JOB) +
|
||||
getProviderAccessToken(), licenseRenewOrderJobRequest.toJson());
|
||||
return WxCpTpLicenseRenewOrderJobResp.fromJson(resultText);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public WxCpTpLicenseCreateOrderResp submitRenewOrder(WxCpTpLicenseRenewOrderRequest licenseRenewOrderRequest) throws WxErrorException {
|
||||
String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(SUBMIT_ORDER_JOB) +
|
||||
getProviderAccessToken(), licenseRenewOrderRequest.toJson());
|
||||
return WxCpTpLicenseCreateOrderResp.fromJson(resultText);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public WxCpTpLicenseOrderListResp getOrderList(String corpId, Date startTime, Date endTime, String cursor, int limit) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("corpid", corpId);
|
||||
jsonObject.addProperty("cursor", cursor);
|
||||
jsonObject.addProperty("limit", limit);
|
||||
if(startTime != null) {
|
||||
jsonObject.addProperty("start_time", startTime.getTime() / 1000);
|
||||
}
|
||||
if(endTime != null) {
|
||||
jsonObject.addProperty("end_time", endTime.getTime() / 1000);
|
||||
}
|
||||
String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(LIST_ORDER) +
|
||||
getProviderAccessToken(), jsonObject.toString());
|
||||
return WxCpTpLicenseOrderListResp.fromJson(resultText);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public WxCpTpLicenseOrderInfoResp getOrderInfo(String orderId) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("order_id", orderId);
|
||||
String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(GET_ORDER) +
|
||||
getProviderAccessToken(), jsonObject.toString());
|
||||
return WxCpTpLicenseOrderInfoResp.fromJson(resultText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpTpLicenseOrderAccountListResp getOrderAccountList(String orderId, int limit, String cursor) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("order_id", orderId);
|
||||
jsonObject.addProperty("cursor", cursor);
|
||||
jsonObject.addProperty("limit", limit);
|
||||
String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(LIST_ORDER_ACCOUNT) +
|
||||
getProviderAccessToken(), jsonObject.toString());
|
||||
return WxCpTpLicenseOrderAccountListResp.fromJson(resultText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpBaseResp activeCode(String code, String corpId, String userId) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("active_code", code);
|
||||
jsonObject.addProperty("corpid", corpId);
|
||||
jsonObject.addProperty("userid", userId);
|
||||
String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(ACTIVE_ACCOUNT) +
|
||||
getProviderAccessToken(), jsonObject.toString());
|
||||
return WxCpBaseResp.fromJson(resultText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpTpLicenseBatchActiveResultResp batchActiveCode(String corpId, List<WxCpTpLicenseActiveAccount> activeAccountList) throws WxErrorException {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("corpid", corpId);
|
||||
map.put("active_list", activeAccountList);
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(BATCH_ACTIVE_ACCOUNT) +
|
||||
getProviderAccessToken(), gsonBuilder.create().toJson(map));
|
||||
return WxCpTpLicenseBatchActiveResultResp.fromJson(resultText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpTpLicenseCodeInfoResp getActiveInfoByCode(String code, String corpId) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("active_code", code);
|
||||
jsonObject.addProperty("corpid", corpId);
|
||||
String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(GET_ACTIVE_INFO_BY_CODE) +
|
||||
getProviderAccessToken(), jsonObject.toString());
|
||||
return WxCpTpLicenseCodeInfoResp.fromJson(resultText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpTpLicenseBatchCodeInfoResp batchGetActiveInfoByCode(Collection<String> codes, String corpId) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
JsonArray list = new JsonArray();
|
||||
for (String code : codes) {
|
||||
list.add(new JsonPrimitive(code));
|
||||
}
|
||||
jsonObject.add("active_code_list", list);
|
||||
jsonObject.addProperty("corpid", corpId);
|
||||
String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(BATCH_GET_ACTIVE_INFO_BY_CODE) +
|
||||
getProviderAccessToken(), jsonObject.toString());
|
||||
return WxCpTpLicenseBatchCodeInfoResp.fromJson(resultText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpTpLicenseCorpAccountListResp getCorpAccountList(String corpId, int limit, String cursor) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("corpid", corpId);
|
||||
jsonObject.addProperty("cursor", cursor);
|
||||
jsonObject.addProperty("limit", limit);
|
||||
String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(LIST_ACTIVED_ACCOUNT) +
|
||||
getProviderAccessToken(), jsonObject.toString());
|
||||
return WxCpTpLicenseCorpAccountListResp.fromJson(resultText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpTpLicenseActiveInfoByUserResp getActiveInfoByUser(String corpId, String userId) throws WxErrorException {
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("corpid", corpId);
|
||||
jsonObject.addProperty("userid", userId);
|
||||
String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(GET_ACTIVE_INFO_BY_USER) +
|
||||
getProviderAccessToken(), jsonObject.toString());
|
||||
return WxCpTpLicenseActiveInfoByUserResp.fromJson(resultText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpTpLicenseBatchTransferResp batchTransferLicense(String corpId, List<WxCpTpLicenseTransfer> transferList) throws WxErrorException {
|
||||
Map<String, Object> map = new HashMap<>(2);
|
||||
map.put("corpid", corpId);
|
||||
map.put("transfer_list", transferList);
|
||||
GsonBuilder gsonBuilder = new GsonBuilder();
|
||||
String resultText = mainService.post(getWxCpTpConfigStorage().getApiUrl(BATCH_TRANSFER_LICENSE) +
|
||||
getProviderAccessToken(), gsonBuilder.create().toJson(map));
|
||||
return WxCpTpLicenseBatchTransferResp.fromJson(resultText);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取服务商token的拼接参数
|
||||
* @return url
|
||||
* @throws WxErrorException /
|
||||
*/
|
||||
private String getProviderAccessToken() throws WxErrorException {
|
||||
return "?provider_access_token=" + mainService.getWxCpProviderToken();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取tp参数配置
|
||||
* @return config
|
||||
*/
|
||||
private WxCpTpConfigStorage getWxCpTpConfigStorage() {
|
||||
return mainService.getWxCpTpConfigStorage();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,457 @@
|
||||
package me.chanjar.weixin.cp.tp.service.impl;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.bean.license.*;
|
||||
import me.chanjar.weixin.cp.bean.license.account.*;
|
||||
import me.chanjar.weixin.cp.bean.license.order.*;
|
||||
import me.chanjar.weixin.cp.config.WxCpTpConfigStorage;
|
||||
import me.chanjar.weixin.cp.config.impl.WxCpTpDefaultConfigImpl;
|
||||
import me.chanjar.weixin.cp.tp.service.WxCpTpLicenseService;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.License.*;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
|
||||
/**
|
||||
* 许可证账号服务测试
|
||||
* @author Totoro
|
||||
* @date 2022/6/27 16:34
|
||||
*/
|
||||
public class WxCpTpLicenseServiceImplTest {
|
||||
|
||||
@Mock
|
||||
private WxCpTpServiceApacheHttpClientImpl wxCpTpService;
|
||||
|
||||
private WxCpTpConfigStorage configStorage;
|
||||
|
||||
private WxCpTpLicenseService wxCpTpLicenseService;
|
||||
|
||||
@BeforeClass
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
configStorage = new WxCpTpDefaultConfigImpl();
|
||||
when(wxCpTpService.getWxCpTpConfigStorage()).thenReturn(configStorage);
|
||||
wxCpTpLicenseService = new WxCpTpLicenseServiceImpl(wxCpTpService);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCrateNewOrder() throws WxErrorException {
|
||||
String orderId = "OASFNAISFASFA252462";
|
||||
String result = "{\n" +
|
||||
"\t\"errcode\": 0,\n" +
|
||||
"\t\"errmsg\": \"ok\",\n" +
|
||||
"\t\"order_id\": \"OASFNAISFASFA252462\"\n" +
|
||||
"}";
|
||||
String url = configStorage.getApiUrl(CREATE_NEW_ORDER) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken();
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
WxCpTpLicenseNewOrderRequest orderRequest = WxCpTpLicenseNewOrderRequest.builder()
|
||||
.accountCount(WxCpTpLicenseAccountCount.builder().baseCount(5).externalContactCount(6).build())
|
||||
.buyerUserId("test")
|
||||
.corpId("test")
|
||||
.accountDuration(WxCpTpLicenseAccountDuration.builder().months(5).build())
|
||||
.build();
|
||||
final WxCpTpLicenseCreateOrderResp newOrder = wxCpTpLicenseService.createNewOrder(orderRequest);
|
||||
assertNotNull(newOrder);
|
||||
assertEquals(newOrder.getOrderId(), orderId);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testCreateRenewOrderJob() throws WxErrorException {
|
||||
String jobId = "test123456";
|
||||
String result = "{\n" +
|
||||
" \"errcode\":0,\n" +
|
||||
" \"errmsg\":\"ok\",\n" +
|
||||
" \"jobid\":\"test123456\",\n" +
|
||||
" \"invalid_account_list\":[\n" +
|
||||
" {\n" +
|
||||
" \"errcode\":1,\n" +
|
||||
" \"errmsg\":\"error\",\n" +
|
||||
" \"userid\":\"userid1\",\n" +
|
||||
" \"type\":1\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"errcode\":0,\n" +
|
||||
" \"errmsg\":\"ok\",\n" +
|
||||
" \"userid\":\"userid2\",\n" +
|
||||
" \"type\":1\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
"}";
|
||||
String url = configStorage.getApiUrl(CREATE_RENEW_ORDER_JOB) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken();
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
List<WxCpTpLicenseBaseAccount> accountList = new ArrayList<>();
|
||||
accountList.add(WxCpTpLicenseBaseAccount.builder().type(1).userid("userid1").build());
|
||||
accountList.add(WxCpTpLicenseBaseAccount.builder().type(1).userid("userid2").build());
|
||||
WxCpTpLicenseRenewOrderJobRequest orderJobRequest = WxCpTpLicenseRenewOrderJobRequest.builder()
|
||||
.jobId("test123456")
|
||||
.accountList(accountList).build();
|
||||
final WxCpTpLicenseRenewOrderJobResp renewOrderJob = wxCpTpLicenseService.createRenewOrderJob(orderJobRequest);
|
||||
assertNotNull(renewOrderJob);
|
||||
|
||||
assertEquals(renewOrderJob.getJobId(), jobId);
|
||||
|
||||
assertEquals(renewOrderJob.getInvalidAccountList().size(), accountList.size());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSubmitRenewOrderJob() throws WxErrorException {
|
||||
String orderId = "test5915231";
|
||||
String result = "{\n" +
|
||||
"\t\"errcode\": 0,\n" +
|
||||
"\t\"errmsg\": \"ok\",\n" +
|
||||
"\t\"order_id\": \"test5915231\"\n" +
|
||||
"}";
|
||||
String url = configStorage.getApiUrl(SUBMIT_ORDER_JOB) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken();
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
WxCpTpLicenseRenewOrderRequest renewOrderRequest = WxCpTpLicenseRenewOrderRequest.builder()
|
||||
.jobId("test123456")
|
||||
.accountDuration(WxCpTpLicenseAccountDuration.builder().months(5).build())
|
||||
.buyerUserId("test")
|
||||
.build();
|
||||
WxCpTpLicenseCreateOrderResp createOrderResp = wxCpTpLicenseService.submitRenewOrder(renewOrderRequest);
|
||||
assertNotNull(createOrderResp);
|
||||
|
||||
assertEquals(createOrderResp.getOrderId(), orderId);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetOrderList() throws WxErrorException {
|
||||
String nextCursor = "DSGAKAFA4524";
|
||||
String orderId = "test123";
|
||||
String result = "{\n" +
|
||||
"\t\"errcode\": 0,\n" +
|
||||
"\t\"errmsg\": \"ok\",\n" +
|
||||
"\t\"next_cursor\":\"DSGAKAFA4524\",\n" +
|
||||
"\t\"has_more\":1,\n" +
|
||||
"\t\"order_list\":[\n" +
|
||||
"\t\t{\n" +
|
||||
"\t\t\t\"order_id\":\"test123\",\n" +
|
||||
"\t\t\t\"order_type\":1\n" +
|
||||
"\t\t}\n" +
|
||||
"\t]\n" +
|
||||
"}";
|
||||
|
||||
String url = configStorage.getApiUrl(LIST_ORDER) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken();
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
WxCpTpLicenseOrderListResp orderList = wxCpTpLicenseService.getOrderList("test", new Date(), new Date(), null, 10);
|
||||
assertNotNull(orderList);
|
||||
|
||||
assertEquals(orderList.getNextCursor(), nextCursor);
|
||||
|
||||
assertEquals(orderList.getOrderList().get(0).getOrderId(), orderId);
|
||||
|
||||
}
|
||||
@Test
|
||||
public void testGetOrder() throws WxErrorException {
|
||||
String corpId = "ASFASF4254";
|
||||
String orderId = "FASASIFJ9W125234";
|
||||
String result = "{\n" +
|
||||
"\t\"errcode\": 0,\n" +
|
||||
"\t\"errmsg\": \"ok\",\n" +
|
||||
"\t\"order\":{\n" +
|
||||
"\t\t\"order_id\":\"FASASIFJ9W125234\",\n" +
|
||||
"\t\t\"order_type\":1,\n" +
|
||||
"\t\t\"order_status\":1,\n" +
|
||||
"\t\t\"corpid\":\"ASFASF4254\",\n" +
|
||||
"\t\t\"price\":10000,\n" +
|
||||
"\t\t\"account_count\":{\n" +
|
||||
"\t \t \"base_count\":100,\n" +
|
||||
" \t \"external_contact_count\":100\n" +
|
||||
"\t },\n" +
|
||||
"\t\t \"account_duration\":\n" +
|
||||
" \t\t {\n" +
|
||||
"\t \t \t\"months\":2\n" +
|
||||
" \t \t \t},\n" +
|
||||
"\t\t\"create_time\":150000000,\n" +
|
||||
"\t \"pay_time\":1550000000\n" +
|
||||
"\t}\n" +
|
||||
"}";
|
||||
String url = configStorage.getApiUrl(GET_ORDER) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken();
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
WxCpTpLicenseOrderInfoResp orderInfo = wxCpTpLicenseService.getOrderInfo(orderId);
|
||||
assertNotNull(orderInfo);
|
||||
|
||||
assertNotNull(orderInfo.getOrder());
|
||||
|
||||
assertEquals(orderInfo.getOrder().getOrderId(), orderId);
|
||||
|
||||
assertEquals(orderInfo.getOrder().getCorpId(), corpId);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetOrderAccount() throws WxErrorException {
|
||||
String orderId = "ASFASF4254";
|
||||
String activeCode = "FASASIFJ9W125234";
|
||||
String result = "{\n" +
|
||||
"\t\"errcode\": 0,\n" +
|
||||
"\t\"errmsg\": \"ok\",\n" +
|
||||
"\t\"next_cursor\": \"ASFASF4254\",\n" +
|
||||
"\t\"has_more\":1,\n" +
|
||||
"\t\"account_list\":[\n" +
|
||||
"\t\t{\n" +
|
||||
"\t\t\t\"active_code\": \"FASASIFJ9W125234\",\n" +
|
||||
"\t\t\t\"userid\":\"XXX\",\n" +
|
||||
"\t\t\t\"type\": 1\n" +
|
||||
"\t\t},\n" +
|
||||
"\t\t{\n" +
|
||||
"\t\t\t\"active_code\": \"code2\",\n" +
|
||||
"\t\t\t\"userid\":\"XXX\",\n" +
|
||||
"\t\t\t\"type\": 2\n" +
|
||||
"\t\t}\n" +
|
||||
"\t]\n" +
|
||||
"}";
|
||||
|
||||
String url = configStorage.getApiUrl(LIST_ORDER_ACCOUNT) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken();
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
WxCpTpLicenseOrderAccountListResp orderAccountList = wxCpTpLicenseService.getOrderAccountList(orderId, 10, null);
|
||||
assertNotNull(orderAccountList);
|
||||
|
||||
assertNotNull(orderAccountList.getAccountList());
|
||||
|
||||
assertEquals(orderAccountList.getAccountList().get(0).getActiveCode(), activeCode);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testActiveAccount() throws WxErrorException {
|
||||
String result = "{\n" +
|
||||
"\t\"errcode\": 0,\n" +
|
||||
"\t\"errmsg\": \"ok\"\n" +
|
||||
"}";
|
||||
|
||||
String url = configStorage.getApiUrl(ACTIVE_ACCOUNT) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken();
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
WxCpBaseResp wxCpBaseResp = wxCpTpLicenseService.activeCode("123456", "123456", "123456");
|
||||
assertNotNull(wxCpBaseResp);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBatchActiveAccount() throws WxErrorException {
|
||||
String result = "{\n" +
|
||||
"\t\"errcode\": 0,\n" +
|
||||
"\t\"errmsg\": \"ok\",\n" +
|
||||
"\t\"active_result\":[\n" +
|
||||
"\t{\n" +
|
||||
"\t\t\"active_code\" : \"aASFINAJOFASF\",\n" +
|
||||
"\t\t\"userid\": \"SAGASGSD\",\n" +
|
||||
"\t\t\"errcode\":0\n" +
|
||||
"\t},\n" +
|
||||
"\t{\n" +
|
||||
"\t\t\"active_code\" : \"ASDEGAFAd\",\n" +
|
||||
"\t\t\"userid\": \"dsfafD\",\n" +
|
||||
"\t\t\"errcode\":0\n" +
|
||||
"\t}]\n" +
|
||||
"}";
|
||||
String url = configStorage.getApiUrl(BATCH_ACTIVE_ACCOUNT) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken();
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
List<WxCpTpLicenseActiveAccount> accountList = new ArrayList<>();
|
||||
accountList.add(WxCpTpLicenseActiveAccount.builder().userid("SAGASGSD").activeCode("aASFINAJOFASF").build());
|
||||
accountList.add(WxCpTpLicenseActiveAccount.builder().userid("dsfafD").activeCode("ASDEGAFAd").build());
|
||||
WxCpTpLicenseBatchActiveResultResp wxCpTpLicenseBatchActiveResultResp = wxCpTpLicenseService.batchActiveCode("123456", accountList);
|
||||
assertNotNull(wxCpTpLicenseBatchActiveResultResp);
|
||||
|
||||
assertEquals(wxCpTpLicenseBatchActiveResultResp.getActiveResults().size(), accountList.size());
|
||||
|
||||
assertEquals(wxCpTpLicenseBatchActiveResultResp.getActiveResults().get(0).getActiveCode(), "aASFINAJOFASF");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetActiveInfoByCode() throws WxErrorException {
|
||||
String activeCode = "asgasfasfa";
|
||||
String result = "{\n" +
|
||||
"\t\"errcode\": 0,\n" +
|
||||
"\t\"errmsg\": \"ok\",\n" +
|
||||
"\t\"active_info\": {\n" +
|
||||
"\t\t\"active_code\": \"asgasfasfa\",\n" +
|
||||
"\t\t\"type\": 1,\n" +
|
||||
"\t\t\"status\": 1,\n" +
|
||||
"\t\t\"userid\": \"asfasgasg\",\n" +
|
||||
"\t\t\"create_time\":1640966400,\n" +
|
||||
"\t\t\"active_time\": 1640966400,\n" +
|
||||
"\t\t\"expire_time\":1640966400\n" +
|
||||
"\t}\n" +
|
||||
"}";
|
||||
|
||||
String url = configStorage.getApiUrl(GET_ACTIVE_INFO_BY_CODE) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken();
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
WxCpTpLicenseCodeInfoResp activeInfoByCode = wxCpTpLicenseService.getActiveInfoByCode("123456", "safasg");
|
||||
assertNotNull(activeInfoByCode);
|
||||
|
||||
assertEquals(activeInfoByCode.getActiveCodeInfo().getActiveCode(), activeCode);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetActiveInfoByUser() throws WxErrorException {
|
||||
String activeCode = "asfaisfhiuaw";
|
||||
String userid = "asfasgasga";
|
||||
String result = "{\n" +
|
||||
"\t\"errcode\": 0,\n" +
|
||||
"\t\"errmsg\": \"ok\",\n" +
|
||||
"\t\"active_status\": 1,\n" +
|
||||
"\t\"active_info_list\": \n" +
|
||||
"\t[\n" +
|
||||
"\t\t {\n" +
|
||||
"\t\t\t\"active_code\": \"asfaisfhiuaw\",\n" +
|
||||
"\t\t\t\"type\": 1,\n" +
|
||||
"\t\t\t\"userid\": \"asfasgasga\",\n" +
|
||||
"\t\t\t\"active_time\": 1640966400,\n" +
|
||||
"\t\t\t\"expire_time\":1640966400\n" +
|
||||
" \t \t },\n" +
|
||||
" {\n" +
|
||||
"\t\t\t\"active_code\": \"gasdawsd\",\n" +
|
||||
"\t\t\t\"type\": 2,\n" +
|
||||
"\t\t\t\"userid\": \"asdfasfasf\",\n" +
|
||||
"\t\t\t\"active_time\":1640966400,\n" +
|
||||
"\t\t\t\"expire_time\":1640966400\n" +
|
||||
"\t\t }\n" +
|
||||
" ]\n" +
|
||||
"}";
|
||||
|
||||
String url = configStorage.getApiUrl(GET_ACTIVE_INFO_BY_USER) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken();
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
WxCpTpLicenseActiveInfoByUserResp activeInfoByUser = wxCpTpLicenseService.getActiveInfoByUser("123456", userid);
|
||||
assertNotNull(activeInfoByUser);
|
||||
|
||||
assertEquals(activeInfoByUser.getActiveStatus().intValue(), 1);
|
||||
|
||||
assertEquals(activeInfoByUser.getActiveInfoList().get(0).getActiveCode(), activeCode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBatchGetActiveInfoByUser() throws WxErrorException {
|
||||
String activeCode = "asgasgasgas";
|
||||
String result = "{\n" +
|
||||
"\t\"errcode\": 0,\n" +
|
||||
"\t\"errmsg\": \"ok\",\n" +
|
||||
"\t\"active_info_list\": [\n" +
|
||||
"\t\t{\n" +
|
||||
"\t\t\t\"active_code\": \"asgasgasgas\",\n" +
|
||||
"\t\t\t\"type\": 1,\n" +
|
||||
"\t\t\t\"status\": 1,\n" +
|
||||
"\t\t\t\"userid\": \"gadfFDF\",\n" +
|
||||
"\t\t\t\"create_time\":1640966400,\n" +
|
||||
"\t\t\t\"active_time\": 1640966400,\n" +
|
||||
"\t\t\t\"expire_time\":1640966400\n" +
|
||||
"\t\t},\n" +
|
||||
"\t\t{\n" +
|
||||
"\t\t\t\"active_code\": \"awsgdgasdasd\",\n" +
|
||||
"\t\t\t\"type\": 2,\n" +
|
||||
"\t\t\t\"status\": 1,\n" +
|
||||
"\t\t\t\"userid\": \"SGASRDASGAQ\",\n" +
|
||||
"\t\t\t\"create_time\":1640966400,\n" +
|
||||
"\t\t\t\"active_time\": 1640966400,\n" +
|
||||
"\t\t\t\"expire_time\":1640966400\n" +
|
||||
"\t\t}\n" +
|
||||
"\t],\n" +
|
||||
"\t\"invalid_active_code_list\":[\"fasgasga\"]\n" +
|
||||
"}";
|
||||
|
||||
|
||||
String url = configStorage.getApiUrl(BATCH_GET_ACTIVE_INFO_BY_CODE) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken();
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
Set<String> codes = new HashSet<>();
|
||||
codes.add("asgasgasgas");
|
||||
codes.add("awsgdgasdasd");
|
||||
codes.add("fasgasga");
|
||||
WxCpTpLicenseBatchCodeInfoResp codeInfoResp = wxCpTpLicenseService.batchGetActiveInfoByCode(codes, "asfasfas");
|
||||
assertNotNull(codeInfoResp);
|
||||
|
||||
assertEquals(codeInfoResp.getActiveCodeInfoList().size() , codes.size() - 1);
|
||||
|
||||
assertNotNull(codeInfoResp.getInvalidActiveCodeList());
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testGetCorpAccountList() throws WxErrorException {
|
||||
String nextCursor = "asfasdfas";
|
||||
String userid = "asdasdasd";
|
||||
String result = "{\n" +
|
||||
"\t\"errcode\": 0,\n" +
|
||||
"\t\"errmsg\": \"ok\",\n" +
|
||||
"\t\"next_cursor\":\"asfasdfas\",\n" +
|
||||
"\t\"has_more\":1,\n" +
|
||||
"\t\"account_list\":[\n" +
|
||||
"\t\t{\n" +
|
||||
"\t\t\t\"userid\": \"asdasdasd\",\n" +
|
||||
"\t\t\t\"type\": 1,\n" +
|
||||
"\t\t\t\"expire_time\":1500000000,\n" +
|
||||
"\t\t\t\"active_time\":1500000000\n" +
|
||||
"\t\t},\n" +
|
||||
"\t\t{\n" +
|
||||
"\t\t\t\"userid\": \"asgasgasdasd\",\n" +
|
||||
"\t\t\t\"type\": 1,\n" +
|
||||
"\t\t\t\"expire_time\":1500000000,\n" +
|
||||
"\t\t\t\"active_time\":1500000000\n" +
|
||||
"\t\t}\n" +
|
||||
"\t]\n" +
|
||||
"}";
|
||||
|
||||
String url = configStorage.getApiUrl(LIST_ACTIVED_ACCOUNT) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken();
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
WxCpTpLicenseCorpAccountListResp accountList = wxCpTpLicenseService.getCorpAccountList("123456", 10, null);
|
||||
assertNotNull(accountList);
|
||||
|
||||
assertNotNull(accountList.getOrderList());
|
||||
|
||||
assertEquals(accountList.getNextCursor(), nextCursor);
|
||||
|
||||
assertEquals(accountList.getOrderList().get(0).getUserid(), userid);
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testBatchTransferLicense() throws WxErrorException {
|
||||
String handoverUserid = "dazdasfasf";
|
||||
String takeoverUserid = "asfasfasf";
|
||||
String result = "{\n" +
|
||||
"\t\"errcode\": 0,\n" +
|
||||
"\t\"errmsg\": \"ok\",\n" +
|
||||
"\t\"transfer_result\":[\n" +
|
||||
"\t{\n" +
|
||||
"\t\t\"handover_userid\":\"dazdasfasf\",\n" +
|
||||
"\t\t\"takeover_userid\":\"asfasfasf\",\n" +
|
||||
"\t\t\"errcode\":0\n" +
|
||||
"\t}]\n" +
|
||||
"}";
|
||||
|
||||
String url = configStorage.getApiUrl(BATCH_TRANSFER_LICENSE) + "?provider_access_token=" + wxCpTpService.getWxCpProviderToken();
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
List<WxCpTpLicenseTransfer> transferList = new ArrayList<>();
|
||||
transferList.add(WxCpTpLicenseTransfer.builder().handoverUserId(handoverUserid).takeoverUserId(takeoverUserid).build());
|
||||
WxCpTpLicenseBatchTransferResp licenseBatchTransferResp = wxCpTpLicenseService.batchTransferLicense("123456", transferList);
|
||||
assertNotNull(licenseBatchTransferResp);
|
||||
|
||||
assertNotNull(licenseBatchTransferResp.getTransferResult());
|
||||
|
||||
assertEquals(licenseBatchTransferResp.getTransferResult().size(), transferList.size());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user