Commit 15d95082 by DuJunLi

优惠券工具类兼容是否用于营销活动,增加会员分群业务工具类

parent 23e50b08
......@@ -8,6 +8,7 @@ import com.xiaomai.enums.RequestType;
import com.xiaomai.enums.Terminal;
import com.xiaomai.utils.CommUtil;
import com.xiaomai.utils.XMJSONPath;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Component;
import org.testng.Assert;
......@@ -48,11 +49,12 @@ public class CouponTools extends BaseTestImpl {
* @param quantity 发放数量
* @param validPeriodType 使用有效期方式:1固定期限 ABSOLUTE 2领取后生效 RELATIVE
* @param memo 备注
* @param useForActivity 是否用于营销活动,true,false
* @return 优惠券ID
*/
public String createCoupon(String useThresholdType, String receiveTimesUpperType, List<String> memberStatusLimits, String couponName,
Boolean allScope, String preferentialType, int quantity, String validPeriodType, String memo) {
Boolean allScope, String preferentialType, int quantity, String validPeriodType, String memo,Boolean useForActivity) {
setUP("API_createCoupon");
JSONObject body = new JSONObject();
......@@ -98,6 +100,22 @@ public class CouponTools extends BaseTestImpl {
if (null != memo || !memo.isEmpty()) {
body.put("memo", memo);
}
body.put("useForActivity", useForActivity);
if(useForActivity.equals(true)){ //如果开启用于营销活动
body.put("quantity", -1); //发放数量不限制
List<String> memberStatusLimitsA=new ArrayList<>();
memberStatusLimitsA.add("POTENTIAL");
memberStatusLimitsA.add("NORMAL");
memberStatusLimitsA.add("HISTORY");
receiveCondition.put("memberStatusLimits", memberStatusLimitsA);//可领取会员类型,默认选中所有
receiveCondition.put("receiveTimesUpperType", "WITHOUT");//每人领取次数不限制
body.put("receiveCondition", receiveCondition); //领取限制放开
body.put("validPeriodType", "RELATIVE");//有效期:领取后生效[用于营销活动的优惠券,只支持选择领取后生效]
body.put("validPeriodStartTime",null);
body.put("validPeriodEndTime",null);
body.put("relativeDay","7");//领取7天内有效
}
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
......@@ -170,11 +188,11 @@ public class CouponTools extends BaseTestImpl {
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("current",0);
body.put("size",500);
if (null != nameLike || !nameLike.isEmpty()) {
body.put("size",100);
if (!StringUtils.isEmpty(nameLike)) {
body.put("nameLike", nameLike);
}
if (null != status || !status.isEmpty()) {
if (!StringUtils.isEmpty(status)) {
body.put("status", status);
}
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs).assetsSuccess(true);
......
......@@ -56,7 +56,7 @@ public class TestBatchSendCouponToMember extends SelectTargetTrainingCampAndGetI
memberStatusLimits.add("HISTORY");
title = "有门槛限领适用全部" + RandomStringUtil.randomString(3);
couponId = couponTools.createCoupon("THRESHOLD", "FIXED", memberStatusLimits, title, true,
"CERTAIN", 2, "RELATIVE", title + "优惠方式选择金额,满10元可以减10元,领取后1天内有效");
"CERTAIN", 2, "RELATIVE", title + "优惠方式选择金额,满10元可以减10元,领取后1天内有效",false);
//2.创建成功后,列表增加一条刚新建的优惠券,搜索可领取优惠券
couponTools.getStudioCouponList("", "CLAIMABLE");
Long goalData = XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(), "$.result.records").toJavaList(JSONObject.class).stream().filter(e ->
......
......@@ -28,6 +28,9 @@ public class TestCreateCoupon extends BaseTestImpl {
String couponIdA="";
String titleB="";
String couponIdB="";
String titleC="";
String couponIdC="";
@BeforeClass
public void beforeTest() {
setTestInfo(ApiModule.Polar_Coupon, "API_createCoupon", LoginAccount.ADU_PROD, Terminal.B, "adu");
......@@ -43,9 +46,14 @@ public class TestCreateCoupon extends BaseTestImpl {
List<String> memberStatusLimitsB=new ArrayList<>();
memberStatusLimitsB.add("POTENTIAL");
titleC="用于营销活动优惠券"+ RandomStringUtil.randomString(3);
couponIdC=couponTools.createCoupon("WITHOUT","WITHOUT",memberStatusLimitsB,titleC,false,
"DISCOUNT", -1,"RELATIVE",titleC+"领取7天内有效",true);
titleA="有门槛限领适用全部"+ RandomStringUtil.randomString(3);
couponIdA=couponTools.createCoupon("THRESHOLD","FIXED",memberStatusLimitsA,titleA,true,
"CERTAIN", 2,"RELATIVE",titleA+"优惠方式选择金额,满10元可以减10元,领取后1天内有效");
"CERTAIN", 2,"RELATIVE",titleA+"优惠方式选择金额,满10元可以减10元,领取后1天内有效",false);
couponTools.getStudioCouponList(titleA,"");
Long goalData=XMJSONPath.getJSONArrayByReadPath(dataApi.getApi_response(),"$.result.records").toJavaList(JSONObject.class).stream().filter(e ->
......@@ -55,7 +63,9 @@ public class TestCreateCoupon extends BaseTestImpl {
titleB="无门槛不限领适用部分"+ RandomStringUtil.randomString(2);
couponIdB=couponTools.createCoupon("WITHOUT","WITHOUT",memberStatusLimitsB,titleB,false,
"DISCOUNT", 2,"ABSOLUTE",titleB+"优惠方式选择折扣,8.8折,适用有效期明天~(当前时间+5天)");
"DISCOUNT", 2,"ABSOLUTE",titleB+"优惠方式选择折扣,8.8折,适用有效期明天~(当前时间+5天)",false);
}
......
......@@ -34,7 +34,7 @@ public class TestGetStudioCouponList extends BaseTestImpl {
String couponName ="用于搜索的优惠券"+RandomStringUtil.randomString(3);
couponTools.createCoupon("WITHOUT","WITHOUT",memberStatusLimitsB,couponName,false,
"DISCOUNT", 2,"ABSOLUTE","搜索的优惠券备注");
"DISCOUNT", 2,"ABSOLUTE","搜索的优惠券备注",false);
JSONObject body = new JSONObject();
body.put("current", 0);
body.put("size", 20);
......
package com.xiaomai.cases.polar.membercluster;
import com.alibaba.fastjson.JSONArray;
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.XMJSONPath;
import org.springframework.stereotype.Component;
import org.testng.Assert;
/**
* 会员分群工具类
*
* @author adu
* data 2024/10/26 10:48
*/
@Component("memberClusterTools")
public class MemberClusterTools extends BaseTestImpl {
/**
* 同一个ApiModule下的登录信息封装出一个类,减少代码冗余
*
* @param apiName
* @param userInfo
*/
public void setUP(String apiName, DataUserInfo... userInfo) {
dataApi.setApiModule(ApiModule.Polar_Membercluster)
.setApiName(apiName)
.setTerminal(Terminal.B);
super.beforeDataRequest(userInfo);
}
/**
* 获取场馆会员分群列表数据
*/
public void getMemberClusterList() {
setUP("API_getMemberClusterList");
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
/**
* 创建/编辑会员人群名称验重check
* @param name
*/
public void memberClusterDuplicateCheck(String name){
setUP("API_memberClusterDuplicateCheck");
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("name", name);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
/**
*
* @param name 会员分群名称
* @param description 人群说明
* @param requireFullHit 人群范围 YES 满足全部条件,NO 满足任意一个
* @param ruleList 人群定义 条件列表
* @return 人群clusterId
*/
public String createMemberCluster(String name, String description, String requireFullHit, JSONArray ruleList) {
setUP("API_createMemberCluster");
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("name", name);
body.put("requireFullHit", requireFullHit);
body.put("ruleList", ruleList);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(), "$.success")) == true, "调用接口返回结果:" + XMJSONPath.readPath(dataApi.getApi_response(), "$.message"));
return XMJSONPath.readPath(dataApi.getApi_response(),"$.result");
}
/**
* 查看人群详情-人群信息
* @param clusterId 人群ID
*/
public void getMemberClusterDetail(String clusterId){
setUP("API_getMemberClusterDetail");
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", clusterId);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
/**
* 删除会员分群
* @param clusterId
*/
public void deleteMemberCluster(String clusterId){
setUP("API_deleteMemberCluster");
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", clusterId);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
/**
*
* @param clusterId
* @param messageType
* 微信:通用 WECHAT_COMMON,会员卡专用 WECHAT_MEMBER_CARD,储值卡专用 WECHAT_DEPOSIT_CARD
* 短信:通用 SMS_COMMON,会员卡专用 SMS_MEMBER_CARD,储值卡专用 SMS_DEPOSIT_CARD
*/
public void batchMessagePushForMemberCluster(String clusterId,String messageType){
setUP("API_batchMessagePushForMemberCluster");
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("clusterId", clusterId);
body.put("messageType", messageType);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
/**
* 查看会员分群人群详情-会员名单
* @param clusterId
*/
public void getClusterMemberList(String clusterId){
setUP("API_getClusterMemberList");
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("clusterId", clusterId);
body.put("current", 0);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
/**
* 获取会员分群人群详情-运营记录
* @param clusterId
*/
public void getClusterOperateRecord(String clusterId){
setUP("API_getClusterOperateRecord");
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("clusterId", clusterId);
body.put("current", 0);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
/**
* 会员分群定向运营发送体验卡
* @param clusterId 选择的分群ID
* @param experienceCardId 体验卡ID
*/
public void batchSendExpCardForMemberCluster(String clusterId,String experienceCardId){
setUP("API_batchSendExpCardForMemberCluster");
JSONObject body = new JSONObject();
body.put("operatorId", dataApi.getLoginInfo().getAdminId());
body.put("studioId", dataApi.getLoginInfo().getStudioId());
body.put("brandId", dataApi.getLoginInfo().getBrandId());
body.put("clusterId", clusterId);
body.put("experienceCardId", experienceCardId);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
/**
* 会员分群定向运营发送优惠券
* @param memberClusterId
* @param couponId
*/
public void batchSendCouponForMemberCluster(String memberClusterId,String couponId){
dataApi.setApiModule(ApiModule.Polar_Coupon)
.setApiName("API_batchSendCoupon")
.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("memberClusterId", memberClusterId);
body.put("couponId", couponId);
dataApi.doRequest(RequestType.JSON, dataparams, body.toString(), dataheadrs);
Assert.assertTrue(Boolean.valueOf(XMJSONPath.readPath(dataApi.getApi_response(),"$.success"))==true,"调用接口返回结果:"+XMJSONPath.readPath(dataApi.getApi_response(),"$.message"));
}
}
\ No newline at end of file
......@@ -26,6 +26,8 @@ public class ApiModule {
public static String Polar_EleContract="polar_eleContract";//训练营活动
public static String Polar_Coupon="polar_coupon";//优惠券
public static String Polar_Membercluster="polar_membercluster";//会员分群
public static String Polar_LuckyDraw ="polar_luckyDraw";//幸运抽奖
public static String Lunar_LuckyDraw ="lunar_luckyDraw";//小程序幸运抽奖
public static String Lunar_Coupon="lunar_coupon";//小程序优惠券
......
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