Commit 95ed0a4e authored by qwj-github's avatar qwj-github

Merge branch 'develop' into qwj_181029

parents 07bf6e52 b97c30d5
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.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.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.cases.SaasDeveloperTest;
import base.Config;
import base.DuibaBase;
import http.service.Manager.ADeveloperService;
import http.service.Saas.UpdateAppInfoService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.apache.commons.exec.ExecuteException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.Test;
@ContextConfiguration(classes = Config.class)
public class 设置_应用信息_DuibaTest extends AbstractTestNGSpringContextTests {
//@ContextConfiguration(classes = Config.class)
public class 设置_应用信息_DuibaTest extends DuibaBase {
private DuibaLog logger = DuibaLog.getLogger();
@Autowired
UpdateAppInfoService updateAppInfoService;
@Autowired
ADeveloperService aDeveloperService;
String appId = "19515";
//设置--保存应用信息
@Test
public void 保存应用信息() throws Exception{
String appId="19515";
String earnCreditsUrl="https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=www.baidu.com";
String creditsDetailUrl="https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=www.baidu.com";
Response response= updateAppInfoService.appInfo(appId);
Boolean isDecimalOpen=response.jsonPath().getBoolean("data.isDecimalOpen");
logger.info("******"+isDecimalOpen);
public void 保存应用信息() throws Exception {
String appId = "19515";
String earnCreditsUrl = "https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=www.baidu.com";
String creditsDetailUrl = "https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=www.baidu.com";
Response response = updateAppInfoService.appInfo(appId);
Boolean isDecimalOpen = response.jsonPath().getBoolean("data.isDecimalOpen");
logger.info("******" + isDecimalOpen);
String unitName = isDecimalOpen ? "元" : "积分";
updateAppInfoService.UpdateAppInfo(appId,unitName,earnCreditsUrl,creditsDetailUrl,isDecimalOpen);
updateAppInfoService.UpdateAppInfo(appId, unitName, earnCreditsUrl, creditsDetailUrl, isDecimalOpen);
Thread.sleep(1000);
Response response2= updateAppInfoService.appInfo(appId);
Response response2 = updateAppInfoService.appInfo(appId);
Assert.assertEquals(response2.jsonPath().getString("data.name"), "(saas自动化)至尊版", "校验应用名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.earnCreditsLetter"), "积分文案&2", "校验积分文案失败");
Assert.assertEquals(response2.jsonPath().getString("data.creditsDetailUrl"), "https://www.baidu.com/s?ie=utf-8&f=8&rsv_bp=1&tn=baidu&wd=www.baidu.com", "校验积分明细链接失败");
logger.info("保存应用信息成功");
}
@Test(description = "// 查询员工信息——高级管理员信息")
public void a_查询高级管理员信息() throws Exception {
Response response1 = aDeveloperService.developer("109","text");
logger.info("response1");
Response response2=updateAppInfoService.selectEmployeeList("","",appId);
logger.info("response2");
String mappname=response1.jsonPath().getString("list[0].appName");
String memail=response1.jsonPath().getString("list[0].email");
String mname=response1.jsonPath().getString("list[0].name");
String demail=response2.jsonPath().getString("data.list[0].developerAccount");
String dname=response2.jsonPath().getString("data.list[0].nickName");
// 校验2个接口的信息是否一致
Assert.assertEquals(mappname,"(saas自动化)至尊版", "校验应用名称失败");
Assert.assertEquals(memail,demail,"校验邮箱失败");
Assert.assertEquals(mname,dname,"校验高级管理员名称失败");
Assert.assertEquals(response2.jsonPath().getString("data.list[0].roleName"),"高级管理员","校验角色名称失败");
logger.info("校验高级管理员信息成功");
}
@Test(description = "//添加/编辑员工")
public void b_添加员工() throws Exception{
Response response=updateAppInfoService.selectAllRoles(appId);
//查询角色接口,得到普通管理员的角色ID
String roleId=response.jsonPath().getString("data[1].id");
//添加一个注册过的开发者&普通管理员信息
updateAppInfoService.saveOrUpdate("18258853242","hmx自动化测试",roleId,"普通管理员",appId);
//刷新员工管理列表
updateAppInfoService.selectEmployeeList("","1",appId);
//校验是否添加成功
Assert.assertEquals(updateAppInfoService.selectEmployeeList("","",appId).jsonPath().getString("data.list[1].developerAccount"),"18258853242", "校验账号信息失败");
Assert.assertEquals(updateAppInfoService.selectEmployeeList("","",appId).jsonPath().getString("data.list[1].nickName"),"hmx自动化测试", "校验名称失败");
Assert.assertEquals(updateAppInfoService.selectEmployeeList("","",appId).jsonPath().getString("data.list[1].roleName"),"普通管理员", "校验角色名称失败");
logger.info("校验普通管理员信息添加成功");
}
@Test(description = "兑吧账号精确搜索,姓名模糊搜索")
public void c_搜索场景() throws Exception{
//通过邮箱号精确搜索
updateAppInfoService.selectEmployeeList("","wxs@duiba.com.cn",appId);
//通过手机号精确搜索
updateAppInfoService.selectEmployeeList("","18258853242",appId);
//姓名模糊搜索
updateAppInfoService.selectEmployeeList("","hmx",appId);
//通过角色名称搜索
updateAppInfoService.selectEmployeeList("395","",appId);
logger.info("校验各种搜索成功");
}
}
......@@ -97,4 +97,32 @@ public class ADeveloperService {
}
return response;
}
//管理后台-开发者维护-查询开发者账号详细信息
public Response developer(String queryStrId,String type) throws Exception {
String url ="http://" + ManagerHost + "/newmanager/ADeveloper/developer";
Map<String,String> map = new HashMap<>();
map.put("queryStr","");
map.put("queryStrId",queryStrId);
map.put("type",type);
map.put("pageNo","1");
map.put("pageSize","20");
logger.info("url"+url);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.ssoLogin()).params(map).get(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("success"), "true");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
}
......@@ -2,6 +2,8 @@ package http.service.Saas;
import base.DuibaLog;
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;
......@@ -73,4 +75,65 @@ public class UpdateAppInfoService {
return response;
}
//查询员工管理高级管理员信息(模糊查询,没有传参数)
public Response selectEmployeeList(String roleId,String keyword,String appId) throws Exception {
String url = "http://" + hdHost + "/employee/selectEmployeeList";
Map<String, String> map = new HashMap<>();
map.put("roleId",roleId);
map.put("rowId","1");
map.put("keyword",keyword);
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//查询有的角色信息
public Response selectAllRoles(String appId) throws Exception {
String url = "http://" + hdHost + "/employee/selectAllRoles";
Map<String, String> map = new HashMap<>();
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).params(map).get(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + response.asString());
}
return response;
}
//添加员工——普通管理员
public Response saveOrUpdate(String developerAccount,String nickName,String roleId,String roleName,String appId) throws Exception {
String url = "http://" + hdHost + "/employee/saveOrUpdate";
Map<String, String> map = new HashMap<>();
map.put("developerAccount",developerAccount);
map.put("nickName",nickName);
map.put("roleId",roleId);
map.put("roleName",roleName);
JSONObject jsonParam = JSONObject.parseObject(JSON.toJSONString(map));
Response response =given().contentType("application/json;charset=UTF-8").cookies(authorization.hdLoginSaas(appId)).body(jsonParam).post(url);
response.prettyPrint();
try {
Assert.assertEquals(response.jsonPath().getString("desc"), "成功");
} catch (Exception e) {
throw new Exception("创建接口1失败,返回信息:" + response.asString());
} catch (Error er) {
throw new Exception("创建接口2失败,返回信息:" + 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 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,String type,String excludeRelated) 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",type);//类型:0:券码 1:链接 2:重复 3:卡密
map.put("excludeRelated",excludeRelated);//true:排查已关联的 false:不排除
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.
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 DevDoUpdateKaMi {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
//添加无规格卡密
public Response doupdateCouponWuguige(String appId,String classifyIds,String title,String type) throws Exception{
String url="http://"+hdHost+"/devItemNew/doUpdateCoupon";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("isOwner","true");
map.put("multiImage","//yun.dui88.com/images/201812/7uukykd9va.png");
map.put("multiSku","false");//是否为多规格,true:是, false:否
map.put("levelLimitType","1");
map.put("arealimitType","1");
map.put("levelCheckbox","[]");
map.put("validDaterange","[]");
map.put("showJumpButton","false");
map.put("cardLibraryId","");
map.put("classifyIds",classifyIds);//商品分组
map.put("title",title);
map.put("sellingPoint","我是卡密无规格的卖点描述");
map.put("smallImage","//yun.dui88.com/images/201812/8oh63tx4ks.jpg");
map.put("devAudit","true");
map.put("arealimitSwitch","false");
map.put("weixinShareDesc","微信分享信息");
map.put("autoOffDate","2030-12-31 00:00");
map.put("usageRule","<p>使用规则</p>");
map.put("description","<p>图文详情</p>");
map.put("type",type);//商品类型
map.put("subType","3");//0:券码 1:链接 2:重复 3:卡密
map.put("limitType","forever");//限制类型
map.put("expressType","free");//运费类型,free:包邮,unity:统一运
//attributes 多规格列表
map.put("attributes","[\n" +
" {\n" +
" \"skuInfo\":{\n" +
" \"cardLibraryId\":\"54\",\n" +
" \"cardLibraryName\":\"5345\",\n" +
" \"remaining\":1,\n" +
" \"salePrice\":\"9.22\",\n" +
" \"facePrice\":\"32.23\",\n" +
" \"merchantCoding\":\"2323232\"\n" +
" },\n" +
" \"children\":null\n" +
" }\n" +
" ]");
//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 doupdateCouponDuoguige(String appId,String classifyIds,String title,String type) throws Exception{
String url="http://"+hdHost+"/devItemNew/doUpdateCoupon";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("isOwner","true");
map.put("multiImage","//yun.dui88.com/images/201812/7uukykd9va.png");
map.put("multiSku","true");//是否为多规格,true:是, false:否
map.put("levelLimitType","1");
map.put("arealimitType","1");
map.put("levelCheckbox","[]");
map.put("validDaterange","[]");
map.put("showJumpButton","false");
map.put("cardLibraryId","");
map.put("classifyIds",classifyIds);//商品分组
map.put("title",title);
map.put("sellingPoint","我是卡密无规格的卖点描述");
map.put("smallImage","//yun.dui88.com/images/201812/8oh63tx4ks.jpg");
map.put("arealimitSwitch","false");
map.put("weixinShareDesc","微信分享信息");
map.put("autoOffDate","2030-12-31 00:00");
map.put("usageRule","<p>使用规则</p>");
map.put("description","<p>图文详情</p>");
map.put("type",type);//商品类型
map.put("subType","3");//0:普通 1:链接 2:重复 3:卡密
map.put("limitType","forever");//限制类型
map.put("expressType","free");//运费类型,free:包邮,unity:统一运
//attributes 多规格列表
map.put("attributes","[\n" +
" {\n" +
" \"id\":\"117\",\n" +
" \"skuInfo\":{\n" +
" \"salePrice\":\"2\",\n" +
" \"cardLibraryId\":\"82\",\n" +
" \"cardLibraryName\":\"卡密2\",\n" +
" \"remaining\":1,\n" +
" \"facePrice\":\"65.77\",\n" +
" \"merchantCoding\":\"RTTT001\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" },\n" +
" {\n" +
" \"id\":\"118\",\n" +
" \"skuInfo\":{\n" +
" \"cardLibraryId\":\"83\",\n" +
" \"cardLibraryName\":\"卡密3\",\n" +
" \"remaining\":9,\n" +
" \"salePrice\":\"3.55\",\n" +
" \"facePrice\":\"7.65\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" },\n" +
" {\n" +
" \"id\":\"119\",\n" +
" \"skuInfo\":{\n" +
" \"cardLibraryId\":\"84\",\n" +
" \"cardLibraryName\":\"卡密4\",\n" +
" \"remaining\":9,\n" +
" \"salePrice\":\"5.77\",\n" +
" \"facePrice\":\"55.5\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" }\n" +
" ]");
//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 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;
}
}
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 DevDoUpdateVirtual {
@Value("${hdserver.host}")
String hdHost;
@Autowired
Authorization authorization;
//添加无规格商家充值
public Response doUpdateVirtualWuguige(String appId, String classifyIds, String title, String type) throws Exception{
String url="http://"+hdHost+"/devItemNew/doUpdateVirtual";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("isOwner","true");
map.put("multiImage","[\n" +
" \"//yun.dui88.com/images/201812/b0pt4h46nb.png\",\n" +
" \"//yun.dui88.com/images/201812/vkk5btvaec.png\"\n" +
" ]");
map.put("multiSku","false");//是否为多规格,true:是, false:否
map.put("levelLimitType","1");
map.put("arealimitType","1");
map.put("levelCheckbox","[]");
map.put("validDaterange","[]");
map.put("showJumpButton","false");
map.put("cardLibraryId","");
map.put("classifyIds",classifyIds);//商品分组
map.put("needAccount","true");//是否开启账号 true 开启,false 未开启
map.put("accountTitle","账号");
map.put("accountPrompt","请输入账号信");
map.put("title",title);
map.put("sellingPoint","我是卡密无规格的卖点描述");
map.put("smallImage","//yun.dui88.com/images/201812/mlc9aoosfk.jpg");
map.put("arealimitSwitch","false");
map.put("weixinShareDesc","微信分享信息");
map.put("autoOffDate","2030-12-31 00:00");
map.put("description","<p>图文详情</p>");
map.put("type",type);//商品类型
map.put("subType","0");//0:普通 1:链接 2:重复 3:卡密
map.put("limitType","forever");//限制类型
map.put("expressType","free");//运费类型,free:包邮,unity:统一运
//attributes 多规格列表
map.put("attributes","[\n" +
" {\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"100\",\n" +
" \"merchantCoding\":\"TTT002\",\n" +
" \"salePrice\":\"6.75\",\n" +
" \"facePrice\":\"2.35\"\n" +
" },\n" +
" \"children\":null\n" +
" }\n" +
" ]");
//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 doUpdateVirtualDuoguige(String appId, String classifyIds, String title, String type) throws Exception{
String url="http://"+hdHost+"/devItemNew/doUpdateVirtual";
Map<String,Object> map = new HashMap<>();
map.put("appId",appId);//应用ID
map.put("isOwner","true");
map.put("multiImage","[\n" +
" \"//yun.dui88.com/images/201812/b0pt4h46nb.png\",\n" +
" \"//yun.dui88.com/images/201812/vkk5btvaec.png\"\n" +
" ]");
map.put("multiSku","true");//是否为多规格,true:是, false:否
map.put("levelLimitType","1");
map.put("arealimitType","1");
map.put("levelCheckbox","[]");
map.put("validDaterange","[]");
map.put("showJumpButton","false");
map.put("cardLibraryId","");
map.put("classifyIds",classifyIds);//商品分组
map.put("needAccount","true");//是否开启账号 true 开启,false 未开启
map.put("accountTitle","账号");
map.put("accountPrompt","请输入账号信");
map.put("title",title);
map.put("sellingPoint","我是卡密无规格的卖点描述");
map.put("smallImage","//yun.dui88.com/images/201812/mlc9aoosfk.jpg");
map.put("arealimitSwitch","false");
map.put("weixinShareDesc","微信分享信息");
map.put("autoOffDate","2030-12-31 00:00");
map.put("description","<p>图文详情</p>");
map.put("type",type);//商品类型
map.put("subType","0");//0:普通 1:链接 2:重复 3:卡密
map.put("limitType","forever");//限制类型
map.put("expressType","free");//运费类型,free:包邮,unity:统一运
//attributes 多规格列表
map.put("attributes","\n" +
" {\n" +
" \"id\":\"120\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"11\",\n" +
" \"salePrice\":\"13\",\n" +
" \"facePrice\":\"32\",\n" +
" \"merchantCoding\":\"111\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" },\n" +
" {\n" +
" \"id\":\"121\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"2\",\n" +
" \"salePrice\":\"23\",\n" +
" \"facePrice\":\"32\",\n" +
" \"merchantCoding\":\"222\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" },\n" +
" {\n" +
" \"id\":\"122\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"32\",\n" +
" \"salePrice\":\"24\",\n" +
" \"facePrice\":\"32.23\",\n" +
" \"merchantCoding\":\"333\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" },\n" +
" {\n" +
" \"id\":\"123\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"2\",\n" +
" \"salePrice\":\"33\",\n" +
" \"facePrice\":\"32.23\",\n" +
" \"merchantCoding\":\"444\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" },\n" +
" {\n" +
" \"id\":\"124\",\n" +
" \"skuInfo\":{\n" +
" \"remaining\":\"3\",\n" +
" \"salePrice\":\"21\",\n" +
" \"facePrice\":\"32.43\",\n" +
" \"merchantCoding\":\"555\"\n" +
" },\n" +
" \"specId\":\"0\",\n" +
" \"children\":null\n" +
" }\n" +
" ]");
//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;
}
}
This diff is collapsed.
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;
}
}
This diff is collapsed.
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