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
3c8b802b
Commit
3c8b802b
authored
Jan 02, 2025
by
zhoujianjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
物品
parent
9fc12091
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
182 additions
and
70 deletions
+182
-70
src/main/java/com/xiaomai/cases/lunar/goods/TestListXcxGoodsGroup.java
+5
-5
src/main/java/com/xiaomai/cases/lunar/goods/TestPurchaseGoods.java
+159
-54
src/main/java/com/xiaomai/cases/polar/goods/TestCreateGoods.java
+4
-4
src/main/java/com/xiaomai/cases/polar/goods/TestDeleteGood.java
+2
-2
src/main/java/com/xiaomai/cases/polar/goods/TestModifyGoods.java
+4
-4
src/main/java/com/xiaomai/cases/polar/goods/TestRefundGoods.java
+7
-0
src/main/java/com/xiaomai/cases/polar/goods/Tools/GoodTools.java
+1
-1
No files found.
src/main/java/com/xiaomai/cases/lunar/goods/TestListXcxGoodsGroup.java
View file @
3c8b802b
...
@@ -143,10 +143,10 @@ public class TestListXcxGoodsGroup extends BaseTestImpl {
...
@@ -143,10 +143,10 @@ public class TestListXcxGoodsGroup extends BaseTestImpl {
}
}
@Test
(
description
=
"清理物品数据"
,
priority
=
1
)
//
@Test(description = "清理物品数据",priority = 1)
public
void
delete
()
{
//
public void delete() {
goodTools
.
deleteGoods
(
createGoodsId
,
info
);
//
goodTools.deleteGoods(createGoodsId,info);
//
}
//
}
}
}
src/main/java/com/xiaomai/cases/lunar/goods/TestPurchaseGoods.java
View file @
3c8b802b
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import
com.xiaomai.basetest.BaseTestImpl
;
import
com.xiaomai.basetest.BaseTestImpl
;
import
com.xiaomai.cases.lunar.order.OrderCTools
;
import
com.xiaomai.cases.lunar.order.OrderCTools
;
import
com.xiaomai.cases.lunar.user.UserTools
;
import
com.xiaomai.cases.lunar.user.UserTools
;
import
com.xiaomai.cases.polar.data.financeData.FinanceDataTools
;
import
com.xiaomai.cases.polar.finance.order.OrderTools
;
import
com.xiaomai.cases.polar.finance.order.OrderTools
;
import
com.xiaomai.cases.polar.goods.Tools.GoodTools
;
import
com.xiaomai.cases.polar.goods.Tools.GoodTools
;
import
com.xiaomai.client.DataUserInfo
;
import
com.xiaomai.client.DataUserInfo
;
...
@@ -12,11 +13,13 @@ import com.xiaomai.enums.LoginAccount;
...
@@ -12,11 +13,13 @@ import com.xiaomai.enums.LoginAccount;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.RandomStringUtil
;
import
com.xiaomai.utils.RandomStringUtil
;
import
com.xiaomai.utils.TimeUtils
;
import
org.testng.Assert
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.Test
;
import
org.testng.annotations.Test
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
import
java.math.RoundingMode
;
public
class
TestPurchaseGoods
extends
BaseTestImpl
{
public
class
TestPurchaseGoods
extends
BaseTestImpl
{
...
@@ -29,15 +32,20 @@ public class TestPurchaseGoods extends BaseTestImpl {
...
@@ -29,15 +32,20 @@ public class TestPurchaseGoods extends BaseTestImpl {
DataUserInfo
info
=
new
DataUserInfo
();
DataUserInfo
info
=
new
DataUserInfo
();
String
goodsId1
;
String
goodsId2
;
String
goodsId3
;
OrderCTools
orderCTools
=
new
OrderCTools
();
OrderCTools
orderCTools
=
new
OrderCTools
();
OrderTools
orderTools
=
new
OrderTools
();
OrderTools
orderTools
=
new
OrderTools
();
FinanceDataTools
financeDataTools
=
new
FinanceDataTools
();
String
orderId1
;
String
orderId2
;
String
orderId3
;
@BeforeMethod
@BeforeMethod
@Override
@Override
...
@@ -49,6 +57,18 @@ public class TestPurchaseGoods extends BaseTestImpl {
...
@@ -49,6 +57,18 @@ public class TestPurchaseGoods extends BaseTestImpl {
@Test
(
description
=
"购买非0元多规格物品"
)
@Test
(
description
=
"购买非0元多规格物品"
)
public
void
testPurchaseGoods_WAITING
()
{
public
void
testPurchaseGoods_WAITING
()
{
//涉及到订单的都使用存量物品数据,因为购买过物品就不能被删除了,所以不会买一次新建一个
// "id": "1874413681302990849",
// "name": "自动化禁用-购买订单单规格1元",
// "id": "1874413587237335042",
// "name": "自动化禁用-购买订单多规格1元",
// "id": "1874413193018896386",
// "name": "自动化禁用-购买订单多规格0元",
// "id": "1874411064376061954",
// "name": "自动化禁用-购买订单单规格0元",
//case1:购买多规格非0元物品生成待支付订单
//获取会员信息
//获取会员信息
memberId
=
userTools
.
getMemberInfo
().
getString
(
"memberId"
);
memberId
=
userTools
.
getMemberInfo
().
getString
(
"memberId"
);
...
@@ -58,16 +78,24 @@ public class TestPurchaseGoods extends BaseTestImpl {
...
@@ -58,16 +78,24 @@ public class TestPurchaseGoods extends BaseTestImpl {
info
.
setTerminal
(
Terminal
.
B
);
info
.
setTerminal
(
Terminal
.
B
);
info
.
setLoginUser
(
LoginAccount
.
GYM_PROD
);
info
.
setLoginUser
(
LoginAccount
.
GYM_PROD
);
//新建一个非0多规格物品
String
goodsId1
=
"1874413587237335042"
;
JSONObject
create
=
goodTools
.
createGoods_multiple
(
"YES"
,
"0.01"
,
10
,
info
);
goodsId1
=
create
.
getString
(
"result"
);
//获取C端商品详情
//获取商品详情
JSONObject
getDetail_goods_C
=
goodCTools
.
getDetail_goods_C
(
goodsId1
);
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
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"
);
String
price
=
getDetail_goods_C
.
getJSONObject
(
"result"
).
getJSONObject
(
"multiSpecInfo"
).
getJSONArray
(
"specCombinationList"
).
getJSONObject
(
0
).
getString
(
"price"
);
int
i
nventory
=
Integer
.
parseInt
(
getDetail_goods_C
.
getJSONObject
(
"result"
).
getJSONObject
(
"multiSpecInfo"
).
getJSONArray
(
"specCombinationList"
).
getJSONObject
(
0
).
getString
(
"inventory"
));
int
beforeI
nventory
=
Integer
.
parseInt
(
getDetail_goods_C
.
getJSONObject
(
"result"
).
getJSONObject
(
"multiSpecInfo"
).
getJSONArray
(
"specCombinationList"
).
getJSONObject
(
0
).
getString
(
"inventory"
));
boolean
checkAllowPurchase
=
Boolean
.
parseBoolean
(
goodCTools
.
checkAllowPurchase
(
id
,
memberId
,
price
,
inventory
).
getJSONObject
(
"result"
).
getString
(
"success"
));
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//获取数据中心-财务中心-营收明细-物品的确认收入
JSONObject
beforeGetCostData_type
=
financeDataTools
.
getCostData_type
(
"DAY"
,
"GOODS"
,
TimeUtils
.
getTodayTime
(),
TimeUtils
.
getTodayEndTime
(),
info
);
BigDecimal
beforeConfirmedAmount
=
new
BigDecimal
(
beforeGetCostData_type
.
getJSONObject
(
"result"
).
getString
(
"confirmedAmount"
));
//确认收入
boolean
checkAllowPurchase
=
Boolean
.
parseBoolean
(
goodCTools
.
checkAllowPurchase
(
id
,
memberId
,
price
,
beforeInventory
).
getJSONObject
(
"result"
).
getString
(
"success"
));
//校验一下物品购买是否可以通过,为true才可以
//校验一下物品购买是否可以通过,为true才可以
if
(
checkAllowPurchase
==
true
){
if
(
checkAllowPurchase
==
true
){
...
@@ -88,10 +116,10 @@ public class TestPurchaseGoods extends BaseTestImpl {
...
@@ -88,10 +116,10 @@ public class TestPurchaseGoods extends BaseTestImpl {
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
purchaseGoods
.
toString
(),
headers
).
assetsSuccess
(
true
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
purchaseGoods
.
toString
(),
headers
).
assetsSuccess
(
true
);
JSONObject
purchaseGoodsResponse
=
xmAppApi
.
getBodyInJSON
();
JSONObject
purchaseGoodsResponse
=
xmAppApi
.
getBodyInJSON
();
String
orderId
=
purchaseGoodsResponse
.
getJSONObject
(
"result"
).
getString
(
"id"
);
orderId1
=
purchaseGoodsResponse
.
getJSONObject
(
"result"
).
getString
(
"id"
);
//校验1:获取B端详情:待支付状态
//校验1:获取B端
订单
详情:待支付状态
JSONObject
getDetailResult
=
orderTools
.
getDetail
(
orderId
,
info
);
JSONObject
getDetailResult
=
orderTools
.
getDetail
(
orderId
1
,
info
);
String
businessNo
=
getDetailResult
.
getJSONObject
(
"result"
).
getString
(
"businessNo"
);
//订单号
String
businessNo
=
getDetailResult
.
getJSONObject
(
"result"
).
getString
(
"businessNo"
);
//订单号
String
state
=
getDetailResult
.
getJSONObject
(
"result"
).
getString
(
"state"
);
String
state
=
getDetailResult
.
getJSONObject
(
"result"
).
getString
(
"state"
);
Assert
.
assertEquals
(
state
,
"WAITING"
,
"未生成待支付物品订单"
);
Assert
.
assertEquals
(
state
,
"WAITING"
,
"未生成待支付物品订单"
);
...
@@ -102,20 +130,49 @@ public class TestPurchaseGoods extends BaseTestImpl {
...
@@ -102,20 +130,49 @@ public class TestPurchaseGoods extends BaseTestImpl {
throw
new
RuntimeException
(
e
);
throw
new
RuntimeException
(
e
);
}
}
//校验2:C端商品详情库存数-1
JSONObject
afterGetDetail_goods_C
=
goodCTools
.
getDetail_goods_C
(
goodsId1
);
int
afterInventory
=
Integer
.
parseInt
(
afterGetDetail_goods_C
.
getJSONObject
(
"result"
).
getJSONObject
(
"multiSpecInfo"
).
getJSONArray
(
"specCombinationList"
).
getJSONObject
(
0
).
getString
(
"inventory"
));
Assert
.
assertEquals
(
afterInventory
,
beforeInventory
-
1
,
"购买1个物品生成待支付订单后,应扣除1个库存数"
);
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//校验3:权益未到,数据中心的确认收入没有增加
//获取数据中心-财务中心-营收明细-物品的确认收入
JSONObject
afterGetCostData_type
=
financeDataTools
.
getCostData_type
(
"DAY"
,
"GOODS"
,
TimeUtils
.
getTodayTime
(),
TimeUtils
.
getTodayEndTime
(),
info
);
BigDecimal
afterConfirmedAmount
=
new
BigDecimal
(
afterGetCostData_type
.
getJSONObject
(
"result"
).
getString
(
"confirmedAmount"
));
//确认收入
Assert
.
assertEquals
(
afterConfirmedAmount
,
beforeConfirmedAmount
,
"购买1个物品生成待支付订单后,财务中心-营收明细-物品的确认收入应无变化"
);
//C端取消订单
//
case2:
C端取消订单
JSONObject
cancel
=
orderCTools
.
cancel
(
orderId
);
JSONObject
cancel
=
orderCTools
.
cancel
(
orderId
1
);
//校验1:获取B端详情:已取消状态
//校验1:获取B端
订单
详情:已取消状态
JSONObject
getDetailResult_cancel
=
orderTools
.
getDetail
(
orderId
,
info
);
JSONObject
getDetailResult_cancel
=
orderTools
.
getDetail
(
orderId
1
,
info
);
String
businessNo_cancel
=
getDetailResult_cancel
.
getJSONObject
(
"result"
).
getString
(
"businessNo"
);
//订单号
String
businessNo_cancel
=
getDetailResult_cancel
.
getJSONObject
(
"result"
).
getString
(
"businessNo"
);
//订单号
String
state_cancel
=
getDetailResult_cancel
.
getJSONObject
(
"result"
).
getString
(
"state"
);
String
state_cancel
=
getDetailResult_cancel
.
getJSONObject
(
"result"
).
getString
(
"state"
);
Assert
.
assertEquals
(
state_cancel
,
"CANCEL"
,
"未生成待支付物品订单"
);
Assert
.
assertEquals
(
state_cancel
,
"CANCEL"
,
"未生成待支付物品订单"
);
//校验2:C端商品详情库存数+1
JSONObject
lastGetDetail_goods_C
=
goodCTools
.
getDetail_goods_C
(
goodsId1
);
int
lastInventory
=
Integer
.
parseInt
(
lastGetDetail_goods_C
.
getJSONObject
(
"result"
).
getJSONObject
(
"multiSpecInfo"
).
getJSONArray
(
"specCombinationList"
).
getJSONObject
(
0
).
getString
(
"inventory"
));
Assert
.
assertEquals
(
lastInventory
,
afterInventory
+
1
,
"取消购买1个物品的待支付订单后,应返回1个库存数"
);
//校验3:权益未涉及,数据中心的确认收入没有变化
//获取数据中心-财务中心-营收明细-物品的确认收入
JSONObject
lastGetCostData_type
=
financeDataTools
.
getCostData_type
(
"DAY"
,
"GOODS"
,
TimeUtils
.
getTodayTime
(),
TimeUtils
.
getTodayEndTime
(),
info
);
BigDecimal
lastConfirmedAmount
=
new
BigDecimal
(
lastGetCostData_type
.
getJSONObject
(
"result"
).
getString
(
"confirmedAmount"
));
//确认收入
Assert
.
assertEquals
(
lastConfirmedAmount
,
afterConfirmedAmount
,
"取消购买1个物品的待支付订单后,财务中心-营收明细-物品的确认收入应无变化"
);
}
}
else
{
else
{
System
.
out
.
println
(
"物品购买校验未通过,不能下单"
);
System
.
out
.
println
(
"物品购买校验未通过,不能下单"
);
...
@@ -135,16 +192,25 @@ public class TestPurchaseGoods extends BaseTestImpl {
...
@@ -135,16 +192,25 @@ public class TestPurchaseGoods extends BaseTestImpl {
info
.
setLoginUser
(
LoginAccount
.
GYM_PROD
);
info
.
setLoginUser
(
LoginAccount
.
GYM_PROD
);
//新建一个0元多规格物品
String
goodsId2
=
"1874413193018896386"
;
JSONObject
create
=
goodTools
.
createGoods_multiple
(
"YES"
,
"0.00"
,
10
,
info
);
goodsId2
=
create
.
getString
(
"result"
);
//获取C端商品详情
//获取商品详情
JSONObject
getDetail_goods_C
=
goodCTools
.
getDetail_goods_C
(
goodsId2
);
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"
);
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"
));
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"
));
int
beforeInventory
=
Integer
.
parseInt
(
getDetail_goods_C
.
getJSONObject
(
"result"
).
getJSONObject
(
"multiSpecInfo"
).
getJSONArray
(
"specCombinationList"
).
getJSONObject
(
0
).
getString
(
"inventory"
));
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
boolean
checkAllowPurchase
=
Boolean
.
parseBoolean
(
goodCTools
.
checkAllowPurchase
(
id
,
memberId
,
"0.00"
,
inventory
).
getJSONObject
(
"result"
).
getString
(
"success"
));
//获取数据中心-财务中心-营收明细-物品的确认收入
JSONObject
beforeGetCostData_type
=
financeDataTools
.
getCostData_type
(
"DAY"
,
"GOODS"
,
TimeUtils
.
getTodayTime
(),
TimeUtils
.
getTodayEndTime
(),
info
);
BigDecimal
beforeConfirmedAmount
=
new
BigDecimal
(
beforeGetCostData_type
.
getJSONObject
(
"result"
).
getString
(
"confirmedAmount"
));
//确认收入
boolean
checkAllowPurchase
=
Boolean
.
parseBoolean
(
goodCTools
.
checkAllowPurchase
(
id
,
memberId
,
"0.00"
,
beforeInventory
).
getJSONObject
(
"result"
).
getString
(
"success"
));
//校验一下物品购买是否可以通过,为true才可以
//校验一下物品购买是否可以通过,为true才可以
if
(
checkAllowPurchase
==
true
){
if
(
checkAllowPurchase
==
true
){
...
@@ -165,14 +231,32 @@ public class TestPurchaseGoods extends BaseTestImpl {
...
@@ -165,14 +231,32 @@ public class TestPurchaseGoods extends BaseTestImpl {
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
purchaseGoods
.
toString
(),
headers
).
assetsSuccess
(
true
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
purchaseGoods
.
toString
(),
headers
).
assetsSuccess
(
true
);
JSONObject
purchaseGoodsResponse
=
xmAppApi
.
getBodyInJSON
();
JSONObject
purchaseGoodsResponse
=
xmAppApi
.
getBodyInJSON
();
String
orderId
=
purchaseGoodsResponse
.
getJSONObject
(
"result"
).
getString
(
"id"
);
orderId2
=
purchaseGoodsResponse
.
getJSONObject
(
"result"
).
getString
(
"id"
);
//校验1:获取B端详情:待支付状态
//校验1:获取B端
订单
详情:待支付状态
JSONObject
getDetailResult
=
orderTools
.
getDetail
(
orderId
,
info
);
JSONObject
getDetailResult
=
orderTools
.
getDetail
(
orderId
2
,
info
);
String
businessNo
=
getDetailResult
.
getJSONObject
(
"result"
).
getString
(
"businessNo"
);
//订单号
String
businessNo
=
getDetailResult
.
getJSONObject
(
"result"
).
getString
(
"businessNo"
);
//订单号
String
state
=
getDetailResult
.
getJSONObject
(
"result"
).
getString
(
"state"
);
String
state
=
getDetailResult
.
getJSONObject
(
"result"
).
getString
(
"state"
);
Assert
.
assertEquals
(
state
,
"PAID"
,
"未生成已完成物品订单"
);
Assert
.
assertEquals
(
state
,
"PAID"
,
"未生成已完成物品订单"
);
//校验2:C端商品详情库存数-1
JSONObject
afterGetDetail_goods_C
=
goodCTools
.
getDetail_goods_C
(
goodsId2
);
int
afterInventory
=
Integer
.
parseInt
(
afterGetDetail_goods_C
.
getJSONObject
(
"result"
).
getJSONObject
(
"multiSpecInfo"
).
getJSONArray
(
"specCombinationList"
).
getJSONObject
(
0
).
getString
(
"inventory"
));
Assert
.
assertEquals
(
afterInventory
,
beforeInventory
-
1
,
"购买1个物品生成已完成订单后,应扣除1个库存数"
);
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//校验3:权益到,数据中心的确认收入增加
//获取数据中心-财务中心-营收明细-物品的确认收入
JSONObject
afterGetCostData_type
=
financeDataTools
.
getCostData_type
(
"DAY"
,
"GOODS"
,
TimeUtils
.
getTodayTime
(),
TimeUtils
.
getTodayEndTime
(),
info
);
BigDecimal
afterConfirmedAmount
=
new
BigDecimal
(
afterGetCostData_type
.
getJSONObject
(
"result"
).
getString
(
"confirmedAmount"
));
//确认收入
Assert
.
assertEquals
(
afterConfirmedAmount
,
beforeConfirmedAmount
.
add
(
price
.
setScale
(
2
,
RoundingMode
.
HALF_UP
)),
"购买1个物品生成待支付订单后,财务中心-营收明细-物品的确认收入应增加对应物品的价格"
);
try
{
try
{
Thread
.
sleep
(
3000
);
Thread
.
sleep
(
3000
);
...
@@ -207,16 +291,24 @@ public class TestPurchaseGoods extends BaseTestImpl {
...
@@ -207,16 +291,24 @@ public class TestPurchaseGoods extends BaseTestImpl {
}
}
//新建一个0元单规格物品
String
goodsId3
=
"1874411064376061954"
;
JSONObject
create
=
goodTools
.
createGoods_single
(
"YES"
,
"0.00"
,
10
,
info
);
//获取C端商品详情
goodsId3
=
create
.
getString
(
"result"
);
JSONObject
getDetail_goods_C
=
goodCTools
.
getDetail_goods_C
(
goodsId3
);
//获取商品详情
JSONObject
getDetail_goods_C
=
goodCTools
.
getDetail_goods_C
(
goodsId3
,
info
);
String
id
=
getDetail_goods_C
.
getJSONObject
(
"result"
).
getString
(
"id"
);
String
id
=
getDetail_goods_C
.
getJSONObject
(
"result"
).
getString
(
"id"
);
BigDecimal
price
=
new
BigDecimal
(
getDetail_goods_C
.
getJSONObject
(
"result"
).
getJSONObject
(
"singleSpecInfo"
).
getString
(
"price"
));
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"
));
int
beforeInventory
=
Integer
.
parseInt
(
getDetail_goods_C
.
getJSONObject
(
"result"
).
getJSONObject
(
"singleSpecInfo"
).
getString
(
"inventory"
));
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
boolean
checkAllowPurchase
=
Boolean
.
parseBoolean
(
goodCTools
.
checkAllowPurchase
(
id
,
memberId
,
"0.00"
,
inventory
).
getJSONObject
(
"result"
).
getString
(
"success"
));
//获取数据中心-财务中心-营收明细-物品的确认收入
JSONObject
beforeGetCostData_type
=
financeDataTools
.
getCostData_type
(
"DAY"
,
"GOODS"
,
TimeUtils
.
getTodayTime
(),
TimeUtils
.
getTodayEndTime
(),
info
);
BigDecimal
beforeConfirmedAmount
=
new
BigDecimal
(
beforeGetCostData_type
.
getJSONObject
(
"result"
).
getString
(
"confirmedAmount"
));
//确认收入
boolean
checkAllowPurchase
=
Boolean
.
parseBoolean
(
goodCTools
.
checkAllowPurchase
(
id
,
memberId
,
"0.00"
,
beforeInventory
).
getJSONObject
(
"result"
).
getString
(
"success"
));
//校验一下物品购买是否可以通过,为true才可以
//校验一下物品购买是否可以通过,为true才可以
if
(
checkAllowPurchase
==
true
){
if
(
checkAllowPurchase
==
true
){
...
@@ -237,14 +329,30 @@ public class TestPurchaseGoods extends BaseTestImpl {
...
@@ -237,14 +329,30 @@ public class TestPurchaseGoods extends BaseTestImpl {
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
purchaseGoods
.
toString
(),
headers
).
assetsSuccess
(
true
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
purchaseGoods
.
toString
(),
headers
).
assetsSuccess
(
true
);
JSONObject
purchaseGoodsResponse
=
xmAppApi
.
getBodyInJSON
();
JSONObject
purchaseGoodsResponse
=
xmAppApi
.
getBodyInJSON
();
String
orderId
=
purchaseGoodsResponse
.
getJSONObject
(
"result"
).
getString
(
"id"
);
orderId3
=
purchaseGoodsResponse
.
getJSONObject
(
"result"
).
getString
(
"id"
);
//校验1:获取B端详情:已完成状态
//校验1:获取B端
订单
详情:已完成状态
JSONObject
getDetailResult
=
orderTools
.
getDetail
(
orderId
,
info
);
JSONObject
getDetailResult
=
orderTools
.
getDetail
(
orderId
3
,
info
);
String
businessNo
=
getDetailResult
.
getJSONObject
(
"result"
).
getString
(
"businessNo"
);
//订单号
String
businessNo
=
getDetailResult
.
getJSONObject
(
"result"
).
getString
(
"businessNo"
);
//订单号
String
state
=
getDetailResult
.
getJSONObject
(
"result"
).
getString
(
"state"
);
String
state
=
getDetailResult
.
getJSONObject
(
"result"
).
getString
(
"state"
);
Assert
.
assertEquals
(
state
,
"PAID"
,
"未生成已完成物品订单"
);
Assert
.
assertEquals
(
state
,
"PAID"
,
"未生成已完成物品订单"
);
//校验2:C端商品详情库存数-1
JSONObject
afterGetDetail_goods_C
=
goodCTools
.
getDetail_goods_C
(
goodsId3
,
info
);
int
afterInventory
=
Integer
.
parseInt
(
afterGetDetail_goods_C
.
getJSONObject
(
"result"
).
getJSONObject
(
"singleSpecInfo"
).
getString
(
"inventory"
));
Assert
.
assertEquals
(
afterInventory
,
beforeInventory
-
1
,
"购买1个物品生成已完成订单后,应扣除1个库存数"
);
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//校验3:权益到,数据中心的确认收入增加
//获取数据中心-财务中心-营收明细-物品的确认收入
JSONObject
afterGetCostData_type
=
financeDataTools
.
getCostData_type
(
"DAY"
,
"GOODS"
,
TimeUtils
.
getTodayTime
(),
TimeUtils
.
getTodayEndTime
(),
info
);
BigDecimal
afterConfirmedAmount
=
new
BigDecimal
(
afterGetCostData_type
.
getJSONObject
(
"result"
).
getString
(
"confirmedAmount"
));
//确认收入
Assert
.
assertEquals
(
afterConfirmedAmount
,
beforeConfirmedAmount
.
add
(
price
.
setScale
(
2
,
RoundingMode
.
HALF_UP
)),
"购买1个物品生成待支付订单后,财务中心-营收明细-物品的确认收入应增加对应物品的价格"
);
}
}
...
@@ -254,22 +362,19 @@ public class TestPurchaseGoods extends BaseTestImpl {
...
@@ -254,22 +362,19 @@ public class TestPurchaseGoods extends BaseTestImpl {
}
}
@Test
(
description
=
"作废签单订单"
,
priority
=
1
)
public
void
discard
(){
//作废签单订单
orderTools
.
discard
(
orderId2
,
"重复录入"
,
"已作废签单订单"
+
RandomStringUtil
.
randomString
(
10
),
info
);
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
orderTools
.
discard
(
orderId3
,
"重复录入"
,
"已作废签单订单"
+
RandomStringUtil
.
randomString
(
10
),
info
);
// @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);
//
// }
}
}
}
src/main/java/com/xiaomai/cases/polar/goods/TestCreateGoods.java
View file @
3c8b802b
...
@@ -44,7 +44,7 @@ public class TestCreateGoods extends XMBaseTest {
...
@@ -44,7 +44,7 @@ public class TestCreateGoods extends XMBaseTest {
//分组是存量的: "id": "1873912725360504834","name": "自动化分组多规格",因为只能创建10个,超了的话影响后续流程还所以还是用存量的
//分组是存量的: "id": "1873912725360504834","name": "自动化分组多规格",因为只能创建10个,超了的话影响后续流程还所以还是用存量的
//获取B端物品列表
//获取B端物品列表
JSONObject
beforeTotalStudioGoods
=
goodTools
.
studioGoods
();
JSONObject
beforeTotalStudioGoods
=
goodTools
.
studioGoods
(
""
);
int
beforeTotal
=
Integer
.
parseInt
(
beforeTotalStudioGoods
.
getJSONObject
(
"result"
).
getString
(
"total"
));
int
beforeTotal
=
Integer
.
parseInt
(
beforeTotalStudioGoods
.
getJSONObject
(
"result"
).
getString
(
"total"
));
...
@@ -267,7 +267,7 @@ public class TestCreateGoods extends XMBaseTest {
...
@@ -267,7 +267,7 @@ public class TestCreateGoods extends XMBaseTest {
//校验1:获取B端物品列表
//校验1:获取B端物品列表
//①统计值增加1
//①统计值增加1
//②有对应的商品id
//②有对应的商品id
JSONObject
afterStudioGoods
=
goodTools
.
studioGoods
();
JSONObject
afterStudioGoods
=
goodTools
.
studioGoods
(
""
);
int
afterTotal
=
Integer
.
parseInt
(
afterStudioGoods
.
getJSONObject
(
"result"
).
getString
(
"total"
));
int
afterTotal
=
Integer
.
parseInt
(
afterStudioGoods
.
getJSONObject
(
"result"
).
getString
(
"total"
));
JSONArray
records
=
afterStudioGoods
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
JSONArray
records
=
afterStudioGoods
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
...
@@ -365,7 +365,7 @@ public class TestCreateGoods extends XMBaseTest {
...
@@ -365,7 +365,7 @@ public class TestCreateGoods extends XMBaseTest {
//单规格:"id": "1873903328974499841", "name": "自动化分组单规格",
//单规格:"id": "1873903328974499841", "name": "自动化分组单规格",
//获取物品列表
//获取物品列表
JSONObject
beforeTotalStudioGoods
=
goodTools
.
studioGoods
();
JSONObject
beforeTotalStudioGoods
=
goodTools
.
studioGoods
(
""
);
int
beforeTotal
=
Integer
.
parseInt
(
beforeTotalStudioGoods
.
getJSONObject
(
"result"
).
getString
(
"total"
));
int
beforeTotal
=
Integer
.
parseInt
(
beforeTotalStudioGoods
.
getJSONObject
(
"result"
).
getString
(
"total"
));
...
@@ -426,7 +426,7 @@ public class TestCreateGoods extends XMBaseTest {
...
@@ -426,7 +426,7 @@ public class TestCreateGoods extends XMBaseTest {
//校验1:获取B端物品列表
//校验1:获取B端物品列表
//①统计值增加1
//①统计值增加1
//②有对应的商品id
//②有对应的商品id
JSONObject
afterStudioGoods
=
goodTools
.
studioGoods
();
JSONObject
afterStudioGoods
=
goodTools
.
studioGoods
(
""
);
int
afterTotal
=
Integer
.
parseInt
(
afterStudioGoods
.
getJSONObject
(
"result"
).
getString
(
"total"
));
int
afterTotal
=
Integer
.
parseInt
(
afterStudioGoods
.
getJSONObject
(
"result"
).
getString
(
"total"
));
JSONArray
records
=
afterStudioGoods
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
JSONArray
records
=
afterStudioGoods
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
...
...
src/main/java/com/xiaomai/cases/polar/goods/TestDeleteGood.java
View file @
3c8b802b
...
@@ -38,7 +38,7 @@ public class TestDeleteGood extends XMBaseTest {
...
@@ -38,7 +38,7 @@ public class TestDeleteGood extends XMBaseTest {
//获取物品列表
//获取物品列表
JSONObject
studioGoods
=
goodTools
.
studioGoods
();
JSONObject
studioGoods
=
goodTools
.
studioGoods
(
""
);
JSONArray
records
=
studioGoods
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
JSONArray
records
=
studioGoods
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
boolean
success
=
false
;
boolean
success
=
false
;
...
@@ -66,7 +66,7 @@ public class TestDeleteGood extends XMBaseTest {
...
@@ -66,7 +66,7 @@ public class TestDeleteGood extends XMBaseTest {
}
}
//校验1:物品列表中没有此数据
//校验1:物品列表中没有此数据
JSONObject
afterStudioGoods
=
goodTools
.
studioGoods
();
JSONObject
afterStudioGoods
=
goodTools
.
studioGoods
(
""
);
JSONArray
afterRecords
=
afterStudioGoods
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
JSONArray
afterRecords
=
afterStudioGoods
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
boolean
afterSuccess
=
false
;
boolean
afterSuccess
=
false
;
...
...
src/main/java/com/xiaomai/cases/polar/goods/TestModifyGoods.java
View file @
3c8b802b
...
@@ -122,7 +122,7 @@ public class TestModifyGoods extends XMBaseTest {
...
@@ -122,7 +122,7 @@ public class TestModifyGoods extends XMBaseTest {
Assert
.
assertEquals
(
getDetail_goodsC
.
getJSONObject
(
"singleSpecInfo"
).
getBigDecimal
(
"price"
).
setScale
(
2
,
RoundingMode
.
HALF_UP
).
toString
(),
"0.09"
,
"编辑成单规格成功后但详情价格非编辑后的0.09"
);
Assert
.
assertEquals
(
getDetail_goodsC
.
getJSONObject
(
"singleSpecInfo"
).
getBigDecimal
(
"price"
).
setScale
(
2
,
RoundingMode
.
HALF_UP
).
toString
(),
"0.09"
,
"编辑成单规格成功后但详情价格非编辑后的0.09"
);
//校验3:获取B端物品列表
//校验3:获取B端物品列表
JSONObject
afterStudioGoods
=
goodTools
.
studioGoods
();
JSONObject
afterStudioGoods
=
goodTools
.
studioGoods
(
""
);
JSONArray
records
=
afterStudioGoods
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
JSONArray
records
=
afterStudioGoods
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
boolean
success
=
false
;
boolean
success
=
false
;
for
(
int
i
=
0
;
i
<
records
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
records
.
size
();
i
++)
{
...
@@ -387,7 +387,7 @@ public class TestModifyGoods extends XMBaseTest {
...
@@ -387,7 +387,7 @@ public class TestModifyGoods extends XMBaseTest {
Assert
.
assertEquals
(
getDetail_goodsC1
.
getString
(
"inventory"
),
"80"
,
"编辑成多规格成功后但详情总库存非编辑后的80"
);
Assert
.
assertEquals
(
getDetail_goodsC1
.
getString
(
"inventory"
),
"80"
,
"编辑成多规格成功后但详情总库存非编辑后的80"
);
//校验3:获取B端物品列表
//校验3:获取B端物品列表
JSONObject
afterStudioGoods1
=
goodTools
.
studioGoods
();
JSONObject
afterStudioGoods1
=
goodTools
.
studioGoods
(
""
);
JSONArray
records1
=
afterStudioGoods1
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
JSONArray
records1
=
afterStudioGoods1
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
boolean
success1
=
false
;
boolean
success1
=
false
;
for
(
int
i
=
0
;
i
<
records1
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
records1
.
size
();
i
++)
{
...
@@ -549,7 +549,7 @@ public class TestModifyGoods extends XMBaseTest {
...
@@ -549,7 +549,7 @@ public class TestModifyGoods extends XMBaseTest {
Assert
.
assertEquals
(
getDetail_goodsC2
.
getString
(
"inventory"
),
"20"
,
"编辑成多规格成功后但详情总库存非编辑后的20"
);
Assert
.
assertEquals
(
getDetail_goodsC2
.
getString
(
"inventory"
),
"20"
,
"编辑成多规格成功后但详情总库存非编辑后的20"
);
//校验3:获取B端物品列表
//校验3:获取B端物品列表
JSONObject
afterStudioGoods2
=
goodTools
.
studioGoods
();
JSONObject
afterStudioGoods2
=
goodTools
.
studioGoods
(
""
);
JSONArray
records2
=
afterStudioGoods2
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
JSONArray
records2
=
afterStudioGoods2
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
boolean
success2
=
false
;
boolean
success2
=
false
;
for
(
int
i
=
0
;
i
<
records2
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
records2
.
size
();
i
++)
{
...
@@ -658,7 +658,7 @@ public class TestModifyGoods extends XMBaseTest {
...
@@ -658,7 +658,7 @@ public class TestModifyGoods extends XMBaseTest {
Assert
.
assertEquals
(
getDetail_goodsC3
.
getJSONObject
(
"singleSpecInfo"
).
getBigDecimal
(
"price"
).
setScale
(
2
,
RoundingMode
.
HALF_UP
).
toString
(),
"0.09"
,
"编辑成单规格成功后但详情价格非编辑后的0.09"
);
Assert
.
assertEquals
(
getDetail_goodsC3
.
getJSONObject
(
"singleSpecInfo"
).
getBigDecimal
(
"price"
).
setScale
(
2
,
RoundingMode
.
HALF_UP
).
toString
(),
"0.09"
,
"编辑成单规格成功后但详情价格非编辑后的0.09"
);
//校验3:获取B端物品列表
//校验3:获取B端物品列表
JSONObject
afterStudioGoods3
=
goodTools
.
studioGoods
();
JSONObject
afterStudioGoods3
=
goodTools
.
studioGoods
(
""
);
JSONArray
records3
=
afterStudioGoods3
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
JSONArray
records3
=
afterStudioGoods3
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
);
boolean
success3
=
false
;
boolean
success3
=
false
;
for
(
int
i
=
0
;
i
<
records3
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
records3
.
size
();
i
++)
{
...
...
src/main/java/com/xiaomai/cases/polar/goods/TestRefundGoods.java
0 → 100644
View file @
3c8b802b
package
com
.
xiaomai
.
cases
.
polar
.
goods
;
import
com.xiaomai.utils.XMBaseTest
;
public
class
TestRefundGoods
extends
XMBaseTest
{
}
src/main/java/com/xiaomai/cases/polar/goods/Tools/GoodTools.java
View file @
3c8b802b
...
@@ -519,7 +519,7 @@ public class GoodTools extends XMBaseTest {
...
@@ -519,7 +519,7 @@ public class GoodTools extends XMBaseTest {
* @author: yff
* @author: yff
**/
**/
public
JSONObject
studioGoods
(
DataUserInfo
...
userInfos
){
public
JSONObject
studioGoods
(
String
nameLike
,
DataUserInfo
...
userInfos
){
dataApi
.
setApiModule
(
ApiModule
.
Polar_Goods
)
dataApi
.
setApiModule
(
ApiModule
.
Polar_Goods
)
.
setApiName
(
"API_pageStudioGoods"
)
.
setApiName
(
"API_pageStudioGoods"
)
.
setTerminal
(
Terminal
.
B
);
.
setTerminal
(
Terminal
.
B
);
...
...
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