Commit 14f2fdab authored by wangxiaoshuang's avatar wangxiaoshuang

wxs

parent f466cb4c
package http.cases.GoodsAndTradeTest;
import base.Config;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.annotations.Test;
import java.text.SimpleDateFormat;
import java.util.Date;
@ContextConfiguration(classes = Config.class)
public class 自有卡券库 extends AbstractTestNGSpringContextTests {
@Test
public void t333(){
Date date=new Date();
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM--dd");
simpleDateFormat.format(date);
System.out.println("---------"+simpleDateFormat.format(date));
}
}
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 DevCards {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
//添加券码
public Response cardsSave(String appId,String type,String name) throws Exception {
String url="http://"+hdHost+"/cardLibrary/save";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("type",type);//类型
map.put("name",name);//名称
map.put("fileUrl","http%3A%2F%2Fyun.dui88.com%2Fcoupons%2F1544497069778.txt");//文件地址
map.put("startDay","");//有效期--开始时间
map.put("endDay","");//有效期--结束时间
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).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 list(String appId,String name) throws Exception {
String url="http://"+hdHost+"/cardLibrary/list";
Map<String,Object> map = new HashMap<>();
map.put("name",name);//名称
map.put("pageNo","1");
map.put("pageSize","15");
map.put("appId",appId);
map.put("type","");
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).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;
}
//导入批次
//删除
public Response delete(String appId,String id) throws Exception {
String url="http://"+hdHost+"/cardLibrary/delete";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);
map.put("id",id);
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).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;
}
}
This diff is collapsed.
...@@ -84,33 +84,5 @@ public class DevDoUpdateObject { ...@@ -84,33 +84,5 @@ public class DevDoUpdateObject {
} }
return response; return response;
} }
//保存积分配置
public Response doUpdateCredits(String appId,String appItemId) throws Exception{
String url="http://"+hdHost+"/devItemNew/doUpdateCredits";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//appid
map.put("appItemId",appItemId);//商品ID
map.put("buttonText","");
map.put("creditsInfos","[{skuId: \"0\"}]");//自定义
map.put("dateRage","[\"2018-11-29\", \"2019-05-31\"]");
map.put("exchangeType","1");//兑换类型,1:自动 2:自定义
map.put("indexHidden","true");//是否在首页商品区隐藏,true:隐藏 false:显示
map.put("limitDate","2018-11-29,2019-05-31");//兑换日期限制
map.put("limitEverydayQuantity","6");//每日限量
map.put("multiSku","false");
map.put("onSale","false");//是否上架 true:立即上架 false:放入仓库
map.put("originalPriceBuy","true");//是否支持原价购买 ,true:支持 false:不支持
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).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;
}
} }
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 DoUpdateCredits {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
//获取商品ID
public Response getCreditsDetail(String appId,String appItemId) throws Exception{
String url="http://"+hdHost+"devItemNew/getCreditsDetail";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//appid
map.put("appItemId",appItemId);//商品ID
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).body(jsonParam).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;
}
//保存积分配置
public Response doUpdateCredits(String appId, String appItemId,String creditsInfos) throws Exception{
String url="http://"+hdHost+"/devItemNew/doUpdateCredits";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//appid
map.put("appItemId",appItemId);//商品ID
map.put("buttonText","");
map.put("creditsInfos",creditsInfos);//自定义
map.put("dateRage","[\"2018-11-29\", \"2019-05-31\"]");
map.put("exchangeType","1");//兑换类型,1:自动 2:自定义
map.put("indexHidden","true");//是否在首页商品区隐藏,true:隐藏 false:显示
map.put("limitDate","2018-11-29,2019-05-31");//兑换日期限制
map.put("limitEverydayQuantity","6");//每日限量
map.put("multiSku","false");
map.put("onSale","false");//是否上架 true:立即上架 false:放入仓库
map.put("originalPriceBuy","true");//是否支持原价购买 ,true:支持 false:不支持
//json 格式转成form表单
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response=given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).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;
}
}
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