Commit 07d0fd49 by yangjian

会员排行榜

parent ab2097ae
package com.xiaomai.cases.polar.charts;
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;
public class ChartsMinTools extends BaseTestImpl {
/**
* @param
* @description:小程序-会员排行榜规则查看
* @author: yangjian
**/
public JSONObject findRuleMin(DataUserInfo... dataUserInfos) {
dataApi.setApiModule(ApiModule.Lunar_Charts)
.setApiName("API_findRuleMin")
.setTerminal(Terminal.minApp);
super.beforeDataRequest(dataUserInfos);
JSONObject jsonObject = new JSONObject();
jsonObject.put("brandId", dataApi.getLoginInfo().getBrandId());
jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
JSONObject response = dataApi.getBodyInJSON();
return response;
}
/**
* @param
* @description:查看小程序排行榜列表
* @author: yangjian
**/
public JSONObject fetchMemberRankList(String memberRankType,DataUserInfo... dataUserInfos) {
dataApi.setApiModule(ApiModule.Lunar_Charts)
.setApiName("API_fetchMemberRankList")
.setTerminal(Terminal.minApp);
super.beforeDataRequest(dataUserInfos);
JSONObject jsonObject = new JSONObject();
jsonObject.put("size", 20);
jsonObject.put("current", 0);
jsonObject.put("memberRankType", memberRankType);//MONTH 、SEASON、YEAR
jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
JSONObject response = dataApi.getBodyInJSON();
return response;
}
/**
* @param
* @description:小程序-当前账号排行榜排行
* @author: yangjian
**/
public JSONObject fetchOneMemberRank(String memberRankType,String memberId,long startDate,long endDate,DataUserInfo... dataUserInfos) {
dataApi.setApiModule(ApiModule.Lunar_Charts)
.setApiName("API_fetchOneMemberRank")
.setTerminal(Terminal.minApp);
super.beforeDataRequest(dataUserInfos);
JSONObject jsonObject = new JSONObject();
jsonObject.put("memberRankType", memberRankType);//MONTH 、SEASON、YEAR
jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
jsonObject.put("memberId", memberId);//查询的会员
jsonObject.put("startDate", startDate);
jsonObject.put("endDate", endDate);
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
JSONObject response = dataApi.getBodyInJSON();
return response;
}
/**
* @param
* @description:小程序-排行榜分享详情
* @author: yangjian
* @param rankOrder 排行名次
* @param checkInCount 上课节数
**/
public JSONObject getShareDetail(String recordId,String activeTab,String rankOrder,String checkInCount,DataUserInfo... dataUserInfos) {
dataApi.setApiModule(ApiModule.Lunar_Training)
.setApiName("API_getShareDetail")
.setTerminal(Terminal.minApp);
super.beforeDataRequest(dataUserInfos);
JSONObject extJson = new JSONObject();
extJson.put("studioId",dataApi.getLoginInfo().getStudioId());
extJson.put("brandId",dataApi.getLoginInfo().getBrandId());
extJson.put("activeTab",activeTab);//MONTH 、SEASON、YEAR
extJson.put("activeLabel","thisMonth");//本月,其他有(上月、本季度、上季度、本年、上年)
extJson.put("rankOrder",rankOrder);
extJson.put("checkInCount",checkInCount);
JSONObject jsonObject = new JSONObject();
jsonObject.put("bizId", recordId);
jsonObject.put("shareType","MEMBER_RANK");
jsonObject.put("extJson", extJson);
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
JSONObject response = dataApi.getBodyInJSON();
return response;
}
}
package com.xiaomai.cases.polar.charts;
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 java.util.ArrayList;
import java.util.List;
public class ChartsTools extends BaseTestImpl {
/**
* @param
* @description:会员排行榜列表
* @author: yangjian
* @param memberRankType 月、季度、年
**/
public JSONObject fetchPageOfMemberRank(String memberRankType,long startDate,long endDate, DataUserInfo... dataUserInfos) {
dataApi.setApiModule(ApiModule.Polar_Charts)
.setApiName("API_fetchPageOfMemberRank")
.setTerminal(Terminal.B);
super.beforeDataRequest(dataUserInfos);
JSONObject jsonObject = new JSONObject();
jsonObject.put("memberRankType", memberRankType);//MONTH 、SEASON、YEAR
jsonObject.put("startDate", startDate);
jsonObject.put("endDate", endDate);
jsonObject.put("size", 20);
jsonObject.put("current", 0);
jsonObject.put("brandId", dataApi.getLoginInfo().getBrandId());
jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId", dataApi.getLoginInfo().getAdminId());
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
JSONObject response = dataApi.getBodyInJSON();
return response;
}
/**
* @param
* @description:会员排行榜列表搜索
* @author: yangjian
* @param memberRankType 月、季度、年
* @param memberId 需要列表搜搜索的会员ID
**/
public JSONObject fetchPageOfMemberRankofmember(String memberRankType,String memberId,long startDate,long endDate, DataUserInfo... dataUserInfos) {
dataApi.setApiModule(ApiModule.Polar_Charts)
.setApiName("API_fetchPageOfMemberRank")
.setTerminal(Terminal.B);
super.beforeDataRequest(dataUserInfos);
JSONObject jsonObject = new JSONObject();
jsonObject.put("memberRankType", memberRankType);//MONTH 、SEASON、YEAR
jsonObject.put("startDate", startDate);
jsonObject.put("endDate", endDate);
jsonObject.put("memberId", memberId);
jsonObject.put("size", 20);
jsonObject.put("current", 0);
jsonObject.put("brandId", dataApi.getLoginInfo().getBrandId());
jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId", dataApi.getLoginInfo().getAdminId());
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
JSONObject response = dataApi.getBodyInJSON();
return response;
}
/**
* @param
* @description:会员排行榜规则查看
* @author: yangjian
**/
public JSONObject findRule(DataUserInfo... dataUserInfos) {
dataApi.setApiModule(ApiModule.Polar_Charts)
.setApiName("API_findRule")
.setTerminal(Terminal.B);
super.beforeDataRequest(dataUserInfos);
JSONObject jsonObject = new JSONObject();
jsonObject.put("brandId", dataApi.getLoginInfo().getBrandId());
jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId", dataApi.getLoginInfo().getAdminId());
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
JSONObject response = dataApi.getBodyInJSON();
return response;
}
/**
* @param
* @description:设置默认规则设置
* @author: yangjian
* @param reward 奖励规则
**/
public JSONObject memberRankListsaveRule1(String reward,String monthRandThreshold,DataUserInfo... dataUserInfos) {
dataApi.setApiModule(ApiModule.Polar_Charts)
.setApiName("API_memberRankListsaveRule")
.setTerminal(Terminal.B);
super.beforeDataRequest(dataUserInfos);
List<String> rankPosterResourceIdList = new ArrayList<>();//三张系统默认图
rankPosterResourceIdList.add("1914597066483085313");
rankPosterResourceIdList.add("1914597080835993602");
rankPosterResourceIdList.add("1914597094131937282");
JSONObject jsonObject = new JSONObject();
jsonObject.put("brandId", dataApi.getLoginInfo().getBrandId());
jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId", dataApi.getLoginInfo().getAdminId());
jsonObject.put("openSeasonRank", "NO");
jsonObject.put("openYearRank", "NO");
jsonObject.put("rankBackgroundResourceId", "1914596968827105282");//推广背景图,给了固定的推广图
jsonObject.put("rankPosterResourceIdList", rankPosterResourceIdList);//榜单海报图
jsonObject.put("reward", reward);//奖励规则
jsonObject.put("monthRandThreshold", monthRandThreshold);//上月榜条件
jsonObject.put("monthRankTitle", "内卷自动化");//月榜自定义名称
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
JSONObject response = dataApi.getBodyInJSON();
return response;
}
/**
* @param
* @description:会员排行榜规则保存
* @author: yangjian
* @param openSeasonRank 季度榜是否开启 YES开启;NO关闭
* @param openYearRank 年度榜是否开启 YES开启;NO关闭
* @param reward 奖励规则
* @param openYearRank 奖励规则
**/
public JSONObject memberRankListsaveRule(String openSeasonRank,String openYearRank,String reward,String monthRandThreshold,String monthRankTitle,String seasonRankThreshold,String seasonRankTitle,String yearRankThreshold,String yearRankTitle,DataUserInfo... dataUserInfos) {
dataApi.setApiModule(ApiModule.Polar_Charts)
.setApiName("API_memberRankListsaveRule")
.setTerminal(Terminal.B);
super.beforeDataRequest(dataUserInfos);
List<String> rankPosterResourceIdList = new ArrayList<>();//三张系统默认图
rankPosterResourceIdList.add("1914597066483085313");
rankPosterResourceIdList.add("1914597080835993602");
rankPosterResourceIdList.add("1914597094131937282");
JSONObject jsonObject = new JSONObject();
jsonObject.put("brandId", dataApi.getLoginInfo().getBrandId());
jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId", dataApi.getLoginInfo().getAdminId());
jsonObject.put("openSeasonRank", openSeasonRank);//季度榜 YES开启;NO关闭
jsonObject.put("openYearRank", openYearRank);//年度榜单 YES开启;NO关闭
jsonObject.put("rankBackgroundResourceId", "1914596968827105282");//推广背景图,给了固定的推广图
jsonObject.put("rankPosterResourceIdList", rankPosterResourceIdList);//榜单海报图
jsonObject.put("reward", reward);//奖励规则
jsonObject.put("monthRandThreshold", monthRandThreshold);//上月榜条件
jsonObject.put("monthRankTitle", monthRankTitle);//月榜自定义名称
jsonObject.put("seasonRankThreshold", seasonRankThreshold);//上季度榜条件
jsonObject.put("seasonRankTitle", seasonRankTitle);//季度榜自定义名称
jsonObject.put("yearRankThreshold", yearRankThreshold);//上年度榜条件
jsonObject.put("yearRankTitle", yearRankTitle);//年榜自定义名称
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
JSONObject response = dataApi.getBodyInJSON();
return response;
}
/**
* @param
* @description:会员排行榜导出
* @author: yangjian
* @param memberRankType MONTH 、SEASON、YEAR分别是月榜、季度、年榜的导出
**/
public JSONObject memberRankList_export(String memberRankType,long startDate,long endDate, DataUserInfo... dataUserInfos) {
dataApi.setApiModule(ApiModule.Polar_Charts)
.setApiName("API_memberRankList_export")
.setTerminal(Terminal.B);
super.beforeDataRequest(dataUserInfos);
JSONObject jsonObject = new JSONObject();
jsonObject.put("memberRankType", memberRankType);
jsonObject.put("startDate", startDate);
jsonObject.put("endDate", endDate);
jsonObject.put("brandId", dataApi.getLoginInfo().getBrandId());
jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
jsonObject.put("operatorId", dataApi.getLoginInfo().getAdminId());
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
JSONObject response = dataApi.getBodyInJSON();
return response;
}
}
package com.xiaomai.cases.polar.charts;
import com.xiaomai.cases.polar.export.ExportTool;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.TimeUtils;
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 TestFetchPageOfMemberRank extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Polar_Charts)
.setApiName("API_fetchPageOfMemberRank")
.setLoginUser(LoginAccount.GYM_PROD)
.setTerminal(Terminal.B);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
ChartsTools chartsTools = new ChartsTools();
ExportTool exportTool =new ExportTool();
@Test(description = "会员排行榜列表")
public void testfetchPageOfMemberRank() throws InterruptedException {
chartsTools.memberRankListsaveRule1("","1");//恢复规则设置默认规则
chartsTools.findRule();//查看规则
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.monthRankTitle"), "内卷自动化", "默认规则榜单名称未设置成功");//断言月榜名称为:内卷自动化
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.monthRandThreshold"), "1", "默认规则月榜条件未设置成功");//断言月榜上榜条件为1
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.openSeasonRank"), "NO", "默认规则月榜条件未设置成功");//断言季度榜未开启
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.openYearRank"), "NO", "默认规则月榜条件未设置成功");//断言年度榜未开启
chartsTools.fetchPageOfMemberRank("MONTH", TimeUtils.getMonthFristDay(),TimeUtils.getMonthLastDay());//会员排行榜月榜
String reward ="{\"items\":[{\"aspect\":\"\",\"type\":\"TEXT\",\"content\":\"B端自动化奖励规则\"}]}";
chartsTools.memberRankListsaveRule("YES","YES",reward,"1","月榜自动化","1","季榜自动化","1","年榜自动化");//设置季度、年榜
chartsTools.findRule();//查看规则
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.openSeasonRank"), "YES", "季度榜未开启");//断言季度榜开启
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.seasonRankThreshold"), "1", "季度榜未开启");//断言季度榜上榜条件为1
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.openYearRank"), "YES", "年度榜未开启");//断言年度榜开启
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.yearRankThreshold"), "1", "季度榜未开启");//断言年度榜上榜条件为1
chartsTools.fetchPageOfMemberRankofmember("YEAR","1805435813468483586",TimeUtils.getStartYear(),TimeUtils.getEndYear());//一年(年榜)会员排榜榜搜索会员:C端自动化会员
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.records[0].rankOrder"), "1", "目标学员非第一名");//由于会员排榜榜每五分钟刷新一次,所以我取点名次数最多的学员
chartsTools.memberRankList_export("MONTH",TimeUtils.getMonthFristDay(),TimeUtils.getMonthLastDay());//月榜导出
exportTool.pageStudioExportRecord();//查看导出记录
Thread.sleep(2000);
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.records[0].workflowName"), "导出排行榜", "未生成导出记录");//断言有导出记录
}
}
package com.xiaomai.cases.polar.charts;
import com.xiaomai.cases.lunar.user.UserTools;
import com.xiaomai.cases.polar.clue.MemberTools;
import com.xiaomai.client.DataUserInfo;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.LoginAccount;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.TimeUtils;
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 TestMinfetchMemberRankList extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Lunar_Charts)
.setApiName("API_fetchMemberRankList")
.setLoginUser(LoginAccount.GYM_MINIAPPC)
.setTerminal(Terminal.minApp);
dal.setCase_owner("yangjian")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
DataUserInfo info = new DataUserInfo();
ChartsTools chartsTools =new ChartsTools();
ChartsMinTools chartsMinTools = new ChartsMinTools();
UserTools userTools = new UserTools();
@Test(description = "小程序会员排榜榜")
public void testJoinActivity() {
info.setTerminal(Terminal.B);
info.setLoginUser(LoginAccount.GYM_PROD);
String reward ="{\"items\":[{\"aspect\":\"\",\"type\":\"TEXT\",\"content\":\"小程序自动化奖励规则\"}]}";
chartsTools.memberRankListsaveRule("YES","YES",reward,"1","月榜自动化","1","季榜自动化","1","年榜自动化",info);//端设置季度、年榜
chartsMinTools.findRuleMin();//小程序查看排行榜规则
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.openSeasonRank"), "YES", "季度榜未开启");//断言季度榜开启
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.seasonRankThreshold"), "1", "季度榜未开启");//断言季度榜上榜条件为1
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.openYearRank"), "YES", "年度榜未开启");//断言年度榜开启
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.yearRankThreshold"), "1", "季度榜未开启");//断言年度榜上榜条件为1
chartsMinTools.fetchMemberRankList("YEAR");//查看年榜
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.records[0].member.id"), "1805435813468483586", "年榜第一名非目标");//C端自动化会员为第一名,刷新5分钟问题
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.records[0].member.resourceId"), "1", "年榜第一名非目标");
String memberId = userTools.getMemberInfo().getString("memberId");
chartsMinTools.fetchOneMemberRank("MONTH",memberId, TimeUtils.getMonthFristDay(),TimeUtils.getMonthLastDay());//查询当前登陆账号排行
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.member.id"), memberId, "查询非目标排榜");//断言查询会员
Assert.assertEquals(XMJSONPath.readPath(dataApi.getApi_response(), "$.result.rankOrder"), "1", "目标非第一名");//断言会员为第一名
String rankOrder=XMJSONPath.readPath(dataApi.getApi_response(),"$.result.rankOrder");//排行名次
String checkInCount=XMJSONPath.readPath(dataApi.getApi_response(),"$.result.checkInCount");//获取上课节数
chartsMinTools.getShareDetail(memberId,"MONTH",rankOrder,checkInCount);
}
}
......@@ -33,6 +33,7 @@ public class ApiModule {
public static String Polar_Salary = "polar_salary";
public static String Polar_Invitation = "polar_invitation";
public static String Polar_Registration = "polar_registration";//活动报名
public static String Polar_Charts = "polar_charts";//会员排行榜-B
public static String Polar_MemberEntry="polar_memberEntry";//入场
public static String Polar_Export="polar_export";//导出
......@@ -53,6 +54,7 @@ public class ApiModule {
public static String Lunar_VenueArea="lunar_venueArea";//场地
public static String Lunar_Goods="lunar_goods";//物品
public static String Lunar_Registration = "lunar_registration";//活动报名
public static String Lunar_Charts = "lunar_charts";//会员排行榜-小程序
public static String Lunar_Invitation = "lunar_invitation";
......
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