Commit 9fc12091 by yangfangfang

物品

parent 378b441a
......@@ -29,7 +29,9 @@ public class TestPurchaseGoods extends BaseTestImpl {
DataUserInfo info = new DataUserInfo();
String goodsId;
String goodsId1;
String goodsId2;
String goodsId3;
OrderCTools orderCTools=new OrderCTools();
......@@ -37,9 +39,6 @@ public class TestPurchaseGoods extends BaseTestImpl {
OrderTools orderTools=new OrderTools();
@BeforeMethod
@Override
public void beforeTest(){
......@@ -61,9 +60,9 @@ public class TestPurchaseGoods extends BaseTestImpl {
//新建一个非0多规格物品
JSONObject create=goodTools.createGoods_multiple("YES","0.01",10,info);
goodsId=create.getString("result");
goodsId1=create.getString("result");
//获取商品详情
JSONObject getDetail_goods_C=goodCTools.getDetail_goods_C(goodsId,info);
JSONObject getDetail_goods_C=goodCTools.getDetail_goods_C(goodsId1,info);
String id=getDetail_goods_C.getJSONObject("result").getJSONObject("multiSpecInfo").getJSONArray("specCombinationList").getJSONObject(0).getString("id");
String price=getDetail_goods_C.getJSONObject("result").getJSONObject("multiSpecInfo").getJSONArray("specCombinationList").getJSONObject(0).getString("price");
int inventory=Integer.parseInt(getDetail_goods_C.getJSONObject("result").getJSONObject("multiSpecInfo").getJSONArray("specCombinationList").getJSONObject(0).getString("inventory"));
......@@ -97,6 +96,12 @@ public class TestPurchaseGoods extends BaseTestImpl {
String state=getDetailResult.getJSONObject("result").getString("state");
Assert.assertEquals(state,"WAITING","未生成待支付物品订单");
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
......@@ -131,10 +136,10 @@ public class TestPurchaseGoods extends BaseTestImpl {
//新建一个0元多规格物品
JSONObject create=goodTools.createGoods_multiple("YES","0",10,info);
goodsId=create.getString("result");
JSONObject create=goodTools.createGoods_multiple("YES","0.00",10,info);
goodsId2=create.getString("result");
//获取商品详情
JSONObject getDetail_goods_C=goodCTools.getDetail_goods_C(goodsId,info);
JSONObject getDetail_goods_C=goodCTools.getDetail_goods_C(goodsId2,info);
String id=getDetail_goods_C.getJSONObject("result").getJSONObject("multiSpecInfo").getJSONArray("specCombinationList").getJSONObject(0).getString("id");
BigDecimal price=new BigDecimal(getDetail_goods_C.getJSONObject("result").getJSONObject("multiSpecInfo").getJSONArray("specCombinationList").getJSONObject(0).getString("price"));
int inventory=Integer.parseInt(getDetail_goods_C.getJSONObject("result").getJSONObject("multiSpecInfo").getJSONArray("specCombinationList").getJSONObject(0).getString("inventory"));
......@@ -169,6 +174,78 @@ public class TestPurchaseGoods extends BaseTestImpl {
Assert.assertEquals(state,"PAID","未生成已完成物品订单");
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
else {
System.out.println("物品购买校验未通过,不能下单");
}
}
@Test(description = "购买0元单规格物品")
public void testPurchaseGoods_PAID_single() {
//获取会员信息
memberId = userTools.getMemberInfo().getString("memberId");
//切换端位
info.setTerminal(Terminal.B);
info.setLoginUser(LoginAccount.GYM_PROD);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
//新建一个0元单规格物品
JSONObject create=goodTools.createGoods_single("YES","0.00",10,info);
goodsId3=create.getString("result");
//获取商品详情
JSONObject getDetail_goods_C=goodCTools.getDetail_goods_C(goodsId3,info);
String id=getDetail_goods_C.getJSONObject("result").getString("id");
BigDecimal price=new BigDecimal(getDetail_goods_C.getJSONObject("result").getJSONObject("singleSpecInfo").getString("price"));
int inventory=Integer.parseInt(getDetail_goods_C.getJSONObject("result").getJSONObject("singleSpecInfo").getString("inventory"));
boolean checkAllowPurchase=Boolean.parseBoolean(goodCTools.checkAllowPurchase(id,memberId,"0.00",inventory).getJSONObject("result").getString("success"));
//校验一下物品购买是否可以通过,为true才可以
if(checkAllowPurchase==true){
//购买0元单规格物品
JSONObject purchaseGoods=new JSONObject();
purchaseGoods.put("depositAmount","0.00");
purchaseGoods.put("depositCardId",null);
purchaseGoods.put("memberId",memberId);
purchaseGoods.put("memo","");
purchaseGoods.put("objectId", RandomStringUtil.randomString(16));
purchaseGoods.put("receivableAmount",price);
purchaseGoods.put("goodsSpecId",goodsId3);
purchaseGoods.put("price",price);
purchaseGoods.put("quantity",1);
purchaseGoods.put("studioId",dataApi.getLoginInfo().getStudioId());
xmAppApi.doRequest(RequestType.JSON, params, purchaseGoods.toString(), headers).assetsSuccess(true);
JSONObject purchaseGoodsResponse = xmAppApi.getBodyInJSON();
String orderId=purchaseGoodsResponse.getJSONObject("result").getString("id");
//校验1:获取B端详情:已完成状态
JSONObject getDetailResult = orderTools.getDetail(orderId,info);
String businessNo= getDetailResult.getJSONObject("result").getString("businessNo");//订单号
String state=getDetailResult.getJSONObject("result").getString("state");
Assert.assertEquals(state,"PAID","未生成已完成物品订单");
}
else {
......@@ -177,4 +254,22 @@ public class TestPurchaseGoods extends BaseTestImpl {
}
// @Test(description = "清理物品数据",priority = 1)
// public void delete() {
// goodTools.deleteGoods(goodsId1,info);
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// goodTools.deleteGoods(goodsId2,info);
// try {
// Thread.sleep(3000);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// goodTools.deleteGoods(goodsId3,info);
//
// }
}
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