mirror of
https://gitee.com/binary/weixin-java-tools.git
synced 2025-04-05 17:38:05 +08:00
🆕 #2615 【企业微信】增加应用市场付费订单和版本相关的接口
This commit is contained in:
parent
6b93962208
commit
220e38d6c4
@ -244,6 +244,17 @@ public class WxCpTpAuthInfo extends WxCpBaseResp {
|
||||
@SerializedName("expired_time")
|
||||
private Long expiredTime;
|
||||
|
||||
/**
|
||||
* 是否虚拟版本
|
||||
*/
|
||||
@SerializedName("is_virtual_version")
|
||||
private Boolean isVirtualVersion;
|
||||
|
||||
/**
|
||||
* 是否由互联企业分享安装。详见 <a href='https://developer.work.weixin.qq.com/document/path/93360#24909'>企业互联</a>
|
||||
*/
|
||||
@SerializedName("is_shared_from_other_corp")
|
||||
private Boolean isSharedFromOtherCorp;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -290,6 +301,7 @@ public class WxCpTpAuthInfo extends WxCpBaseResp {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpAuthInfo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
@ -240,6 +240,19 @@ public class WxCpTpPermanentCodeInfo extends WxCpBaseResp {
|
||||
*/
|
||||
@SerializedName("expired_time")
|
||||
private Long expiredTime;
|
||||
|
||||
/**
|
||||
* 是否虚拟版本
|
||||
*/
|
||||
@SerializedName("is_virtual_version")
|
||||
private Boolean isVirtualVersion;
|
||||
|
||||
/**
|
||||
* 是否由互联企业分享安装。详见 <a href='https://developer.work.weixin.qq.com/document/path/93360#24909'>企业互联</a>
|
||||
*/
|
||||
@SerializedName("is_shared_from_other_corp")
|
||||
private Boolean isSharedFromOtherCorp;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -304,6 +317,7 @@ public class WxCpTpPermanentCodeInfo extends WxCpBaseResp {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpPermanentCodeInfo.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
@ -0,0 +1,49 @@
|
||||
package me.chanjar.weixin.cp.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
/**
|
||||
* 应用市场延长试用期结果
|
||||
* @author leiguoqing
|
||||
* @date 2022年4月24日
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class WxCpTpProlongTryResult extends WxCpBaseResp {
|
||||
|
||||
/**
|
||||
* The constant serialVersionUID.
|
||||
*/
|
||||
private static final long serialVersionUID = -5028321625140879571L;
|
||||
|
||||
/**
|
||||
* 延长后的试用到期时间(秒级时间戳)
|
||||
*/
|
||||
@SerializedName("try_end_time")
|
||||
private Long tryEndTime;
|
||||
|
||||
|
||||
/**
|
||||
* From json wx cp tp order list get result.
|
||||
*
|
||||
* @param json the json
|
||||
* @return the wx cp tp order list get result
|
||||
*/
|
||||
public static WxCpTpProlongTryResult fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpProlongTryResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* To json string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,210 @@
|
||||
package me.chanjar.weixin.cp.bean.order;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
/**
|
||||
* 应用版本付费订单详情
|
||||
*
|
||||
* @author leiguoqing
|
||||
* @date 2022年4月24日
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class WxCpTpOrderDetails extends WxCpBaseResp {
|
||||
|
||||
/**
|
||||
* The constant serialVersionUID.
|
||||
*/
|
||||
private static final long serialVersionUID = -5028321625140879571L;
|
||||
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
@SerializedName("orderid")
|
||||
private String orderId;
|
||||
|
||||
/**
|
||||
* 订单状态。0-未支付,1-已支付,2-已关闭, 3-未支付且已过期, 4-申请退款中, 5-申请退款成功, 6-退款被拒绝
|
||||
*/
|
||||
@SerializedName("order_status")
|
||||
private Integer orderStatus;
|
||||
|
||||
/**
|
||||
* 订单类型。0-普通订单,1-扩容订单,2-续期,3-版本变更
|
||||
*/
|
||||
@SerializedName("order_type")
|
||||
private Integer orderType;
|
||||
|
||||
/**
|
||||
* 客户企业的corpid
|
||||
*/
|
||||
@SerializedName("paid_corpid")
|
||||
private String paidCorpId;
|
||||
|
||||
/**
|
||||
* 下单操作人员userid。如果是服务商代下单,没有该字段。
|
||||
*/
|
||||
@SerializedName("operator_id")
|
||||
private String operatorId;
|
||||
|
||||
|
||||
/**
|
||||
* 应用id
|
||||
*/
|
||||
@SerializedName("suiteid")
|
||||
private String suiteId;
|
||||
|
||||
|
||||
/**
|
||||
* 应用id。(仅旧套件有该字段)
|
||||
*/
|
||||
@SerializedName("appid")
|
||||
private String appId;
|
||||
|
||||
|
||||
/**
|
||||
* 购买版本ID
|
||||
*/
|
||||
@SerializedName("edition_id")
|
||||
private String editionId;
|
||||
|
||||
|
||||
/**
|
||||
* 购买版本名字
|
||||
*/
|
||||
@SerializedName("edition_name")
|
||||
private String editionName;
|
||||
|
||||
|
||||
/**
|
||||
* 实付款金额,单位分
|
||||
*/
|
||||
@SerializedName("price")
|
||||
private Long price;
|
||||
|
||||
|
||||
/**
|
||||
* 购买的人数
|
||||
*/
|
||||
@SerializedName("user_count")
|
||||
private Integer userCount;
|
||||
|
||||
|
||||
/**
|
||||
* 购买的时间,单位天
|
||||
*/
|
||||
@SerializedName("order_period")
|
||||
private Integer orderPeriod;
|
||||
|
||||
/**
|
||||
* 下单时间,秒级时间戳
|
||||
*/
|
||||
@SerializedName("order_time")
|
||||
private Long orderTime;
|
||||
|
||||
/**
|
||||
* 付款时间,秒级时间戳
|
||||
*/
|
||||
@SerializedName("paid_time")
|
||||
private Long paidTime;
|
||||
|
||||
|
||||
/**
|
||||
* 购买生效期的开始时间,秒级时间戳
|
||||
*/
|
||||
@SerializedName("begin_time")
|
||||
private Long beginTime;
|
||||
|
||||
|
||||
/**
|
||||
* 购买生效期的结束时间,秒级时间戳
|
||||
*/
|
||||
@SerializedName("end_time")
|
||||
private Long endTime;
|
||||
|
||||
/**
|
||||
* 下单来源。0-客户下单;1-服务商代下单;2-代理商代下单
|
||||
*/
|
||||
@SerializedName("order_from")
|
||||
private Integer orderFrom;
|
||||
|
||||
|
||||
/**
|
||||
* 下单方corpid
|
||||
*/
|
||||
@SerializedName("operator_corpid")
|
||||
private String operatorCorpId;
|
||||
|
||||
/**
|
||||
* 服务商分成金额,单位分
|
||||
*/
|
||||
@SerializedName("service_share_amount")
|
||||
private Long serviceShareAmount;
|
||||
|
||||
|
||||
/**
|
||||
* 平台分成金额,单位分
|
||||
*/
|
||||
@SerializedName("platform_share_amount")
|
||||
private Long platformShareAmount;
|
||||
|
||||
|
||||
/**
|
||||
* 代理商分成金额,单位分
|
||||
*/
|
||||
@SerializedName("dealer_share_amount")
|
||||
private Long dealerShareAmount;
|
||||
|
||||
|
||||
/**
|
||||
* 渠道商信息(仅当有渠道商报备后才会有此字段)
|
||||
*/
|
||||
@SerializedName("dealer_corp_info")
|
||||
private DealerCorpInfo dealerCorpInfo;
|
||||
|
||||
|
||||
/**
|
||||
* 渠道商信息(仅当有渠道商报备后才会有此字段)
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public static class DealerCorpInfo {
|
||||
/**
|
||||
* 代理商corpid
|
||||
*/
|
||||
@SerializedName("corpid")
|
||||
private String corpId;
|
||||
|
||||
|
||||
/**
|
||||
* 代理商名
|
||||
*/
|
||||
@SerializedName("corp_name")
|
||||
private String corpName;
|
||||
}
|
||||
|
||||
/**
|
||||
* From json wx cp tp order details.
|
||||
*
|
||||
* @param json the json
|
||||
* @return the wx cp tp order details
|
||||
*/
|
||||
public static WxCpTpOrderDetails fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpOrderDetails.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* To json string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package me.chanjar.weixin.cp.bean.order;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import me.chanjar.weixin.cp.bean.WxCpBaseResp;
|
||||
import me.chanjar.weixin.cp.util.json.WxCpGsonBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 应用版本付费订单列表
|
||||
*
|
||||
* @author leiguoqing
|
||||
* @date 2022年4月24日
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class WxCpTpOrderListGetResult extends WxCpBaseResp {
|
||||
|
||||
/**
|
||||
* The constant serialVersionUID.
|
||||
*/
|
||||
private static final long serialVersionUID = -5028321625140879571L;
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
*/
|
||||
@SerializedName("order_list")
|
||||
private List<WxCpTpOrderDetails> orderList;
|
||||
|
||||
|
||||
/**
|
||||
* From json wx cp tp order list get result.
|
||||
*
|
||||
* @param json the json
|
||||
* @return the wx cp tp order list get result
|
||||
*/
|
||||
public static WxCpTpOrderListGetResult fromJson(String json) {
|
||||
return WxCpGsonBuilder.create().fromJson(json, WxCpTpOrderListGetResult.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* To json string.
|
||||
*
|
||||
* @return the string
|
||||
*/
|
||||
@Override
|
||||
public String toJson() {
|
||||
return WxCpGsonBuilder.create().toJson(this);
|
||||
}
|
||||
|
||||
}
|
@ -204,6 +204,15 @@ public interface WxCpApiPathConsts {
|
||||
String CONTACT_SEARCH = "/cgi-bin/service/contact/search";
|
||||
String GET_ADMIN_LIST = "/cgi-bin/service/get_admin_list";
|
||||
|
||||
// 获取订单详情
|
||||
String GET_ORDER = "/cgi-bin/service/get_order";
|
||||
|
||||
// 获取订单列表
|
||||
String GET_ORDER_LIST = "/cgi-bin/service/get_order_list";
|
||||
|
||||
// 延长试用期
|
||||
String PROLONG_TRY = "/cgi-bin/service/prolong_try";
|
||||
|
||||
}
|
||||
|
||||
interface User {
|
||||
|
@ -0,0 +1,33 @@
|
||||
package me.chanjar.weixin.cp.tp.service;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.WxCpTpProlongTryResult;
|
||||
|
||||
|
||||
/**
|
||||
* 应用版本付费版本相关接口
|
||||
*
|
||||
* @author leiguoqing
|
||||
* @date 2022年4月24日
|
||||
*/
|
||||
public interface WxCpTpEditionService {
|
||||
|
||||
/**
|
||||
* 延长试用期
|
||||
* <p>
|
||||
* <a href='https://developer.work.weixin.qq.com/document/path/91913'>文档地址</a>
|
||||
* <p/>
|
||||
* 注意:
|
||||
* <ul>
|
||||
* <li>一个应用可以多次延长试用,但是试用总天数不能超过60天</li>
|
||||
* <li>仅限时试用或试用过期状态下的应用可以延长试用期</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param buyerCorpId 购买方corpId
|
||||
* @param prolongDays 延长天数
|
||||
* @param appId 仅旧套件需要填此参数
|
||||
* @return the order
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
WxCpTpProlongTryResult prolongTry(String buyerCorpId, Integer prolongDays, String appId) throws WxErrorException;
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package me.chanjar.weixin.cp.tp.service;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.order.WxCpTpOrderDetails;
|
||||
import me.chanjar.weixin.cp.bean.order.WxCpTpOrderListGetResult;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
|
||||
/**
|
||||
* 应用版本付费订单相关接口
|
||||
*
|
||||
* @author leiguoqing
|
||||
* @date 2022年4月24日
|
||||
*/
|
||||
public interface WxCpTpOrderService {
|
||||
|
||||
/**
|
||||
* 获取订单详情
|
||||
* <p>
|
||||
* <a href='https://developer.work.weixin.qq.com/document/15219#%E8%8E%B7%E5%8F%96%E8%AE%A2%E5%8D%95%E8%AF%A6%E6%83%85'>文档地址</a>
|
||||
* <p/>
|
||||
*
|
||||
* @param orderId 订单号
|
||||
* @return the order
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
WxCpTpOrderDetails getOrder(String orderId) throws WxErrorException;
|
||||
|
||||
|
||||
/**
|
||||
* 获取订单列表
|
||||
* <p>
|
||||
* <a href='https://developer.work.weixin.qq.com/document/15219#%E8%8E%B7%E5%8F%96%E8%AE%A2%E5%8D%95%E5%88%97%E8%A1%A8'>文档地址</a>
|
||||
* <p/>
|
||||
*
|
||||
* @param startTime 起始时间
|
||||
* @param endTime 终止时间
|
||||
* @param testMode 指定拉取正式或测试模式的订单。默认正式模式。0-正式模式,1-测试模式。
|
||||
* @return the order
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
WxCpTpOrderListGetResult getOrderList(Date startTime, Date endTime, Integer testMode) throws WxErrorException;
|
||||
}
|
@ -530,4 +530,31 @@ public interface WxCpTpService {
|
||||
*/
|
||||
void expireProviderToken();
|
||||
|
||||
/**
|
||||
* 获取应用版本付费订单相关接口服务
|
||||
*
|
||||
* @return the wx cp tp order service
|
||||
*/
|
||||
WxCpTpOrderService getWxCpTpOrderService();
|
||||
|
||||
/**
|
||||
* 设置应用版本付费订单相关接口服务
|
||||
*
|
||||
* @param wxCpTpOrderService the wx cp tp order service
|
||||
*/
|
||||
void setWxCpTpOrderService(WxCpTpOrderService wxCpTpOrderService);
|
||||
|
||||
/**
|
||||
* 获取应用版本付费版本相关接口服务
|
||||
*
|
||||
* @return the wx cp tp edition service
|
||||
*/
|
||||
WxCpTpEditionService getWxCpTpEditionService();
|
||||
|
||||
/**
|
||||
* 设置应用版本付费版本相关接口服务
|
||||
*
|
||||
* @param wxCpTpEditionService the wx cp tp edition service
|
||||
*/
|
||||
void setWxCpTpOrderService(WxCpTpEditionService wxCpTpEditionService);
|
||||
}
|
||||
|
@ -48,6 +48,8 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ
|
||||
private WxCpTpMediaService wxCpTpMediaService = new WxCpTpMediaServiceImpl(this);
|
||||
private WxCpTpOAService wxCpTpOAService = new WxCpTpOAServiceImpl(this);
|
||||
private WxCpTpUserService wxCpTpUserService = new WxCpTpUserServiceImpl(this);
|
||||
private WxCpTpOrderService wxCpTpOrderService = new WxCpTpOrderServiceImpl(this);
|
||||
private WxCpTpEditionService wxCpTpEditionService = new WxCpTpEditionServiceImpl(this);
|
||||
|
||||
/**
|
||||
* 全局的是否正在刷新access token的锁.
|
||||
@ -594,6 +596,26 @@ public abstract class BaseWxCpTpServiceImpl<H, P> implements WxCpTpService, Requ
|
||||
this.configStorage.expireProviderToken();
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpTpOrderService getWxCpTpOrderService() {
|
||||
return wxCpTpOrderService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWxCpTpOrderService(WxCpTpOrderService wxCpTpOrderService) {
|
||||
this.wxCpTpOrderService = wxCpTpOrderService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public WxCpTpEditionService getWxCpTpEditionService() {
|
||||
return wxCpTpEditionService;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWxCpTpOrderService(WxCpTpEditionService wxCpTpEditionService) {
|
||||
this.wxCpTpEditionService = wxCpTpEditionService;
|
||||
}
|
||||
|
||||
private WxJsapiSignature doCreateWxJsapiSignature(String url, String authCorpId, String jsapiTicket) {
|
||||
long timestamp = System.currentTimeMillis() / 1000;
|
||||
String noncestr = RandomUtils.getRandomStr();
|
||||
|
@ -0,0 +1,52 @@
|
||||
package me.chanjar.weixin.cp.tp.service.impl;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.WxCpTpProlongTryResult;
|
||||
import me.chanjar.weixin.cp.tp.service.WxCpTpEditionService;
|
||||
import me.chanjar.weixin.cp.tp.service.WxCpTpService;
|
||||
|
||||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.PROLONG_TRY;
|
||||
|
||||
/**
|
||||
* 应用版本付费版本相关接口实现
|
||||
*
|
||||
* @author leigouqing
|
||||
* @date 2022年4月24日
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class WxCpTpEditionServiceImpl implements WxCpTpEditionService {
|
||||
|
||||
/**
|
||||
* The Main service.
|
||||
*/
|
||||
private final WxCpTpService mainService;
|
||||
|
||||
/**
|
||||
* 延长试用期
|
||||
* <p>
|
||||
* <a href='https://developer.work.weixin.qq.com/document/path/91913'>文档地址</a>
|
||||
* <p/>
|
||||
* <ul>
|
||||
* <li>一个应用可以多次延长试用,但是试用总天数不能超过60天</li>
|
||||
* <li>仅限时试用或试用过期状态下的应用可以延长试用期</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param buyerCorpId 购买方corpId
|
||||
* @param prolongDays 延长天数
|
||||
* @param appId 仅旧套件需要填此参数
|
||||
* @return the order
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
@Override
|
||||
public WxCpTpProlongTryResult prolongTry(String buyerCorpId, Integer prolongDays, String appId) throws WxErrorException {
|
||||
String url = mainService.getWxCpTpConfigStorage().getApiUrl(PROLONG_TRY);
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("buyer_corpid", buyerCorpId);
|
||||
jsonObject.addProperty("prolong_days", prolongDays);
|
||||
jsonObject.addProperty("appid", appId);
|
||||
String result = mainService.post(url, jsonObject.toString());
|
||||
return WxCpTpProlongTryResult.fromJson(result);
|
||||
}
|
||||
}
|
@ -0,0 +1,71 @@
|
||||
package me.chanjar.weixin.cp.tp.service.impl;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.order.WxCpTpOrderDetails;
|
||||
import me.chanjar.weixin.cp.bean.order.WxCpTpOrderListGetResult;
|
||||
import me.chanjar.weixin.cp.tp.service.WxCpTpOrderService;
|
||||
import me.chanjar.weixin.cp.tp.service.WxCpTpService;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_ORDER;
|
||||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_ORDER_LIST;
|
||||
|
||||
/**
|
||||
* 应用版本付费订单相关接口实现
|
||||
*
|
||||
* @author leigouqing
|
||||
* @date 2022年4月24日
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
public class WxCpTpOrderServiceImpl implements WxCpTpOrderService {
|
||||
|
||||
/**
|
||||
* The Main service.
|
||||
*/
|
||||
private final WxCpTpService mainService;
|
||||
|
||||
/**
|
||||
* 获取订单详情
|
||||
* <p>
|
||||
* <a href='https://developer.work.weixin.qq.com/document/15219#%E8%8E%B7%E5%8F%96%E8%AE%A2%E5%8D%95%E8%AF%A6%E6%83%85'>文档地址</a>
|
||||
* <p/>
|
||||
*
|
||||
* @param orderId 订单号
|
||||
* @return the order
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
@Override
|
||||
public WxCpTpOrderDetails getOrder(String orderId) throws WxErrorException {
|
||||
String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_ORDER);
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("orderid", orderId);
|
||||
String result = this.mainService.post(url, jsonObject.toString());
|
||||
return WxCpTpOrderDetails.fromJson(result);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单列表
|
||||
* <p>
|
||||
* <a href='https://developer.work.weixin.qq.com/document/15219#%E8%8E%B7%E5%8F%96%E8%AE%A2%E5%8D%95%E5%88%97%E8%A1%A8'>文档地址</a>
|
||||
* <p/>
|
||||
*
|
||||
* @param startTime 起始时间
|
||||
* @param endTime 终止时间
|
||||
* @param testMode 指定拉取正式或测试模式的订单。默认正式模式。0-正式模式,1-测试模式。
|
||||
* @return the order list
|
||||
* @throws WxErrorException the wx error exception
|
||||
*/
|
||||
@Override
|
||||
public WxCpTpOrderListGetResult getOrderList(Date startTime, Date endTime, Integer testMode) throws WxErrorException {
|
||||
String url = mainService.getWxCpTpConfigStorage().getApiUrl(GET_ORDER_LIST);
|
||||
JsonObject jsonObject = new JsonObject();
|
||||
jsonObject.addProperty("start_time", startTime.getTime() / 1000);
|
||||
jsonObject.addProperty("end_time", endTime.getTime() / 1000);
|
||||
jsonObject.addProperty("test_mode", testMode);
|
||||
String result = this.mainService.post(url, jsonObject.toString());
|
||||
return WxCpTpOrderListGetResult.fromJson(result);
|
||||
}
|
||||
}
|
@ -201,7 +201,9 @@ public class BaseWxCpTpServiceImplTest {
|
||||
" \"edition_name\":\"协同版\",\n" +
|
||||
" \"app_status\":3,\n" +
|
||||
" \"user_limit\":200,\n" +
|
||||
" \"expired_time\":1541990791\n" +
|
||||
" \"expired_time\":1541990791,\n" +
|
||||
" \"is_virtual_version\":false,\n" +
|
||||
" \"is_shared_from_other_corp\":true\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
" }\n" +
|
||||
@ -295,7 +297,9 @@ public class BaseWxCpTpServiceImplTest {
|
||||
" \"edition_name\":\"协同版\",\n" +
|
||||
" \"app_status\":3,\n" +
|
||||
" \"user_limit\":200,\n" +
|
||||
" \"expired_time\":1541990791\n" +
|
||||
" \"expired_time\":1541990791,\n" +
|
||||
" \"is_virtual_version\":false,\n" +
|
||||
" \"is_shared_from_other_corp\":true\n" +
|
||||
" },\n" +
|
||||
" {\n" +
|
||||
" \"agentid\":1,\n" +
|
||||
@ -303,7 +307,9 @@ public class BaseWxCpTpServiceImplTest {
|
||||
" \"edition_name\":\"协同版\",\n" +
|
||||
" \"app_status\":3,\n" +
|
||||
" \"user_limit\":200,\n" +
|
||||
" \"expired_time\":1541990791\n" +
|
||||
" \"expired_time\":1541990791,\n" +
|
||||
" \"is_virtual_version\":false,\n" +
|
||||
" \"is_shared_from_other_corp\":true\n" +
|
||||
" }\n" +
|
||||
" ]\n" +
|
||||
" }\n" +
|
||||
|
@ -0,0 +1,70 @@
|
||||
package me.chanjar.weixin.cp.tp.service.impl;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.WxCpTpProlongTryResult;
|
||||
import me.chanjar.weixin.cp.config.WxCpTpConfigStorage;
|
||||
import me.chanjar.weixin.cp.config.impl.WxCpTpDefaultConfigImpl;
|
||||
import me.chanjar.weixin.cp.tp.service.WxCpTpEditionService;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.PROLONG_TRY;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 应用版本付费版本相关接口测试
|
||||
*/
|
||||
public class WxCpTpEditionServiceImplTest {
|
||||
|
||||
@Mock
|
||||
private WxCpTpServiceApacheHttpClientImpl wxCpTpService;
|
||||
|
||||
private WxCpTpConfigStorage configStorage;
|
||||
|
||||
private WxCpTpEditionService wxCpTpEditionService;
|
||||
|
||||
@BeforeClass
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
configStorage = new WxCpTpDefaultConfigImpl();
|
||||
when(wxCpTpService.getWxCpTpConfigStorage()).thenReturn(configStorage);
|
||||
wxCpTpEditionService = new WxCpTpEditionServiceImpl(wxCpTpService);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 延长试用期
|
||||
*/
|
||||
@Test
|
||||
public void testProlongTry() throws WxErrorException {
|
||||
|
||||
String buyerCorpId = "wx7da9abf8ac62baaa";
|
||||
Integer prolongDays = 7;
|
||||
String appId = "1";
|
||||
|
||||
Long tryEndTime = 1565152189L;
|
||||
|
||||
String result = "" +
|
||||
" {\n" +
|
||||
" \"errcode\" : 0,\n" +
|
||||
" \"errmsg\" : \"ok\",\n" +
|
||||
" \"try_end_time\" : 1565152189\n" +
|
||||
" }";
|
||||
|
||||
String url = configStorage.getApiUrl(PROLONG_TRY);
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
|
||||
final WxCpTpProlongTryResult prolongTryResult = wxCpTpEditionService.prolongTry(buyerCorpId, prolongDays, appId);
|
||||
|
||||
assertNotNull(prolongTryResult);
|
||||
|
||||
assertEquals(prolongTryResult.getTryEndTime(), tryEndTime);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,156 @@
|
||||
package me.chanjar.weixin.cp.tp.service.impl;
|
||||
|
||||
import me.chanjar.weixin.common.error.WxErrorException;
|
||||
import me.chanjar.weixin.cp.bean.order.WxCpTpOrderDetails;
|
||||
import me.chanjar.weixin.cp.bean.order.WxCpTpOrderListGetResult;
|
||||
import me.chanjar.weixin.cp.config.WxCpTpConfigStorage;
|
||||
import me.chanjar.weixin.cp.config.impl.WxCpTpDefaultConfigImpl;
|
||||
import me.chanjar.weixin.cp.tp.service.WxCpTpOrderService;
|
||||
import org.apache.commons.lang3.time.DateUtils;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.testng.annotations.BeforeClass;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_ORDER;
|
||||
import static me.chanjar.weixin.cp.constant.WxCpApiPathConsts.Tp.GET_ORDER_LIST;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Matchers.eq;
|
||||
import static org.mockito.Mockito.when;
|
||||
import static org.testng.Assert.*;
|
||||
|
||||
/**
|
||||
* 应用版本付费订单相关接口测试
|
||||
*/
|
||||
public class WxCpTpOrderServiceImplTest {
|
||||
|
||||
@Mock
|
||||
private WxCpTpServiceApacheHttpClientImpl wxCpTpService;
|
||||
|
||||
private WxCpTpConfigStorage configStorage;
|
||||
|
||||
private WxCpTpOrderService wxCpTpOrderService;
|
||||
|
||||
@BeforeClass
|
||||
public void setUp() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
configStorage = new WxCpTpDefaultConfigImpl();
|
||||
when(wxCpTpService.getWxCpTpConfigStorage()).thenReturn(configStorage);
|
||||
wxCpTpOrderService = new WxCpTpOrderServiceImpl(wxCpTpService);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取订单详情
|
||||
*/
|
||||
@Test
|
||||
public void testGetOrder() throws WxErrorException {
|
||||
String orderId = "2018091822ks1sd3s";
|
||||
|
||||
String result = "" +
|
||||
"{\n" +
|
||||
" \"errcode\" : 0,\n" +
|
||||
" \"errmsg\" : \"ok\",\n" +
|
||||
" \"orderid\" : \"2018091822ks1sd3s\",\n" +
|
||||
" \"order_status\" : 1,\n" +
|
||||
" \"order_type\" : 1,\n" +
|
||||
" \"paid_corpid\" : \"wwfedd7e5291d63aaa\",\n" +
|
||||
" \"operator_id\" : \"zhangsan\",\n" +
|
||||
" \"suiteid\" : \"wx67cce113441ccaaa\",\n" +
|
||||
" \"appid\" : 1,\n" +
|
||||
" \"edition_id\" : \"RLS65535\",\n" +
|
||||
" \"edition_name\" : \"协同版\",\n" +
|
||||
" \"price\" : 100,\n" +
|
||||
" \"user_count\" : 1000,\n" +
|
||||
" \"order_period\": 365,\n" +
|
||||
" \"order_time\" : 1533702999,\n" +
|
||||
" \"paid_time\" : 1533702910,\n" +
|
||||
" \"begin_time\" : 1533702910,\n" +
|
||||
" \"end_time\" : 1553515904,\n" +
|
||||
" \"order_from\" : 1,\n" +
|
||||
" \"operator_corpid\" : \"wwfedd7e5292d63aaa\",\n" +
|
||||
" \"service_share_amount\" : 60,\n" +
|
||||
" \"platform_share_amount\" : 10,\n" +
|
||||
" \"dealer_share_amount\" : 30,\n" +
|
||||
" \"dealer_corp_info\":\n" +
|
||||
" {\n" +
|
||||
" \"corpid\": \"xxxx\",\n" +
|
||||
" \"corp_name\": \"name\"\n" +
|
||||
" }\n" +
|
||||
" }";
|
||||
String url = configStorage.getApiUrl(GET_ORDER);
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
|
||||
final WxCpTpOrderDetails orderDetails = wxCpTpOrderService.getOrder(orderId);
|
||||
|
||||
assertNotNull(orderDetails);
|
||||
|
||||
assertEquals(orderDetails.getOrderId(), orderId);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取订单列表
|
||||
*/
|
||||
@Test
|
||||
public void testGetOrderList() throws WxErrorException {
|
||||
String orderId = "2018091822ks1sd3s";
|
||||
Date startTime = new Date();
|
||||
Date endTime = DateUtils.addDays(startTime, 5);
|
||||
Integer testMode = 0;
|
||||
|
||||
String result = "" +
|
||||
" {\n" +
|
||||
" \"errcode\" : 0,\n" +
|
||||
" \"errmsg\" : \"ok\",\n" +
|
||||
" \"order_list\": [\n" +
|
||||
" {\n" +
|
||||
" \"orderid\" : \"2018091822ks1sd3s\",\n" +
|
||||
" \"order_status\" : 1,\n" +
|
||||
" \"order_type\" : 1,\n" +
|
||||
" \"paid_corpid\" : \"wwfedd7e5292d63aaa\",\n" +
|
||||
" \"operator_id\" : \"zhangsan\",\n" +
|
||||
" \"suiteid\" : \"wx67cce113441cc7a6\",\n" +
|
||||
" \"appid\" : 1,\n" +
|
||||
" \"edition_id\" : \"RLS65535\",\n" +
|
||||
" \"edition_name\" : \"协同版\",\n" +
|
||||
" \"price\" : 100,\n" +
|
||||
" \"user_count\" : 1000,\n" +
|
||||
" \"order_period\": 365,\n" +
|
||||
" \"order_time\" : 1533702999,\n" +
|
||||
" \"paid_time\" : 1533702910,\n" +
|
||||
" \"begin_time\" : 1533702910,\n" +
|
||||
" \"end_time\" : 1553515904,\n" +
|
||||
" \"order_from\" : 1,\n" +
|
||||
" \"operator_corpid\" : \"wwfedd7e5292d63aaa\",\n" +
|
||||
" \"service_share_amount\" : 60,\n" +
|
||||
" \"platform_share_amount\" : 10,\n" +
|
||||
" \"dealer_share_amount\" : 30,\n" +
|
||||
" \"dealer_corp_info\":\n" +
|
||||
" {\n" +
|
||||
" \"corpid\": \"xxxx\",\n" +
|
||||
" \"corp_name\": \"name\"\n" +
|
||||
" }\n" +
|
||||
" }]\n" +
|
||||
" }";
|
||||
|
||||
String url = configStorage.getApiUrl(GET_ORDER_LIST);
|
||||
when(wxCpTpService.post(eq(url), any(String.class))).thenReturn(result);
|
||||
|
||||
final WxCpTpOrderListGetResult orderList = wxCpTpOrderService.getOrderList(startTime, endTime, testMode);
|
||||
|
||||
assertNotNull(orderList);
|
||||
|
||||
final List<WxCpTpOrderDetails> detailsList = orderList.getOrderList();
|
||||
|
||||
assertTrue(Objects.nonNull(detailsList) && !detailsList.isEmpty());
|
||||
|
||||
assertEquals(detailsList.get(0).getOrderId(), orderId);
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user