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

add

parent 6a4df1ca
...@@ -50,16 +50,14 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase { ...@@ -50,16 +50,14 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase {
private static DuibaLog logger = DuibaLog.getLogger(); private static DuibaLog logger = DuibaLog.getLogger();
private String groupId = "6,7"; private String groupId = "7";
private Integer user01 = 4812;//appid=18816 private Integer user01 = 4907;//appid=18816
private String consumerId01 = "100108112";//activity_order_con.tb_trade_center_activity_order_0848 private String consumerId01 = "100109082";//activity_order_con.tb_trade_center_activity_order_0794
private Integer user02 = 4813;//appid=18816 private Integer user02 = 4908;//appid=18816
private String consumerId02 = "100108113";//activity_order_con.tb_trade_center_activity_order_0849 private String consumerId02 = "100109083";//activity_order_con.tb_trade_center_activity_order_0795
private Integer user03 = 4814;//appid=2239 private Integer user03 = 4909;//appid=2239
private String consumerId03 = "100108114";//activity_order_con.tb_trade_center_activity_order_0850 private String consumerId03 = "100109084";//activity_order_con.tb_trade_center_activity_order_0796
private Integer user04 = 4815;//appid=2239
private String consumerId04 = "100108115";//activity_order_con.tb_trade_center_activity_order_0851
List<String> wins = new ArrayList<>(); List<String> wins = new ArrayList<>();
List<String> loses = new ArrayList<>(); List<String> loses = new ArrayList<>();
...@@ -71,15 +69,21 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase { ...@@ -71,15 +69,21 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase {
// @BeforeMethod @BeforeMethod
//注意初始化的方法不能与父类的相同,会被覆盖住 //注意初始化的方法不能与父类的相同,会被覆盖住
public void setUpPkActivity() { public void setUpPkActivity() {
try { try {
createPk("2","2020-08-12 00:00:00",groupId); createPk("3","2020-08-12 00:00:00",groupId);
Response cretePlugin = pkActivityService.pluginSave(newBetId); Response cretePlugin = pkActivityService.pluginSave(newBetId);
cretePlugin.prettyPrint(); cretePlugin.prettyPrint();
//先定向再开启
Map<String, Object> mapId = jdbc.findSimpleResult("SELECT * FROM credits_activity.tb_activity_plugin ORDER BY gmt_create DESC LIMIT 1");
pluginId = String.valueOf(mapId.get("id"));
logger.info("pk瓜分优惠券开奖的id为"+pluginId);
pluginService.changeStatus(pluginId, "1");
Boolean res = jdbc.update("update act_com_conf.tb_bet_config set plugin_id = ? where id = ?",pluginId,newBetId);
}catch (Exception e){ }catch (Exception e){
e.printStackTrace(); e.printStackTrace();
...@@ -92,70 +96,45 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase { ...@@ -92,70 +96,45 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase {
public void 调试() throws Exception{ public void 调试() throws Exception{
Response cretePlugin = pkActivityService.pluginSave("1123"); Response cretePlugin = pkActivityService.pluginSave("1123");
cretePlugin.prettyPrint(); cretePlugin.prettyPrint();
} }
@Test @Test
public void 瓜分红包_两个选项_押注人数不同_开奖测试() throws Exception{ public void 瓜分红包_两个选项_押注人数不同_开奖测试() throws Exception{
//
// List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
// logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
// for (int i=0;i<pks.size();i++){
// optionsIds.add(pks.get(i).get("id").toString());
// }
// logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
// Map<String,Object> user01_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0848 where consumer_id = '100108112' and account_type = '6'\n");
// Long use1_Acc1 = Long.valueOf(user01_account1.get("balance_amount").toString());
// Map<String,Object> user02_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0849 where consumer_id = '100108113' and account_type = '6'\n");
// Long use2_Acc1 = Long.valueOf(user02_account1.get("balance_amount").toString());
// Map<String,Object> user03_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0850 where consumer_id = '100108114' and account_type = '6'\n");
// Long use3_Acc1 = Long.valueOf(user03_account1.get("balance_amount").toString());
// Map<String,Object> user04_account1 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0851 where consumer_id = '100108115' and account_type = '6'\n");
// Long use4_Acc1 = Long.valueOf(user04_account1.get("balance_amount").toString());
//
//
// //押注第一个选项:user01,user02
// //押注第二个选项:user03,user04
// 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(0));
// Response res4 = pkService.doJoin(user04,newBetId,optionsIds.get(1));
// wins.add(consumerId01);
// wins.add(consumerId03);
// loses.add(consumerId02);
// loses.add(consumerId04);
//
// //修改开奖时间
// this.modifyOpenPrizeTime(newBetId,60);
//
// //调用开奖接口
// 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、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数,4、校验account表的红包值加上去
// checkPKConfig();
// checkPKResult("18816");
// checkPKResult("2239");
// checkUserOrder(wins,loses);
// checkRecord(wins,loses);
//
// Map<String,Object> user01_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0848 where consumer_id = '100108112' and account_type = '6'\n");
// Long use1_Acc2 = Long.valueOf(user01_account2.get("balance_amount").toString());
// Assert.assertEquals(use1_Acc2.toString(),String.valueOf(use1_Acc1+10),"用户1入账校验失败");
// Map<String,Object> user02_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0849 where consumer_id = '100108113' and account_type = '6'\n");
// Long use2_Acc2 = Long.valueOf(user02_account2.get("balance_amount").toString());
// Assert.assertEquals(use2_Acc2,use2_Acc1,"用户2入账校验失败");
// Map<String,Object> user03_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0850 where consumer_id = '100108114' and account_type = '6'\n");
// Long use3_Acc2 = Long.valueOf(user03_account2.get("balance_amount").toString());
// Assert.assertEquals(use3_Acc2.toString(),String.valueOf(use3_Acc1+10),"用户3入账校验失败");
// Map<String,Object> user04_account2 = jdbc.findSimpleResult("select * from consumer_accounts.tb_consumer_account_0851 where consumer_id = '100108115' and account_type = '6'\n");
// Long use4_Acc2 = Long.valueOf(user04_account2.get("balance_amount").toString());
// Assert.assertEquals(use4_Acc2,use4_Acc1,"用户4入账校验失败");
List<Map<String,Object>> pks = jdbc.findModeResult("select * from act_com_conf.tb_bet_option where bet_id = ?",newBetId);
logger.info("pk活动信息为"+JSONObject.toJSONString(pks));
for (int i=0;i<pks.size();i++){
optionsIds.add(pks.get(i).get("id").toString());
}
logger.info("pk活动id为:"+newBetId+",选项id为:"+ optionsIds.toString());
//押注第一个选项:user01,user02
//押注第二个选项:user03,user04
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(0));
wins.add(consumerId01);
wins.add(consumerId03);
loses.add(consumerId02);
//修改开奖时间
this.modifyOpenPrizeTime(newBetId,60);
// 调用开奖接口
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、先押注 的选项为胜方,胜负的额押注人数>负方的押注人数,4、校验account表的红包值加上去
checkPKConfig();
checkPKResult("18816");
checkUserOrder(wins,loses);
checkRecord(wins,loses);
} }
...@@ -175,11 +154,9 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase { ...@@ -175,11 +154,9 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase {
public void modifyOpenPrizeTime(String betId,int x) throws Exception{ public void modifyOpenPrizeTime(String betId,int x) throws Exception{
DateTime time1 = new DateTime(); DateTime time1 = new DateTime();
// int x=20+(int)(Math.random()*100);
DateTime endTime = time1.minusMillis(x); DateTime endTime = time1.minusMillis(x);
DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter format = DateTimeFormat.forPattern("yyyy-MM-dd HH:mm:ss");
// String endTimeStr = format.print(endTime.getMillis()).toString();
String endTimeStr = "2018-11-26 20:24:39"; String endTimeStr = "2018-11-26 20:24:39";
logger.info("\ntime1="+ format.print(time1.getMillis())+"\n设置的开奖时间endTime="+ endTimeStr); logger.info("\ntime1="+ format.print(time1.getMillis())+"\n设置的开奖时间endTime="+ endTimeStr);
Boolean result1 = jdbc.update("update act_com_conf.tb_bet_config set end_time = ? where id = ?\n",endTimeStr,betId); Boolean result1 = jdbc.update("update act_com_conf.tb_bet_config set end_time = ? where id = ?\n",endTimeStr,betId);
...@@ -195,7 +172,7 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase { ...@@ -195,7 +172,7 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase {
Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败"); Assert.assertEquals(betGroupRelation.get("config_status").toString(),"4","pk关系表开奖状态更新失败");
logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString()); logger.info("pk活动配置表状态更新为:"+betConfig.get("config_status").toString()+",pk关系表活动状态更新为:"+betGroupRelation.get("config_status").toString());
Response betList = pkActivityService.getMngBetList(); Response betList = pkActivityService.getMngBetList();
betList.prettyPrint(); // betList.prettyPrint();
List<BetMngVo> betMngVoList = betList.jsonPath().getList("data.page",BetMngVo.class); List<BetMngVo> betMngVoList = betList.jsonPath().getList("data.page",BetMngVo.class);
for (BetMngVo bet:betMngVoList){ for (BetMngVo bet:betMngVoList){
if (bet.getId().equals(newBetId)){ if (bet.getId().equals(newBetId)){
...@@ -224,9 +201,9 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase { ...@@ -224,9 +201,9 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase {
String dbName = "activity_order_con.tb_trade_center_activity_order_"+ String.format("%04d", Long.parseLong(wins.get(i)) % 1024); String dbName = "activity_order_con.tb_trade_center_activity_order_"+ String.format("%04d", Long.parseLong(wins.get(i)) % 1024);
logger.info("用户的分表名dbName为"+dbName); logger.info("用户的分表名dbName为"+dbName);
Map<String,Object> user_order = jdbc.findSimpleResult("select * from "+dbName+" where consumer_id = ? and duiba_activity_id = ?\n",wins.get(i),newBetId); Map<String,Object> user_order = jdbc.findSimpleResult("select * from "+dbName+" where consumer_id = ? and duiba_activity_id = ?\n",wins.get(i),newBetId);
Long account = Long.valueOf(user_order.get("add_credits").toString()); Long account = Long.valueOf(user_order.get("exchange_status").toString());
Assert.assertEquals(account.toString(),"10","开奖后订单更新"); Assert.assertEquals(account.toString(),"1","开奖后订单更新");
logger.info("用户"+wins.get(i)+"订单获取的红包值为:"+user_order.get("add_credits").toString()); logger.info("用户"+wins.get(i)+"订单状态为待领奖:"+user_order.get("exchange_status").toString());
} }
...@@ -234,9 +211,9 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase { ...@@ -234,9 +211,9 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase {
String dbName = "activity_order_con.tb_trade_center_activity_order_"+ String.format("%04d", Long.parseLong(loses.get(i)) % 1024); String dbName = "activity_order_con.tb_trade_center_activity_order_"+ String.format("%04d", Long.parseLong(loses.get(i)) % 1024);
logger.info("用户的分表名dbName为"+dbName); logger.info("用户的分表名dbName为"+dbName);
Map<String,Object> user_order = jdbc.findSimpleResult("select * from "+dbName+" where consumer_id = ? and duiba_activity_id = ?\n",loses.get(i),newBetId); Map<String,Object> user_order = jdbc.findSimpleResult("select * from "+dbName+" where consumer_id = ? and duiba_activity_id = ?\n",loses.get(i),newBetId);
String account = user_order.get("add_credits").toString(); String account = user_order.get("exchange_status").toString();
Assert.assertEquals(account.toString(),"","开奖后订单更新"); Assert.assertEquals(account.toString(),"-1","开奖后订单更新");
logger.info("用户"+loses.get(i)+"订单获取的红包值为:"+user_order.get("add_credits").toString()); logger.info("用户"+loses.get(i)+"订单状态为:"+user_order.get("add_credits").toString());
} }
} }
...@@ -245,16 +222,16 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase { ...@@ -245,16 +222,16 @@ public class pk_开奖_瓜分优惠券 extends DuibaTestBase {
for (int i=0;i<wins.size();i++){ for (int i=0;i<wins.size();i++){
Map<String,Object> useRecord = jdbc.findSimpleResult("select * from act_record.tb_bet_record where bet_id = ? and consumer_id = ? \n",newBetId,wins.get(i)); Map<String,Object> useRecord = jdbc.findSimpleResult("select * from act_record.tb_bet_record where bet_id = ? and consumer_id = ? \n",newBetId,wins.get(i));
Assert.assertEquals(useRecord.get("bonus").toString(), "10", "record表的红包值校验失败"); Assert.assertEquals(useRecord.get("bonus").toString(), "0", "record表的红包值校验失败");
Assert.assertEquals(useRecord.get("exchange_status").toString(), "2", "record表的发奖状态校验失败"); Assert.assertEquals(useRecord.get("exchange_status").toString(), "1", "record表的发奖状态校验失败");
logger.info("用户"+wins.get(i)+"订单获取的红包值为:"+useRecord.get("bonus").toString()); logger.info("用户"+wins.get(i)+"订单获取的红包值为:"+useRecord.get("bonus").toString()+"领奖状态为待领奖"+useRecord.get("exchange_status").toString());
} }
for (int i=0;i<loses.size();i++){ for (int i=0;i<loses.size();i++){
Map<String,Object> useRecord = jdbc.findSimpleResult("select * from act_record.tb_bet_record where bet_id = ? and consumer_id = ? \n",newBetId,loses.get(i)); Map<String,Object> useRecord = jdbc.findSimpleResult("select * from act_record.tb_bet_record where bet_id = ? and consumer_id = ? \n",newBetId,loses.get(i));
Assert.assertEquals(useRecord.get("bonus").toString(), "0", "record表的红包值校验失败"); Assert.assertEquals(useRecord.get("bonus").toString(), "0", "record表的红包值校验失败");
Assert.assertEquals(useRecord.get("exchange_status").toString(), "0", "record表的发奖状态校验失败"); Assert.assertEquals(useRecord.get("exchange_status").toString(), "0", "record表的发奖状态校验失败");
logger.info("用户"+loses.get(i)+"订单获取的红包值为:"+useRecord.get("bonus").toString()); logger.info("用户"+loses.get(i)+"订单获取的红包值为:"+useRecord.get("bonus").toString()+"领奖状态为待领奖"+useRecord.get("exchange_status").toString());
} }
} }
......
...@@ -120,8 +120,14 @@ public class PkActivityService { ...@@ -120,8 +120,14 @@ public class PkActivityService {
if (bonusType.equals("2")){ if (bonusType.equals("2")){
para.put("bonusAmount","0.1");//实际瓜分红包金额 para.put("bonusAmount","0.1");//实际瓜分红包金额
para.put("title","【自动化】瓜分红包"+time); para.put("title","【自动化】瓜分红包"+time);
}else { }else if (bonusType.equals("1")){
para.put("title","【自动化】瓜分经验"+time); para.put("title","【自动化】瓜分经验"+time);
}else {
para.put("title","【自动化】新建pk活动-瓜分优惠券");
para.put("bonusAmount","");
para.put("pluginId","12");//插件id
para.put("prizeLimit","1000");//发放上限
} }
para.put("configStatus","1"); para.put("configStatus","1");
para.put("creditsValue","1"); para.put("creditsValue","1");
...@@ -308,11 +314,11 @@ public class PkActivityService { ...@@ -308,11 +314,11 @@ public class PkActivityService {
//创建pk开奖的插件活动id //创建pk开奖的插件活动id
public Response pluginSave(String pkActivityId) throws Exception { public Response pluginSave(String pkActivityId) throws Exception {
String saveUrl = ManagerHost + "/plugin/save"; String saveUrl = "http://"+ ManagerHost + "/plugin/save";
String configUrl = ManagerHost + "/plugin/editConfig.htm"; String configUrl ="http://"+ ManagerHost + "/plugin/editConfig.htm";
//获取创建活动的token //获取创建活动的token
Response response=given().contentType("text/html;charset=UTF-8").cookies(authorization.ssoLogin()).get("http://"+configUrl); Response response=given().contentType("text/html;charset=UTF-8").cookies(authorization.ssoLogin()).get(configUrl);
String token = MatcherString.getString(response.asString(), "token: '(.*?)'", 1); String token = MatcherString.getString(response.asString(), "token: '(.*?)'", 1);
List<Map<String,String>> listPrizes = new ArrayList<>(); List<Map<String,String>> listPrizes = new ArrayList<>();
...@@ -332,31 +338,18 @@ public class PkActivityService { ...@@ -332,31 +338,18 @@ public class PkActivityService {
award.put("name","LV优惠券自动化测试链接券"); award.put("name","LV优惠券自动化测试链接券");
award.put("stockAfterChange","10"); award.put("stockAfterChange","10");
award.put("remaining","10"); award.put("remaining","10");
Map<String,String> award2 = new HashMap<>();
award.put("type","thanks");
award.put("description","谢谢参与");
award.put("logo","//yun.duiba.com.cn/upload/uP99F1462438316972.png");
award.put("valid","true");
award.put("rate","");
award.put("arealimit","false");
award.put("stockBeforeChange","0");
award.put("stockAfterChange","0");
award.put("remaining","0");
listPrizes.add(award); listPrizes.add(award);
listPrizes.add(award2);
String prizes = JSON.toJSONString(listPrizes); String prizes = JSON.toJSONString(listPrizes);
Map<String, String> map = new HashMap<>(); Map<String, String> map = new HashMap<>();
map.put("title", "【自动化】pk开奖插件"); map.put("title", "【自动化】pk开奖插件");
map.put("brickId", "0"); map.put("brickId", "92");
map.put("ruleDescription", "自动化活动规则"); map.put("ruleDescription", "自动化活动规则");
map.put("rateDescription", "自动化概率说明"); map.put("rateDescription", "自动化概率说明");
map.put("multiSkinsMode", "false"); map.put("multiSkinsMode", "false");
map.put("multiSkinIds","[]"); map.put("multiSkinIds","[]");
map.put("triggerTime","[]"); map.put("triggerTime","[]");
map.put("limitCount","1"); map.put("limitCount","1");
map.put("exitDays", "7"); map.put("exitDays", "7");
map.put("anticheatExchangeLimit", "false"); map.put("anticheatExchangeLimit", "false");
...@@ -373,10 +366,13 @@ public class PkActivityService { ...@@ -373,10 +366,13 @@ public class PkActivityService {
map.put("subType","plugdraw"); map.put("subType","plugdraw");
map.put("joinVerificyMode","15"); map.put("joinVerificyMode","15");
map.put("pkId",pkActivityId); map.put("pkId",pkActivityId);
map.put("scenarios", "chome");
logger.info("请求保存插件活动接口的参数为:" + JSONObject.toJSONString(map)); logger.info("请求保存插件活动接口的参数为:" + JSONObject.toJSONString(map));
logger.info("请求保存插件活动接口:" + saveUrl); logger.info("请求保存插件活动接口:" + saveUrl);
Response saveResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).post("http://"+saveUrl); Response saveResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).post(saveUrl);
saveResponse.prettyPrint(); saveResponse.prettyPrint();
try{ try{
Assert.assertEquals(saveResponse.jsonPath().getString("success"),"true"); Assert.assertEquals(saveResponse.jsonPath().getString("success"),"true");
......
...@@ -2,6 +2,7 @@ package http.service.Manager; ...@@ -2,6 +2,7 @@ package http.service.Manager;
import base.DuibaLog; import base.DuibaLog;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization; import http.service.Authorization;
import io.restassured.response.Response; import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -345,9 +346,4 @@ public class PluginService { ...@@ -345,9 +346,4 @@ public class PluginService {
} }
} }
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