Commit 497bbc74 authored by wangxiaoshuang's avatar wangxiaoshuang

wxs

parent 7b169114
package http.cases.GoodsAndTradeTest;
import base.Config;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.goods.DuibaDoUpdateCoupon;
import http.service.goods.DuibaList;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.testng.Assert;
import utils.PublicMethod;
@ContextConfiguration(classes = Config.class)
public class 供应商优惠券 extends DuibaTestBase {
@Autowired
DuibaDoUpdateCoupon duibaDoUpdateCoupon;
@Autowired
DuibaList duibaList;
private DuibaLog logger = DuibaLog.getLogger();
private static String data;
private static String itemId;
//新增链接券
public void 供应商链接券() throws Exception{
data = PublicMethod.data();
String name="[自动化]供应商链接券"+data;
//添加优惠券接口
duibaDoUpdateCoupon.doUpdateCouponLianjie(name);
//查询列表,验证是否添加成功
Response response =duibaList.listIndex("admin",name);
//获取商品ID
itemId = String.valueOf(response.jsonPath().getString("data.page.rows[0].itemDto.id"));
//校验数据
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.name"), "【自动化】供应商链接券"+data, "校验优惠券name失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.type"), "coupon", "校验优惠券类型失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.remaining"), "100", "校验优惠券库存失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.version"), "1", "校验优惠券版本(新版本展示1,旧版本0失败)");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.actualPrice"), "10000", "校验优惠券供货价失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.facePrice"), "11000", "校验优惠券版本建议零售价失败");
logger.info("校验title,belong成功");
}
//新增重复券
public void 供应商重复券() throws Exception{
data = PublicMethod.data();
String name="[自动化]供应商重复券"+data;
//添加优惠券接口
duibaDoUpdateCoupon.doUpdateCouponChongfu(name);
//查询列表,验证是否添加成功
Response response =duibaList.listIndex("admin",name);
//获取商品ID
itemId = String.valueOf(response.jsonPath().getString("data.page.rows[0].itemDto.id"));
//校验数据
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.name"), "【自动化】供应商重复券"+data, "校验优惠券name失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.type"), "coupon", "校验优惠券类型失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.remaining"), "200", "校验优惠券库存失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.version"), "1", "校验优惠券版本(新版本展示1,旧版本0失败)");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.actualPrice"), "8800", "校验优惠券供货价失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.facePrice"), "18800", "校验优惠券版本建议零售价失败");
logger.info("校验title,belong成功");
}
//新增重复券
public void 供应商普通券() throws Exception{
data = PublicMethod.data();
String name="[自动化]供应商普通券"+data;
//添加优惠券接口
duibaDoUpdateCoupon.doUpdateCouponChongfu(name);
//查询列表,验证是否添加成功
Response response =duibaList.listIndex("admin",name);
//获取商品ID
itemId = String.valueOf(response.jsonPath().getString("data.page.rows[0].itemDto.id"));
//校验数据
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.name"), "【自动化】供应商普通券"+data, "校验优惠券name失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.type"), "coupon", "校验优惠券类型失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.remaining"), "9", "校验优惠券库存失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.version"), "1", "校验优惠券版本(新版本展示1,旧版本0失败)");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.actualPrice"), "3600", "校验优惠券供货价失败");
Assert.assertEquals(response.jsonPath().getString("data.page.rows[0].itemDto.facePrice"), "7200", "校验优惠券版本建议零售价失败");
logger.info("校验title,belong成功");
}
//删除链接券
public void 删除链接券() throws Exception{
duibaDoUpdateCoupon.deleteItem(itemId);
}
}
package http.service.goods;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class DuibaDoUpdateCoupon {
@Value("${manager.host}")
String ManagerHost;//ManagerHost = mng.duibatest.com.cn
@Autowired
Authorization authorization;
//优惠券--链接券
public Response doUpdateCouponLianjie(String name) throws Exception {
String url="http://"+ManagerHost+"/newmanager/goods/coupon/doUpdateCoupon";
Map<String,Object> map = new HashMap<>();
map.put("subType","1");//0 普通券 1链接券 2重复券
map.put("multiImage","//yun.dui88.com/images/201812/b02d3ed2t1.png");
map.put("preSaasMallVTypeList","[]");
map.put("saasMallVTypeList","[]");
map.put("expressType","unity");
map.put("arealimitType","1");
map.put("arealimitSwitch","on");
map.put("opTypeCaptchaCheck","on");
map.put("directRecharge","0");
map.put("multiSku","false");//是否多规格,false 否,true 是
map.put("attributes","[\n" +
" {\n" +
" \"skuInfo\":{\n" +
" \"remaining\":100,\n" +
" \"salePrice\":\"10\",\n" +
" \"suggestMarketPrice\":\"11\",\n" +
" \"facePrice\":\"222\"\n" +
" },\n" +
" \"children\":null\n" +
" }\n" +
" ]");//多规格列表
map.put("cardLibraryId","");//卡券库ID
map.put("classifyId","");//优惠券分类
map.put("opTypeActivity","off");//是否活动专用
map.put("itemLimitConfigVO","{\n" +
" \"limitScope\":\"forever\",\n" +
" \"limitCount\":\"10\"\n" +
" }");//
map.put("showBarCode","");
map.put("showButton","");
map.put("linkUrl","http://www.baidu.com");
map.put("validDaterange","");
map.put("couponCode","");
map.put("couponCount","100");
map.put("validStartDay","2018-12-22");
map.put("validEndDay","2058-12-22");
map.put("name",name);
map.put("memo","接口自动化--链接券");
map.put("smallImage","//yun.dui88.com/images/201812/80r8dze8zz.pn");
map.put("arealimitAreas","[\n" +
" {\n" +
" \"provinceCode\":\"320000\",\n" +
" \"provinceName\":\"江苏省\",\n" +
" \"cityName\":\"全省范围\",\n" +
" \"cityCode\":\"all\"\n" +
" }\n" +
" ]");
map.put("usageRule","<p>21212</p>");
map.put("type","coupon");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//添加重复券码
public Response doUpdateCouponChongfu(String name) throws Exception {
String url="http://"+ManagerHost+"/newmanager/goods/coupon/doUpdateCoupon";
Map<String,Object> map = new HashMap<>();
map.put("subType","2");//0 普通券 1链接券 2重复券
map.put("multiImage","//yun.dui88.com/images/201812/b02d3ed2t1.png");
map.put("preSaasMallVTypeList","[]");
map.put("saasMallVTypeList","[]");
map.put("expressType","unity");
map.put("arealimitType","1");
map.put("arealimitSwitch","on");
map.put("opTypeCaptchaCheck","on");
map.put("directRecharge","0");
map.put("multiSku","false");//是否多规格,false 否,true 是
map.put("attributes","[\n" +
" {\n" +
" \"skuInfo\":{\n" +
" \"remaining\":100,\n" +
" \"salePrice\":\"88\",\n" +
" \"suggestMarketPrice\":\"188\",\n" +
" \"facePrice\":\"20\"\n" +
" },\n" +
" \"children\":null\n" +
" }\n" +
" ]");//多规格列表
map.put("cardLibraryId","");//卡券库ID
map.put("classifyId","");//优惠券分类
map.put("opTypeActivity","off");//是否活动专用
map.put("itemLimitConfigVO","{\n" +
" \"limitScope\":\"forever\",\n" +
" \"limitCount\":\"10\"\n" +
" }");//
map.put("showBarCode","");
map.put("showButton","");
map.put("linkUrl","");
map.put("validDaterange","");
map.put("couponCode","9999");
map.put("couponCount","200");
map.put("validStartDay","2018-12-22");
map.put("validEndDay","2058-12-22");
map.put("name",name);
map.put("memo","接口自动化--重复券");
map.put("smallImage","//yun.dui88.com/images/201812/80r8dze8zz.pn");
map.put("arealimitAreas","[\n" +
" {\n" +
" \"provinceCode\":\"320000\",\n" +
" \"provinceName\":\"江苏省\",\n" +
" \"cityName\":\"全省范围\",\n" +
" \"cityCode\":\"all\"\n" +
" }\n" +
" ]");
map.put("usageRule","<p>21212</p>");
map.put("type","coupon");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//新增普通券码
public Response doUpdateCouponPutong(String name,String cardLibraryId,String cardLibraryName) throws Exception {
String url="http://"+ManagerHost+"/newmanager/goods/coupon/doUpdateCoupon";
Map<String,Object> map = new HashMap<>();
map.put("subType","0");//0 普通券 1链接券 2重复券
map.put("multiImage","//yun.dui88.com/images/201812/b02d3ed2t1.png");
map.put("preSaasMallVTypeList","[]");
map.put("saasMallVTypeList","[]");
map.put("expressType","unity");
map.put("arealimitType","1");
map.put("arealimitSwitch","on");
map.put("opTypeCaptchaCheck","on");
map.put("directRecharge","0");
map.put("multiSku","false");//是否多规格,false 否,true 是
map.put("attributes","[\n" +
" {\n" +
" \"skuInfo\":{\n" +
" \"remaining\":9,\n" +
" \"salePrice\":\"36\",\n" +
" \"suggestMarketPrice\":\"72\",\n" +
" \"facePrice\":\"20\"\n" +
" },\n" +
" \"children\":null\n" +
" }\n" +
" ]");//多规格列表
map.put("cardLibraryId",cardLibraryId);//卡券库ID
map.put("cardLibraryName",cardLibraryName);
map.put("classifyId","");//优惠券分类
map.put("opTypeActivity","off");//是否活动专用
map.put("itemLimitConfigVO","{\n" +
" \"limitScope\":\"forever\",\n" +
" \"limitCount\":\"10\"\n" +
" }");//
map.put("showBarCode","");
map.put("showButton","");
map.put("linkUrl","");
map.put("validStartDay","2018-12-22");
map.put("validEndDay","2058-12-22");
map.put("name",name);
map.put("memo","接口自动化--重复券");
map.put("smallImage","//yun.dui88.com/images/201812/80r8dze8zz.pn");
map.put("arealimitAreas","[\n" +
" {\n" +
" \"provinceCode\":\"320000\",\n" +
" \"provinceName\":\"江苏省\",\n" +
" \"cityName\":\"全省范围\",\n" +
" \"cityCode\":\"all\"\n" +
" }\n" +
" ]");
map.put("usageRule","<p>21212</p>");
map.put("type","coupon");
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).body(jsonParam).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
//删除优惠券
public Response deleteItem(String id) throws Exception {
String url="http://"+ManagerHost+"/newmanager/goods/item/deleteItem/"+id;
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).get();
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
}
package http.service.goods;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import http.service.Authorization;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.testng.Assert;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
@Service
public class DuibaList {
@Value("${manager.host}")
String ManagerHost;//ManagerHost = mng.duibatest.com.cn
@Autowired
Authorization authorization;
//查询列表
public Response listIndex(String nameType,String name) throws Exception{
String url="http://"+ManagerHost+"/newmanager/goods/item/index";
Map<String,Object> map = new HashMap<>();
map.put("status","");
map.put("itemType","");
map.put("operType","");
map.put("nameType",nameType);//??
map.put("pageSize","20");
map.put("pageNo","1");
map.put("itemClassifyIdObject","");
map.put("itemClassifyIdCoupon","");
map.put("itemName",name);//商品名称
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).get(url);
try{
Assert.assertEquals(response.jsonPath().getString("desc"),"成功");
}catch(Exception e){
throw new Exception("创建接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("创建失败,返回信息:"+response.asString());
}
return response;
}
}
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