Commit 86458923 authored by 赵然's avatar 赵然

zr

parent af1990f8
/**
* Copyright (C), 2015-2018
* FileName: 瓜分积分测试_AccessTest
* Author: zhaoran
* Date: 2018/12/10 19:45
* Description:
*/
package http.cases.PkMoudleTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.PkMoudleService;
import http.service.hd.PkDevelopService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.math.BigDecimal;
public class 瓜分积分_AccessTest extends DuibaTestBase {
@Autowired
PkMoudleService pkMoudleService;
@Autowired
PkDevelopService pkDevelopService;
private DuibaLog logger = DuibaLog.getLogger();
private static Integer uid = 5029;//
//@Test
public void 创建PK活动() throws Exception{
Response response = pkDevelopService.betEditor("21771","4",null,"30");
Assert.assertEquals(response.jsonPath().getString("desc"),"成功","创建组件化pk活动失败");
}
}
\ No newline at end of file
/**
* Copyright (C), 2015-2018
* FileName: BetMngVo
* Author: qianwenjun
* Date: 2018/8/5 10:12
* Description:
*/
package http.model;
import java.util.List;
/**
* @author 赵然
* @create 2018/12/11
* @since 1.0.0
*/
public class BetDevelopVo {
public List<BetOptionVo> getBetOptionDtoList() {
return betOptionDtoList;
}
public void setBetOptionDtoList(List<BetOptionVo> betOptionDtoList) {
this.betOptionDtoList = betOptionDtoList;
}
private List<BetOptionVo> betOptionDtoList;
private String betType; //'押注类型 1-单选单次,2-多选无限制'
private String bonusAmount; //'每人实际分得金额'
private String bonusType; //'瓜分类型1瓜分经验2瓜分红包3发奖品4瓜分积分'
private String configStatus; //'投注活动的状态:1关闭不可见2关闭可见3开启4结束'
private String creditsValue; //'积分价值'
private String endTime; //'活动结束时间'
private String shareExp; //'瓜分的经验池'
private String startTime; // '活动开始时间'
private String title; //'投注活动标题'
// private String id; //主键
// private String pluginId; //'发奖品时需要填插件id'
// private String prizeLimit; //'发奖品时的发放上限'
// public String getPluginId() {
// return pluginId;
// }
//
// public void setPluginId(String pluginId) {
// this.pluginId = pluginId;
// }
//
// public String getPrizeLimit() {
// return prizeLimit;
// }
// public void setPrizeLimit(String prizeLimit) {
// this.prizeLimit = prizeLimit;
// }
public String getBetType() {
return betType;
}
public void setBetType(String betType) {
this.betType = betType;
}
public String getBonusAmount() {
return bonusAmount;
}
public void setBonusAmount(String bonusAmount) {
this.bonusAmount = bonusAmount;
}
public String getBonusType() {
return bonusType;
}
public void setBonusType(String bonusType) {
this.bonusType = bonusType;
}
public String getConfigStatus() {
return configStatus;
}
public void setConfigStatus(String configStatus) {
this.configStatus = configStatus;
}
public String getCreditsValue() {
return creditsValue;
}
public void setCreditsValue(String creditsValue) {
this.creditsValue = creditsValue;
}
public String getEndTime() {
return endTime;
}
public void setEndTime(String endTime) {
this.endTime = endTime;
}
public String getShareExp() {
return shareExp;
}
public void setShareExp(String shareExp) {
this.shareExp = shareExp;
}
public String getStartTime() {
return startTime;
}
public void setStartTime(String startTime) {
this.startTime = startTime;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
// public String getId() {
// return id;
// }
//
// public void setId(String id) {
// this.id = id;
// }
}
\ No newline at end of file
......@@ -19,7 +19,7 @@ public class BetOptionVo {
private String optionImg;
private String optionName;
private String rightAnswer;
public String getOptionImg() {
return optionImg;
......@@ -37,5 +37,11 @@ public class BetOptionVo {
this.optionName = optionName;
}
public String getRightAnswer() {
return rightAnswer;
}
public void setRightAnswer(String rightAnswer) {
this.rightAnswer = rightAnswer;
}
}
\ No newline at end of file
package http.service.hd;
import base.DuibaLog;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.model.BetOptionVo;
import http.model.BetDevelopVo;
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;
import org.testng.Assert;
import utils.MatcherString;
import utils.PublicMethod;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* @author zhaoran
* @create 2018/12/11
* @since 1.0.0
*/
@Service
public class PkDevelopService {
@Value("${hdserver.host}")
String hdHost;
@Value("${manager.host}")
String ManagerHost;
@Autowired
Authorization authorization;
private DuibaLog logger = DuibaLog.getLogger();
public Response betEditor(String appId,String bonusType,String bonusAmount,String shareExp) throws Exception{
String data = PublicMethod.data();
String url = "http://" + hdHost + "/visual-editor/bet/post";
//创建投注项
List<BetOptionVo> betOptionVoList = new ArrayList<>();
BetOptionVo betOptionVo1 = new BetOptionVo();
BetOptionVo betOptionVo2 = new BetOptionVo();
betOptionVo1.setOptionImg("//yun.dui88.com/images/201812/75j84chnkg.jpg");
betOptionVo1.setOptionName("1");
betOptionVo1.setRightAnswer(null);
betOptionVo2.setOptionImg("//yun.dui88.com/images/201812/4f51vmzfpu.png");
betOptionVo2.setOptionName("2");
betOptionVo2.setRightAnswer(null);
betOptionVoList.add(betOptionVo1);
betOptionVoList.add(betOptionVo2);
//创建活动配置
List<BetDevelopVo> betDevelopVoList = new ArrayList<>();
BetDevelopVo betDevelopVo = new BetDevelopVo();
betDevelopVo.setBetOptionDtoList(betOptionVoList);
betDevelopVo.setBetType("1");
betDevelopVo.setBonusType(bonusType);
if (bonusType.equals("2")){
betDevelopVo.setTitle("【自动化】组件pk_瓜分红包"+data);
}else if (bonusType.equals("4")){
betDevelopVo.setTitle("【自动化】组件pk_瓜分积分"+data);
}
betDevelopVo.setBonusAmount(bonusAmount);
betDevelopVo.setConfigStatus("3");
betDevelopVo.setCreditsValue("1");
betDevelopVo.setEndTime("2029-12-31 00:00");
betDevelopVo.setShareExp(shareExp);
betDevelopVoList.add(betDevelopVo);
Map<String,Object> para = new HashMap<>();
para.put("list",betDevelopVoList);
para.put("rules","自动化规则自动化规则");
para.put("title","组件pk自动化");
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(para));
Response betResponse = given().contentType("application/json;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).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 doDraw() throws Exception{
String url = "http://" + ManagerHost + "/newmanager/betOpenPrize/doDraw";
Map<String,Object> para = new HashMap<>();
// para.put("pageNo","1");
// para.put("pageSize","20");
Response doDrawResponse = given().cookies(authorization.ssoLogin()).params(para).get(url);
try{
Assert.assertEquals(doDrawResponse.jsonPath().getString("success"),"true");
}catch(Exception e){
throw new Exception("pk活动开奖接口失败,返回信息:"+doDrawResponse.asString());
}catch(Error er){
throw new Exception("pk活动开奖接口失败,返回信息:"+doDrawResponse.asString());
}
return doDrawResponse;
}
// public static void main(String[] args) throws Exception{
// String endTime = "2021-12-31 23:55:00";
// PkActivityService pkActivityService = new PkActivityService();
//
// Response betResponse = pkActivityService.bet("2",endTime);
// String betId = MatcherString.getString(betResponse.asString(),"\"data\":(.*?)}",1);
// Response betRelation = pkActivityService.betGroupRelation(betId,endTime);
// Response modifyStatusResponse = pkActivityService.modifySatus(betId);
//
// }
}
\ No newline at end of file
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