Commit c48198cd by yangjian

小程序预约私教课

parent dc31a1f1
package com.xiaomai.cases.lunar.reserve.personal;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.client.DataUserInfo;
import com.xiaomai.enums.ApiModule;
import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.XMBaseTest;
import java.util.ArrayList;
import java.util.List;
public class ResevervePersonalTools extends XMBaseTest {
public void setUP(String apiName, DataUserInfo... userInfo) {
dataApi.setApiModule(ApiModule.Lunar_Reserve)
.setApiName(apiName)
.setTerminal(Terminal.minApp);
super.beforeDataRequest(userInfo);
}
/**
* @description:查询小程序私教课教练
* @author: yj
* @date: 2024/8/14 16:34
* @param memberId
* @param scheduleStartTime
* @param scheduleEndTime
* @param scheduleEndTime
* @return: com.alibaba.fastjson.JSONObject
**/
public JSONObject getEnablePersonalCoachList(String memberId, Long scheduleStartTime,String coachId, Long scheduleEndTime){
setUP("API_getEnablePersonalCoachList");
JSONObject jsonObject = new JSONObject();
jsonObject.put("brandId", dataApi.getLoginInfo().getBrandId());
jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
jsonObject.put("startDate", scheduleStartTime);
jsonObject.put("endDate",scheduleEndTime);
jsonObject.put("courseChooseEnum","ALL");
jsonObject.put("memberId",memberId);//会员ID
jsonObject.put("coachId",coachId);//教练ID
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
return dataApi.getBodyInJSON();
}
/**
* @description:小程序-获取教练下的私教课
* @author: yj
* @date: 2024/8/14 16:34
* @param coachId 教练ID
* @param courseType 课程类型
* @return: com.alibaba.fastjson.JSONObject
**/
public JSONObject getCourseByPage(String coachId,String courseType){
setUP("API_getCourseByPage");
JSONObject jsonObject = new JSONObject();
jsonObject.put("brandId", dataApi.getLoginInfo().getBrandId());
jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
jsonObject.put("coachId",coachId);//教练ID
jsonObject.put("courseType",courseType);//课程类型:PERSONAL 私教
jsonObject.put("current",0);
jsonObject.put("size",5);
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
return dataApi.getBodyInJSON();
}
/**
* @description:小程序-获取私教课的预约规则
* @author: yj
* @date: 2024/8/14 16:34
* @return: com.alibaba.fastjson.JSONObject
**/
public JSONObject personalBookingRules(){
setUP("API_personalBookingRules");
JSONObject jsonObject = new JSONObject();
jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
return dataApi.getBodyInJSON();
}
/**
* @description:查看小程序预约私教课页面的可预定时间
* @author: yj
* @date: 2024/8/14 16:34
* @return: com.alibaba.fastjson.JSONObject
**/
public JSONObject getPersonalTimeBlocks(String coachId, String courseId,String selectedDate){
setUP("API_getPersonalTimeBlocks");
JSONObject jsonObject = new JSONObject();
jsonObject.put("studioId", dataApi.getLoginInfo().getStudioId());
jsonObject.put("brandId", dataApi.getLoginInfo().getBrandId());
jsonObject.put("coachId", coachId);
jsonObject.put("courseId", courseId);
jsonObject.put("selectedDate", selectedDate);
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
return dataApi.getBodyInJSON();
}
/**
* @description:查看小程序,私教课的预约记录
* @author: yj
* @date: 2024/8/14 16:34
* @return: com.alibaba.fastjson.JSONObject
**/
public JSONObject getPageByMemberbype(String signInStateSet1, String memberId,String scheduleStartDate,String scheduleEndDate){
setUP("API_getPageByMember");
List signInStateSet = new ArrayList();
signInStateSet.add(signInStateSet1);//预约状态
JSONObject jsonObject = new JSONObject();
jsonObject.put("current", 0);
jsonObject.put("signInStateSet", signInStateSet);
jsonObject.put("size", 10);
jsonObject.put("memberId", memberId);
jsonObject.put("scheduleStartDate", scheduleStartDate);
jsonObject.put("scheduleEndDate", scheduleEndDate);
jsonObject.put("courseType", "PERSONAL");//课程类型私教
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
return dataApi.getBodyInJSON();
}
/**
* @description:查看私教课的预约详情
* @author: yj
* @date: 2024/8/14 16:34
* @return: com.alibaba.fastjson.JSONObject
**/
public JSONObject getDetailByIdbype(String reserveId){
setUP("API_getDetailById");
JSONObject jsonObject = new JSONObject();
jsonObject.put("reserveId", reserveId);
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
return dataApi.getBodyInJSON();
}
/**
* @description:小程序私教课的取消约课
* @author: xuyamei
* @date: 2024/6/26 10:32
* @param reserveId 预约id
* @param memberId 会员id
* @param success 正常传true
* @return: void
**/
public void cancelMemberReservebype(String reserveId, String memberId, boolean success) {
setUP("API_cancelMemberReserve");
JSONArray reserveIds = new JSONArray();
reserveIds.add(reserveId);
JSONObject body = new JSONObject();
body.put("reserveIds",reserveIds);
body.put("memberId",memberId);
dataApi.doRequest(RequestType.JSON,dataparams,body.toString(),dataheadrs).assetsSuccess(success);
}
/**
* @description:小程序预约私教课
* @author: xuyamei
* @date: 2024/6/26 10:32
* @return: void
**/
public JSONObject addPersonal(String areaIds1,String benefitId,String chiefCoachId,String courseId,String memberId,String planCheckBalance,String reserveMemberNum,String scheduleStartTime,String spanMinutes) {
setUP("API_addPersonal");
JSONArray areaIds = new JSONArray();
areaIds.add(areaIds1);
JSONObject jsonObject = new JSONObject();
jsonObject.put("areaIds",areaIds);
jsonObject.put("benefitId",benefitId);
jsonObject.put("chiefCoachId",chiefCoachId);
jsonObject.put("courseId",courseId);
jsonObject.put("memberId",memberId);
jsonObject.put("memo","自动化约私教课");
jsonObject.put("planCheckBalance",planCheckBalance);
jsonObject.put("reserveMemberNum",reserveMemberNum);
jsonObject.put("scheduleStartTime",scheduleStartTime);
jsonObject.put("spanMinutes",spanMinutes);
jsonObject.put("studioId",dataApi.getLoginInfo().getStudioId());
jsonObject.put("brandId",dataApi.getLoginInfo().getBrandId());
dataApi.doRequest(RequestType.JSON, dataparams, jsonObject.toJSONString(), dataheadrs).assetsSuccess(true);
return dataApi.getBodyInJSON();
}
}
package com.xiaomai.cases.lunar.reserve.personal;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xiaomai.cases.lunar.reserve.ReserveCTools;
import com.xiaomai.cases.lunar.user.UserTools;
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.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 TestAddPersonal extends XMBaseTest {
@BeforeMethod
public void beforeTest(){
xmAppApi.setApiModule(ApiModule.Lunar_Reserve)
.setApiName("API_addPersonal")
.setLoginUser(LoginAccount.GYM_MINIAPPC)
.setTerminal(Terminal.minApp);
dal.setCase_owner("yj")
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super.beforeTest();
}
@Test(description = "使用会员卡约私教课")
public void testaddPersonal() {
UserTools userTools = new UserTools();
String memberId = userTools.getMemberInfo().getString("memberId");
ResevervePersonalTools resevervePersonalTools =new ResevervePersonalTools();
String coachId="1796482517508263938";//固定教练杨剑-杨老师教练
resevervePersonalTools.getCourseByPage(coachId,"PERSONAL");
String courseId = XMJSONPath.readPath(dataApi.getApi_response(), "$.result.records[0].brandCourseId");//拿教练的第一个私教课程
ReserveCTools reserveCTools =new ReserveCTools();
String todayStartTimeTamp = CommUtil.oneKeyGetAddDay(1);
String scheduleEndTime = CommUtil.oneKeyGetAddDay(1);
reserveCTools.listUserReservableBenefit(courseId,"PERSONAL","MEMBER",memberId,Long.parseLong(todayStartTimeTamp));
String benefitId = XMJSONPath.readPath(dataApi.getApi_response(), "$.result[0].benefitId");//拿教练的第一个私教课程
JSONObject jsonObject = new JSONObject();
jsonObject.put("benefitId",benefitId);
jsonObject.put("chiefCoachId",coachId);//教练ID
jsonObject.put("courseId",courseId);
jsonObject.put("memberId",memberId);
jsonObject.put("memo","自动化小程序约私教课");
jsonObject.put("planCheckBalance",1);
jsonObject.put("reserveMemberNum",1);
jsonObject.put("scheduleStartTime",Long.valueOf(todayStartTimeTamp));//预约0点到0点10分的私教课
jsonObject.put("spanMinutes",10);
jsonObject.put("studioId",dataApi.getLoginInfo().getStudioId());
jsonObject.put("brandId",dataApi.getLoginInfo().getBrandId());
xmAppApi.doRequest(RequestType.JSON, params, jsonObject.toJSONString(), headers).assetsSuccess(true);
JSONObject response = xmAppApi.getBodyInJSON();
String reserveId = XMJSONPath.readPath(response, "$.result.reserveId");//预约成功后,拿预约记录id
resevervePersonalTools.getPageByMemberbype("UN_SIGNED",memberId,todayStartTimeTamp,scheduleEndTime);
Assert.assertEquals( XMJSONPath.readPath(dataApi.getApi_response(),"$.result.records[0].id"),reserveId,"预约记录状态异常");//查看第一条是否为正常约课的私教课记录
resevervePersonalTools.cancelMemberReservebype(reserveId,memberId,true);//取消预约的私教课
resevervePersonalTools.getDetailByIdbype(reserveId);
Assert.assertEquals( XMJSONPath.readPath(dataApi.getApi_response(),"$.result.courseType"),"PERSONAL","非私教课类型");
Assert.assertEquals( XMJSONPath.readPath(dataApi.getApi_response(),"$.result.reserveState"),"RESERVE_CANCEL","未取消约课");
}
}
......@@ -26,9 +26,10 @@ public class ApiModule {
public static String Polar_EleContract="polar_eleContract";//训练营活动
public static String Polar_Coupon="polar_coupon";//优惠券
public static String Lunar_Coupon="lunar_coupon";//小程序优惠券
public static String Polar_Reserve="polar_reserve";//预约
public static String Lunar_Reserve="lunar_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";//数据中心
......
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