1
0
mirror of synced 2025-12-24 02:57:55 +08:00

🆕 #2615 【企业微信】增加应用市场付费订单和版本相关的接口

This commit is contained in:
不敲代码的攻城狮
2022-04-25 10:10:07 +08:00
committed by GitHub
parent 6b93962208
commit 220e38d6c4
15 changed files with 831 additions and 3 deletions

View File

@@ -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" +

View File

@@ -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);
}
}

View File

@@ -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);
}
}