Commit 12e07b97 authored by wangxiaoshuang's avatar wangxiaoshuang

wxs

parent 467b1c62
package http.cases.GoodsAndTradeTest;
import base.Config;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
@ContextConfiguration(classes = Config.class)
public class 自有实物商品 extends AbstractTestNGSpringContextTests {
}
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 DevDoUpdateObject {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
//单规格实物---自有商品
public Response doUpdateAppItem(String appId,String levelLimitType,String classifyIds,String title,String sellingPoint,String levelCheckbox) throws Exception{
String url="http://"+hdHost+"/devItemNew/doUpdateObject";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("isOwner","1");//是否自有商品 1:是 0:否
map.put("multiImage","[\"//yun.dui88.com/images/201811/i01a314qr1.jpg\"]");//商品主图列表,json数组
map.put("multiSku","false");//是否为多规格,true:是, false:否
map.put("levelLimitType",levelLimitType);
map.put("classifyIds",classifyIds);//商品分组id列表
map.put("title",title);//标题
map.put("sellingPoint",sellingPoint);//卖点描述
map.put("devAudit","true");//是否开启商品审核 true:开启 false:关闭
map.put("arealimitSwitch","true");
map.put("arealimitAreas","[{\"provinceCode\":\"320000\",\"provinceName\":\"江苏省\",\"cityName\":\"全省范围\",\"cityCode\":\"all\"}]");
map.put("levelLimit","true");//是否开启vip等级限制 true开启,false 未开启
map.put("levelCheckbox",levelCheckbox);//会员等级列表
map.put("expressPrice","0");//运费价格
map.put("weixinShareDesc","");//微信分享描述
map.put("description","<p>图文详情:接口自动化的图文信息</p>");
map.put("type","object");//商品类型 object:实物,coupon:优惠券,virtual:虚拟商品 ,phonebill:话费 , alipay:支付宝 ,qb:Q币 ,phoneflow:流量
map.put("subType","0");//优惠券子类型 0:普通, 1:链接型 , 2:可重复, 3:卡密
map.put("limitType","forever");//限制类型,forever:永久 everyday 每天 DAY_3:表示每3天
map.put("limitCount","10");//限制次数
map.put("expressType","free");//运费类型,free:包邮,unity:统一运费,template:运费模板
map.put("attributes","[{\"skuInfo\":{\"remaining\":\"22\",\"salePrice\":\"222\",\"facePrice\":\"22\",\"merchantCoding\":\"test\"},\"children\":null}]");
//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;
}
//查询商品列表
public Response appItems(String appId,String itemName) throws Exception{
String url="http://" + hdHost+"/devItem/appItems";
Map<String,String> map = new HashMap<>();
map.put("appId",appId);
map.put("itemName",itemName);
map.put("rowId","1");
map.put("pageSize","10");
map.put("itemType","");
map.put("status","");
map.put("belong","");
map.put("priceType","");
map.put("classifyId","");
// logger.info("======="+url);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas()).params(map).post(url);
try{
Assert.assertEquals(response.jsonPath().getString("success"),"true","/devItem/appItems接口失败");
}catch(Exception e){
throw new Exception("/devItem/appItems接口失败,返回信息:"+response.asString());
}catch(Error er){
throw new Exception("/devItem/appItems接口失败,返回信息:"+response.asString());
}
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 DuibadoUpdateObject {
@Value("${manager.host}")
String ManagerHost;//ManagerHost = mng.duibatest.com.cn
@Autowired
Authorization authorization;
/*
{,"attributes":[{"skuInfo":{"remaining":"100","supplyPrice":"10","salePrice":"22","facePrice":"11","merchantCoding":"TTTYYY"},"children":null}]}
*/
//单规格实物---兑吧商品
public Response doUpdateObject(String name) throws Exception {
String url="http://"+ManagerHost+"/goods/object/doUpdateObject";
Map<String,Object> map = new HashMap<>();
map.put("type","object");
map.put("multiImage","[\"//yun.dui88.com/images/201811/ndz1zqhyh3.png\"]");
map.put("preSaasMallVTypeList","[]");
map.put("saasMallVTypeList","[1,2,3,4]");
map.put("expressType","unity");
map.put("directRecharge","0");
map.put("multiSku","false");
map.put("attrsCopy","[]");
map.put("opTypeActivity","off");
map.put("name",name);
map.put("memo","兑吧商品备注");
map.put("multiImageStr","//yun.dui88.com/images/201811/ndz1zqhyh3.png");//商品主图
map.put("smallImage","//yun.dui88.com/images/201811/8quo3igywn.png");//商品缩略图
map.put("expressPrice","3");
map.put("description","商品描述分享信息");
map.put("alertMessage","999");
map.put("attributes","888");
map.put("attributes","[{\"skuInfo\":{\"remaining\":\"100\",\"supplyPrice\":\"10\",\"salePrice\":\"22\",\"facePrice\":\"11\",\"merchantCoding\":\"TTTYYY\"},\"children\":null}]");
//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;
}
}
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