Commit 3fa9d5b7 authored by 赵然's avatar 赵然

Merge branch 'develop'

parents 719330f9 aa0becb3
package http.cases.ExchangeTest;
public class Database {
//主订单库
public static String orders_consumer = "orders_consumer";
//主订单分表
public static String orders = "orders_0614";
public static String orders2 = "orders_0874";
public static String orders3 = "orders_0693";
public static String orders4 = "orders_0208";
public static String orders5 = "orders_0209";
public static String orders6 = "orders_0210";
public static String orders7 = "orders_0211";
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.CouponExchangeService;
import http.service.app.MobileService;
import http.service.app.SeckillService;
import http.service.hd.PlatformCouponService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
//@ContextConfiguration(classes = DuibaConfig.class)
public class Exchange_ExchangeTest extends DuibaTestBase{
@Value("${manager.host}")
String ManagerHost;
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private PlatformCouponService platformCouponService;
@Autowired
private SeckillService SeckillService;
@Autowired
ManagerService managerService;
private DuibaLog logger = DuibaLog.getLogger();
// private MysqlUtils jdbc;
//指定用户
private static int uid = 3766;
// @BeforeClass
// public void before(){
// jdbc = MysqlUtils.mysqlDuiba("dafuweng");
// }
// @AfterClass
// public void after(){
// jdbc.releaseConn();
//
// }
//实物兑换并发货
@Test(description = "实物兑换")
public void goods() throws Exception {
//查询数据库,当前积分
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:"+credits);
//扣去100积分
credits = String.valueOf(Integer.valueOf(credits)-100);
//活动详情页
Response response =mobileService.detail(authorization.dafuwengLogin(uid),"26762");
Map<String,String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()),"200","活动详情页请求异常");
//实物兑换
response = couponExchangeService.objectExchange(map,"159143","2619","null","z9sydmcs","null");
// response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i=10;
//异步接口,直到兑换成功
while(i>0&&"兑换正在处理中...".equals(message)){
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:"+creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits,creditsNew);
logger.info("校验兑换前后积分正确");
//兑吧管理后台发货
managerService.expressSend(orderId);
logger.info("实物兑换订单成功");
}
//秒杀
@Test(description = "秒杀兑换")
public void seckill(){
Response response = SeckillService.ajaxSubmit("18556");
response.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("success"),"true");
}
//优惠券兑换
@Test(description = "优惠券兑换")
public void coupon() throws Exception {
//查询数据库,当前积分
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:"+credits); //扣去100积分
credits = String.valueOf(Integer.valueOf(credits)-100);
//优惠券兑换
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid),"157070","27050");
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid,orderId);
String status = response.jsonPath().getString("status");
//异步接口
int i=10;
while(i>0&&"processing".equals(status)){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid,orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:"+creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(),creditsNew,"优惠券兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.*;
import utils.ExcelDataProvider;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Iterator;
import java.util.Map;
/**
* Created by yeqinqin on 2018/4/24.
*/
public class ObjectExchange_ExchangeTest extends DuibaTestBase{
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private CrecordService crecordService;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
@Autowired
QbExchangeService qbExchangeService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 2707;
@BeforeClass
public void before() {
managerService.update(uid,"5555555");
// jdbc = MysqlUtils.mysqlDuiba("orders_consumer");
try {
jdbc.update("delete from orders_consumer.orders_0614 where consumer_id = 100011622 and biz_params = 'DUIBA_SELF'", null);
} catch (Exception e) {
e.printStackTrace();
}
}
// @AfterClass
// public void after() {
// jdbc.releaseConn();
//
// }
//实物兑换并发货
//@Test(description = "实物兑换")
public void goods() throws Exception {
//查询数据库,当前积分
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
//扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 100);
//活动详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "26762");
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
response = couponExchangeService.objectExchange(map, "159143", "2619", "null", "z9sydmcs", "null");
// response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
//查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits, creditsNew);
logger.info("校验兑换前后积分正确");
//兑吧管理后台发货
managerService.expressSend(orderId);
logger.info("实物兑换订单成功");
}
//优惠券兑换
//@Test(description = "优惠券兑换")
public void coupon() throws Exception {
//查询数据库,当前积分
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits); //扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 100);
//优惠券兑换
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), "157070", "27050");
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(), uid,orderId);
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && "processing".equals(status)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
//查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
Map<String,Object> mapConsumer = jdbc.findSimpleResult("SELECT * FROM new_consumer.consumer_0010 WHERE `app_id` = 2239 AND id = 100011622");
String creditsNew = String.valueOf(mapuser.get("credits"));
String creditsCon = String.valueOf(mapConsumer.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "优惠券兑换后积分扣除异常");
Assert.assertEquals(creditsCon,creditsNew,"本地积分与用户积分不符");
logger.info("校验兑换前后积分正确");
}
//直充类单档话费兑换_1元话费
@Test(description = "直充类单档话费兑换")
public void phonebillDingzhi() throws Exception {
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
//扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 100);
//兑换详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "1660");
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//1元话费兑换
response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid), "156497", "1660");
response.prettyPrint();
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取提交结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(), uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,兑换提交成功!待处理
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
//获取兑换结果
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
String isProcess = response.jsonPath().getString("isProcess");
int j = 10;
//异步接口,兑换成功
while (j > 0 && "兑换正在处理中...".equals(isProcess)) {
Thread.sleep(1000);
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
isProcess = response.jsonPath().getString("isProcess");
j--;
}
//查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "话费兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
}
//多档位话费兑换_10元话费
@Test(dataProvider = "providerMethod")
public void 多档位兑换(Map<String,String> data) throws Exception {
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
//扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - Integer.valueOf(data.get("credits")));
//兑换详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "1");
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//10元话费兑换
response = couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid), data.get("degreeId"));
response.prettyPrint();
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取提交结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,兑换提交成功!待处理
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
//获取兑换结果
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
String isProcess = response.jsonPath().getString("isProcess");
int j = 10;
//异步接口,兑换成功
while (j > 0 && "兑换正在处理中...".equals(isProcess)) {
Thread.sleep(1000);
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
isProcess = response.jsonPath().getString("isProcess");
j--;
}
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "话费兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
}
//自有实物兑换并发货
@Test(description = "实物兑换")
public void 自有实物兑换() throws Exception {
//查询数据库,当前积分
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
Map<String, Object> mapStock = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 674900860200090332");
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
//扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 1);
String stock = String.valueOf(mapStock.get("stock"));
logger.info("兑换前库存:" + stock);
//扣去1
stock = String.valueOf(Integer.valueOf(stock) - 1);
//活动详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "27970");
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
response = couponExchangeService.objectExchange(map, "161100", null, "null", "z9sydmcs", "null");
// response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
//查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后库存
Assert.assertEquals(credits, creditsNew,"积分校验失败");
logger.info("校验兑换前后积分正确");
mapStock = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 674900860200090332");
String stockNew = String.valueOf(mapStock.get("stock"));
logger.info("兑换后库存:" + stockNew);
//校验比较,兑换前后积分
Assert.assertEquals(stock, stockNew,"库存校验失败");
logger.info("校验兑换前后库存正确");
//兑吧管理后台发货
// response = managerService.expressSend(orderId);
// logger.info("实物兑换订单成功");
}
//自有优惠券兑换_重复券
@Test(description = "自有优惠券兑换")
public void 自有优惠券() throws Exception {
//查询数据库,当前积分
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
//select * from goods.tb_goods_batch where gid=159857 查询库存id gid=itemid
Map<String, Object> mapStock = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 607824566024920113");
String stock = String.valueOf(mapStock.get("stock"));
logger.info("兑换前库存:" + stock);
//扣去1
stock = String.valueOf(Integer.valueOf(stock) - 1);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits); //扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 1);
//优惠券兑换
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid), "159857", null);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(), uid,orderId);
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && "processing".equals(status)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
response.prettyPrint();
//查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "优惠券兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
mapStock = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 607824566024920113");
String stockNew = String.valueOf(mapStock.get("stock"));
logger.info("兑换后库存:" + stockNew);
//校验比较,兑换前后积分
Assert.assertEquals(stock, stockNew,"库存校验失败");
logger.info("校验兑换前后库存正确");
}
//自有虚拟商品单档兑换
@Test(description = "自有虚拟商品单档兑换")
public void 自有虚拟商品单档兑换() throws Exception {
//查询数据库,当前积分
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits); //扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 1);
Map<String, Object> mapStock = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 674900860200070105");
String stock = String.valueOf(mapStock.get("stock"));
logger.info("兑换前库存:" + stock);
//扣去1
stock = String.valueOf(Integer.valueOf(stock) - 1);
//优惠券兑换
Response response = virtualExchangeService.exchange(authorization.dafuwengLogin(uid), "159849", "DUIBA_SELF");
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(), uid,orderId);
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && "processing".equals(status)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(), uid,orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
Thread.sleep(1000);
//查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "优惠券兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
mapStock = jdbc.findSimpleResult("select * from stock.tb_stock where stock_id = 674900860200070105");
String stockNew = String.valueOf(mapStock.get("stock"));
logger.info("兑换后库存:" + stockNew);
//校验比较,兑换前后积分
Assert.assertEquals(stock, stockNew,"库存校验失败");
logger.info("校验兑换前后库存正确");
Thread.sleep(2000);
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from orders_consumer.orders_0614 where consumer_id = 100011622 and biz_params = 'DUIBA_SELF' ",null);
//logger.info("selectResult结果为:"+selectResult);
Assert.assertEquals( selectResult.get("biz_params"),"DUIBA_SELF","虚拟商品出奖标识DUIBA_SELF校验失败");
logger.info("数据库存储虚拟商品标记结果为:"+selectResult.get("biz_params"));
}
//直充类流量兑换
@Test(description = "直充类流量兑换")
public void 流量兑换() throws Exception {
int uid = 4376;
Thread.sleep(2000);
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
//扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 600);
//兑换详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "3");
//Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//流量兑换
response = couponExchangeService.phoneflowExchange(authorization.dafuwengLogin(uid), "51200", "3","13193354550","中国联通","陕西");
response.prettyPrint();
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取提交结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,兑换提交成功!待处理
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
//获取兑换结果
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
String isProcess = response.jsonPath().getString("isProcess");
int j = 10;
//异步接口,兑换成功
while (j > 0 && "兑换正在处理中...".equals(isProcess)) {
Thread.sleep(1000);
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
isProcess = response.jsonPath().getString("isProcess");
j--;
}
//查询数据库,获取当前积分
Thread.sleep(2000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "话费兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
}
//直充类支付宝兑换
@Test(description = "直充类支付宝兑换")
public void 支付宝兑换() throws Exception {
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
//扣去100积分
credits = String.valueOf(Integer.valueOf(credits) - 100);
//兑换详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "55");
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//支付宝(1元)兑换
response = couponExchangeService.alipayExchange(uid,"55");
response.prettyPrint();
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取提交结果
response = mobileService.orderStatusQuery(response.getDetailedCookies(), uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("message");
int i = 10;
//异步接口,兑换提交成功!待处理
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(response.getDetailedCookies(),uid, orderId);
response.prettyPrint();
message = response.jsonPath().getString("message");
i--;
}
//获取兑换结果
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
String isProcess = response.jsonPath().getString("isProcess");
int j = 10;
//异步接口,兑换成功
while (j > 0 && "兑换正在处理中...".equals(isProcess)) {
Thread.sleep(1000);
response = crecordService.recordFresh(uid,orderId);
response.prettyPrint();
isProcess = response.jsonPath().getString("isProcess");
j--;
}
//查询数据库,获取当前积分
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:" + creditsNew);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "支付宝兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
}
// @Test(description = "qb 兑换",dataProvider = "providerMethodQb")
public void qbExchange(Map<String,String> data) throws Exception {
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554",data.get("degreeId"));
// response.prettyPrint();
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
logger.info("兑换后积分:" + mapuser.get("credits"));
String creditsNew = String.valueOf((Long)mapuser.get("credits")+Integer.valueOf(data.get("credits")));
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "qb兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
//订单状态校验
Thread.sleep(5000);
Map<String, Object> orderMap = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0614 where id ="+orderId);
String status = (String)orderMap.get("status");
Assert.assertTrue(status.equals("success"),"校验订单状态失败");
logger.info("校验兑换订单状态正确");
}
@DataProvider
public Iterator<Object[]> providerMethod(Method method) throws IOException {
Iterator<Object[]> result = null;
result = new ExcelDataProvider("duiba/多档位兑换");
return result;
}
@DataProvider
public Iterator<Object[]> providerMethodQb(Method method) throws IOException {
Iterator<Object[]> result = null;
result = new ExcelDataProvider("duiba/qb兑换");
return result;
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.*;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DsOrderService;
import utils.MatcherString;
import utils.ExcelDataProvider;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.io.IOException;
import java.lang.reflect.Method;
import java.sql.SQLException;
import java.util.Iterator;
import java.util.Map;
/**
* Created by mabo on 2018/9/13
*/
public class Qb_兑换流程测试_ExchangeTest extends DuibaTestBase {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private CrecordService crecordService;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
@Autowired
QbExchangeService qbExchangeService;
@Autowired
DeveloperAccountService developerAccountService;
@Autowired
DsOrderService dsOrderService;
@Autowired
SupplierExchangeTemplateService supplierExchangeTemplateService;
private DuibaLog logger = DuibaLog.getLogger();
@BeforeClass
public void beforeClass(){
//模版设置成处理后成功
supplierExchangeTemplateService.use("476");
}
@BeforeMethod
public void beforeMethod() throws SQLException {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '2'");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '2'");
}
@DataProvider
public Iterator<Object[]> providerMethodQb(Method method) throws IOException {
Iterator<Object[]> result = null;
result = new ExcelDataProvider("duiba/qb兑换");
return result;
}
@Test
public void qbExchange() throws Exception {
int uid = 3767;
Map<String, Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:" + credits);
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","3");
String orderId = (String)response.jsonPath().get("orderId");
logger.info("订单号:"+orderId);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
logger.info("兑换后积分:" + mapuser.get("credits"));
String creditsNew = String.valueOf((Long)mapuser.get("credits")+30);
//校验比较,兑换前后积分
Assert.assertEquals(credits.trim(), creditsNew, "qb兑换后积分扣除异常");
logger.info("校验兑换前后积分正确");
//订单状态校验
Thread.sleep(5000);
Map<String, Object> orderMap = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0207 where id ="+orderId);
String status = (String)orderMap.get("status");
logger.info("订单状态:"+status);
Assert.assertTrue(status.equals("success"),"校验订单状态失败");
logger.info("校验兑换订单状态正确");
}
@Test
public void qbExchange_积分不足() throws Exception {
int uid = 3086;
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","5");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换失败,用户积分余额不足")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
Map<String, Object> orderMap = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0693 where id ="+orderId);
String orderStatus = String.valueOf(orderMap.get("status"));
Assert.assertEquals(message,"兑换失败,用户积分余额不足","校验message失败");
Assert.assertEquals(orderStatus,"fail","校验订单状态失败");
logger.info("积分不足兑换校验成功");
}
@Test
public void 开发者余额不足测试() throws Exception{
int uid = 3490;
//开发者余额, 开发者账户:xuyan_8707@163.com
Response accountResponse = developerAccountService.accountInfoCommon("xuyan_8707@163.com");
String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
logger.info("兑换前的开发者账户余额:" + remainMoney);
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"2");
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
String message=null;
String succcess = null;
try{
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("没有兑换成功"));
Assert.assertTrue(message.contains("\"success\":false"));
}
@Test
public void 每日兑换限制() throws Exception {
int uid = 3767;
//第一次兑换
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//第二次兑换
try{
response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","1");
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("已兑完"));
Assert.assertTrue(message.contains("\"success\":false"));
}
@Test
public void 永久兑换限制() throws Exception {
int uid = 3767;
//第一次兑换
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","2");
String orderId = (String)response.jsonPath().get("orderId");
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
String message = response.jsonPath().getString("message");
int i=10;
while(!message.equals("兑换提交成功!待处理")&&i>0){
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid),orderId);
message = response.jsonPath().getString("message");
i--;
}
//第二次兑换
try{
response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","2");
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("已兑完"));
Assert.assertTrue(message.contains("\"success\":false"));
}
//@Test
public void 审核通过测试() throws Exception {
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
// String remainMoneyNew =String.valueOf(Integer.valueOf(remainMoney) - 9600) ;
int uid = 2709;
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","100");
String orderId = (String)response.jsonPath().get("orderId");
response.prettyPrint();
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
Response auditResponse = dsOrderService.submitAudit(orderId,"pass");
auditResponse.prettyPrint();
//判断订单是否审核成功,如果订单没有成功则继续审核
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"pass");
mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoney);
// Assert.assertEquals(remainMoney,remainMoneyNew,"校验开发者账户余额失败");
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
remainMoney =String.valueOf(Integer.valueOf(remainMoney) - 9600) ;
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"success","校验订单状态失败");
logger.info("校验支付宝扣费订单成功");
}
//@Test
public void 审核不通过测试() throws Exception{
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
//qb兑换
int uid = 2709;
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","100");
String orderId = (String)response.jsonPath().get("orderId");
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
//订单审核
Response auditResponse = dsOrderService.submitAudit(orderId,"reject");
auditResponse.prettyPrint();
//判断订单是否审核失败
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"reject");
mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("当前订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// String remainMoneyNew = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
// Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"fail","校验订单状态失败");
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
logger.info("校验支付宝审核订单失败返还金额成功");
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import utils.RedisUtil;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.*;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DsOrderService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2018/07/06.
*/
public class 优惠券_兑换流程测试_ExchangeTest extends DuibaTestBase {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private DsOrderService dsOrderService;
@Autowired
ManagerService managerService;
@Autowired
DeveloperAccountService developerAccountService;
@Autowired
CrecordService crecordService;
private DuibaLog logger = DuibaLog.getLogger();
// private MysqlUtils jdbc;
private String url = "http://activity.m.duibatest.com.cn";
//指定用户
private static int uid = 3768;
// @BeforeClass
// public void before(){
//
// jdbc = MysqlUtils.mysqlDuiba("");
//
// }
//
// @AfterClass
// public void after(){
//
// jdbc.releaseConn();
// }
@DataProvider
public Object[][] providerMethod(Method method) {
Object[][] result = null;
if (method.getName().equals("优惠券日期兑换限制测试")) {
result = new Object[][]{
new Object[]{1, "171479", "29538", "69xjl0a", "优惠券日期兑换限制未开始"}, //case1
new Object[]{2, "171480", "29539", "z9sydmcs", "优惠券日期兑换限制进行中"}, //case2
new Object[]{3, "171481", "29540", "cmixdqn", "优惠券日期兑换限制已结束"}, //case2
};
}
if (method.getName().equals("优惠券库存不足测试")) {
result = new Object[][]{
new Object[]{"169775", "29180", "69xjl0a", "优惠券商品库存不足测试"}, //case1
new Object[]{"172163", "29677", "z9sydmcs", "优惠券定向库存不足测试"}, //case2
new Object[]{"174773","30286","qyarwreq","优惠券预分配库存不足测试"},
};
}
if (method.getName().equals("优惠券审核通过测试")) {
result = new Object[][]{
new Object[]{1,"169698", "29156", "兑吧优惠券审核通过测试"}, //case1
new Object[]{2,"172178", "", "自有优惠券审核通过测试"}, //case2
};
}
if (method.getName().equals("优惠券马上使用按钮测试")){
result = new Object[][]{
new Object[]{1,"172292", "29708", "优惠券商家落地页下载按钮测试"}, //case1
new Object[]{2,"172293", "29709", "优惠券兑换记录页下载按钮测试"}, //case2
new Object[]{3,"172294","29710","优惠券链接券按钮测试"}, //case3
};
}
if (method.getName().equals("自有优惠券会员等级测试")){
result = new Object[][]{
new Object[]{1,"172713","pmqy9","优惠券会员等级范围测试"}, //case1
new Object[]{2,"172715","3bam907y", "优惠券会员特定等级测试"}, //case2
};
}
if (method.getName().equals("优惠券地区兑换限制测试")){
result = new Object[][]{
new Object[]{1,"175459","30434","pmqy9","优惠券地区黑名单不可兑测试"}, //case1
new Object[]{2,"175603","30435","3bam907y", "优惠券地区黑名单可兑测试"}, //case2
new Object[]{3,"175604","30436","6dc8ntp", "优惠券地区白名单可兑测试"}, //case3
new Object[]{4,"175605","30437","tvtgya6","优惠券地区白名单不可兑测试"}, //case4
};
}
return result;
}
@Test
public void 优惠券扣库存测试() throws Exception {
//查询优惠券兑换前的库存
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id ='705804724784620492'");
String stock = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换前的优惠券库存:" + stock);
stock = String.valueOf(Integer.parseInt(stock) - 1) ;
//优惠券兑换
this.优惠券兑换("169713","29164",uid);
//查询优惠券兑换后的库存
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id ='705804724784620492'");
String stockNew = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换后的优惠券库存:" + stockNew);
Assert.assertEquals(stockNew,stock,"校验优惠券库存失败");
logger.info("优惠券兑换扣库存校验成功");
}
@Test
public void 优惠券预分配库存测试() throws Exception{
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM goods.pre_stock WHERE point_id = '584'");
String stock = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换前的优惠券预分配库存:" + stock);
stock = String.valueOf(Integer.valueOf(stock)-1);
//查询优惠券兑换前的积分,增加等待时间,同步更新积分
Thread.sleep(1000);
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前的积分:"+credits);
credits = String.valueOf(Integer.valueOf(credits)-10);
//优惠券兑换
this.优惠券兑换("174797","30290",uid);
//查询优惠券兑换后的预分配库存和积分
mapStock = jdbc.findSimpleResult("SELECT * FROM goods.pre_stock WHERE point_id = '584'");
String stockNew = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换后的优惠券预分配库存:" + stockNew);
Thread.sleep(1000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:"+creditsNew);
Assert.assertEquals(stockNew,stock,"校验优惠券预分配库存失败");
Assert.assertEquals(creditsNew,credits,"校验优惠券预分配最小兑换价格失败");
logger.info("校验惠券预分配库存和最小兑换积分成功");
}
@Test
public void 优惠券共享库存测试() throws Exception{
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM goods.pre_stock WHERE point_id = '586'");
String stock = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换前的优惠券共享库存:" + stock);
stock = String.valueOf(Integer.valueOf(stock)-1);
//优惠券兑换
this.优惠券兑换("174923","30318",uid);
//查询优惠券兑换后的共享库存
mapStock = jdbc.findSimpleResult("SELECT * FROM goods.pre_stock WHERE point_id = '586'");
String stockNew = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换后的优惠券共享库存:" + stockNew);
Assert.assertEquals(stockNew,stock,"校验优惠券共享库存库存失败");
logger.info("校验优惠券共享库存扣除成功");
}
@Test
public void 优惠券预分配每日限额测试() throws Exception{
//获取当前的时间
Date dNow = new Date();
SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd");
String ftDate = ft.format(dNow);
try {
//优惠券第一次兑换
this.优惠券兑换("174928","30319",uid);
//每日限额用完,无法再次兑换
Thread.sleep(3000);
Map<String,String> map = new HashMap<>();
map.put("appItemId","174928");
map.put("itemId","30319");
map.put("token","uvbhjc");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"30319");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
Assert.assertEquals(response.jsonPath().getString("message"),"今日已兑完,明天再来哦(14)","校验message失败");
Assert.assertEquals(exchangeText,"今日已兑完","校验马上兑换按钮状态失败");
logger.info("校验优惠券预分配每日限额兑换成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
//清除兑换数据和 redis
jdbc.update("DELETE FROM goods.pre_stock_consume_detail WHERE point_id = 588");
RedisUtil.clearObjectKey("121-588");
RedisUtil.clearKey("everydayStock" + ftDate + "588");
}
}
/**
* @param appItemId 商品入库Id
* @param itemId 商品id
* @param token 活动token
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 优惠券库存不足测试( String appItemId, String itemId, String token, String caseName) throws Exception{
logger.info(caseName);
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("itemId",itemId);
map.put("token",token);
//优惠券兑换
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29180");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
Assert.assertEquals(response.jsonPath().getString("message"),"今日已兑完,明天再来哦(14)","校验message失败");
Assert.assertEquals(exchangeText,"已兑完","校验马上兑换按钮状态失败");
logger.info("校验优惠券商品库存不足和预分配库存不足场景成功");
}
@Test
public void 优惠券积分不足测试() throws Exception{
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(3086,true),"29164");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
//优惠券兑换
Response response = this.优惠券兑换("169713","29164",3086);
Assert.assertEquals(exchangeText,"积分不足","校验马上兑换按钮状态失败");
Assert.assertEquals(response.jsonPath().getString("message"),"兑换失败,用户积分余额不足","校验message失败");
logger.info("校验优惠券商品积分不足场景成功");
}
/**
* @param caseNum 用例id
* @param appItemId 商品入库Id
* @param itemId 商品id
* @param caseName 用例名称打印
* @throws Exception
*/
//@Test(dataProvider = "providerMethod")
public void 优惠券审核通过测试(int caseNum, String appItemId, String itemId, String caseName) throws Exception{
logger.info(caseName);
//查询兑换前的开发者余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者余额:" + remainMoney);
// String remainMoneyNew =String.valueOf(Integer.valueOf(remainMoney) - 1000) ;
//优惠券兑换
String orderId = this.优惠券兑换订单(appItemId,itemId,uid);
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders4+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders4+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
Response auditResponse = dsOrderService.submitAudit(orderId,"pass");
auditResponse.prettyPrint();
//判断订单是否审核成功,如果订单没有成功则继续审核
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"pass");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders4+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
switch (caseNum){
case 1:
//查询兑换后的开发者余额
// accountResponse = developerAccountService.accountInfo();
// remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者余额:" + remainMoney);
Assert.assertEquals(status,"success","订单状态校验失败");
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
remainMoney =String.valueOf(Integer.valueOf(remainMoney) - 1000) ;
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
logger.info("校验兑吧优惠券审核通过扣费成功");
break;
case 2:
Assert.assertEquals(status,"success","订单状态校验失败");
logger.info("校验自有优惠券审核通过成功");
}
}
@Test
public void 优惠券用户永久兑换限制测试() throws Exception{
Map<String,String> map = new HashMap<>();
map.put("appItemId","170294");
map.put("itemId","29293");
map.put("token","69xjl0a");
try{
//优惠券兑换,用户兑换限制次数1次
Response response = this.优惠券兑换("170294","29293",uid);
Assert.assertEquals(response.jsonPath().getString("status"),"success","校验兑换失败");
logger.info("用户成功兑换一次");
//再次兑换
Thread.sleep(3000);
response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29293");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
Assert.assertEquals(response.jsonPath().getString("message"),"已兑换","校验用户兑换限制失败");
Assert.assertEquals(exchangeText,"已兑换","校验马上兑换按钮状态失败");
logger.info("校验优惠券用户永久兑换限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '29293'");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '29293'");
}
}
@Test
public void 优惠券用户每日兑换限制测试() throws Exception{
Map<String,String> map = new HashMap<>();
map.put("appItemId","171478");
map.put("itemId","29531");
map.put("token","69xjl0a");
try{
//优惠券兑换,用户兑换限制次数1次
Response response = this.优惠券兑换("171478","29531", uid);
Assert.assertEquals(response.jsonPath().getString("status"),"success","校验兑换失败");
logger.info("用户成功兑换一次");
//再次兑换
Thread.sleep(3000);
response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29531");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
Assert.assertEquals(response.jsonPath().getString("message"),"今日已兑换","校验用户兑换限制失败");
Assert.assertEquals(exchangeText,"今日已兑换","校验马上兑换按钮状态失败");
logger.info("校验优惠券用户每天兑换限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '29531'");
}
}
@Test
public void 优惠券每日兑换上限测试() throws Exception{
Map<String,String> map = new HashMap<>();
map.put("appItemId","170295");
map.put("itemId","29294");
map.put("token","69xjl0a");
try{
//优惠券兑换,用户兑换限制次数1次
Response response= this.优惠券兑换("170295","29294", uid);
Assert.assertEquals(response.jsonPath().getString("status"),"success","校验兑换失败");
logger.info("用户成功兑换一次");
//再次兑换
Thread.sleep(3000);
response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29294");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
Assert.assertEquals(response.jsonPath().getString("message"),"今日已兑完,明天再来哦(14)","校验每日兑换上限失败");
Assert.assertEquals(exchangeText,"今日已兑完","校验马上兑换按钮状态失败");
logger.info("校验优惠券每日兑换上限成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM goods.tb_everyday_limit WHERE item_id = '29294'");
}
}
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param itemId 商品id
* @param token 活动token
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 优惠券日期兑换限制测试(int caseNum, String appItemId, String itemId, String token, String caseName) throws Exception{
logger.info(caseName);
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("itemId",itemId);
map.put("token",token);
//兑换
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
switch (caseNum){
case 1:
Assert.assertEquals(response.jsonPath().getString("message"),"请在限定时间内兑换哦(13)","校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"即将开始","校验马上兑换按钮状态失败");
logger.info("校验优惠券日期兑换限制未开始成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"马上兑换","校验马上兑换按钮状态失败");
logger.info("校验优惠券日期兑换限制进行中成功");
break;
case 3:
Assert.assertEquals(response.jsonPath().getString("message"),"已结束","校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"已结束","校验马上兑换按钮状态失败");
logger.info("校验优惠券日期兑换限制已结束成功");
break;
}
}
@Test
public void 优惠券限时兑换测试() throws Exception{
Map<String,String> map = new HashMap<>();
map.put("appItemId","172079");
map.put("itemId","29667");
map.put("token","69xjl0a");
//兑换
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"29667");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
Calendar cal = Calendar.getInstance();
int hour = cal.get(Calendar.HOUR_OF_DAY);
logger.info("当前时间是:" + hour + "时");
if(hour >= 0 && hour < 15 ){
//限时兑换未开始
Assert.assertEquals(response.jsonPath().getString("message"),"请在限定时间内兑换哦(13)","校验限时兑换失败");
Assert.assertEquals(exchangeText,"即将开始","校验马上兑换按钮状态失败");
logger.info("校验优惠券限时兑换未开始场景成功");
}else if(hour >= 15 && hour < 19){
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验限时兑换失败");
Assert.assertEquals(exchangeText,"马上兑换","校验马上兑换按钮状态失败");
logger.info("校验优惠券限时兑换进行中场景成功");
}else{
Assert.assertEquals(response.jsonPath().getString("message"),"今日已兑完,明天再来哦(14)","校验日期兑换限制失败");
Assert.assertEquals(exchangeText,"今日已结束","校验马上兑换按钮状态失败");
logger.info("校验优惠券限时兑换结束场景成功");
}
}
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param itemId 商品id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 优惠券马上使用按钮测试(int caseNum, String appItemId, String itemId, String caseName)throws Exception{
logger.info(caseName);
//优惠券兑换
String orderId = this.优惠券兑换订单(appItemId,itemId,uid);
//优惠券兑换结果页
Response resultResponse = crecordService.recordDetail(orderId,uid);
resultResponse.prettyPrint();
String btnText = MatcherString.getString(resultResponse.asString(),"\"btnText\":\"(.*?)\",",1);
String actualPay = MatcherString.getString(resultResponse.asString(),"\"actualPay\":\"(.*?)\",",1);
String androidDownload = MatcherString.getString(resultResponse.asString(),"\"androidDownload\":\"(.*?)\",",1);
String androidDownloadUrl = MatcherString.getString(resultResponse.asString(),"\"androidDownloadUrl\":\"(.*?)\",",1);
//优惠券兑换记录页
Thread.sleep(3000);
Response recordResponse = crecordService.recordDetailNew(orderId,uid);
recordResponse.prettyPrint();
String useButtonText = MatcherString.getString(recordResponse.asString(),"\"useButtonText\":\"(.*?)\",",1);
String androidDownloadUrl2 = MatcherString.getString(recordResponse.asString(),"\"androidDownloadUrl\":\"(.*?)\",",1);
switch (caseNum){
case 1:
Assert.assertEquals(btnText,"马上使用","校验结果页按钮文案失败");
Assert.assertEquals(actualPay,"10积分","校验结果页积分文案失败");
Assert.assertEquals(androidDownload,"https://m2.mobike.com/active/fission_packet_joint/index.html","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"马上使用","校验兑换记录页按钮文案失败");
Assert.assertEquals(androidDownloadUrl2,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fm2.mobike.com%2Factive%2Ffission_packet_joint%2Findex.html&amp;dpm=2239.25.2.0&amp;dcm=101.29708.172292.0","校验兑换记录页按钮跳转链接失败");
logger.info("校验优惠券商家落地页下载链接页面成功");
break;
case 2:
Assert.assertEquals(btnText,"马上领取","校验结果页按钮文案失败");
Assert.assertEquals(actualPay,"20积分","校验结果页积分文案失败");
Assert.assertEquals(androidDownload,"https://u.163.com/aoshzxiaoshouxiaoshou4","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"马上领取","校验兑换记录页按钮文案失败");
Assert.assertEquals(androidDownloadUrl2,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fu.163.com%2Faoshzxiaoshouxiaoshou4&amp;dpm=2239.25.2.0&amp;dcm=101.29709.172293.0","校验兑换记录页按钮跳转链接失败");
logger.info("校验优惠券兑换记录页下载链接页面成功");
break;
case 3:
Assert.assertEquals(btnText,"马上下载","校验结果页按钮文案失败");
Assert.assertEquals(actualPay,"30积分","校验结果页积分文案失败");
Assert.assertEquals(androidDownloadUrl,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fm.wkzuche.com%2Fh5%2F%23%2Factivity%2Fshare%3Fchannel%3Ddb%402018&amp;dpm=2239.25.1.0&amp;dcm=101.29710.172294.0","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"马上下载","校验兑换记录页按钮文案失败");
Assert.assertEquals(androidDownloadUrl2,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fm.wkzuche.com%2Fh5%2F%23%2Factivity%2Fshare%3Fchannel%3Ddb%402018&amp;dpm=2239.25.2.0&amp;dcm=101.29710.172294.0","校验兑换记录页按钮跳转链接失败");
logger.info("校验优惠券链接券页面成功");
break;
}
}
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param token token
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 自有优惠券会员等级测试(int caseNum, String appItemId, String token,String caseName) throws Exception{
logger.info(caseName);
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("token",token);
//会员等级不符,详情页按钮“如何获得兑换资格”
Response detailResponse = mobileService.appItemDetail(appItemId,uid);
detailResponse.prettyPrint();
//会员等级不符,兑换
Response failResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
failResponse.prettyPrint();
//会员等级符合条件,兑换,vip=5
Response response = couponExchangeService.couponExchange(authorization.generateSignAutoLogin("2wGQc3MZaQsqYFWcX4gguya5PnnS",3402),appItemId,"");
response.prettyPrint();
switch (caseNum){
case 1:
Assert.assertEquals(detailResponse.asString().contains("如何获得兑换资格"),true);
Assert.assertEquals(failResponse.jsonPath().getString("success"),"false","校验兑换结果失败");
Assert.assertEquals(failResponse.jsonPath().getString("message"),"会员等级不符,请挑选其他吧(15)","校验兑换结果消息失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
logger.info("校验优惠券会员等级范围成功");
break;
case 2:
Assert.assertEquals(detailResponse.asString().contains("如何获得兑换资格"),true);
Assert.assertEquals(failResponse.jsonPath().getString("success"),"false","校验兑换结果失败");
Assert.assertEquals(failResponse.jsonPath().getString("message"),"会员等级不符,请挑选其他吧(15)","校验兑换结果消息失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
logger.info("校验优惠券会员特定等级成功");
break;
}
}
/**
* @param caseNum 用例编号
* @param appItemId 商品入库Id
* @param itemId 商品id
* @param token token
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 优惠券地区兑换限制测试(int caseNum, String appItemId, String itemId, String token,String caseName) throws Exception{
logger.info(caseName);
Map<String,String> map = new HashMap<>();
map.put("appItemId",appItemId);
map.put("itemId",itemId);
map.put("token",token);
//商品详情页兑换按钮
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),itemId);
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(),"\"exchangeText\":\"(.*?)\"",1);
//优惠券兑换
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/couponExchange/exchange");
response.prettyPrint();
switch (caseNum){
case 1:
Assert.assertEquals(exchangeText,"所处区域不可兑换","校验兑换按钮失败");
Assert.assertEquals(response.jsonPath().getString("message"),"不在可兑换区域哦,请挑选其他吧(30)","校验兑换结果失败");
logger.info("校验优惠券地区黑名单不可兑换成功");
break;
case 2:
Assert.assertEquals(exchangeText,"马上兑换","校验兑换按钮失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
logger.info("校验优惠券地区黑名单以外可兑换成功");
break;
case 3:
Assert.assertEquals(exchangeText,"马上兑换","校验兑换按钮失败");
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验兑换结果失败");
logger.info("校验优惠券地区白名单可兑换成功");
break;
case 4:
Assert.assertEquals(exchangeText,"所处区域不可兑换","校验兑换按钮失败");
Assert.assertEquals(response.jsonPath().getString("message"),"不在可兑换区域哦,请挑选其他吧(30)","校验兑换结果失败");
logger.info("校验优惠券地区白名单以外不可兑换成功");
break;
}
}
//优惠券兑换接口抽离
public Response 优惠券兑换(String appItemId,String itemId,int uid) throws Exception {
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid),appItemId,itemId);
String orderId = response.jsonPath().getString("orderId");
logger.info("订单号:" + orderId);
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
return response;
}
public String 优惠券兑换订单(String appItemId,String itemId,int uid) throws Exception {
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid),appItemId,itemId);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
return orderId;
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.AlipayExchangeService;
import http.service.app.ConfirmService;
import http.service.app.CouponExchangeService;
import http.service.app.MobileService;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DsOrderService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
/**
* Created by lvwenyan on 2018/06/08.
*/
public class 商品订单失败测试_ExchangeTest extends DuibaTestBase {
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private ManagerService managerService;
@Autowired
private MobileService mobileService;
@Autowired
private DsOrderService dsOrderService;
@Autowired
private ConfirmService confirmService;
@Autowired
private AlipayExchangeService alipayExchangeService;
@Autowired
private Authorization authorization;
@Autowired
private DeveloperAccountService developerAccountService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 3769;
@Test
public void 实物扣积分失败测试() throws Exception{
managerService.index();
try {
//修改活动扣积分模板 consumeTemplateId: 1-扣积分成功;2-扣积分失败
managerService.doEdit2("2");
//实物兑换
//Response response= this.实物兑换("166813","28430");
Response response= this.实物兑换("170875","27970");
Assert.assertEquals(response.jsonPath().getString("data.message"),"兑换失败,扣积分-失败测试","校验message失败");
Assert.assertEquals(response.jsonPath().getString("data.status"),"fail","校验status失败");
Map<String,Object> mapOrderId = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+ Database.orders2 + " ORDER BY finish_time DESC LIMIT 1;");
String orderStatus = String.valueOf(mapOrderId.get("status"));
String orderError = String.valueOf(mapOrderId.get("error4consumer"));
Assert.assertEquals(orderStatus,"fail","校验数据库status失败");
Assert.assertEquals(orderError,"兑换失败,扣积分-失败测试","校验数据库error失败");
logger.info("校验实物扣积分失败成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
//还原活动扣积分模板 consumeTemplateId: 1-扣积分成功;2-扣积分失败
managerService.doEdit2("1");
}
}
@Test
public void 实物审核不通过测试() throws Exception{
//获取当前库存和积分
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =683671791616420831");
String stock = String.valueOf(mapStock.get("stock"));
logger.info("当前商品库存:" + stock);
Map<String,Object> mapCredits = jdbc.findSimpleResult("SELECT user.id,user.credits,consumer.credits FROM dafuweng.`user` as user , new_consumer.consumer_0010 as consumer WHERE consumer.partner_user_id=user.id and user.id="+uid);
String userCredits = String.valueOf(mapCredits.get("credits"));
String conCredits = String.valueOf(mapCredits.get("credits(2)"));
logger.info("当前用户积分: " + userCredits);
//实物兑换
String orderId = this.实物兑换订单(uid,"167007","28479");
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
//订单审核
Response auditResponse = dsOrderService.submitAudit(orderId,"reject");
auditResponse.prettyPrint();
//判断订单是否审核失败
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"reject");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("当前订单节点:" + flowWork);
j--;
}
String orderStatus = String.valueOf(mapOrder.get("status"));
String orderError = String.valueOf(mapOrder.get("error4consumer"));
//再次获取当前库存和积分
Thread.sleep(1000);
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =683671791616420831");
String stockNew = String.valueOf(mapStock.get("stock"));
mapCredits = jdbc.findSimpleResult("SELECT user.id,user.credits,consumer.credits FROM dafuweng.`user` as user , new_consumer.consumer_0010 as consumer WHERE consumer.partner_user_id=user.id and user.id="+uid);
String userCreditsNew = String.valueOf(mapCredits.get("credits"));
String conCreditsNew = String.valueOf(mapCredits.get("credits(2)"));
//校验订单状态,校验返回库存和积分
Assert.assertEquals(orderStatus,"fail","校验数据库status失败");
Assert.assertEquals(orderError,"审核不通过(备注:测试订单审核不通过)","校验数据库error失败");
logger.info("校验实物订单审核不通过成功");
Assert.assertEquals(stockNew,stock,"校验stock失败");
Assert.assertEquals(userCreditsNew,userCredits,"校验userCredits失败");
Assert.assertEquals(conCreditsNew,conCredits,"校验conCredits失败");
logger.info("校验实物订单失败返还库存和积分成功");
}
@Test
public void 实物发货撤销测试() throws Exception{
//实物兑换【勿动】自动化兑吧实物
String orderId = this.实物兑换订单(uid,"166813","28430");
logger.info("订单号:" + orderId);
//管理端订单发货撤销
Response response = managerService.cancelOrder(orderId);
response.prettyPrint();
//获取数据库订单状态
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
int i =10;
while (i > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
String orderStatus = String.valueOf(mapOrder.get("status"));
String orderError = String.valueOf(mapOrder.get("error4consumer"));
Assert.assertEquals(response.jsonPath().getString("success"),"true","校验管理端订单发货撤销失败");
Assert.assertEquals(orderStatus,"fail","校验数据库status失败");
Assert.assertEquals(orderError,"测试订单发货撤销","校验数据库error失败");
logger.info("校验实物订单发货撤销成功");
}
@Test
public void 实物加钱购取消订单测试() throws Exception{
//实物兑换
Response objectResponse = couponExchangeService.objectExchange(uid,"167080","null");
String orderId = objectResponse.jsonPath().getString("orderId");
logger.info("订单id:" + orderId);
//手机端取消订单,需等待订单流程到付款节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点: "+ flowWork);
int i =10;
while (i > 0 && !flowWork.equals("ConsumerPay-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
Response cancelResponse = confirmService.cancelOrder(uid,orderId);
cancelResponse.prettyPrint();
//获取数据库订单最终状态j
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String orderStatus = String.valueOf(mapOrder.get("status"));
String orderError = String.valueOf(mapOrder.get("error4consumer"));
Assert.assertEquals(cancelResponse.jsonPath().getString("success"),"true","校验取消订单操作失败");
Assert.assertEquals(orderStatus,"fail","校验数据库status失败");
Assert.assertEquals(orderError,"取消订单","校验数据库error失败");
logger.info("校验实物加钱购取消订单成功");
}
@Test
public void 支付宝兑换失败测试() throws Exception{
//支付宝兑换,使用异常的支付宝账户
Response alipayResponse = alipayExchangeService.exchange(uid,"fail_acctunusual@126.com","测试","1");
String orderId = alipayResponse.jsonPath().getString("orderId");
logger.info("订单id:" + orderId);
Response statusResponse = mobileService.orderStatusQuery(uid,orderId);
statusResponse.prettyPrint();
String message = statusResponse.jsonPath().getString("message");
int i = 30;
//异步接口,直到兑换成功
while (i > 0 && message.equals("兑换正在处理中...")) {
Thread.sleep(1000);
statusResponse = mobileService.orderStatusQuery(uid,orderId);
statusResponse.prettyPrint();
message = statusResponse.jsonPath().getString("message");
i--;
}
//异步接口,判断订单状态,直到处理完成
while (i > 0 && message.equals("兑换提交成功!待处理")) {
Thread.sleep(1000);
statusResponse = mobileService.orderStatusQuery(uid,orderId);
statusResponse.prettyPrint();
message = statusResponse.jsonPath().getString("message");
i--;
}
//获取数据库订单数据
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String orderStatus = String.valueOf(mapOrder.get("status"));
String orderError = String.valueOf(mapOrder.get("error4consumer"));
Assert.assertEquals(statusResponse.jsonPath().getString("message"),"40004:Business Failed_PAYEE_NOT_EXIST:收款账号不存在","校验message失败");
Assert.assertEquals(orderStatus,"fail","校验数据库status失败");
Assert.assertEquals(orderError,"40004:Business Failed_PAYEE_NOT_EXIST:收款账号不存在","校验数据库error失败");
logger.info("校验支付宝异常账户兑换失败成功");
}
//@Test
public void 支付宝审核不通过测试() throws Exception{
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
//支付宝兑换
String orderId = this.支付宝兑换订单(uid,"peeulk6392@sandbox.com","沙箱环境","10");
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
//订单审核
Response auditResponse = dsOrderService.submitAudit(orderId,"reject");
auditResponse.prettyPrint();
//判断订单是否审核失败
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"reject");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("当前订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// String remainMoneyNew = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"fail","校验订单状态失败");
logger.info("校验支付宝审核订单失败返还金额成功");
}
// 上游不稳定,暂时关闭
// 上游不稳定,暂时关闭
// @Test
// public void 话费上游兑换失败测试() throws Exception{
//
// try {
// //修改大富翁上游兑换模板(phonebill-oufei)
// managerService.use("104");
// Thread.sleep(500);
// //话费兑换
// Response phoneResponse= couponExchangeService.phonebillExchange(authorization.dafuwengLogin(uid),"156497","1660");
// String orderId = phoneResponse.jsonPath().getString("orderId");
// logger.info("订单id:" + orderId);
//
// Response statusResponse = mobileService.orderStatusQuery(uid,orderId);
// statusResponse.prettyPrint();
// String message = statusResponse.jsonPath().getString("message");
// int i = 10;
// //异步接口,直到兑换成功
// while (i > 0 && message.equals("兑换正在处理中...")) {
// Thread.sleep(1000);
// statusResponse = mobileService.orderStatusQuery(uid,orderId);
// statusResponse.prettyPrint();
// message = statusResponse.jsonPath().getString("message");
// i--;
// }
//
// //获取数据库订单数据,上游订单处理失败需增加等待时间
// Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders+" WHERE id = " + orderId);
// String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
// logger.info("数据库订单节点:" + flowWork);
// int j =10;
// while (j > 0 && !flowWork.equals("Fail-complete")) {
// Thread.sleep(1000);
// mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders+" WHERE id = " + orderId);
// flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
// logger.info("数据库订单节点:" + flowWork);
// j--;
// }
// String orderStatus = String.valueOf(mapOrder.get("status"));
// String orderError = String.valueOf(mapOrder.get("error4consumer"));
// String orderErrorDev = String.valueOf(mapOrder.get("error4developer"));
//
// Assert.assertEquals(statusResponse.jsonPath().getString("message"),"兑换提交成功!待处理");
// Assert.assertEquals(orderStatus,"fail","校验数据库status失败");
// Assert.assertEquals(orderError,"兑换失败,请稍后重试","校验数据库error4consumer失败");
// Assert.assertEquals(orderErrorDev,"上游兑换失败","校验数据库error4developer失败");
//
// logger.info("校验话费上游兑换失败成功");
//
//
// }catch (Exception e){
// throw new Exception("异常信息打印:" + e);
//
// }finally {
// //还原活动扣积分模板 consumeTemplateId: 1-扣积分成功;2-扣积分失败
// managerService.use("102");
//
// }
//
// }
public Response 实物兑换(String appItemId, String itemId) throws Exception{
Response objectResponse = couponExchangeService.objectExchange(3268,appItemId,itemId);
objectResponse.prettyPrint();
String orderId = objectResponse.jsonPath().getString("orderId");
Response statusResponse = mobileService.orderAmbStatusQuery(3268,orderId);
statusResponse.prettyPrint();
String message = statusResponse.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && message.equals("兑换正在处理中...")) {
Thread.sleep(1000);
statusResponse = mobileService.orderAmbStatusQuery(3268,orderId);
statusResponse.prettyPrint();
message = statusResponse.jsonPath().getString("data.message");
i--;
}
return statusResponse;
}
public String 实物兑换订单(int uid, String appItemId, String itemId) throws Exception{
Response objectResponse = couponExchangeService.objectExchange(uid,appItemId,itemId);
objectResponse.prettyPrint();
String orderId = objectResponse.jsonPath().getString("orderId");
Response statusResponse = mobileService.orderAmbStatusQuery(uid,orderId);
statusResponse.prettyPrint();
String message = statusResponse.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && message.equals("兑换正在处理中...")) {
Thread.sleep(1000);
statusResponse = mobileService.orderAmbStatusQuery(uid,orderId);
statusResponse.prettyPrint();
message = statusResponse.jsonPath().getString("data.message");
i--;
}
return orderId;
}
//支付宝兑换接口抽离
public String 支付宝兑换订单(int uid,String alipay,String realname,String degreeId) throws Exception {
Response response = alipayExchangeService.exchange(uid,alipay,realname,degreeId);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
return orderId;
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.CouponExchangeService;
import http.service.app.CrecordService;
import http.service.app.MobileService;
import http.service.app.VirtualExchangeService;
import http.service.hd.DeveloperAccountService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
/**
* Created by yeqinqin on 2018/6/11.
*/
public class 实物_兑换异常测试_ExchangeTest extends DuibaTestBase {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private CrecordService crecordService;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
@Autowired
DeveloperAccountService developerAccountService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 3770;
//实物兑换积分不足
@Test(description = "实物兑换积分不足")
public void 积分不足() throws Exception {
//活动详情页
Response response = mobileService.detail(authorization.dafuwengLogin(3086), "28515");
Map<String, String> map = authorization.dafuwengLogin(3086);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
response = couponExchangeService.objectExchange(map, "167141", "28515", "null", "z9sydmcs", "null");
response.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(3086,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(3086,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
//校验messaga字段返回值
String message2 = response.jsonPath().getString("data.message");
Assert.assertEquals(message2,"兑换失败,用户积分余额不足","message字段校验失败-期望是积分不足");
// authorization.dafuwengLogin(2720,true);
}
//实物兑换限制消费
@Test(description = "实物兑换已兑换")
public void 已兑换() throws Exception {
//活动详情页
Response response = mobileService.detail(authorization.dafuwengLogin(uid), "28633");
// response.prettyPrint();
Map<String, String> map = authorization.dafuwengLogin(uid);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "活动详情页请求异常");
//实物兑换
Response response1 = couponExchangeService.objectExchange1(map, "167611", "28633", "null", "z9sydmcs", "null");
response1.prettyPrint();
//校验兑换成功
// Assert.assertEquals(response.jsonPath().getString("success"),"true");
//获取orderId
// String orderId = response1.jsonPath().getString("orderId");
// //获取兑换结果
// Response response3 = mobileService.orderAmbStatusQuery(orderId);
// response3.prettyPrint();
// String message = response3.jsonPath().getString("data.message");
// int i = 10;
// //异步接口,直到兑换成功
// while (i > 0 && "兑换正在处理中...".equals(message)) {
// Thread.sleep(1000);
// response3 = mobileService.orderAmbStatusQuery(orderId);
// response3.prettyPrint();
// message = response3.jsonPath().getString("data.message");
// i--;
// }
//校验messaga字段返回值
String message2 = response1.jsonPath().getString("message");
Assert.assertEquals(message2,"已兑换","message字段校验失败-期望是已兑换");
}
@Test
public void 开发者余额不足测试() throws Exception{
int uid = 3490;
//开发者余额, 开发者账户:xuyan_8707@163.com
Response accountResponse = developerAccountService.accountInfoCommon("xuyan_8707@163.com");
String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
logger.info("兑换前的开发者账户余额:" + remainMoney);
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"31050");
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
logger.info("~~~"+exchangeText);
Assert.assertTrue(exchangeText.contains("已兑完"));
String message=null;
String succcess = null;
try{
Response response = couponExchangeService.objectExchange1(authorization.dafuwengLogin(uid), "178880", "31050", "null", "z9sydmcs", "null");
message = response.jsonPath().getString("message");
}catch (Exception e){
message = e.toString();
}
logger.info(message);
Assert.assertTrue(message.contains("没有兑换成功"));
}
// @Test
public void 每日兑换限制() throws Exception {
int uid = 3490;
//第一次兑换
Response response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), "178879", "31049", "null", "z9sydmcs", "null");
response.prettyPrint();
String orderId = response.jsonPath().getString("orderId");
//获取兑换结果
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
int i = 10;
//异步接口,直到兑换成功
while (i > 0 && "兑换正在处理中...".equals(message)) {
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
//第二次兑换
try{
response = couponExchangeService.objectExchange(authorization.dafuwengLogin(uid), "178879", "31049", "null", "z9sydmcs", "null");
response.prettyPrint();
}catch (Exception e){
// message = e.toString();
}
// logger.info(message);
// Assert.assertTrue(message.contains("已兑完"));
// Assert.assertTrue(message.contains("\"success\":false"));
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Authorization;
import http.service.app.AppPlatformCouponService;
import http.service.app.CrecordService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2018/08/09.
*/
//@ContextConfiguration(classes = DuibaConfig.class)
public class 平台券_兑换流程测试_ExchangeTest extends DuibaTestBase {
@Autowired
AppPlatformCouponService appPlatformCouponService;
@Autowired
Authorization authorization;
@Autowired
CrecordService crecordService;
private DuibaLog logger = DuibaLog.getLogger();
private static int uid = 3770;
private String url = "http://activity.m.duibatest.com.cn";
// private MysqlUtils jdbc;
// @BeforeClass
// public void before(){
//
// jdbc = MysqlUtils.mysqlDuiba("");
//
// }
//
// @AfterClass
// public void after(){
//
// jdbc.releaseConn();
// }
@DataProvider
public Object[][] providerMethod(Method method) {
Object[][] result = null;
if (method.getName().equals("平台券库存不足测试")) {
result = new Object[][]{
new Object[]{"73734759122009","n990y8dac","平台券商品库存不足测试"}, //case1
new Object[]{"73734793724984", "s4c0zy","平台券预分配库存不足测试"}, //case2
};
}
if(method.getName().equals("平台券预分配库存测试")){
result = new Object[][]{
new Object[]{"73734759122009","n990y8dac","平台券商品库存不足测试"}, //case1
};
}
if(method.getName().equals("平台券马上使用按钮测试")){
result = new Object[][]{
new Object[]{1,"74372992121534","平台券商家落地页链接测试"}, //case1
new Object[]{2,"74922024942959","平台券兑换记录页链接测试"}, //case2
new Object[]{3,"74378122799009","平台券链接券测试"}, //case3
};
}
return result;
}
@Test
public void 平台券扣积分和库存测试() throws Exception {
//查询平台券兑换前的库存和积分
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =737253124770670925");
String stock = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换前的平台券库存:" + stock);
stock = String.valueOf(Integer.parseInt(stock) - 1) ;
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前积分:"+credits); //扣去100积分
credits = String.valueOf(Integer.valueOf(credits)-10);
//平台券兑换
String orderId = this.平台券兑换订单(uid,"73725292586909");
logger.info("订单号:" + orderId);
//查询优惠券兑换后的库存和积分
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id =737253124770670925");
String stockNew = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换后的优惠券库存:" + stockNew);
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:"+creditsNew);
//查询订单状态
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders6+" WHERE id = " + orderId);
String status = String.valueOf(mapOrder.get("status"));
Assert.assertEquals(stockNew,stock,"校验平台券库存失败");
Assert.assertEquals(creditsNew,credits,"校验平台券扣积分失败");
Assert.assertEquals(status,"success","校验订单状态失败");
logger.info("平台券兑换扣库存和积分校验成功");
}
/**
* @param pcgId 平台券Id
* @param token token
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 平台券库存不足测试(String pcgId, String token, String caseName) throws Exception{
logger.info(caseName);
Map<String,String> map = new HashMap<>();
map.put("pcgId",pcgId);
map.put("token",token);
//平台券兑换
Response response = given().contentType("application/x-www-form-urlencoded").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/platformCoupon/takeOrder");
response.prettyPrint();
//平台券页面兑换按钮
Response detailResponse = appPlatformCouponService. platformDetail(uid,pcgId);
detailResponse.prettyPrint();
Assert.assertEquals(response.jsonPath().getString("message"),"库存不足","校验message失败");
Assert.assertEquals(detailResponse.asString().contains("已兑完"),true);
logger.info("校验平台券库存不足成功");
}
@Test
public void 平台券积分不足测试() throws Exception{
Map<String,String> map = new HashMap<>();
map.put("pcgId","73725292586909");
map.put("token","dnsog");
//获取按钮状态
Response detailResponse = appPlatformCouponService.platformDetail(3086,true,"73725292586909");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(),"exchangeText: '(.*?)',",1);
//平台券兑换
Response response = given().contentType("application/x-www-form-urlencoded").cookies(authorization.dafuwengLogin(3086)).params(map).post(url + "/platformCoupon/takeOrder");
response.prettyPrint();
//exchangetext=2: 积分不足
Assert.assertEquals(exchangeText,"2","校验按钮状态失败");
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
logger.info("校验平台券商品积分不足场景成功");
//切换回正常用户
//authorization.dafuwengLogin(uid,true);
}
@Test
public void 平台券预分配库存测试() throws Exception{
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 741004276004170604");
String stock = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换前的平台券预分配库存:" + stock);
stock = String.valueOf(Integer.valueOf(stock)-1);
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("兑换前的积分:"+credits);
credits = String.valueOf(Integer.valueOf(credits)-10);
//平台券兑换
this.平台券兑换(uid,"74100364718684");
//查询兑换后的库存和积分
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 741004276004170604");
String stockNew = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换后的平台券预分配库存:" + stockNew);
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("兑换后积分:"+creditsNew);
Assert.assertEquals(stockNew,stock,"校验平台券预分配库存失败");
Assert.assertEquals(creditsNew,credits,"校验平台券预分配最小兑换价格失败");
logger.info("校验平台券预分配库存和最小兑换积分成功");
}
@Test
public void 平台券共享库存测试() throws Exception{
Map<String,Object> mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 743716478156171001");
String stock = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换前的平台券共享库存:" + stock);
stock = String.valueOf(Integer.valueOf(stock)-1);
//优惠券兑换
this.平台券兑换(uid,"74371604856809");
//查询兑换后的库存
mapStock = jdbc.findSimpleResult("SELECT * FROM stock.tb_stock WHERE stock_id = 743716478156171001");
String stockNew = String.valueOf(mapStock.get("stock")) ;
logger.info("兑换后的平台券共享库存:" + stockNew);
Assert.assertEquals(stockNew,stock,"校验平台券共享库存库存失败");
logger.info("校验平台券共享库存扣除成功");
}
@Test
public void 平台券预分配每日限额测试() throws Exception{
try {
//平台券第一次兑换
this.平台券兑换(uid,"74735076603359");
//每日限额用完,无法再次兑换
Map<String,String> map = new HashMap<>();
map.put("pcgId","74735076603359");
map.put("token","dnsog");
//获取按钮状态
Response detailResponse = appPlatformCouponService.platformDetail(uid,"74735076603359");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(),"exchangeText: '(.*?)',",1);
//平台券兑换
Response response = given().contentType("application/x-www-form-urlencoded").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/platformCoupon/takeOrder");
response.prettyPrint();
//exchangetext=3: 已兑完
Assert.assertEquals(exchangeText,"3","校验按钮状态失败");
Assert.assertEquals(response.jsonPath().getString("message"),"库存不足","校验message失败");
logger.info("校验平台券预分配每日限额兑换成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
//清除兑换数据和 redis
jdbc.update("DELETE FROM stock.tb_sales_volume WHERE relation_id = 74735076603359");
}
}
@Test
public void 平台券用户兑换限制测试() throws Exception{
try{
//平台券第一次兑换
this.平台券兑换(uid,"74371944595109");
//用户限制次数用完,无法兑换
Map<String,String> map = new HashMap<>();
map.put("pcgId","74371944595109");
map.put("token","dnsog");
//获取按钮状态
Response detailResponse = appPlatformCouponService.platformDetail(uid,"74371944595109");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(),"exchangeText: '(.*?)',",1);
Response response = given().contentType("application/x-www-form-urlencoded").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/platformCoupon/takeOrder");
response.prettyPrint();
//exchangetext=1: 已兑换
Assert.assertEquals(exchangeText,"1","校验按钮状态失败");
Assert.assertEquals(response.jsonPath().getString("message"),"用户已兑换","校验message失败");
logger.info("校验平台券用户兑换限制成功");
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM goods.tb_goods_limit_record WHERE gid = 74371944595109 AND consumer_id = 100088018");
}
}
/**
* @param caseNum 用例编号
* @param pcgId 平台券id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 平台券马上使用按钮测试(int caseNum, String pcgId, String caseName)throws Exception{
logger.info(caseName);
String orderId = this.平台券兑换订单(uid,pcgId);
logger.info("订单号: "+ orderId);
//平台券兑换结果页,需要等待订单刷新成功
Thread.sleep(3000);
Response resultResponse = crecordService.recordDetail(orderId,uid);
resultResponse.prettyPrint();
String btnText = MatcherString.getString(resultResponse.asString(),"\"btnText\":\"(.*?)\",",1);
String androidDownloadUrl = MatcherString.getString(resultResponse.asString(),"\"androidDownloadUrl\":\"(.*?)\",",1);
//平台券兑换记录页
Thread.sleep(3000);
Response recordResponse = crecordService.recordDetailNew(orderId,uid);
recordResponse.prettyPrint();
String useButtonText = MatcherString.getString(recordResponse.asString(),"\"useButtonText\":\"(.*?)\",",1);
String androidDownloadUrl2 = MatcherString.getString(recordResponse.asString(),"\"androidDownloadUrl\":\"(.*?)\",",1);
switch (caseNum){
case 1:
Assert.assertEquals(btnText,"马上使用","校验结果页按钮文案失败");
Assert.assertEquals(androidDownloadUrl,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fm.aomygod.com%2Fact-richang-meidehuierwaitui.html&amp;dpm=2239.25.1.0&amp;dcm=103.74372992121534.0.0","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"马上使用","校验兑换记录页按钮文案失败");
Assert.assertEquals(androidDownloadUrl2,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fm.aomygod.com%2Fact-richang-meidehuierwaitui.html&amp;dpm=2239.25.2.0&amp;dcm=103.74372992121534.0.0","校验兑换记录页按钮跳转链接失败");
logger.info("校验平台券商家落地页下载链接页面成功");
break;
case 2:
Assert.assertEquals(btnText,"马上下载","校验结果页按钮文案失败");
Assert.assertEquals(androidDownloadUrl,"//activity.m.duibatest.com.cn/log/redirect?url=http%3A%2F%2Fm.lrts.me%2Fapp&amp;dpm=2239.25.1.0&amp;dcm=103.74922024942959.0.0","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"马上下载","校验兑换记录页按钮文案失败");
Assert.assertEquals(androidDownloadUrl2,"//activity.m.duibatest.com.cn/log/redirect?url=http%3A%2F%2Fm.lrts.me%2Fapp&amp;dpm=2239.25.2.0&amp;dcm=103.74922024942959.0.0","校验兑换记录页按钮跳转链接失败");
logger.info("校验平台券兑换记录页下载链接页面成功");
break;
case 3:
Assert.assertEquals(btnText,"马上使用","校验结果页按钮文案失败");
Assert.assertEquals(androidDownloadUrl,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fm.4008123123.com%2F&amp;dpm=2239.25.1.0&amp;dcm=103.74378122799009.0.0","校验结果页按钮链接失败");
Assert.assertEquals(useButtonText,"马上使用","校验兑换记录页按钮文案失败");
Assert.assertEquals(androidDownloadUrl2,"//activity.m.duibatest.com.cn/log/redirect?url=https%3A%2F%2Fm.4008123123.com%2F&amp;dpm=2239.25.2.0&amp;dcm=103.74378122799009.0.0","校验兑换记录页按钮跳转链接失败");
logger.info("校验平台券链接券页面成功");
break;
}
}
//平台券兑换接口抽离
public Response 平台券兑换(int uid,String pcgId) throws Exception {
Response response = appPlatformCouponService.takeOrder(uid,pcgId);
String orderId = response.jsonPath().getString("orderId");
logger.info("订单号:" + orderId);
//查看兑换结果
response = appPlatformCouponService.getOrderStatus(uid,orderId);
response.prettyPrint();
return response;
}
public String 平台券兑换订单(int uid,String pcgId) throws Exception {
Response response = appPlatformCouponService.takeOrder(uid,pcgId);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = appPlatformCouponService.getOrderStatus(uid,orderId);
response.prettyPrint();
return orderId;
}
}
package http.cases.ExchangeTest;
import base.DuibaLog;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.*;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DsOrderService;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.Map;
/**
* Created by lvwenyan on 2018/06/08.
*/
public class 开发者账户余额校验测试 extends DuibaTestBase {
@Autowired
private CouponExchangeService couponExchangeService;
@Autowired
private ManagerService managerService;
@Autowired
private MobileService mobileService;
@Autowired
private DsOrderService dsOrderService;
@Autowired
QbExchangeService qbExchangeService;
@Autowired
private AlipayExchangeService alipayExchangeService;
@Autowired
private Authorization authorization;
@Autowired
private DeveloperAccountService developerAccountService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 3769;
@DataProvider
public Object[][] providerMethod(Method method) {
Object[][] result = null;
if (method.getName().equals("优惠券审核通过测试")) {
result = new Object[][]{
new Object[]{1,"169698", "29156", "兑吧优惠券审核通过测试"}, //case1
new Object[]{2,"172178", "", "自有优惠券审核通过测试"}, //case2
};
}
return result;
}
@Test
public void 商品订单支付宝审核不通过测试() throws Exception{
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
//支付宝兑换
String orderId = this.支付宝兑换订单(uid,"peeulk6392@sandbox.com","沙箱环境","10");
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
//订单审核
Response auditResponse = dsOrderService.submitAudit(orderId,"reject");
auditResponse.prettyPrint();
//判断订单是否审核失败
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"reject");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders5+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("当前订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// String remainMoneyNew = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"fail","校验订单状态失败");
logger.info("校验支付宝审核订单失败返还金额成功");
}
@Test
public void Qb审核通过测试() throws Exception {
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
// String remainMoneyNew =String.valueOf(Integer.valueOf(remainMoney) - 9600) ;
int uid = 2709;
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","100");
String orderId = (String)response.jsonPath().get("orderId");
response.prettyPrint();
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
Response auditResponse = dsOrderService.submitAudit(orderId,"pass");
auditResponse.prettyPrint();
//判断订单是否审核成功,如果订单没有成功则继续审核
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"pass");
mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoney);
// Assert.assertEquals(remainMoney,remainMoneyNew,"校验开发者账户余额失败");
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
remainMoney =String.valueOf(Integer.valueOf(remainMoney) - 9600) ;
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"success","校验订单状态失败");
logger.info("校验支付宝扣费订单成功");
}
@Test
public void Qb审核不通过测试() throws Exception{
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
//qb兑换
int uid = 2709;
Response response = qbExchangeService.doTakePrize(authorization.dafuwengLogin(uid),"1234345554","100");
String orderId = (String)response.jsonPath().get("orderId");
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
//订单审核
Response auditResponse = dsOrderService.submitAudit(orderId,"reject");
auditResponse.prettyPrint();
//判断订单是否审核失败
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"reject");
mapOrder = jdbc.findSimpleResult("SELECT * from orders_consumer.orders_0616 where id ="+orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("当前订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// String remainMoneyNew = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
// Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"fail","校验订单状态失败");
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[1].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
logger.info("校验支付宝审核订单失败返还金额成功");
}
/**
* @param caseNum 用例id
* @param appItemId 商品入库Id
* @param itemId 商品id
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 优惠券审核通过测试(int caseNum, String appItemId, String itemId, String caseName) throws Exception{
int uid = 3768;
logger.info(caseName);
//查询兑换前的开发者余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者余额:" + remainMoney);
// String remainMoneyNew =String.valueOf(Integer.valueOf(remainMoney) - 1000) ;
//优惠券兑换
String orderId = this.优惠券兑换订单(appItemId,itemId,uid);
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders4+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders4+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
Response auditResponse = dsOrderService.submitAudit(orderId,"pass");
auditResponse.prettyPrint();
//判断订单是否审核成功,如果订单没有成功则继续审核
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"pass");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders4+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
switch (caseNum){
case 1:
//查询兑换后的开发者余额
// accountResponse = developerAccountService.accountInfo();
// remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者余额:" + remainMoney);
Assert.assertEquals(status,"success","订单状态校验失败");
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
remainMoney =String.valueOf(Integer.valueOf(remainMoney) - 1000) ;
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
logger.info("校验兑吧优惠券审核通过扣费成功");
break;
case 2:
Assert.assertEquals(status,"success","订单状态校验失败");
logger.info("校验自有优惠券审核通过成功");
}
}
@Test
public void 支付宝审核通过测试() throws Exception{
int uid = 3771;
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
// String remainMoneyNew =String.valueOf(Integer.valueOf(remainMoney) - 1020) ;
//支付宝兑换
String orderId = this.支付宝兑换订单(uid,"peeulk6392@sandbox.com","沙箱环境","10");
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders7+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders7+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
Response auditResponse = dsOrderService.submitAudit(orderId,"pass");
auditResponse.prettyPrint();
//判断订单是否审核成功,如果订单没有成功则继续审核
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"pass");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders7+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoney);
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
remainMoney =String.valueOf(Integer.valueOf(remainMoney) - 1020) ;
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"success","校验订单状态失败");
logger.info("校验支付宝扣费订单成功");
}
//支付宝兑换接口抽离
public String 支付宝兑换订单(int uid,String alipay,String realname,String degreeId) throws Exception {
Response response = alipayExchangeService.exchange(uid,alipay,realname,degreeId);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
return orderId;
}
public String 优惠券兑换订单(String appItemId,String itemId,int uid) throws Exception {
Response response = couponExchangeService.couponExchange(authorization.dafuwengLogin(uid),appItemId,itemId);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
return orderId;
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Authorization;
import http.service.Manager.ADeveloperService;
import http.service.app.AlipayExchangeService;
import http.service.app.MobileService;
import http.service.hd.DeveloperAccountService;
import http.service.hd.DsOrderService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by lvwenyan on 2018/08/24.
*/
public class 支付宝_兑换流程测试_ExchangeTest extends DuibaTestBase {
@Autowired
AlipayExchangeService alipayExchangeService;
@Autowired
MobileService mobileService;
@Autowired
Authorization authorization;
@Autowired
DsOrderService dsOrderService;
@Autowired
DeveloperAccountService developerAccountService;
@Autowired
ADeveloperService aDeveloperService;
private static int uid = 3771;
private DuibaLog logger = DuibaLog.getLogger();
// private MysqlUtils jdbc;
private String url = "http://activity.m.duibatest.com.cn";
// @BeforeClass
// public void before(){
//
// jdbc = MysqlUtils.mysqlDuiba("");
//
// }
//
// @AfterClass
// public void after(){
//
// jdbc.releaseConn();
// }
@DataProvider
public Object[][] providerMethod(Method method) {
Object[][] result = null;
if (method.getName().equals("支付宝用户兑换限制测试")) {
result = new Object[][]{
new Object[]{1, "peeulk6392@sandbox.com", "沙箱环境", "2", "支付宝用户永久兑换限制测试"}, //case1
new Object[]{2, "peeulk6392@sandbox.com", "沙箱环境", "3", "支付宝用户每日兑换限制测试"}, //case2
};
}
return result;
}
//@Test
public void 支付宝审核通过测试() throws Exception{
//查询兑换前的开发者账户余额
// Response accountResponse = developerAccountService.accountInfo();
// String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换前的开发者账户余额:" + remainMoney);
// String remainMoneyNew =String.valueOf(Integer.valueOf(remainMoney) - 1020) ;
//支付宝兑换
String orderId = this.支付宝兑换订单(uid,"peeulk6392@sandbox.com","沙箱环境","10");
logger.info("订单号:" + orderId);
//订单审核,判断是否在待审核节点
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders7+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
String orderIdmain = String.valueOf(mapOrder.get("order_num"));
logger.info("兑吧订单号为:" + orderIdmain);
int i =10;
while (i > 0 && !flowWork.equals("Audit-started")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders7+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
i--;
}
Response auditResponse = dsOrderService.submitAudit(orderId,"pass");
auditResponse.prettyPrint();
//判断订单是否审核成功,如果订单没有成功则继续审核
int j =10;
while (j > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(1000);
auditResponse = dsOrderService.submitAudit(orderId,"pass");
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders7+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String status = String.valueOf(mapOrder.get("status"));
//兑换后的开发者账户余额
// accountResponse = developerAccountService.accountInfo();
// remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
// logger.info("兑换后的开发者账户余额:" + remainMoney);
//校验开发者账户余额变动
Response accountResponse = developerAccountService.cashDetail(orderIdmain);
String remainMoney = String.valueOf(Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].balance"))+Integer.valueOf(accountResponse.jsonPath().getString("data.list[0].moneyChange")));
logger.info("兑换前的开发者账户余额:" + remainMoney);
remainMoney =String.valueOf(Integer.valueOf(remainMoney) - 1020) ;
String remainMoneyNew = accountResponse.jsonPath().getString("data.list[0].balance");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
Assert.assertEquals(status,"success","校验订单状态失败");
logger.info("校验支付宝扣费订单成功");
}
@Test
public void 支付宝积分不足测试() throws Exception{
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(3086,true),"55");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
//支付宝兑换
Response response = alipayExchangeService.exchange(3086,"peeulk6392@sandbox.com","沙箱环境","10");
String orderId = response.jsonPath().getString("orderId");
logger.info("订单号:" + orderId);
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(3086), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && !status.equals("fail")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(3086), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
//订单状态
Map<String,Object> mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders3+" WHERE id = " + orderId);
String flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
int j =10;
while (j > 0 && !flowWork.equals("Fail-complete")) {
Thread.sleep(300);
mapOrder = jdbc.findSimpleResult("SELECT * FROM "+Database.orders_consumer+"."+Database.orders3+" WHERE id = " + orderId);
flowWork = String.valueOf(mapOrder.get("flowwork_stage"));
logger.info("数据库订单节点:" + flowWork);
j--;
}
String orderStatus = String.valueOf(mapOrder.get("status"));
Assert.assertEquals(exchangeText,"积分不足","校验马上兑换按钮状态失败");
Assert.assertEquals(response.jsonPath().getString("message"),"兑换失败,用户积分余额不足","校验message失败");
Assert.assertEquals(orderStatus,"fail","校验订单状态失败");
logger.info("校验支付宝商品积分不足场景成功");
}
@Test
public void 支付宝余额不足测试() throws Exception{
//开发者余额, 开发者账户:xuyan_8707@163.com
Response accountResponse = developerAccountService.accountInfoCommon("xuyan_8707@163.com");
String remainMoney = accountResponse.jsonPath().getString("data.remainMoney");
logger.info("兑换前的开发者账户余额:" + remainMoney);
//兑换按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(3490),"55");
detailResponse.prettyPrint();
String exchangeText = MatcherString.getString(detailResponse.asString(), "\"exchangeText\":\"(.*?)\",", 1);
//支付宝兑换
Map<String,String> map = new HashMap<>();
map.put("alipay","peeulk6392@sandbox.com");
map.put("realname","沙箱环境");
map.put("degreeId","10");
map.put("itemId","55");
map.put("token","fw7qga0");
Response response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(3490)).params(map).post(url+"/alipayExchange/exchange");
response.prettyPrint();
accountResponse = developerAccountService.accountInfoCommon("xuyan_8707@163.com");
String remainMoneyNew = accountResponse.jsonPath().getString("data.remainMoney");
logger.info("兑换后的开发者账户余额:" + remainMoneyNew);
Assert.assertEquals(exchangeText,"已兑完","校验马上兑换按钮状态失败");
Assert.assertEquals(response.jsonPath().getString("message"),"对不起,没有兑换成功,请挑选其他吧(2)","校验message失败");
Assert.assertEquals(remainMoneyNew,remainMoney,"校验开发者账户余额失败");
logger.info("校验支付宝商品余额不足成功");
}
@Test
public void 支付宝自定义档位扣积分测试() throws Exception{
//兑换前的积分
Map<String,Object> mapCredits = jdbc.findSimpleResult("SELECT * FROM dafuweng.`user` WHERE id = "+uid);
String credits = String.valueOf(mapCredits.get("credits"));
logger.info("兑换前的用户积分:" + credits);
credits = String.valueOf(Integer.valueOf(credits)-10);
this.支付宝兑换(uid,"peeulk6392@sandbox.com","沙箱环境","10");
//兑换后的积分
mapCredits = jdbc.findSimpleResult("SELECT * FROM dafuweng.`user` WHERE id = "+uid);
String creditsNew = String.valueOf(mapCredits.get("credits"));
logger.info("兑换后的用户积分:" + creditsNew);
Assert.assertEquals(creditsNew,credits,"校验支付宝扣积分失败");
logger.info("校验支付宝自定义档位扣积分成功");
}
@Test
public void 支付宝会员等级测试() throws Exception{
//开发者账号马博专用,appId=18740
Map<String,String> map = new HashMap<>();
map.put("alipay","peeulk6392@sandbox.com");
map.put("realname","沙箱环境");
map.put("degreeId","1");
map.put("itemId","55");
map.put("token","fw7qga0");
//会员符合条件,兑换
Response successResponse = this.支付宝兑换(3574,"peeulk6392@sandbox.com","沙箱环境","1");
//会员不符合条件,兑换,vip=5
Response failResponse = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.generateSignAutoLogin("3nG61oCgKyPNcHCyxwSmxsF6tNfj",3575)).params(map).post(url + "/alipayExchange/exchange");
failResponse.prettyPrint();
Assert.assertEquals(successResponse.jsonPath().getString("status"),"success","校验支付宝兑换状态失败");
Assert.assertEquals(failResponse.jsonPath().getString("message"),"会员等级不符,请挑选其他吧(15)","校验支付宝兑换状态失败");
logger.info("校验支付宝会员等级兑换成功");
}
/**
* @param caseNum 用例编号
* @param alipay 支付宝账号
* @param realName 支付宝姓名
* @param degreeId 档位
* @param caseName 用例名称打印
* @throws Exception
*/
@Test(dataProvider = "providerMethod")
public void 支付宝用户兑换限制测试(int caseNum, String alipay, String realName, String degreeId, String caseName) throws Exception{
Map<String,String> map = new HashMap<>();
map.put("alipay",alipay);
map.put("realname",realName);
map.put("degreeId",degreeId);
map.put("itemId","55");
map.put("token","fw7qga0");
try{
//支付宝兑换
Response response = this.支付宝兑换(uid,alipay,realName,degreeId);
Assert.assertEquals(response.jsonPath().getString("status"),"success","校验兑换失败");
logger.info("用户成功兑换一次");
//再次兑换
Thread.sleep(3000);
response = given().contentType("application/x-www-form-urlencoded;charset=UTF-8").cookies(authorization.dafuwengLogin(uid)).params(map).post(url + "/alipayExchange/exchange");
response.prettyPrint();
//获取按钮状态
Response detailResponse = mobileService.detail(authorization.dafuwengLogin(uid),"55");
// detailResponse.prettyPrint();
String btnText2 = MatcherString.getString(detailResponse.asString(), "\"2\":\\{\"btnText\":\"(.*?)\",", 1);
String btnText3 = MatcherString.getString(detailResponse.asString(), "\"3\":\\{\"btnText\":\"(.*?)\",", 1);
switch (caseNum){
case 1:
logger.info("再次兑换按钮:" + btnText2);
Assert.assertEquals(response.jsonPath().getString("message"),"已兑完","校验用户兑换限制失败");
Assert.assertEquals(btnText2,"已兑换","校验马上兑换按钮状态失败");
logger.info("校验支付宝用户永久兑换限制成功");
break;
case 2:
logger.info("再次兑换按钮:" + btnText3);
Assert.assertEquals(response.jsonPath().getString("message"),"已兑完","校验用户兑换限制失败");
Assert.assertEquals(btnText3,"今日已兑换","校验马上兑换按钮状态失败");
logger.info("校验支付宝用户每日兑换限制成功");
break;
}
}catch (Exception e){
throw new Exception("异常信息打印:" + e);
}finally {
jdbc.update("DELETE FROM credits_dev.consumer_limit_record_only WHERE item_id = '55'");
jdbc.update("DELETE FROM credits_dev.consumer_limit_record WHERE item_id = '55'");
}
}
//支付宝兑换接口抽离
public String 支付宝兑换订单(int uid,String alipay,String realname,String degreeId) throws Exception {
Response response = alipayExchangeService.exchange(uid,alipay,realname,degreeId);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
return orderId;
}
public Response 支付宝兑换(int uid,String alipay,String realname,String degreeId) throws Exception {
Response response = alipayExchangeService.exchange(uid,alipay,realname,degreeId);
String orderId = response.jsonPath().getString("orderId");
//查看兑换结果
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
String status = response.jsonPath().getString("status");
//异步接口
int i = 10;
while (i > 0 && status.equals("processing")) {
Thread.sleep(1000);
response = mobileService.orderStatusQuery(authorization.dafuwengLogin(uid), orderId);
response.prettyPrint();
status = response.jsonPath().getString("status");
i--;
}
return response;
}
}
package http.cases.ExchangeTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Authorization;
import http.service.app.MobileService;
import http.service.app.VirtualExchangeService;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
/**
* Created by yeqinqin on 2018/6/11.
*/
public class 虚拟商品_兑换异常测试 extends DuibaTestBase {
@Autowired
private MobileService mobileService;
@Autowired
private Authorization authorization;
@Autowired
ManagerService managerService;
@Autowired
VirtualExchangeService virtualExchangeService;
private DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 0;
//实物兑换积分不足
@Test(description = "自有虚拟商品积分不足")
public void 积分不足() throws Exception {
//活动详情页
Response response = mobileService.appItemDetail(authorization.dafuwengLogin(uid), "181159");
Map<String, String> map = authorization.dafuwengLogin(uid,true);
Assert.assertEquals(String.valueOf(response.getStatusCode()), "200", "商品详情页面");
response.prettyPrint();
System.out.println(response.asString());
System.out.println("女汉子");
//自有虚拟商品兑换
response = virtualExchangeService.exchange(authorization.dafuwengLogin(uid), "181159", "123");
//获取orderId
String orderId = response.jsonPath().getString("orderId");
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
String message = response.jsonPath().getString("data.message");
//异步接口,直到兑换成功
int i=10;
//异步接口,直到兑换成功
while(i>0&&"兑换正在处理中...".equals(message)){
Thread.sleep(1000);
response = mobileService.orderAmbStatusQuery(uid,orderId);
response.prettyPrint();
message = response.jsonPath().getString("data.message");
i--;
}
Assert.assertEquals(message.trim(),"兑换失败,用户积分余额不足","校验自有虚拟商品积分不足");
}
}
...@@ -267,13 +267,16 @@ public class 新集卡_助力发集卡_DuibaTest extends DuibaTestBase { ...@@ -267,13 +267,16 @@ public class 新集卡_助力发集卡_DuibaTest extends DuibaTestBase {
Long dbPostfix = Long.valueOf(consumerId)%b; Long dbPostfix = Long.valueOf(consumerId)%b;
String dbName = null; String dbName = null;
System.out.println(dbPostfix); System.out.println(dbPostfix);
if (dbPostfix.intValue()<100){ // if (dbPostfix.intValue()<100){
dbName = dbPrex +"_00"+ dbPostfix; // dbName = dbPrex +"_00"+ dbPostfix;
}else if (dbPostfix.intValue()<1000){ // }else if (dbPostfix.intValue()<1000){
dbName = dbPrex +"_0"+ dbPostfix; // dbName = dbPrex +"_0"+ dbPostfix;
}else { // }else {
dbName = dbPrex +"_"+ dbPostfix; // dbName = dbPrex +"_"+ dbPostfix;
} // }
String tag = String.format("%04d", Long.parseLong(consumerId) % 1024);
dbName = dbPrex +"_"+ tag;
logger.info("该用户的表名为:"+dbName); logger.info("该用户的表名为:"+dbName);
return dbName; return dbName;
} }
......
...@@ -19,7 +19,7 @@ import java.util.List; ...@@ -19,7 +19,7 @@ import java.util.List;
* Created by humengxin on 2018/8/21. * Created by humengxin on 2018/8/21.
*/ */
@ContextConfiguration(classes = Config.class) @ContextConfiguration(classes = Config.class)
public class 自定义分类 extends AbstractTestNGSpringContextTests { public class 自定义分类_DuibaTest extends AbstractTestNGSpringContextTests {
@Autowired @Autowired
ZdyflService zdyflService; ZdyflService zdyflService;
......
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import http.service.Activity.ManagerService;
import http.service.Activity.NewActivityService;
import http.service.Activity.SingleLotteryService;
import http.service.hd.ActivityService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.Map;
/**
* Created by zhaoran on 2018/3/13.
*/
public class SingleLottery_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
ActivityService activityService;
@Autowired
NewActivityService newActivityService;
@Autowired
ManagerService managerService;
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 3775;
// private static String consumer_id = "100088034";
private static String tag = "0226";
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("积分抽奖")) {
result = new Object[][]{
new Object[]{1, "18873", "ix18rh", "单品抽奖之iOS商家落地优惠券","iOS"},
new Object[]{1, "18873", "ix18rh", "单品抽奖之android商家落地优惠券","android"},
new Object[]{2, "18874", "zqwwq", "单品抽奖之实物","iOS"},
new Object[]{3, "19952", "40g83xb5", "单品抽奖之话费充值","iOS"},
new Object[]{4, "19954", "40g83xb5", "单品抽奖之支付宝充值","iOS"},
new Object[]{5, "19955", "9fm5ohz", "单品抽奖之Q币充值","iOS"},
new Object[]{6, "19958", "x62stnum", "单品抽奖之兑换记录页优惠券","iOS"},
new Object[]{7, "19959", "zpgcr", "单品抽奖之链接优惠券","iOS"},
};
}
return result;
}
@Test(dataProvider = "providerMethod" )
public void 积分抽奖(int caseNum,String activityId,String token,String casename,String device) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//查询数据库,当前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("抽奖前积分:"+credits);
//扣去1积分
credits = String.valueOf(Integer.valueOf(credits)-1);
Response response =singleLotteryService.doJoin(uid,activityId,activityId,token);
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,device);
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,device);
i--;
}
//根据case选择对应的校验项
switch(caseNum){
case 1:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【勿动】商家落地页_单品抽奖","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "coupon", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("showUse"), "true", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("useBtnText"), "马上使用", "校验按钮文案展示失败");
if ( device.equals("iOS")) {
Assert.assertEquals(response.jsonPath().getString("iosDownloadUrl"), "https://app.aixuedai.com/app/coupon/dbCoupon?productId=515272", "校验Url失败");
}else{
Assert.assertEquals(response.jsonPath().getString("androidDownloadUrl"),"https://www.baidu.com/","校验Url失败");
}
logger.info("校验链接券码项:openUrl,useBtnText成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【勿动】自动化实物奖品","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "27131", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "object", "校验奖品类型失败");
logger.info("校验商家落地项:descrption,itemId,lotteryType成功");
break;
case 3:
Assert.assertEquals(response.jsonPath().getString("descrption"),"多档位话费充值","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "1", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "phonebill", "校验奖品类型失败");
logger.info("校验商家落地项:descrption,itemId,lotteryType成功");
break;
case 4:
Assert.assertEquals(response.jsonPath().getString("descrption"),"支付宝充值","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "55", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "alipay", "校验奖品类型失败");
logger.info("校验商家落地项:descrption,itemId,lotteryType成功");
break;
case 5:
Assert.assertEquals(response.jsonPath().getString("descrption"),"Q币充值","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "2", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "qb", "校验奖品类型失败");
logger.info("校验商家落地项:descrption,itemId,lotteryType成功");
break;
case 6:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【勿动】兑换记录页_单品抽奖","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "coupon", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("showUse"), "true", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("useBtnText"), "查看使用方法", "校验按钮文案展示失败");
Assert.assertTrue(response.jsonPath().getString("iosDownloadUrl").contains("//activity.m.duibatest.com.cn/crecord/recordDetailNew"),"兑换记录页url与实际url不匹配");
logger.info("校验链接券码项:openUrl,useBtnText成功");
break;
case 7:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【勿动】自动化链接券码_单品抽奖","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "coupon", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("showUse"), "true", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("useBtnText"), "马上使用", "校验按钮文案展示失败");
Assert.assertEquals(response.jsonPath().getString("iosDownloadUrl"), "https://app.aixuedai.com/app/coupon/dbCoupon?productId=515272", "校验Url失败");
logger.info("校验链接券码项:openUrl,useBtnText成功");
break;
}
//通用校验项
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验信息失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验状态失败");
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("抽奖后积分:"+creditsNew);
//校验比较,抽奖前后积分
Assert.assertEquals(credits,creditsNew);
logger.info("校验领奖前后积分正确");
//出奖实物走领奖发奖逻辑以及订单校验
if(caseNum == 2){
//待领奖校验子订单状态
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from credits_dev.single_lottery_order where id = '"+id+"'");
String exchangeStatus = String.valueOf(selectResult.get("exchange_status"));
Assert.assertEquals(exchangeStatus, "1", "待领奖校验兑换状态失败");
//领奖操作
String recordId = MatcherString.getString(response.asString(), "recordId=(.*?)&", 1);
response = newActivityService.doTakePrize(uid,"object", recordId);
Assert.assertEquals(response.jsonPath().getString("message"), "领奖成功");
logger.info("结果:领奖流程成功");
selectResult = jdbc.findSimpleResult("select * from credits_dev.single_lottery_order where id = '"+id+"'");
Assert.assertEquals(String.valueOf(selectResult.get("exchange_status")), "2", "待发货校验兑换状态失败");
String orderId = String.valueOf(selectResult.get("order_id"));
Map<String, Object> selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_"+tag+" where id = '"+orderId+"' ");
String flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("领奖后数据库订单节点:"+flowWork);
int j =10;
while (j > 0 && !flowWork.equals("SupplierExchange-started")) {
Thread.sleep(300);
selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_"+tag+" where id = '"+orderId+"' ");
flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("领奖后数据库订单节点:" + flowWork);
j--;
}
Assert.assertEquals(flowWork,"SupplierExchange-started","数据库主订单流程节点校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("item_id")),"27131","数据库主订单奖项id校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("biz_params")),"胡梦新:18258853242:浙江省:杭州市:西湖区:数娱大厦","数据库主订单biz_params校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("pay_status")),"prereduce","数据库主订单pay_status校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("status")),"consume_success","数据库主订单status校验失败");
//发货操作
managerService.expressSend(orderId);
logger.info("实物发货订单成功");
selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_"+tag+" where id = '"+orderId+"' ");
String flowWork2 = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("发货后数据库订单节点:"+flowWork2);
int k =10;
while (k > 0 && !flowWork2.equals("Success-complete")) {
Thread.sleep(1000);
selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_"+tag+" where id = '"+orderId+"' ");
flowWork2 = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("发货后数据库订单节点:" + flowWork2);
k--;
}
Assert.assertEquals(String.valueOf(selectResult2.get("pay_status")),"successs","数据库主订单pay_status校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("status")),"success","数据库主订单status校验失败");
}else if(caseNum == 7){
//待领奖校验子订单状态
Thread.sleep(2000);
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from credits_dev.single_lottery_order where id = '"+id+"'");
String orderId = String.valueOf(selectResult.get("order_id"));
Map<String, Object> selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_"+tag+" where id = '"+orderId+"' ");
String flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("领奖后数据库订单节点:"+flowWork);
int k =10;
while (k > 0 && !flowWork.equals("Success-complete")) {
Thread.sleep(300);
selectResult2 = jdbc.findSimpleResult("select * from orders_consumer.orders_"+tag+" where id = '"+orderId+"' ");
flowWork = String.valueOf(selectResult2.get("flowwork_stage"));
logger.info("领奖后数据库订单节点:" + flowWork);
k--;
}
Assert.assertEquals(flowWork,"Success-complete","数据库主订单流程节点校验失败");
Assert.assertEquals(String.valueOf(selectResult2.get("item_id")),"29761","数据库主订单奖项id校验失败");
}
}
@Test(description = "出福袋,免费抽奖不扣积分" )
public void 免费抽奖() throws Exception {
logger.info("-------------------------------------出福袋,免费抽奖不扣积分-------------------------------------");
//查询数据库,当前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("抽奖前积分:"+credits);
Response response =singleLotteryService.doJoin(uid,"21309","21309","8hbyive");
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(1000);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
response.prettyPrint();
i--;
}
response.prettyPrint();
if(activityService.isRunning("10.110.10.12","17791","tuia-engine")){
logger.info("tuia-engine服务启动成功");
Assert.assertEquals(response.jsonPath().getString("lottery.useBtnText"), "马上使用", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("lottery.showUse"), "true", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验信息失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验状态失败");
}else{
logger.info("tuia-engine服务启动未成功,福袋降级成谢谢参与!");
}
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("抽奖后积分:"+creditsNew);
//校验比较,抽奖前后积分
Assert.assertEquals(credits,creditsNew);
logger.info("校验领奖前后积分正确");
}
}
\ No newline at end of file
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import utils.PublicMethod;
import http.service.Activity.ManagerService;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import http.service.hd.DeveloperService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
/**
* Created by zhaoran on 2018/4/17.
*/
public class 单品抽奖_中鼓励奖_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
DeveloperService developerService;
@Autowired
Authorization authorization;
@Autowired
ManagerService managerService;
@Value("${activity.host}")
String activityHost;
private static DuibaLog logger = DuibaLog.getLogger();
private static String actId;
private static String data;
//指定用户
private static int uid = 2709;
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("鼓励奖限制测试")) {
result = new Object[][]{
new Object[]{1, "27128", "1", "","鼓励奖优惠券数量1,数量用完则判断是否可中主奖"},
new Object[]{2, "27000", "99999", "1","鼓励奖限制,数量用完后用户无法再中鼓励奖"},
};
}
return result;
}
@Test(dataProvider = "providerMethod")
public void 鼓励奖限制测试(int caseNum,String inciteItemId,String inciteItemRemaining,String inciteItemConsumerWinLimit,String casename) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//创建活动
this.创建并上架活动(inciteItemId, inciteItemRemaining, inciteItemConsumerWinLimit);
Response response = developerService.list2("【自动化】鼓励奖限制"+data);
String activityId = response.jsonPath().getString("data.list[0].id");
//当天首次抽奖中鼓励奖
response = this.单品抽奖入参(activityId,activityId,"asdsad");
//根据case选择对应的校验项
switch(caseNum){
case 1:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【勿动】自动化优惠券——商家落地页","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "coupon", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("showUse"), "true", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验status失败");
logger.info("第一次抽奖,校验descrption,showUse,lotteryType,message,status成功");
logger.info("当天首次抽奖中鼓励奖—优惠券");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("descrption"),"自动化测试活动实物","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "object", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验status失败");
logger.info("第一次抽奖,校验descrption,lotteryType,message,status成功");
logger.info("当天首次抽奖中鼓励奖—实物");
break;
}
//当天第二次抽奖
response = this.单品抽奖入参(activityId,activityId,"asdsad");
Assert.assertEquals(response.jsonPath().getString("descrption"),"支付宝充值","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "alipay", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验status失败");
logger.info("第二次抽奖lotteryType,useBtnText,success");
logger.info("当天第二次抽奖中主奖—支付宝");
//删除测试数据
this.删除活动();
try {
jdbc.update("delete from credits_dev.duiba_single_lottery where title=?", "【自动化】鼓励奖限制"+data);
jdbc.update("delete from credits_dev.operating_activity where title=?", "【自动化】鼓励奖限制"+data);
} catch (Exception e) {
System.out.println(e);
}
}
public Response 单品抽奖入参(String operationAcitvityId,String oaId,String token) throws Exception {
//进行接口测试传参
Response response =singleLotteryService.doJoin(uid,operationAcitvityId,oaId,token);
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
i--;
}
return response;
}
public void 创建并上架活动(String inciteItemId,String inciteItemRemaining,String inciteItemConsumerWinLimit) throws Exception {
data = PublicMethod.data();
String title = "【自动化】鼓励奖限制"+data;
//创建单品抽奖活动
//构建鼓励奖
Map<String,String> incite = new HashMap<>();
incite.put("inciteItemId",inciteItemId);
incite.put("inciteItemRate","100");
incite.put("inciteItemRemaining",inciteItemRemaining);
incite.put("preInciteItemRemaining","99999");
incite.put("inciteItemConsumerWinLimit",inciteItemConsumerWinLimit);
incite.put("inciteItemMinComein","");
singleLotteryService.SingleLottery_create(title,incite);
//获取新建活动id
Response response = singleLotteryService.manager_index();
actId = MatcherString.getString(response.asString(), "<td>(.*?)</td>\n", 1);
//管理后台开启活动
singleLotteryService.changeStatus(actId,"1");
//开发者上架活动
developerService.joinIn(actId,"2");
logger.info("创建活动并上架成功");
}
public void 删除活动() throws Exception{
//管理后台删除单品抽奖活动
singleLotteryService.delete(actId);
//开发者删除推荐位活动
Response response = developerService.list2("【自动化】鼓励奖限制"+data);
String actId = response.jsonPath().getString("data.list[0].id");
developerService.delActivity(actId);
}
}
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import utils.PublicMethod;
import http.service.Activity.ManagerService;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import http.service.hd.ActivityService;
import http.service.hd.DeveloperService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.Map;
/**
* Created by zhaoran on 2018/4/17.
*/
public class 单品抽奖_出奖限制_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
DeveloperService developerService;
@Autowired
Authorization authorization;
@Autowired
ManagerService managerService;
@Autowired
ActivityService activityService;
@Value("${activity.host}")
String activityHost;
private static DuibaLog logger = DuibaLog.getLogger();
private static String actId;
private static String data;
//指定用户
private static int uid = 3777;
@AfterClass
public void after() throws Exception{
//数据库删除
try {
jdbc.update("delete from credits_dev.operating_activity where title=?","【自动化】出奖限制"+data);
jdbc.update("delete from credits_dev.duiba_single_lottery where title=?","【自动化】出奖限制"+data);
} catch (Exception e) {
System.out.println(e);
}
}
@Test(description = "每个用户可抽中奖品数上限为1")
public void 出奖限制测试() throws Exception {
this.创建并上架活动();
Response response = developerService.list2("【自动化】出奖限制"+data);
String activityId = response.jsonPath().getString("data.list[0].id");
//当天首次抽奖
response = this.单品抽奖入参(activityId,activityId,"asdsad");
Assert.assertEquals(response.jsonPath().getString("descrption"),"支付宝充值","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "alipay", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验message失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验status失败");
logger.info("第一次抽奖,校验descrption,lotteryType,message,status成功");
//当天第二次抽奖
response = this.单品抽奖入参(activityId,activityId,"asdsad");
logger.info("tuia-engine服务启动成功");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "lucky", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("lottery.useBtnText"), "马上使用", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("success"), "true", "校验success失败");
logger.info("第二次抽奖lotteryType,useBtnText,success");
this.删除活动();
}
public Response 单品抽奖入参(String operationAcitvityId,String oaId,String token) throws Exception {
//进行接口测试传参
Response response =singleLotteryService.doJoin(uid,operationAcitvityId,oaId,token);
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
i--;
}
return response;
}
public void 创建并上架活动() throws Exception {
data = PublicMethod.data();
String title = "【自动化】出奖限制"+data;
//创建单品抽奖活动
//构建鼓励奖
Map<String,String> incite = new HashMap<>();
incite.put("inciteItemId","");
incite.put("inciteItemRate","");
incite.put("inciteItemRemaining","");
incite.put("preInciteItemRemaining","");
incite.put("inciteItemConsumerWinLimit","");
incite.put("inciteItemMinComein","");
singleLotteryService.SingleLottery_create(title,incite);
//获取新建活动id
Response response = singleLotteryService.manager_index();
actId = MatcherString.getString(response.asString(), "<td>(.*?)</td>\n", 1);
//管理后台开启活动
singleLotteryService.changeStatus(actId,"1");
//开发者上架活动
developerService.joinIn(actId,"2");
logger.info("创建活动并上架成功");
}
public void 删除活动() throws Exception{
//管理后台删除单品抽奖活动
singleLotteryService.delete(actId);
//开发者删除推荐位活动
Response response = developerService.list2("【自动化】出奖限制"+data);
String actId = response.jsonPath().getString("data.list[0].id");
developerService.delActivity(actId);
}
}
package http.cases.SingleLotteryTest;
import base.Config;
import http.service.Activity.ManagerService;
import http.service.Activity.SingleLotteryService;
import http.service.Authorization;
import http.service.hd.DeveloperService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.testng.AbstractTestNGSpringContextTests;
import org.testng.Assert;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
import static io.restassured.RestAssured.given;
/**
* Created by zhaoran on 2018/4/17.
*/
@ContextConfiguration(classes = Config.class)
public class 单品抽奖_异常场景_AccessTest extends AbstractTestNGSpringContextTests {
@Autowired
SingleLotteryService singleLotteryService;
@Autowired
DeveloperService developerService;
@Autowired
Authorization authorization;
@Autowired
ManagerService managerService;
@Value("${activity.host}")
String activityHost;
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 2709;
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("限制抽奖测试")) {
result = new Object[][]{
new Object[]{1, "20065", "积分不足"},
new Object[]{2, "20066", "永久次数抽完"},
new Object[]{3, "20073", "当日次数抽完"},
};
}
if(method.getName().equals("中奖限制测试")) {
result = new Object[][]{
new Object[]{"每人限中1次,次数用完无法中奖", "1340","20915"},
new Object[]{"活动奖品剩余不足,无法中奖", "1341","20927"},
new Object[]{"活动奖品库存不足,无法中奖", "1342","20941"},
};
}
return result;
}
@Test(description = "开发者关闭活动,用户调接口抽奖场景")
public void 活动关闭测试() throws Exception {
//关闭活动
Response HdResponse = developerService.closeActivity("20046","2239");
//参加抽奖
Response response = this.单品抽奖异常场景传参("20046");
//判断结果
Assert.assertEquals(response.jsonPath().getString("success"), "false", "校验success失败");
Assert.assertEquals(response.jsonPath().getString("message"), "活动已结束", "校验message失败");
logger.info("活动状态关闭后的抽奖页面验证成功");
//打开活动
HdResponse = developerService.openActivity("20046","2239");
}
@Test(dataProvider = "providerMethod")
public void 限制抽奖测试(int casenum,String activityId,String casename) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//参加抽奖
Response response = this.单品抽奖异常场景传参(activityId);
//根据case选择对应的校验项
switch(casenum){
case 1:
Assert.assertEquals(response.jsonPath().getString("message"),"积分不足","校验message失败");
logger.info("积分不足测试校验项:messag成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("message"),"已抽完","校验message失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"),"2","校验lotteryButtonStatus失败");
logger.info("永久次数不足测试校验项:message,lotteryButtonStatus成功");
break;
case 3:
String success = MatcherString.getString(response.asString(), "\"success\": (.*?),", 1);
int i= 8;
while(i>0&&(success.equals("true"))){
response = this.单品抽奖异常场景传参(activityId);
success = MatcherString.getString(response.asString(), "\"success\": (.*?),", 1);
i--;
}
Assert.assertEquals(response.jsonPath().getString("message"),"今日已抽完","校验message失败");
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"),"8","校验lotteryButtonStatus失败");
logger.info("今日次数不足测试校验项:message,lotteryButtonStatus成功");
break;
}
//通用校验项
Assert.assertEquals(response.jsonPath().getString("success"),"false","校验success失败");
logger.info("通用校验项:success成功");
}
@Test
public void 未登录抽奖测试() throws Exception {
//获取未登录场景cookie
Response responses = authorization.autoLogin();
//进行接口测试传参
Response response = singleLotteryService.init(responses.getDetailedCookies(),"18873");
//校验项
Assert.assertEquals(response.jsonPath().getString("lotteryButtonStatus"),"7","校验lotteryButtonStatus失败");
logger.info("未登录状态下无免费次数抽奖校验:lotteryButtonStatus成功");
}
@Test(dataProvider = "providerMethod")
public void 中奖限制测试(String casename,String actId,String activityId) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//获取管理员后台活动信息
Response ManagerResponse = singleLotteryService.AdminDuibaSingleLottery(actId);
logger.info("预设中奖商品为:实物类");
logger.info("预设中奖几率为:"+MatcherString.getString(ManagerResponse.asString(), "mainItemRate\" value=\"(.*?)\"", 1)+"%");
logger.info("预设中奖每人限制:"+MatcherString.getString(ManagerResponse.asString(), "consumerWinLimit\" value=\"(.*?)\"", 1));
logger.info("预设剩余奖品数:"+MatcherString.getString(ManagerResponse.asString(), "mainItemRemaining\" value=\"(.*?)\"", 1));
//获取奖品剩余库存
String appItemId = MatcherString.getString(ManagerResponse.asString(), "mainItemId\" value=\"(.*?)\"", 1);
String Objremaind = this.getremind(appItemId);
logger.info("预设奖品库存:"+Objremaind+"个");
//进行接口测试传参
Response response =singleLotteryService.doJoin(uid,activityId,activityId,"asdsad");
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
i--;
}
String type = String.valueOf(response.jsonPath().getString("lotteryType"));
if (type.equals("lucky")){
Assert.assertTrue(response.jsonPath().getString("lottery.link").contains("//activity.m.duibatest.com.cn/crecord/recordLuckDetailNew?"));
Assert.assertEquals(response.jsonPath().getString("lottery.useBtnText"),"马上使用","校验useBtnText失败");
Assert.assertEquals(response.jsonPath().getString("isAppLucky"),"true","校验谢谢参与转福袋失败");
logger.info("校验中奖限制测试:link,useBtnText,isAppLucky成功");
logger.info("校验中奖限制测试成功,未返回预设必中实物奖品");
}
if (type.equals("thanks")){
logger.info("福袋库存不足会降级成谢谢参与!");//福袋库存不足会降级成谢谢参与!
}
if (type.equals("object")&&MatcherString.getString(ManagerResponse.asString(), "mainItemRemaining\" value=\"(.*?)\"", 1).equals("0")){
throw new Exception("用例失败,不应返回实物信息:"+response.asString());
}
}
@Test(description = "该单品抽奖已在大富翁app上架可参与")
public void 开发者未上架单品抽奖() {
Response response = this.单品抽奖异常场景传参("33488");
//logger.info("CCCCC"+response.asString());
Assert.assertEquals(response.jsonPath().getString("success"),"false");
Assert.assertEquals(response.jsonPath().getString("message"),"无权访问");
}
public Response 单品抽奖异常场景传参(String activityId) {
Map<String, String> map = new HashMap<>();
map.put("operationAcitvityId", activityId);
map.put("oaId", activityId);
map.put("token", "hdfjks");
Response response = given().cookies(authorization.dafuwengLogin(uid)).params(map).post(activityHost + "/singleLottery/doJoin");
response.prettyPrint();
return response;
}
public String getremind(String gid) throws Exception{
Response ManagerResponse = managerService.CouponConfig(gid);
ManagerResponse.prettyPrint();
String remind = MatcherString.getString(ManagerResponse.asString(), "remaining\" value=\"(.*?)\"", 1);
return remind;
}
}
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.lang.reflect.Method;
import java.util.Map;
/**
* Created by zhaoran on 2018/6/8.
*/
public class 自有单品抽奖_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 2709;
@BeforeClass
public void before() {
try {
jdbc.update("delete from orders_consumer.orders_0616 where consumer_id = 100011624 and biz_params = 'DUIBA_SELF'", null);
} catch (Exception e) {
e.printStackTrace();
}
}
@DataProvider
public Object[][] providerMethod(Method method){
Object[][] result = null;
if(method.getName().equals("自有单品抽奖")) {
result = new Object[][]{
new Object[]{1, "26476", "ix18rh", "单品抽奖之优惠券","iOS"},
new Object[]{2, "26477", "ix18rh", "单品抽奖之实物","android"},
new Object[]{3, "26480", "40g83xb5", "单品抽奖之话费充值","iOS"},
new Object[]{4, "26478", "40g83xb5", "单品抽奖之支付宝充值","iOS"},
new Object[]{5, "26479", "9fm5ohz", "单品抽奖之Q币充值","iOS"},
new Object[]{6, "26481", "x62stnum", "单品抽奖之虚拟商品","iOS"},
};
}
return result;
}
@Test(dataProvider = "providerMethod" )
public void 自有单品抽奖(int caseNum,String activityId,String token,String casename,String device) throws Exception {
logger.info("-------------------------------------"+casename+"-------------------------------------");
//查询数据库,当前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("抽奖前积分:"+credits);
//扣去1积分
credits = String.valueOf(Integer.valueOf(credits)-1);
Response response =singleLotteryService.doJoin(uid,activityId,activityId,token);
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,device);
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,device);
i--;
}
//根据case选择对应的校验项
switch(caseNum){
case 1:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【自动化】优惠券-普通","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "coupon", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("showUse"), "true", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("useBtnText"), "马上使用", "校验按钮文案展示失败");
if ( device.equals("iOS")) {
Assert.assertEquals(response.jsonPath().getString("iosDownloadUrl"), "www.baidu.com", "校验Url失败");
}else{
Assert.assertEquals(response.jsonPath().getString("androidDownloadUrl"),"www.baidu.com","校验Url失败");
}
logger.info("校验链接券码项:openUrl,useBtnText成功");
break;
case 2:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【自动化测试误删】实物奖品","校验实物标题失败");
Assert.assertTrue(response.jsonPath().getString("url").contains("/activity/takePrizeNew?recordId"),"兑换记录页url与实际url不匹配");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "object", "校验奖品类型失败");
logger.info("校验商家落地项:descrption,url,lotteryType成功");
break;
case 3:
Assert.assertEquals(response.jsonPath().getString("descrption"),"多档位话费充值","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "1", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "phonebill", "校验奖品类型失败");
Assert.assertTrue(response.jsonPath().getString("url").contains("/activity/takePrizeNew?recordId"),"兑换记录页url与实际url不匹配");
logger.info("校验商家落地项:descrption,itemId,lotteryType,url成功");
break;
case 4:
Assert.assertEquals(response.jsonPath().getString("descrption"),"支付宝充值","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "55", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "alipay", "校验奖品类型失败");
Assert.assertTrue(response.jsonPath().getString("url").contains("/activity/takePrizeNew?recordId"),"兑换记录页url与实际url不匹配");
logger.info("校验商家落地项:descrption,itemId,lotteryType,url成功");
break;
case 5:
Assert.assertEquals(response.jsonPath().getString("descrption"),"Q币充值","校验实物标题失败");
Assert.assertEquals(response.jsonPath().getString("itemId"), "2", "校验实物ID失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "qb", "校验奖品类型失败");
Assert.assertTrue(response.jsonPath().getString("url").contains("/activity/takePrizeNew?recordId"),"兑换记录页url与实际url不匹配");
logger.info("校验商家落地项:descrption,itemId,lotteryType,url成功");
break;
case 6:
Assert.assertEquals(response.jsonPath().getString("descrption"),"【自动化】自有虚拟商品","校验优惠券标题失败");
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "virtual", "校验奖品类型失败");
Assert.assertTrue(response.jsonPath().getString("url").contains("//activity.m.duibatest.com.cn/crecord/recordDetailNew"),"兑换记录页url与实际url不匹配");
logger.info("校验链接券码项:openUrl,useBtnText成功");
Thread.sleep(2000);
Map<String, Object> selectResult = jdbc.findSimpleResult("select * from orders_consumer.orders_0616 where consumer_id = 100011624 and biz_params = 'DUIBA_SELF' ",null);
//logger.info("selectResult结果为:"+selectResult);
Assert.assertEquals( selectResult.get("biz_params"),"DUIBA_SELF","虚拟商品出奖标识DUIBA_SELF校验失败");
logger.info("数据库存储虚拟商品标记结果为:"+selectResult.get("biz_params"));
break;
}
//通用校验项
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验信息失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验状态失败");
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("抽奖后积分:"+creditsNew);
//校验比较,抽奖前后积分
Assert.assertEquals(credits,creditsNew);
logger.info("校验领奖前后积分正确");
}
}
\ No newline at end of file
package http.cases.SingleLotteryTest;
import base.DuibaTestBase;
import http.service.Activity.SingleLotteryService;
import utils.MatcherString;
import base.DuibaLog;
import io.restassured.response.Response;
import org.springframework.beans.factory.annotation.Autowired;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.util.Map;
/**
* Created by zhaoran on 2018/6/8.
*/
public class 自有库存不足_AccessTest extends DuibaTestBase {
@Autowired
SingleLotteryService singleLotteryService;
private static DuibaLog logger = DuibaLog.getLogger();
//指定用户
private static int uid = 3927;
@Test
public void 自有单品抽奖库存不足() throws Exception {
//查询数据库,当前积分(抽奖扣积分流程校验)
Map<String,Object> mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String credits = String.valueOf(mapuser.get("credits"));
logger.info("抽奖前积分:"+credits);
//扣去1积分
credits = String.valueOf(Integer.valueOf(credits)-1);
Response response =singleLotteryService.doJoin(uid,"34541","34541","238wmftdc");
//response.prettyPrint();
String id =MatcherString.getString(response.asString(), "singleLotteryOrderId\":(.*?),", 1);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
int i = 10;
while ("处理中".equals(response.jsonPath().getString("message")) && i > 0) {
Thread.sleep(500);
response = singleLotteryService.getOrderStatus(uid,id,"iOS");
i--;
}
Assert.assertEquals(response.jsonPath().getString("lotteryType"), "lucky", "校验奖品类型失败");
Assert.assertEquals(response.jsonPath().getString("lottery.showUse"), "true", "校验是否展示马上使用失败");
Assert.assertEquals(response.jsonPath().getString("lottery.useBtnText"), "马上使用", "校验按钮文案展示失败");
//通用校验项
Assert.assertEquals(response.jsonPath().getString("message"), "成功", "校验信息失败");
Assert.assertEquals(response.jsonPath().getString("status"), "1", "校验状态失败");
//查询数据库,获取当前积分
Thread.sleep(3000);
mapuser = jdbc.findSimpleResult("select * from dafuweng.user where id="+uid);
String creditsNew = String.valueOf(mapuser.get("credits"));
logger.info("抽奖后积分:"+creditsNew);
//校验比较,抽奖前后积分
Assert.assertEquals(credits,creditsNew);
logger.info("校验领奖前后积分正确");
}
}
\ No newline at end of file
...@@ -172,7 +172,7 @@ public class ZdyflService { ...@@ -172,7 +172,7 @@ public class ZdyflService {
return response; return response;
} }
//自定义分类-活动移出分类 //自定义分类_DuibaTest-活动移出分类
public Response removeClassifyAppItem1(String classifyId,String operatingActivityId) throws Exception { public Response removeClassifyAppItem1(String classifyId,String operatingActivityId) throws Exception {
String url=hdHost+"/devItem/removeClassifyAppItem"; String url=hdHost+"/devItem/removeClassifyAppItem";
...@@ -191,7 +191,7 @@ public class ZdyflService { ...@@ -191,7 +191,7 @@ public class ZdyflService {
return response; return response;
} }
//自定义分类-商品移出分类 //自定义分类_DuibaTest-商品移出分类
public Response removeClassifyAppItem2(String classifyId,String appItemId) throws Exception { public Response removeClassifyAppItem2(String classifyId,String appItemId) throws Exception {
String url=hdHost+"/devItem/removeClassifyAppItem"; String url=hdHost+"/devItem/removeClassifyAppItem";
......
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