Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
X
xm-sportstest
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
xiamai-test
xm-sportstest
Commits
9fc12091
Commit
9fc12091
authored
Dec 31, 2024
by
yangfangfang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
物品
parent
378b441a
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
104 additions
and
9 deletions
+104
-9
src/main/java/com/xiaomai/cases/lunar/goods/TestPurchaseGoods.java
+104
-9
No files found.
src/main/java/com/xiaomai/cases/lunar/goods/TestPurchaseGoods.java
View file @
9fc12091
...
...
@@ -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"
);
goodsId
1
=
create
.
getString
(
"result"
);
//获取商品详情
JSONObject
getDetail_goods_C
=
goodCTools
.
getDetail_goods_C
(
goodsId
,
info
);
JSONObject
getDetail_goods_C
=
goodCTools
.
getDetail_goods_C
(
goodsId
1
,
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
);
goodsId
2
=
create
.
getString
(
"result"
);
//获取商品详情
JSONObject
getDetail_goods_C
=
goodCTools
.
getDetail_goods_C
(
goodsId
,
info
);
JSONObject
getDetail_goods_C
=
goodCTools
.
getDetail_goods_C
(
goodsId
2
,
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);
//
// }
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment