Commit 8ff7435f by yangfangfang

Merge remote-tracking branch 'origin/master'

parents e7ec62c1 e850728f
package com.xiaomai.cases.polar.applet;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
* @Author zxy
* @Description
* @Date 2024/7/2 15:34
*/
public class TestGetWeChatDetail extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Applet)
.setApiName("API_getWeChatDetail")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("zyx")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "获取公众号的授权信息")
public void testGetWeChatDetail(){
JSONObject object = new JSONObject();
object.put("tenantId",xmAppApi.getLoginInfo().getStudioId());
object.put("tenantType","STUDIO");
xmAppApi.doRequest(RequestType.JSON,params,object.toString(),headers).assetsSuccess(true);
Assert.assertEquals(XMJSONPath.readPath(xmAppApi.getBodyInJSON(),"$.result.status"),"DONE");
}
}
package com.xiaomai.cases.polar.clue;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.cases.polar.studioConfig.HomeTools;
import com.xiaomai.client.DataUserInfo;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
......@@ -22,6 +23,7 @@ import java.util.Random;
*/
public class TestCreate extends XMBaseTest {
MemberTools memberTools = new MemberTools();
HomeTools homeTools = new HomeTools();
@BeforeMethod
public void beforeTest(){
......@@ -42,6 +44,8 @@ public class TestCreate extends XMBaseTest {
dataUserInfo.setTerminal(Terminal.B);
dataUserInfo.setLoginUser(LoginAccount.GYM_PROD2);
//首页数据概览-新增会员数
int member = Integer.parseInt(homeTools.preview("本周").getJSONObject("result").getJSONArray("metrics").getJSONObject(0).getString("value"));
//全部线索快捷筛选
JSONObject res = memberTools.fetchQuickSearch().getJSONObject("result");
int addToday = Integer.parseInt(res.getString("addToday"));
......@@ -122,6 +126,10 @@ public class TestCreate extends XMBaseTest {
Assert.assertEquals(addThisWeek_my1,addThisWeek_my+1);//我的快捷筛选本周新增+1
// Assert.assertEquals(addThisMonth_my1,addThisMonth_my+1);//我的快捷筛选本月新增+1
//首页数据概览-新增会员数
int member1 = Integer.parseInt(homeTools.preview("本周").getJSONObject("result").getJSONArray("metrics").getJSONObject(0).getString("value"));
Assert.assertEquals(member1,member+1);//新增会员数+1
//在另一个场馆添加该会员,并在添加后校验是否添加成功
memberTools.join(memberId,dataUserInfo);
......
......@@ -2,6 +2,7 @@ package com.xiaomai.cases.polar.clue;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.cases.polar.studioConfig.HomeTools;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
......@@ -22,6 +23,7 @@ import java.util.Random;
*/
public class TestCreateFeedback extends XMBaseTest {
MemberTools memberTools = new MemberTools();
HomeTools homeTools = new HomeTools();
String memberId;
String feedbackId;
String feedbackId1;
......@@ -57,12 +59,18 @@ public class TestCreateFeedback extends XMBaseTest {
}
//查询该线索的跟进
num = memberTools.searchFeedback(memberId).getJSONObject("result").getJSONArray("records").size();
num_todo = memberTools.listTodoTask(memberId).getJSONArray("result").size();
num = memberTools.searchFeedback(memberId).getJSONObject("result").getJSONArray("records").size();//已完成状态的跟进记录
num_todo = memberTools.listTodoTask(memberId).getJSONArray("result").size();//未开始&已逾期状态的跟进任务
//跟进管理查询今日待跟进
int todayWaitFeedback_num = Integer.parseInt(memberTools.summaryFeedback().getJSONObject("result").getString("todayWaitFeedback"));
//首页查询今日待跟进
int home_todayWaitFeedback_num = homeTools.queryTodayFeedback().getJSONArray("result").size();
Random random = new Random();
String[] feedbackMethod = {"PHONE","WECHAT","SMS","VISIT","OTHERS"};
String[] feedbackResult = {"CONTACTED","INTENTION_CONFIRMED","APPOINTED","EXPERIENCED","REGISTERED","REGISTERED","RENEW_FOLLOW"};
String[] feedbackMethod = {"PHONE","WECHAT","SMS","VISIT","OTHERS"};//跟进方式
String[] feedbackResult = {"CONTACTED","INTENTION_CONFIRMED","APPOINTED","EXPERIENCED","REGISTERED","REGISTERED","RENEW_FOLLOW"};//跟进阶段
JSONObject object = new JSONObject();
object.put("brandId", xmAppApi.getLoginInfo().getBrandId());
......@@ -77,21 +85,30 @@ public class TestCreateFeedback extends XMBaseTest {
xmAppApi.doRequest(RequestType.JSON,params,object.toString(),headers).assetsSuccess(true);
feedbackId = xmAppApi.getBodyInJSON().getString("result");
feedbackId = xmAppApi.getBodyInJSON().getString("result");//创建成功生成一条已完成和一条未开始的跟进记录,此feedbackId为已完成的那条跟进记录ID
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
}
//校验未开始&已逾期的任务列表新增一条数据
JSONArray jsonArray = memberTools.listTodoTask(memberId).getJSONArray("result");
feedbackId1 = jsonArray.getJSONObject(0).getString("id");
int num_todo1 = jsonArray.size();
Assert.assertEquals(num_todo1,num_todo+1);
//校验已完成的任务列表新增一条数据
int num1 = memberTools.searchFeedback(memberId).getJSONObject("result").getJSONArray("records").size();
Assert.assertEquals(num1,num+1);
Assert.assertEquals(num_todo1,num_todo+1);
Assert.assertEquals(memberTools.summaryFeedback().getJSONObject("result").getString("todayWaitFeedback"),"1");
//跟进管理查询今日待跟进
int todayWaitFeedback_num1 = Integer.parseInt(memberTools.summaryFeedback().getJSONObject("result").getString("todayWaitFeedback"));
Assert.assertEquals(todayWaitFeedback_num1,todayWaitFeedback_num+1);
//首页查询今日待跟进
int home_todayWaitFeedback_num1 = homeTools.queryTodayFeedback().getJSONArray("result").size();
Assert.assertEquals(home_todayWaitFeedback_num1,home_todayWaitFeedback_num+1);
}
......@@ -110,6 +127,7 @@ public class TestCreateFeedback extends XMBaseTest {
int num2 = memberTools.searchFeedback(memberId).getJSONObject("result").getJSONArray("records").size();
int num_todo2 = memberTools.listTodoTask(memberId).getJSONArray("result").size();
//删除后,已完成和未开始的跟进记录列表都减少一条数据
Assert.assertEquals(num2,num);
Assert.assertEquals(num_todo2,num_todo);
......
package com.xiaomai.cases.polar.data;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.cases.polar.memberCard.CardTools;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.TimeUtils;
import com.xiaomai.utils.XMBaseTest;
import com.xiaomai.utils.XMJSONPath;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.sql.Time;
public class TestCamDataTrend extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Data)
.setApiName("API_camDatatrend")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "上课数据-趋势分析-次数")
public void testcamDatatrend() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("dateType","DAY");
jsonObject.put("endTime", TimeUtils.getWeekLastTime());
jsonObject.put("startTime",TimeUtils.getWeekFirstTime());
jsonObject.put("metric","CLASS_SESSION_NUMBER");
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
@Test(description = "上课数据-趋势分析-消耗金额")
public void testcamDatatrend1() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("dateType","DAY");
jsonObject.put("endTime", TimeUtils.getWeekLastTime());
jsonObject.put("startTime",TimeUtils.getWeekFirstTime());
jsonObject.put("metric","TOTAL_COST");
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
@Test(description = "上课数据-趋势分析-上课人次")
public void testcamDatatrend2() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("dateType","DAY");
jsonObject.put("endTime", TimeUtils.getWeekLastTime());
jsonObject.put("startTime",TimeUtils.getWeekFirstTime());
jsonObject.put("metric","TOTAL_NUMBER");
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
@Test(description = "上课数据-趋势分析-上课时长")
public void testcamDatatrend3() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("dateType","DAY");
jsonObject.put("endTime", TimeUtils.getWeekLastTime());
jsonObject.put("startTime",TimeUtils.getWeekFirstTime());
jsonObject.put("metric","CLASS_HOUR");
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
}
package com.xiaomai.cases.polar.data;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.TimeUtils;
import com.xiaomai.utils.XMBaseTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestGetCourseCostDetail extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Data)
.setApiName("API_getCourseCostDetail")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "数据中心-上课数据-课消明细-团课")
public void testgetCourseCostDetail() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("current",0);
jsonObject.put("size",20);
jsonObject.put("coachId","");
jsonObject.put("dateType","DAY");
jsonObject.put("sort","TOTAL_COST_DESC");
jsonObject.put("consumeType","GROUP_CLASS");
jsonObject.put("endTime", TimeUtils.getWeekLastTime());
jsonObject.put("startTime",TimeUtils.getWeekFirstTime());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
@Test(description = "数据中心-上课数据-课消明细-私教课")
public void testgetCourseCostDetail1() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("current",0);
jsonObject.put("size",20);
jsonObject.put("coachId","");
jsonObject.put("dateType","DAY");
jsonObject.put("sort","TOTAL_COST_DESC");
jsonObject.put("consumeType","PERSONAL");
jsonObject.put("endTime", TimeUtils.getWeekLastTime());
jsonObject.put("startTime",TimeUtils.getWeekFirstTime());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
@Test(description = "数据中心-上课数据-课消明细-训练营")
public void testgetCourseCostDetail2() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("current",0);
jsonObject.put("size",20);
jsonObject.put("coachId","");
jsonObject.put("dateType","DAY");
jsonObject.put("sort","TOTAL_COST_DESC");
jsonObject.put("consumeType","TRAINING_CAMP");
jsonObject.put("endTime", TimeUtils.getWeekLastTime());
jsonObject.put("startTime",TimeUtils.getWeekFirstTime());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
}
package com.xiaomai.cases.polar.data;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.TimeUtils;
import com.xiaomai.utils.XMBaseTest;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestTetCourseCostData extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Data)
.setApiName("API_getCourseCostData")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "上课数据-课消数据-全部")
public void testgetCourseCostData() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("dateType","WEEK");
jsonObject.put("endTime", TimeUtils.getWeekLastTime());
jsonObject.put("startTime",TimeUtils.getWeekFirstTime());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
@Test(description = "上课数据-课消数据-团课")
public void testgetCourseCostData1() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("dateType","WEEK");
jsonObject.put("consumeType","GROUP_CLASS");
jsonObject.put("endTime", TimeUtils.getWeekLastTime());
jsonObject.put("startTime",TimeUtils.getWeekFirstTime());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
@Test(description = "上课数据-课消数据-私教课")
public void testgetCourseCostData2() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("dateType","WEEK");
jsonObject.put("consumeType","PERSONAL");
jsonObject.put("endTime", TimeUtils.getWeekLastTime());
jsonObject.put("startTime",TimeUtils.getWeekFirstTime());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
@Test(description = "上课数据-课消数据-训练营")
public void testgetCourseCostData3() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("dateType","WEEK");
jsonObject.put("consumeType","TRAINING_CAMP");
jsonObject.put("endTime", TimeUtils.getWeekLastTime());
jsonObject.put("startTime",TimeUtils.getWeekFirstTime());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
@Test(description = "上课数据-课消数据-手动扣次")
public void testgetCourseCostData4() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("dateType","WEEK");
jsonObject.put("consumeType","MANUAL_DEDUCT");
jsonObject.put("endTime", TimeUtils.getWeekLastTime());
jsonObject.put("startTime",TimeUtils.getWeekFirstTime());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
@Test(description = "上课数据-课消数据-自动消耗")
public void testgetCourseCostData5() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("dateType","WEEK");
jsonObject.put("consumeType","AUTO_CONSUME");
jsonObject.put("endTime", TimeUtils.getWeekLastTime());
jsonObject.put("startTime",TimeUtils.getWeekFirstTime());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
@Test(description = "上课数据-课消数据-单次约课")
public void testgetCourseCostData6() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("dateType","WEEK");
jsonObject.put("consumeType","SINGLE_RESERVE");
jsonObject.put("endTime", TimeUtils.getWeekLastTime());
jsonObject.put("startTime",TimeUtils.getWeekFirstTime());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
}
......@@ -388,6 +388,32 @@ public JSONObject membercardsearch( DataUserInfo...dataUserInfos) {
return response;
}
/**
* @param
* @description:会员卡查看编辑记录
* @author: yangjian
**/
public JSONObject fetchPageOfHistory( String memberCardId ,DataUserInfo...dataUserInfos) {
dataApi.setApiModule(ApiModule.Polar_Card)
.setApiName("API_fetchPageOfHistory")
.setTerminal(Terminal.B);
super.beforeDataRequest(dataUserInfos);
JSONObject jsonObject = new JSONObject();
jsonObject.put("memberCardId",memberCardId);
jsonObject.put("current",0);
jsonObject.put("size",20);
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
JSONObject response=dataApi.getBodyInJSON();
return response;
}
......
package com.xiaomai.cases.polar.memberCard;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
import com.xiaomai.utils.XMJSONPath;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
public class TestFetchUserCardList extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Card)
.setApiName("API_fetchUserCardList")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "查看会员名下的已购会员卡")
public void testfetchUserCardList() {
JSONObject jsonObject = new JSONObject();
List memberCardStateList = new ArrayList();
memberCardStateList.add("UN_ACTIVE");
memberCardStateList.add("NORMAL");
memberCardStateList.add("SUSPEND");
jsonObject.put("accountType","MEMBER");
jsonObject.put("memberId","1801173772541014017");//后要变成会员id的变量
jsonObject.put("memberCardStateList",memberCardStateList);
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
}
package com.xiaomai.cases.polar.memberCard;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
import com.xiaomai.utils.XMJSONPath;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestFindHistoryDetailById extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Card)
.setApiName("API_findHistoryDetailById")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "查看会员卡编辑记录-会员卡详情")
public void testfindHistoryDetailById() {
CardTools Cardtools = new CardTools();
Cardtools.fetchPageOfMemberCard();
String memberCardId = XMJSONPath.readPath(dataApi.getApi_response(), "$.result.records[0].id");//拿售卖记录第一张会员卡的ID
Cardtools.fetchPageOfHistory(memberCardId);
String id = XMJSONPath.readPath(dataApi.getApi_response(), "$.result.records[0].snapshotId");//第一条编辑记录
JSONObject jsonObject = new JSONObject();
jsonObject.put("id",id);
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
}
}
......@@ -17,6 +17,7 @@ import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
......@@ -37,7 +38,7 @@ public class GroupScheduleTools extends XMBaseTest {
super.beforeDataRequest(userInfo);
}
/**
/**
* 创建团课排课
*
* @param courseId 团课课程ID
......@@ -49,7 +50,7 @@ public class GroupScheduleTools extends XMBaseTest {
* @param force 是否冲突 false有2种场景:1无冲突时直接传false排课创建成功,2是有冲突时传false代表不忽略冲突,不会创建排课;true是指有冲突时忽略冲突,选择仍要排课【没冲突时就传false,有冲突就传true,如果排课时有冲突但是传了false不会创建排课哈】
* @param endType 排课结束方式:1 按日期,2 按次数
*/
public void createGroupRuleSchedule(String courseId, String chiefCoachId, String startDate, String endDate, List<String> venueAreaIds, List<String> assistCoachIds, Boolean force, int endType,int minuteOffset,DataUserInfo... userInfo) {
public void createGroupRuleSchedule(String courseId, String chiefCoachId, String startDate, String endDate, List<String> venueAreaIds, List<String> assistCoachIds, Boolean force, int endType, int minuteOffset, DataUserInfo... userInfo) {
setUP("API_createGroupRuleSchedule", userInfo);
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
......@@ -73,114 +74,117 @@ public class GroupScheduleTools extends XMBaseTest {
body.put("endDate", CommUtil.getNDayEndTimeTamp(60)); //排课结束日期,这里就设置自动延顺60天,结束日期会覆盖你传的endDate
}
dataApi.doRequest(RequestType.JSON,dataparams,body.toString(),dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
}
/**
* 查看排课日程
*
* @param courseId 可根据课程查询
* @param coachId 可根据教练查询
* @param coachId 可根据教练查询
* @return
*/
public JSONArray getGroupRuleScheduleList(String courseId, String coachId,DataUserInfo... userInfo){
setUP("API_getGroupRuleScheduleList",userInfo);
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
if(courseId!=null&&courseId.length()!=0){
body.put("courseId", courseId);
}
if(coachId!=null&&coachId.length()!=0){
body.put("coachId", coachId);
}
dataApi.doRequest(RequestType.JSON,dataparams,body.toString(),dataheadrs).assetsSuccess(true);
return XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result");
}
public JSONArray getGroupRuleScheduleList(String courseId, String coachId, DataUserInfo... userInfo) {
setUP("API_getGroupRuleScheduleList", userInfo);
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
if (courseId != null && courseId.length() != 0) {
body.put("courseId", courseId);
}
if (coachId != null && coachId.length() != 0) {
body.put("coachId", coachId);
}
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
return XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result");
}
/**
* 查询存量团课课程
*
* @param courseName
* @return
*/
public String getStockGroupCourseId(String courseName){
dataApi.setApiModule(ApiModule.Polar_Course)
.setApiName("API_getGroupClassPage")
.setTerminal(Terminal.B);
super.beforeDataRequest();
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("courseState", "ON");
body.put("current", 0);
body.put("size", 50);
body.put("courseNameLike", courseName);
dataApi.doRequest(RequestType.JSON,dataparams,body.toString(),dataheadrs).assetsSuccess(true);
if(XMJSONPath.readPath(dataApi.getApi_response(),"$.result.records").length()==0){
return "";
}
else {
return XMJSONPath.readPath(dataApi.getApi_response(),"$.result.records[0].brandCourseId");
}
}
public String getStockGroupCourseId(String courseName) {
dataApi.setApiModule(ApiModule.Polar_Course)
.setApiName("API_getGroupClassPage")
.setTerminal(Terminal.B);
super.beforeDataRequest();
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("courseState", "ON");
body.put("current", 0);
body.put("size", 50);
body.put("courseNameLike", courseName);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
if (XMJSONPath.readPath(dataApi.getApi_response(), "$.result.records").length() == 0) {
return "";
} else {
return XMJSONPath.readPath(dataApi.getApi_response(), "$.result.records[0].brandCourseId");
}
}
/**
* 删除团课排课日程
*
* @param ruleId
*/
public void delGroupRuleSchedule(String ruleId, Boolean force, DataUserInfo... userInfo){
setUP("API_delGroupRuleSchedule",userInfo);
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("force", force);
body.put("ruleId", ruleId);
dataApi.doRequest(RequestType.JSON,dataparams,body.toString(),dataheadrs).assetsSuccess(true);
}
public void delGroupRuleSchedule(String ruleId, Boolean force, DataUserInfo... userInfo) {
setUP("API_delGroupRuleSchedule", userInfo);
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("force", force);
body.put("ruleId", ruleId);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
}
/**
* 获取教练ID
*
* @param nickNameList 可根据传入的昵称,获取对应的ID
* @return
*/
public List<String> getStudioAdminId(List<String> nickNameList){
dataApi.setApiModule(ApiModule.Polar_Admin)
.setApiName("API_pageStudioAdmin")
.setTerminal(Terminal.B);
super.beforeDataRequest();
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("current", 0);
body.put("size", 50);
body.put("state", "DUTY");
body.put("teachingType", "LEAGUE_CLASS");
dataApi.doRequest(RequestType.JSON,dataparams,body.toString(),dataheadrs).assetsSuccess(true);
int count=Integer.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.result.total"));
List<String> adminIds = new ArrayList<>();
if (count > 0) {
JSONArray records = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.records");
adminIds = records.stream()
.filter(obj -> CollectionUtils.isEmpty(nickNameList) || nickNameList.contains(((JSONObject) obj).getString("nickName"))) //如果nickNameList为空或者包含搜索结果集中对应的昵称,就会过滤
.map(obj -> {
JSONObject adminIdInfo = (JSONObject) obj;
return adminIdInfo.getString("id");
}
).collect(Collectors.toList());
return adminIds;
}
return null;
}
public List<String> getStudioAdminId(List<String> nickNameList) {
dataApi.setApiModule(ApiModule.Polar_Admin)
.setApiName("API_pageStudioAdmin")
.setTerminal(Terminal.B);
super.beforeDataRequest();
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("current", 0);
body.put("size", 50);
body.put("state", "DUTY");
body.put("teachingType", "LEAGUE_CLASS");
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
int count = Integer.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.total"));
List<String> adminIds = new ArrayList<>();
if (count > 0) {
JSONArray records = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.records");
adminIds = records.stream()
.filter(obj -> CollectionUtils.isEmpty(nickNameList) || nickNameList.contains(((JSONObject) obj).getString("nickName"))) //如果nickNameList为空或者包含搜索结果集中对应的昵称,就会过滤
.map(obj -> {
JSONObject adminIdInfo = (JSONObject) obj;
return adminIdInfo.getString("id");
}
).collect(Collectors.toList());
return adminIds;
}
return null;
}
/**
* 获取存量场地
......@@ -214,28 +218,29 @@ public class GroupScheduleTools extends XMBaseTest {
/**
* 查看团课排课日程详情
*
* @param ruldId
*/
public void getGroupRuleScheduleDetail(String ruldId){
public void getGroupRuleScheduleDetail(String ruldId) {
setUP("API_getGroupRuleScheduleDetail");
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("id", ruldId);
dataApi.doRequest(RequestType.JSON,dataparams,body.toString(),dataheadrs).assetsSuccess(true);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
}
/**
* @param scheduleId
* @description:获取课次详情
* @author: xuyamei
* @date: 2024/6/23 17:45
* @param scheduleId
* @date: 2024/6/23 17:45
* @return: com.alibaba.fastjson.JSONObject
**/
public JSONObject getScheduleItemDetail(String scheduleId,DataUserInfo...dataUserInfo){
setUP("API_getScheduleItemDetail",dataUserInfo);
public JSONObject getScheduleItemDetail(String scheduleId, DataUserInfo... dataUserInfo) {
setUP("API_getScheduleItemDetail", dataUserInfo);
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
......@@ -248,14 +253,14 @@ public class GroupScheduleTools extends XMBaseTest {
}
/**
* @description:查询课表
* @author: xuyamei
* @date: 2024/6/23 17:46
* @param startDate
* @param endDate
* @description:查询课表
* @author: xuyamei
* @date: 2024/6/23 17:46
* @return: com.alibaba.fastjson.JSONArray
**/
public JSONArray getGroupScheduleTable(Long startDate,Long endDate){
public JSONArray getGroupScheduleTable(Long startDate, Long endDate) {
setUP("API_getGroupScheduleTable");
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
......@@ -264,23 +269,28 @@ public class GroupScheduleTools extends XMBaseTest {
body.put("startDate", startDate);
body.put("endDate", endDate);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
return dataApi.getBodyInJSON().getJSONObject("result").getJSONArray("timetableGroups").getJSONObject(0).getJSONArray("timetableList");
if (Integer.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.totalCount")) > 0) {
return dataApi.getBodyInJSON().getJSONObject("result").getJSONArray("timetableGroups").getJSONObject(0).getJSONArray("timetableList");
}
else {
return null;
}
}
/**
* @description:编辑课次
* @author: xuyamei
* @date: 2024/6/23 20:45
* @param scheduleId:课次id
* @param startTime:开始时间
* @param chiefCoachId:教练
* @param minMemberNum:开课人数
* @param maxMemberNum:最大人数上限
* @param dataUserInfos
* @description:编辑课次
* @author: xuyamei
* @date: 2024/6/23 20:45
* @return: void
**/
public void editGroupSchedule(String scheduleId,Long startTime,String chiefCoachId,int minMemberNum,int maxMemberNum,DataUserInfo...dataUserInfos){
setUP("API_editGroupSchedule",dataUserInfos);
public void editGroupSchedule(String scheduleId, Long startTime, String chiefCoachId, int minMemberNum, int maxMemberNum, DataUserInfo... dataUserInfos) {
setUP("API_editGroupSchedule", dataUserInfos);
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
......@@ -301,15 +311,15 @@ public class GroupScheduleTools extends XMBaseTest {
/**
* @param scheduleId :排课id
* @param dataUserInfos
* @description:删除单个排课
* @author: xuyamei
* @date: 2024/6/23 21:12
* @param scheduleId :排课id
* @param dataUserInfos
* @date: 2024/6/23 21:12
* @return: void
**/
public void delGroupScheduleItem(String scheduleId,DataUserInfo...dataUserInfos){
setUP("API_delGroupScheduleItem",dataUserInfos);
public void delGroupScheduleItem(String scheduleId, DataUserInfo... dataUserInfos) {
setUP("API_delGroupScheduleItem", dataUserInfos);
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
......@@ -321,6 +331,31 @@ public class GroupScheduleTools extends XMBaseTest {
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
}
/**
* 获取指定下周某一天的课次ID
* @param n
* @return
*/
public Set<String> getTableDate(int n) {
//查看团课课表
getGroupScheduleTable(Long.valueOf(CommUtil.oneKeyGetNextWeekStartDay()), Long.valueOf(CommUtil.oneKeyGetNextWeekEndDay()));
//获取下周周N及后续的课次
String date = CommUtil.oneKeyGetNextWeekXDay(n);//下周N 日期时间戳
int count = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups").size();
if (count > 0) {
JSONArray array = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.timetableGroups");
Set<String> scheduleIds = array.toJavaList(JSONObject.class).stream()
.filter(e -> e.getString("date").equals(date))//过滤出日期等于下周N的数据
.flatMap(e -> e.getJSONArray("timetableList").toJavaList(JSONObject.class).stream())//对过滤出的数据再次取目标数据重新组合成一个新的数据流
.map(e -> e.getString("scheduleId"))//获取scheduleId
.collect(Collectors.toSet());
return scheduleIds;
}
return null;
}
}
......
......@@ -5,6 +5,7 @@ import com.xiaomai.basetest.BaseTestImpl;
import com.xiaomai.cases.polar.course.CourseTools;
import com.xiaomai.cases.polar.setting.courseCategory.CourseCategoryTools;
import com.xiaomai.cases.polar.setting.venue.VenueAreaTools;
import com.xiaomai.cases.polar.studioConfig.HomeTools;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.Terminal;
......@@ -19,6 +20,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* 创建排课
* @author adu
* data 2024/6/12 15:54
*/
......@@ -52,6 +54,9 @@ public class TestCreateGroupRuleSchedule extends BaseTestImpl {
@Test(description = "测试新建团课排课")
public void testCreateGroupRuleSchedule() {
//查询今日待上课的数据
HomeTools homeTools = new HomeTools();
int num = homeTools.queryTodaySchedule().getJSONArray("result").size();
//获取存量课程ID
String courseId = groupScheduleTools.getStockGroupCourseId(courseName);
......@@ -76,12 +81,18 @@ public class TestCreateGroupRuleSchedule extends BaseTestImpl {
groupScheduleTools.createGroupRuleSchedule(courseId, chiefCoachIdS, todayStartTimeTamp, endDateTimeTamp, venueAreaIds, assistCoachIdS, false, 1,480);
//2-查询排课日程
JSONArray result = groupScheduleTools.getGroupRuleScheduleList(courseId, chiefCoachIdS);
Assert.assertTrue(result.size() >= 1);
//创建今日待上课的排课后再查询今日待上课的数据
int num1 = homeTools.queryTodaySchedule().getJSONArray("result").size();
Assert.assertEquals(num1, num+1);
//统计查询到的目标日程数量
int size = result.size();
String ruldId = XMJSONPath.readPath(result.getJSONObject(0), "$.ruleId");
groupScheduleTools.delGroupRuleSchedule(ruldId,true);
JSONArray result2 = groupScheduleTools.getGroupRuleScheduleList(courseId, chiefCoachIdS);
//删除成功后,统计查询到的目标日程数量是否-1
Assert.assertEquals(result2.size(), size - 1);
......
package com.xiaomai.cases.polar.schedule.group;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.CommUtil;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 删除课次(删除当前课次/删除当前及后续课次)
*
* @author adu
* data 2024/6/30 17:02
*/
public class TestDelGroupScheduleItem extends UniversalDataScheduling {
@BeforeClass
public void beforeTest() {
setTestInfo(ApiModule.Polar_Schedule, "API_delGroupScheduleItem", LoginAccount.ADU_PROD, Terminal.B, "adu");
super.beforeTest();
}
@Test(description = "删除当前课次")
public void testDelCurrentSchedule() {
//获取下周四的课次ID
Set<String> scheduleIds = groupScheduleTools.getTableDate(10);
//如果课次ID有值则继续走删除的case
if (!scheduleIds.isEmpty()) {
scheduleIds.stream().forEach(scheduleId -> {
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("applyRestRule", false);
body.put("scheduleId", scheduleId);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
});
//删除成功后check 下周四课表是否有数据
groupScheduleTools.getGroupScheduleTable(Long.valueOf(CommUtil.oneKeyGetNextWeekXDay(10)), Long.valueOf(CommUtil.oneKeyGetNextWeekEndXDay(4)));
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.totalCount"), "0");
}
}
@Test(description = "删除当前及后续课次", priority = 1)
public void testDelCurrentAndSubsequentSchedule() {
//获取下周三的课次ID
Set<String> scheduleIds = groupScheduleTools.getTableDate(9);
//如果课次ID有值则继续走删除的case
if (!scheduleIds.isEmpty()) {
scheduleIds.stream().forEach(scheduleId -> {
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("applyRestRule", true);
body.put("scheduleId", scheduleId);
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
});
//删除成功后check 从下周三到下周日课表是否有数据
groupScheduleTools.getGroupScheduleTable(Long.valueOf(CommUtil.oneKeyGetNextWeekXDay(9)), Long.valueOf(CommUtil.oneKeyGetNextWeekEndDay()));
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.totalCount"), "0");
}
}
@AfterClass(description = "删除此case创建的日程")
public void delData(){
List<String> ruleIdIds = new ArrayList<>();
//查询这个case创建的相关日程
JSONArray result = groupScheduleTools.getGroupRuleScheduleList(courseId, chiefCoachIdS);
int count = result.size();
if (count > 0) {//如果有数据,则获取对应日程ID
ruleIdIds = result.stream().map(obj -> {
JSONObject ruldIdInfo = (JSONObject) obj;
return ruldIdInfo.getString("ruleId");
}
).collect(Collectors.toList());
}
if (ruleIdIds != null) {//获取到的日程ID不为空时,则逐个删除相关日程
ruleIdIds.stream().forEach(ruleId -> {
//删除对应日程
groupScheduleTools.delGroupRuleSchedule(ruleId, true);
});
}
}
}
\ No newline at end of file
......@@ -20,6 +20,7 @@ import java.util.ArrayList;
import java.util.List;
/**
* 编辑排课日程
* @author adu
* data 2024/6/13 14:31
*/
......@@ -101,8 +102,6 @@ public class TestEditGroupRuleSchedule extends BaseTestImpl {
groupScheduleTools.delGroupRuleSchedule(ruldId,true);
}
......
package com.xiaomai.cases.polar.schedule.group;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.CommUtil;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* 编辑当前课次/编辑当前及后续课次
* @author adu
* data 2024/7/2 10:45
*/
public class TestEditGroupSchedule extends UniversalDataScheduling {
public static Date now = new Date();
Set<String> scheduleIdsN;
@BeforeClass
public void beforeTest() {
setTestInfo(ApiModule.Polar_Schedule, "API_editGroupSchedule", LoginAccount.ADU_PROD, Terminal.B, "adu");
super.beforeTest();
}
@Test(description = "编辑当前课次")
public void testEditCurrentSchedule() {
//获取下周四的课次ID
scheduleIdsN = groupScheduleTools.getTableDate(10);
//如果课次ID有值则继续走删除的case
if (!scheduleIdsN.isEmpty()) {
scheduleIdsN.stream().forEach(scheduleId -> {
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("applyRestRule", false);
body.put("scheduleId", scheduleId);
//获取下周四某个时间点的开始时间戳
Date getWeekStartDayData = CommUtil.getStartOfDateWeek(now);//获取本周的第一天
Date getNextWeekXDayData = CommUtil.addNDays(getWeekStartDayData, 10);
String getNextWeekXDayDataS = new SimpleDateFormat("yyyy-MM-dd").format(getNextWeekXDayData.getTime());
String startStamp = CommUtil.getStringTimestampByStrTime(getNextWeekXDayDataS + " " + "13:30");
body.put("startTime", startStamp);
body.put("chiefCoachId", chiefCoachIdS);
body.put("minMemberNum", 1);
body.put("maxMemberNum", 10);
body.put("venueAreaIds", new ArrayList<>());
body.put("assistCoachIds", new ArrayList<>());
body.put("spanMinutes", 50);
body.put("force", true);//有冲突时忽略冲突
body.put("retainBooking", false);//不保留学员预约
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
//编辑成功后check对应课次详情修改内容是否同步成功
groupScheduleTools.getScheduleItemDetail(scheduleId);
String detailResult = dataApi.getApi_response();
Assert.assertEquals(XMJSONPath.readPath(detailResult, "$.result.chiefCoachId"), chiefCoachIdS);
Assert.assertEquals(XMJSONPath.readPath(detailResult, "$.result.minMemberNum"), "1");
Assert.assertEquals(XMJSONPath.readPath(detailResult, "$.result.maxMemberNum"), "10");
Assert.assertEquals(XMJSONPath.readPath(detailResult, "$.result.startTime"), startStamp);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult, "$.result.assistCoachIds").size() == 0, "助教修改后(置空)没生效");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult, "$.result.venueAreaIds").size() == 0, "场地修改后(置空)没生效");
});
}
}
@Test(description = "编辑当前及后续课次", priority = 1)
public void testEditCurrentAndSubsequentSchedule() {
//获取下周二的课次ID
Set<String> scheduleIds = groupScheduleTools.getTableDate(8);
//如果课次ID有值则继续走编辑的case
if (!scheduleIds.isEmpty()) {
scheduleIds.stream().forEach(scheduleId -> {
JSONObject body = new JSONObject();
body.put("operatorId", xmAppApi.getLoginInfo().getAdminId());
body.put("studioId", xmAppApi.getLoginInfo().getStudioId());
body.put("brandId", xmAppApi.getLoginInfo().getBrandId());
body.put("applyRestRule", true);//改的时日程当前及后续
body.put("scheduleId", scheduleId);
//获取下周二某个时间点的开始时间戳
Date getWeekStartDayData = CommUtil.getStartOfDateWeek(now);
Date getNextWeekXDayData = CommUtil.addNDays(getWeekStartDayData, 8);
String getNextWeekXDayDataS = new SimpleDateFormat("yyyy-MM-dd").format(getNextWeekXDayData.getTime());
String startStamp1 = CommUtil.getStringTimestampByStrTime(getNextWeekXDayDataS + " " + "13:00"); //和创建时间一致,不修改时间
body.put("startTime", startStamp1);
body.put("chiefCoachId", chiefCoachIdS);
body.put("minMemberNum", 6);//修改开课人数
body.put("maxMemberNum", 999);
body.put("venueAreaIds", venueAreaIds);
body.put("assistCoachIds", new ArrayList<>());//修改教练
body.put("spanMinutes", 50);
body.put("force", true);//有冲突时忽略冲突
//body.put("retainBooking", true);//保留学员预约,无改动到时间,教练,场地则不需要传此字段
xmAppApi.doRequest(RequestType.JSON, params, body.toString(), headers).assetsSuccess(true);
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
//编辑成功后check对应课次详情修改内容是否同步成功
checkData(scheduleId,startStamp1);
//查看下周三课次是否同步被修改
Set<String> scheduleIdX = groupScheduleTools.getTableDate(9);
Date getNextWeekXDayData2 = CommUtil.addNDays(getWeekStartDayData, 9);
String getNextWeekXDayDataS2 = new SimpleDateFormat("yyyy-MM-dd").format(getNextWeekXDayData2.getTime());
String startStamp2 = CommUtil.getStringTimestampByStrTime(getNextWeekXDayDataS2 + " " + "13:00"); //和创建时间一致,不修改时间
if (!scheduleIdX.isEmpty()) {
scheduleIdX.stream().forEach(scheduleId1 -> {
//编辑成功后check同规则中下周三课次详情修改内容是否同步成功
checkData(scheduleId1,startStamp2);
});
}
});
}
}
/**
* 编辑后通过查看课次详情check数据是否同步被修改
* @param scheduleId
*/
public void checkData(String scheduleId,String tiemStamp){
groupScheduleTools.getScheduleItemDetail(scheduleId);
String detailResult1 = dataApi.getApi_response();
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.chiefCoachId"), chiefCoachIdS);
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.minMemberNum"), "6");
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.maxMemberNum"), "999");
Assert.assertEquals(XMJSONPath.readPath(detailResult1, "$.result.startTime"), tiemStamp);
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult1, "$.result.assistCoachIds").size() == 0, "助教修改后(置空)没生效");
Assert.assertTrue(XMJSONPath.getJSONArrayByReadPath(detailResult1, "$.result.venueAreaIds").containsAll(venueAreaIds), "场地无修改,但是却变动了");
}
@AfterClass(description = "删除此case创建的日程")
public void delData(){
List<String> ruleIdIds = new ArrayList<>();
//查询这个case创建的相关日程
JSONArray result = groupScheduleTools.getGroupRuleScheduleList(courseId, chiefCoachIdS);
int count = result.size();
if (count > 0) {//如果有数据,则获取对应日程ID
ruleIdIds = result.stream().map(obj -> {
JSONObject ruldIdInfo = (JSONObject) obj;
return ruldIdInfo.getString("ruleId");
}
).collect(Collectors.toList());
}
if (ruleIdIds != null) {//获取到的日程ID不为空时,则逐个删除相关日程
ruleIdIds.stream().forEach(ruleId -> {
//删除对应日程
groupScheduleTools.delGroupRuleSchedule(ruleId, true);
});
}
if (!scheduleIdsN.isEmpty()) {
scheduleIdsN.stream().forEach(scheduleId -> {
//删除case1中编辑独立出去的课次
groupScheduleTools.delGroupScheduleItem(scheduleId);
});
}
}
}
\ No newline at end of file
package com.xiaomai.cases.polar.schedule.group;
import com.xiaomai.basetest.BaseTestImpl;
import com.xiaomai.cases.polar.course.CourseTools;
import com.xiaomai.cases.polar.setting.courseCategory.CourseCategoryTools;
import com.xiaomai.cases.polar.setting.venue.VenueAreaTools;
import com.xiaomai.utils.CommUtil;
import org.testng.annotations.BeforeClass;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
/**
* 创建排课通用类
* @author adu
* data 2024/7/2 10:54
*/
public class UniversalDataScheduling extends BaseTestImpl {
@Resource(name = "courseCategoryTools")
CourseCategoryTools courseCategoryTools;
@Resource(name = "courseTools")
CourseTools courseTools;
@Resource(name = "groupScheduleTools")
GroupScheduleTools groupScheduleTools;
@Resource(name = "venueAreaTools")
VenueAreaTools venueAreaTools;
String courseName = "阿杜自动化团课课程";
String courseId = "";
String chiefCoachIdS = "";
List<String> venueAreaIds = null;
List<String> assistCoachIdS = null;
@BeforeClass
public void beforeTest() {
super.beforeTest();
//获取存量课程ID
courseId = groupScheduleTools.getStockGroupCourseId(courseName);
if (courseId == "") {
//获取存量课程分类ID
String categoryId = courseCategoryTools.getCourseCategoryPage("普拉提");
courseId = courseTools.createGroupCourse(courseName, categoryId, "STUDIO");
}
//获取存量场地
venueAreaIds = groupScheduleTools.getStockArea("流星花园秘密基地");
//获取存量教练
List<String> chiefCoachId = new ArrayList<>();
chiefCoachId.add("杜君丽");
chiefCoachIdS = groupScheduleTools.getStudioAdminId(chiefCoachId).get(0).toString();
//获取存量助教
List<String> assistCoachIds = new ArrayList<>();
assistCoachIds.add("木头");
assistCoachIds.add("吴彦祖");
assistCoachIdS = groupScheduleTools.getStudioAdminId(assistCoachIds);
//创建排课(按次数)
groupScheduleTools.createGroupRuleSchedule(courseId, chiefCoachIdS, CommUtil.oneKeyGetNextWeekStartDay(), CommUtil.oneKeyGetNextWeekEndDay(), venueAreaIds, assistCoachIdS, true, 2, 780);
}
}
\ No newline at end of file
package com.xiaomai.cases.polar.studio;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestBrand_get extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Studio)
.setApiName("API_brand_get")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "获取场馆信息")
public void testbrandget() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
Assert.assertEquals(XMJSONPath.readPath(xmAppApi.getBodyInJSON(),"$code"),"200");
}
}
package com.xiaomai.cases.polar.studio;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
public class TestEditBrand extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Studio)
.setApiName("API_editBrand")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "编辑品牌信息")
public void testeditBrand() {
JSONObject Object1 = new JSONObject();
Object1.put("content", "自动化文本");
Object1.put("type", "TEXT");
List intro = new ArrayList();
intro.add(Object1);
JSONObject jsonObject = new JSONObject();
jsonObject.put("cover","1800412674735546369");
jsonObject.put("intro",intro);
jsonObject.put("logo","1800420544722051074");
jsonObject.put("name","小麦乐动自动化场馆");
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
Assert.assertEquals(XMJSONPath.readPath(xmAppApi.getBodyInJSON(),"$code"),"200");
}
}
package com.xiaomai.cases.polar.studio;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
public class TestEditStudioExt extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Studio)
.setApiName("API_editStudioExt")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "编辑场馆信息")
public void testeditStudioExt() {
JSONObject address = new JSONObject();
address.put("address", "同人广场自动化编辑场馆信息");
address.put("province", 330000);
address.put("city", 330100);
address.put("distinct", 330106);
address.put("fullAddress", "浙江省杭州市西湖区同人广场自动化编辑场馆信息");
JSONObject announcement = new JSONObject();
announcement.put("announcementSwitch", "VALID");
announcement.put("content", "场馆公告自动化");
List dayOfWeeks = new ArrayList();
dayOfWeeks.add(1);
dayOfWeeks.add(2);
dayOfWeeks.add(3);
dayOfWeeks.add(4);
dayOfWeeks.add(5);
dayOfWeeks.add(6);
dayOfWeeks.add(7);
JSONObject Object = new JSONObject();
Object.put("dayOfWeeks", dayOfWeeks);
Object.put("startMinute", 0);
Object.put("endMinute", 1439);
List businessTimes = new ArrayList();
businessTimes.add(Object);
List phones = new ArrayList();
phones.add("12312312312");
List services = new ArrayList();
services.add("自动化设施");
//List images = new ArrayList();
//images.add("");
JSONObject jsonObject = new JSONObject();
jsonObject.put("address",address);
jsonObject.put("announcement",announcement);
jsonObject.put("businessTimes",businessTimes);
jsonObject.put("phones",phones);
jsonObject.put("services",services);
//jsonObject.put("images",images);
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
Assert.assertEquals(XMJSONPath.readPath(xmAppApi.getBodyInJSON(),"$code"),"200");
}
}
package com.xiaomai.cases.polar.studio;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.cases.polar.memberCard.CardTools;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestGetStudio extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Studio)
.setApiName("API_getStudio")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "获取场馆信息")
public void testgetStudio() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
Assert.assertEquals(XMJSONPath.readPath(xmAppApi.getBodyInJSON(),"$code"),"200");
}
}
package com.xiaomai.cases.polar.studio;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestGetStudioExt extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Studio)
.setApiName("API_getStudioExt")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "获取场馆基础信息")
public void testgetStudioExt() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
Assert.assertEquals(XMJSONPath.readPath(xmAppApi.getBodyInJSON(),"$code"),"200");
}
}
package com.xiaomai.cases.polar.studio;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestMessageBox_getTypes extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Studio)
.setApiName("API_messageBox_getTypes")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "获取消息类型")
public void testmessageBoxGetTypes() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
Assert.assertEquals(XMJSONPath.readPath(xmAppApi.getBodyInJSON(),"$code"),"200");
}
}
package com.xiaomai.cases.polar.studio;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestMessageBox_list extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Studio)
.setApiName("API_messageBox_list")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "获取消息类型")
public void testmessageBoxlist() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("current",0);
jsonObject.put("size",20);
//jsonObject.put("messageTypes","");
jsonObject.put("adminId",xmAppApi.getLoginInfo().getAdminId());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
Assert.assertEquals(XMJSONPath.readPath(xmAppApi.getBodyInJSON(),"$code"),"200");
}
}
package com.xiaomai.cases.polar.studio;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
public class TestMessageBox_readAll extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Studio)
.setApiName("API_messageBox_readAll")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "消息一键已读")
public void testmessageBoxreadAll() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("onlyUnread",true);
jsonObject.put("adminId",xmAppApi.getLoginInfo().getAdminId());
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
Assert.assertEquals(XMJSONPath.readPath(xmAppApi.getBodyInJSON(),"$code"),"200");
}
}
package com.xiaomai.cases.polar.studio;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
import com.xiaomai.utils.XMJSONPath;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.ArrayList;
import java.util.List;
public class TestSaveShortcutEntries extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Studio)
.setApiName("API_saveShortcutEntries")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "编辑首页功能")
public void testsaveShortcutEntries() {
JSONObject jsonObject = new JSONObject();
List shortcutEntries = new ArrayList();
shortcutEntries.add("CLUE_MANAGEMENT");
shortcutEntries.add("FOLLOW_MANAGEMENT");
shortcutEntries.add("CARD_MANAGEMENT");
shortcutEntries.add("TRAINING_CAMP");
shortcutEntries.add("COURSE_MANAGEMENT");
shortcutEntries.add("WORKOUT_SCHEDULE");
shortcutEntries.add("RESERVE_RECORD");
shortcutEntries.add("BILLING");
shortcutEntries.add("ORDER_MANAGEMENT");
shortcutEntries.add("INCOME_OUTCOME");
jsonObject.put("adminId",xmAppApi.getLoginInfo().getAdminId());
jsonObject.put("shortcutEntries",shortcutEntries);
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
Assert.assertEquals(XMJSONPath.readPath(xmAppApi.getBodyInJSON(),"$code"),"200");
}
}
package com.xiaomai.cases.polar.studioConfig;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.basetest.BaseTestImpl;
import com.xiaomai.client.DataUserInfo;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.TimeUtils;
import com.xiaomai.utils.XMBaseTest;
/**
* @Author zxy
* @Description
* @Date 2024/7/2 14:33
*/
public class HomeTools extends BaseTestImpl {
//首页数据概览
public JSONObject preview(String type,DataUserInfo...userInfos){
dataApi.setApiModule(ApiModule.Polar_Homepage)
.setApiName("API_preview")
.setTerminal(Terminal.B);
super.beforeDataRequest(userInfos);
JSONObject object = new JSONObject();
switch (type) {
case "本周":
object.put("startTime", TimeUtils.getWeekFirstTime());
object.put("endTime", TimeUtils.getWeekLastTime());
break;
case "本月":
object.put("startTime",TimeUtils.getMonthFristDay());
object.put("endTime",TimeUtils.getMonthLastTime());
break;
case "今日":
object.put("startTime",TimeUtils.getTodayTime());
object.put("endTime",TimeUtils.getTodayEndTime());
break;
case "昨日":
object.put("startTime",TimeUtils.getDayTime(-1,00,00));
object.put("endTime",TimeUtils.getTodayEndTime(-1));
break;
}
dataApi.doRequest(RequestType.JSON,dataparams,object.toString(),dataheadrs).assetsSuccess(true);
return dataApi.getBodyInJSON();
}
//首页今日待上课
public JSONObject queryTodaySchedule(DataUserInfo...userInfos){
dataApi.setApiModule(ApiModule.Polar_Homepage)
.setApiName("API_queryTodaySchedule")
.setTerminal(Terminal.B);
super.beforeDataRequest(userInfos);
JSONObject object = new JSONObject();
object.put("studioId",dataApi.getLoginInfo().getStudioId());
object.put("operatorId",dataApi.getLoginInfo().getAdminId());
dataApi.doRequest(RequestType.JSON,dataparams,object.toString(),dataheadrs).assetsSuccess(true);
return dataApi.getBodyInJSON();
}
//首页今日待上课
public JSONObject queryTodayFeedback(DataUserInfo...userInfos){
dataApi.setApiModule(ApiModule.Polar_Homepage)
.setApiName("API_queryTodayFeedback")
.setTerminal(Terminal.B);
super.beforeDataRequest(userInfos);
JSONObject object = new JSONObject();
object.put("studioId",dataApi.getLoginInfo().getStudioId());
object.put("operatorId",dataApi.getLoginInfo().getAdminId());
dataApi.doRequest(RequestType.JSON,dataparams,object.toString(),dataheadrs).assetsSuccess(true);
return dataApi.getBodyInJSON();
}
}
......@@ -8,10 +8,12 @@ public class ApiModule {
public static String Polar_Admin ="polar_admin";
public static String Polar_Config ="polar_config";
public static String Polar_Setting ="polar_setting";//通用设置
public static String Polar_Applet ="polar_applet";
public static String Polar_Clue ="polar_clue";
public static String Polar_Applet ="polar_applet";//专属小程序
public static String Polar_Clue ="polar_clue";//crm
public static String Polar_Homepage ="polar_homePage";//首页
public static String Polar_Member ="polar_member";//会员管理
public static String Polar_Course ="polar_course";//会员管理
public static String Polar_Studio ="polar_studio";//场馆
public static String Polar_Finance="polar_finance";//财务中心
......@@ -23,6 +25,8 @@ public class ApiModule {
public static String Polar_Reserve="polar_reserve";//预约
public static String Lunar_Reserve="lunar_reserve";//预约
public static String Lunar_User="lunar_user";//预约
public static String Lunar_Card ="lunar_card";//小程序会员卡
public static String Polar_Data ="polar_data";//数据中心
......
......@@ -9,6 +9,7 @@ import java.beans.Introspector;
import java.beans.PropertyDescriptor;
import java.io.FileInputStream;
import java.lang.reflect.Method;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -166,6 +167,52 @@ public class CommUtil {
return getStringTimestamp(getWeekEndDay, "yyyy-MM-dd HH:mm:ss");
}
/**
* 获取下周第一天
* @return
*/
public static String oneKeyGetNextWeekStartDay() {
Date getWeekStartDayData = getStartOfDateWeek(now);//获取本周的第一天
Date getNextWeekStartDayData=addNDays(getWeekStartDayData,7);
String getNextWeekStartDay = getFormatTimeStr(getNextWeekStartDayData, "yyyy-MM-dd HH:mm:ss");//时间格式转化为string
return getStringTimestamp(getNextWeekStartDay, "yyyy-MM-dd HH:mm:ss");
}
/**
* 获取下周最后一天
* @return
*/
public static String oneKeyGetNextWeekEndDay() {
Date getWeekEndDayData = getEndOfDateWeek(now);//获取本周的最后一天
Date getNextWeekEndDayData =addNDays(getWeekEndDayData,7);
String getNextWeekEndDay = getFormatTimeStr(getNextWeekEndDayData, "yyyy-MM-dd HH:mm:ss");//时间格式转化为string
return getStringTimestamp(getNextWeekEndDay, "yyyy-MM-dd HH:mm:ss");
}
/**
* 获取下周某一天(结束日期)
* @param n ,n=7是下周最后一天周日,n=6下周周六,n=5下周周五,n=4下周周四
* @return
*/
public static String oneKeyGetNextWeekEndXDay(int n) {
Date getWeekEndDayData = getEndOfDateWeek(now);//获取本周的最后一天
Date getNextWeekEndDayData =addNDays(getWeekEndDayData,n);
String getNextWeekEndDay = getFormatTimeStr(getNextWeekEndDayData, "yyyy-MM-dd HH:mm:ss");//时间格式转化为string
return getStringTimestamp(getNextWeekEndDay, "yyyy-MM-dd HH:mm:ss");
}
/**
* 获取下周某一天(开始时间)
* @param n 以7为基数(7是周一),+1(8)是周二,+2(9)是周三,10是周四
* @return
*/
public static String oneKeyGetNextWeekXDay(int n) {
Date getWeekStartDayData = getStartOfDateWeek(now);//获取本周的第一天
Date getNextWeekStartDayData=addNDays(getWeekStartDayData,n);
String getNextWeekStartDay = getFormatTimeStr(getNextWeekStartDayData, "yyyy-MM-dd HH:mm:ss");//时间格式转化为string
return getStringTimestamp(getNextWeekStartDay, "yyyy-MM-dd HH:mm:ss");
}
public static Date getEndOfDay(Date date) {
assert date != null;
return new DateTime(date).withTime(23, 59, 59, 999).toDate();
......@@ -198,6 +245,36 @@ public class CommUtil {
return getStringTimestamp(getNDayEndTime, "yyyy-MM-dd HH:mm:ss");
}
/**
* 获取当前时间整点时间戳
*/
public static Long getWholeHourTimestamp(){
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
Long wholeHourTimestamp = calendar.getTimeInMillis();
System.out.println("整点时间戳: " + wholeHourTimestamp);
return wholeHourTimestamp;
}
public static String getStringTimestampByStrTime(String time) {
String timestamp = null;
DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm");
java.util.Date date = null;
try {
date = df.parse(time);
} catch (ParseException e) {
e.printStackTrace();
}
Calendar cal = Calendar.getInstance();
cal.setTime(date);
long timestamp1 = cal.getTimeInMillis();
timestamp = Long.toString(timestamp1);
return timestamp;
}
//@Test
public void test() {
......@@ -205,6 +282,16 @@ public class CommUtil {
System.out.println("当前时间时间戳" + oneKeyGetAddDay(0));
System.out.println("****" +getNDayEndTimeTamp(0));
}
public static void main(String[] args) {
getWholeHourTimestamp();
Date getWeekStartDayData = getStartOfDateWeek(now);//获取本周的第一天
Date getNextWeekXDayData=addNDays(getWeekStartDayData,9);
String getNextWeekXDayDataS = new SimpleDateFormat("yyyy-MM-dd").format(getNextWeekXDayData.getTime());
String startStamp = getStringTimestampByStrTime(getNextWeekXDayDataS + " " + "14:00");
System.out.println("********"+startStamp);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment