Commit ec4bfb9d authored by 钱雯君's avatar 钱雯君

add

parent 77052a56
......@@ -104,47 +104,47 @@ public class pk_开奖_瓜分红包测试 extends DuibaTestBase {
this.modifyOpenPrizeTime(newBetId);
//调用开奖接口
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
//校验点
//1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数
Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",newBetId);
logger.info("betConfig的信息为:"+ JSONObject.toJSONString(betConfig));
Assert.assertEquals(betConfig.get("config_status").toString(),"4","配置表状态更新失败");
Map<String,Object> betGroupRelation = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_group_relation where bet_id = ?\n",newBetId);
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Response betList = pkActivityService.getMngBetList();
betList.prettyPrint();
List<BetMngVo> betMngVoList = betList.jsonPath().getList("data.page",BetMngVo.class);
for (BetMngVo bet:betMngVoList){
if (bet.getId().equals(newBetId)){
Assert.assertEquals(bet.getConfigStatus(),"4","开奖结果校验失败");
}
}
Map<String,Object> user01_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0060 where consumer_id = '100066364' and duiba_activity_id = ?\n",newBetId);
Assert.assertEquals(user01_order.get("add_credits").toString(),"10","开奖后发奖值校验失败");
Map<String,Object> user02_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0061 where consumer_id = '100066365' and duiba_activity_id = ?\n",newBetId);
Assert.assertEquals(user02_order.get("add_credits").toString(),"10","开奖后发奖值校验失败");
Map<String,Object> user03_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0062 where consumer_id = '100066366' and duiba_activity_id = ?\n",newBetId);
Assert.assertEquals(user03_order.get("add_credits").toString(),"","开奖后发奖值校验失败");
Map<String,Object> user04_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0063 where consumer_id = '100066367' and duiba_activity_id = ?\n",newBetId);
Assert.assertEquals(user04_order.get("add_credits").toString(),"","开奖后发奖值校验失败");
logger.info("用户01获取的红包值为:"+user01_order.get("add_credits").toString()+",用户02获取的红包值为:"+user02_order.get("add_credits").toString());
logger.info("用户03获取的红包值为:"+user03_order.get("add_credits").toString()+",用户04获取的红包值为:"+user04_order.get("add_credits").toString());
Map<String,Object> bet1Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",newBetId,optionsIds.get(0));
Assert.assertEquals(bet1Result.get("rank").toString(),"1","开始押注的选项获胜校验失败");
Map<String,Object> bet2Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",newBetId,optionsIds.get(1));
Assert.assertEquals(bet2Result.get("rank").toString(),"2","开始押注的选项获胜校验失败");
Long bet1Times = Long.valueOf(bet1Result.get("bet_times").toString());
Long bet2Times = Long.valueOf(bet2Result.get("bet_times").toString());
Assert.assertTrue(bet1Times>bet2Times,"活动获胜人数比失败人数多校验失败");
logger.info("选项1的押注人数为:"+bet1Result.get("bet_times").toString()+",选项2的押注人数为:"+bet2Result.get("bet_times").toString());
// Response doDrowRresponse = pkActivityService.doDraw();
// Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
// Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
// Thread.sleep(8000);
//
// //校验点
// //1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数
// Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",newBetId);
// logger.info("betConfig的信息为:"+ JSONObject.toJSONString(betConfig));
// Assert.assertEquals(betConfig.get("config_status").toString(),"4","配置表状态更新失败");
// Map<String,Object> betGroupRelation = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_group_relation where bet_id = ?\n",newBetId);
// Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
// logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
// Response betList = pkActivityService.getMngBetList();
// betList.prettyPrint();
// List<BetMngVo> betMngVoList = betList.jsonPath().getList("data.page",BetMngVo.class);
// for (BetMngVo bet:betMngVoList){
// if (bet.getId().equals(newBetId)){
// Assert.assertEquals(bet.getConfigStatus(),"4","开奖结果校验失败");
// }
// }
//
// Map<String,Object> user01_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0060 where consumer_id = '100066364' and duiba_activity_id = ?\n",newBetId);
// Assert.assertEquals(user01_order.get("add_credits").toString(),"10","开奖后发奖值校验失败");
// Map<String,Object> user02_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0061 where consumer_id = '100066365' and duiba_activity_id = ?\n",newBetId);
// Assert.assertEquals(user02_order.get("add_credits").toString(),"10","开奖后发奖值校验失败");
// Map<String,Object> user03_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0062 where consumer_id = '100066366' and duiba_activity_id = ?\n",newBetId);
// Assert.assertEquals(user03_order.get("add_credits").toString(),"","开奖后发奖值校验失败");
// Map<String,Object> user04_order = jdbc.findSimpleResult("select * from activity_order_con.tb_trade_center_activity_order_0063 where consumer_id = '100066367' and duiba_activity_id = ?\n",newBetId);
// Assert.assertEquals(user04_order.get("add_credits").toString(),"","开奖后发奖值校验失败");
// logger.info("用户01获取的红包值为:"+user01_order.get("add_credits").toString()+",用户02获取的红包值为:"+user02_order.get("add_credits").toString());
// logger.info("用户03获取的红包值为:"+user03_order.get("add_credits").toString()+",用户04获取的红包值为:"+user04_order.get("add_credits").toString());
//
// Map<String,Object> bet1Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",newBetId,optionsIds.get(0));
// Assert.assertEquals(bet1Result.get("rank").toString(),"1","开始押注的选项获胜校验失败");
// Map<String,Object> bet2Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",newBetId,optionsIds.get(1));
// Assert.assertEquals(bet2Result.get("rank").toString(),"2","开始押注的选项获胜校验失败");
// Long bet1Times = Long.valueOf(bet1Result.get("bet_times").toString());
// Long bet2Times = Long.valueOf(bet2Result.get("bet_times").toString());
// Assert.assertTrue(bet1Times>bet2Times,"活动获胜人数比失败人数多校验失败");
// logger.info("选项1的押注人数为:"+bet1Result.get("bet_times").toString()+",选项2的押注人数为:"+bet2Result.get("bet_times").toString());
}
......@@ -161,15 +161,15 @@ public class pk_开奖_瓜分红包测试 extends DuibaTestBase {
//押注第一个选项:user01,user02
//押注第二个选项:user03,user04
// Response res1 = pkService.doJoin(user01,newBetId,optionsIds.get(0));
Response res1 = pkService.doJoin(user01,newBetId,optionsIds.get(0));
Response res2 = pkService.doJoin(user02,newBetId,optionsIds.get(1));
// Response res3 = pkService.doJoin(user03,newBetId,optionsIds.get(1));
Response res3 = pkService.doJoin(user03,newBetId,optionsIds.get(1));
Response res4 = pkService.doJoin(user04,newBetId,optionsIds.get(1));
//修改开奖时间
this.modifyOpenPrizeTime(newBetId);
// //调用开奖接口
//调用开奖接口
// Response doDrowRresponse = pkActivityService.doDraw();
// Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
// Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
......@@ -179,9 +179,9 @@ public class pk_开奖_瓜分红包测试 extends DuibaTestBase {
// //1、pk活动表配置的状态更新为4;2、订单表的addCredits字段为瓜分的红包值;3、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数
// Map<String,Object> betConfig = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_config where id = ?",newBetId);
// logger.info("betConfig的信息为:"+ JSONObject.toJSONString(betConfig));
// Assert.assertEquals(betConfig.get("config_status").toString(),"true","配置表状态更新失败");
// Assert.assertEquals(betConfig.get("config_status").toString(),"4","配置表状态更新失败");
// Map<String,Object> betGroupRelation = jdbc.findSimpleResult("select * from act_com_conf.tb_bet_group_relation where bet_id = ?\n",newBetId);
// Assert.assertEquals(betGroupRelation.get("config_status").toString(),"true","pk关系表开奖状态更新失败");
// Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
// logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
// Response betList = pkActivityService.getMngBetList();
// betList.prettyPrint();
......@@ -204,9 +204,9 @@ public class pk_开奖_瓜分红包测试 extends DuibaTestBase {
// logger.info("用户03获取的红包值为:"+user03_order.get("add_credits").toString()+",用户04获取的红包值为:"+user04_order.get("add_credits").toString());
//
// Map<String,Object> bet1Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",newBetId,optionsIds.get(0));
// Assert.assertEquals(bet1Result.get("rank").toString(),"true","开始押注的选项获胜校验失败");
// Assert.assertEquals(bet1Result.get("rank").toString(),"2","开始押注的选项获胜校验失败");
// Map<String,Object> bet2Result = jdbc.findSimpleResult("select * from bet_activity.tb_bet_result where bet_id = ? and option_id = ?\n",newBetId,optionsIds.get(1));
// Assert.assertEquals(bet2Result.get("rank").toString(),"true","开始押注的选项获胜校验失败");
// Assert.assertEquals(bet2Result.get("rank").toString(),"1","开始押注的选项获胜校验失败");
// Long bet1Times = Long.valueOf(bet1Result.get("bet_times").toString());
// Long bet2Times = Long.valueOf(bet2Result.get("bet_times").toString());
// Assert.assertTrue(bet1Times<bet2Times,"活动获胜人数比失败人数多校验失败");
......@@ -223,7 +223,7 @@ public class pk_开奖_瓜分红包测试 extends DuibaTestBase {
public void createPk(String bounsType,String endTime,String groupId) throws Exception {
Response betResponse = pkActivityService.bet(bounsType,endTime);
Response betResponse = pkActivityService.betForSetUp(bounsType,endTime);
String betId = MatcherString.getString(betResponse.asString(),"\"data\": (\\w*)",1);
newBetId = betId;
logger.info("newBetId的信息为"+newBetId);
......@@ -277,15 +277,15 @@ public class pk_开奖_瓜分红包测试 extends DuibaTestBase {
try {
//调用开奖接口
// Response doDrowRresponse = pkActivityService.doDraw();
// Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
// Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
// Thread.sleep(8000);
Response doDrowRresponse = pkActivityService.doDraw();
Assert.assertEquals(doDrowRresponse.jsonPath().getString("success"),"true","开奖结果校验失败");
Assert.assertEquals(doDrowRresponse.jsonPath().getString("data"),"开奖中。。。","开奖messag校验失败");
Thread.sleep(8000);
Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title = '【自动化】新建pk活动-瓜分红包')");
Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id in (select id from act_com_conf.tb_bet_config where title = '【自动化】新建pk活动-瓜分红包')");
Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title = '【自动化】新建pk活动-瓜分红包'");
// Boolean result1 = jdbc.update("delete from act_com_conf.tb_bet_option where bet_id in (select id from act_com_conf.tb_bet_config where title = '【自动化】新建pk活动-瓜分红包')");
// Boolean result2 = jdbc.update("delete from act_com_conf.tb_bet_group_relation where bet_id in (select id from act_com_conf.tb_bet_config where title = '【自动化】新建pk活动-瓜分红包')");
// Boolean result3 = jdbc.update("delete from act_com_conf.tb_bet_config where title = '【自动化】新建pk活动-瓜分红包'");
......
......@@ -13,6 +13,9 @@ import com.alibaba.fastjson.JSONObject;
import http.model.BetOptionVo;
import http.service.Authorization;
import io.restassured.response.Response;
import org.joda.time.DateTime;
import org.joda.time.format.DateTimeFormat;
import org.joda.time.format.DateTimeFormatter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
......@@ -46,6 +49,7 @@ public class PkActivityService {
public Response bet(String bonusType,String endTime) throws Exception{
String url = "http://" + ManagerHost + "/newmanager/bet";
List<BetOptionVo> betOptionVoList = new ArrayList<>();
BetOptionVo betOptionVo1 = new BetOptionVo();
BetOptionVo betOptionVo2 = new BetOptionVo();
......@@ -87,6 +91,52 @@ public class PkActivityService {
}
public Response betForSetUp(String bonusType,String endTime) throws Exception{
String url = "http://" + ManagerHost + "/newmanager/bet";
DateTime date = new DateTime();
DateTimeFormatter formatter = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
String time = formatter.print(date.getMillis()).toString();
List<BetOptionVo> betOptionVoList = new ArrayList<>();
BetOptionVo betOptionVo1 = new BetOptionVo();
BetOptionVo betOptionVo2 = new BetOptionVo();
betOptionVo1.setOptionImg("//yun.dui88.com/images/201807/6pyca34t5e.jpeg");
betOptionVo1.setOptionName("【自动化】选项A1");
betOptionVo2.setOptionImg("//yun.dui88.com/images/201807/kcrl1q7hkt.jpeg");
betOptionVo2.setOptionName("【自动化】选项A2");
betOptionVoList.add(betOptionVo1);
betOptionVoList.add(betOptionVo2);
Map<String,Object> para = new HashMap<>();
para.put("betOptionDtoList",betOptionVoList);
para.put("betType","1");//1-单选单次;
para.put("bonusType",bonusType);//1-经验;2-红包
if (bonusType.equals("2")){
para.put("bonusAmount","0.1");//实际瓜分红包金额
para.put("title","【自动化】瓜分红包"+time);
}else {
para.put("title","【自动化】瓜分经验"+time);
}
para.put("configStatus","1");
para.put("creditsValue","1");
para.put("endTime",endTime);
para.put("shareExp","13");
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(para));
Response betResponse = given().contentType("application/json;charset=UTF-8").cookies(authorization.ssoLogin()).body(jsonParam).post(url);
betResponse.prettyPrint();
try{
Assert.assertEquals(betResponse.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("创建pk活动接口失败,返回信息:"+betResponse.asString());
}catch(Error er){
throw new Exception("创建pk活动接口失败,返回信息:"+betResponse.asString());
}
return betResponse;
}
public Response betGroupRelation(String betId,String endTime,String groupId) throws Exception{
String url = "http://" + ManagerHost + "/newmanager/betGroupRelation";
......
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