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
7261572c
Commit
7261572c
authored
Jan 02, 2025
by
yangfangfang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
物品
parent
3c8b802b
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
246 additions
and
11 deletions
+246
-11
src/main/java/com/xiaomai/cases/lunar/goods/GoodCTools.java
+33
-0
src/main/java/com/xiaomai/cases/lunar/goods/TestListXcxGoodsGroup.java
+18
-10
src/main/java/com/xiaomai/cases/lunar/goods/TestPurchaseGoods.java
+1
-1
src/main/java/com/xiaomai/cases/polar/goods/TestRefundGoods.java
+194
-0
No files found.
src/main/java/com/xiaomai/cases/lunar/goods/GoodCTools.java
View file @
7261572c
...
@@ -6,6 +6,7 @@ import com.xiaomai.client.DataUserInfo;
...
@@ -6,6 +6,7 @@ import com.xiaomai.client.DataUserInfo;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.ApiModule
;
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.XMBaseTest
;
import
com.xiaomai.utils.XMBaseTest
;
import
java.math.BigDecimal
;
import
java.math.BigDecimal
;
...
@@ -107,4 +108,36 @@ public class GoodCTools extends XMBaseTest {
...
@@ -107,4 +108,36 @@ public class GoodCTools extends XMBaseTest {
}
}
/**
* @param
* @description:C端购买物品
* @author: yff
**/
public
JSONObject
purchaseGoods
(
String
depositAmount
,
String
depositCardId
,
String
memberId
,
String
memo
,
String
receivableAmount
,
String
id
,
String
price
,
int
quantity
,
DataUserInfo
...
userInfos
){
dataApi
.
setApiModule
(
ApiModule
.
Lunar_Goods
)
.
setApiName
(
"API_purchaseGoods"
)
.
setTerminal
(
Terminal
.
minApp
);
super
.
beforeDataRequest
(
userInfos
);
JSONObject
purchaseGoods
=
new
JSONObject
();
purchaseGoods
.
put
(
"depositAmount"
,
depositAmount
);
purchaseGoods
.
put
(
"depositCardId"
,
depositCardId
);
purchaseGoods
.
put
(
"memberId"
,
memberId
);
purchaseGoods
.
put
(
"memo"
,
memo
);
purchaseGoods
.
put
(
"objectId"
,
RandomStringUtil
.
randomString
(
16
));
purchaseGoods
.
put
(
"receivableAmount"
,
receivableAmount
);
purchaseGoods
.
put
(
"goodsSpecId"
,
id
);
purchaseGoods
.
put
(
"price"
,
price
);
purchaseGoods
.
put
(
"quantity"
,
quantity
);
purchaseGoods
.
put
(
"studioId"
,
dataApi
.
getLoginInfo
().
getStudioId
());
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
purchaseGoods
.
toString
(),
dataheadrs
).
assetsSuccess
(
true
);
return
dataApi
.
getBodyInJSON
();
}
}
}
src/main/java/com/xiaomai/cases/lunar/goods/TestListXcxGoodsGroup.java
View file @
7261572c
...
@@ -49,7 +49,7 @@ public class TestListXcxGoodsGroup extends BaseTestImpl {
...
@@ -49,7 +49,7 @@ public class TestListXcxGoodsGroup extends BaseTestImpl {
JSONArray
result
=
listXcxGoodsGroup
.
getJSONArray
(
"result"
);
JSONArray
result
=
listXcxGoodsGroup
.
getJSONArray
(
"result"
);
boolean
success
=
false
;
boolean
success
=
false
;
for
(
int
i
=
0
;
i
<
result
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
result
.
size
();
i
++){
if
(
!
result
.
getJSONObject
(
i
).
getString
(
"id"
).
equals
(
id
)){
if
(
!
result
.
getJSONObject
(
1
).
getString
(
"id"
).
equals
(
id
)){
success
=
true
;
success
=
true
;
}
}
Assert
.
assertEquals
(
success
,
true
,
"分组里没有一个物品,这个分组不应该在小程序物品组列表展示"
);
Assert
.
assertEquals
(
success
,
true
,
"分组里没有一个物品,这个分组不应该在小程序物品组列表展示"
);
...
@@ -77,10 +77,18 @@ public class TestListXcxGoodsGroup extends BaseTestImpl {
...
@@ -77,10 +77,18 @@ public class TestListXcxGoodsGroup extends BaseTestImpl {
//获取小程序物品分组列表:有该分组
//获取小程序物品分组列表:有该分组
JSONObject
listXcxGoodsGroup1
=
goodCTools
.
listXcxGoodsGroup
();
JSONObject
listXcxGoodsGroup1
=
goodCTools
.
listXcxGoodsGroup
();
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
JSONArray
result1
=
listXcxGoodsGroup1
.
getJSONArray
(
"result"
);
JSONArray
result1
=
listXcxGoodsGroup1
.
getJSONArray
(
"result"
);
boolean
success1
=
false
;
boolean
success1
=
false
;
for
(
int
i
=
0
;
i
<
result1
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
result1
.
size
();
i
++){
if
(
result1
.
getJSONObject
(
i
).
getString
(
"id"
).
equals
(
id
)){
if
(
result1
.
getJSONObject
(
1
).
getString
(
"id"
).
equals
(
id
)){
success1
=
true
;
success1
=
true
;
}
}
Assert
.
assertEquals
(
success1
,
true
,
"分组的物品是启用且开启小程序售卖的,这个分组应该在小程序物品组列表展示"
);
Assert
.
assertEquals
(
success1
,
true
,
"分组的物品是启用且开启小程序售卖的,这个分组应该在小程序物品组列表展示"
);
...
@@ -108,7 +116,7 @@ public class TestListXcxGoodsGroup extends BaseTestImpl {
...
@@ -108,7 +116,7 @@ public class TestListXcxGoodsGroup extends BaseTestImpl {
JSONArray
result2
=
listXcxGoodsGroup2
.
getJSONArray
(
"result"
);
JSONArray
result2
=
listXcxGoodsGroup2
.
getJSONArray
(
"result"
);
boolean
success2
=
false
;
boolean
success2
=
false
;
for
(
int
i
=
0
;
i
<
result2
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
result2
.
size
();
i
++){
if
(
!
result2
.
getJSONObject
(
i
).
getString
(
"id"
).
equals
(
id
)){
if
(
!
result2
.
getJSONObject
(
1
).
getString
(
"id"
).
equals
(
id
)){
success2
=
true
;
success2
=
true
;
}
}
Assert
.
assertEquals
(
success2
,
true
,
"分组的物品是启用且关闭小程序售卖的,这个分组应该不在小程序物品组列表展示"
);
Assert
.
assertEquals
(
success2
,
true
,
"分组的物品是启用且关闭小程序售卖的,这个分组应该不在小程序物品组列表展示"
);
...
@@ -135,7 +143,7 @@ public class TestListXcxGoodsGroup extends BaseTestImpl {
...
@@ -135,7 +143,7 @@ public class TestListXcxGoodsGroup extends BaseTestImpl {
JSONArray
result3
=
listXcxGoodsGroup3
.
getJSONArray
(
"result"
);
JSONArray
result3
=
listXcxGoodsGroup3
.
getJSONArray
(
"result"
);
boolean
success3
=
false
;
boolean
success3
=
false
;
for
(
int
i
=
0
;
i
<
result3
.
size
();
i
++){
for
(
int
i
=
0
;
i
<
result3
.
size
();
i
++){
if
(
!
result3
.
getJSONObject
(
i
).
getString
(
"id"
).
equals
(
id
)){
if
(
!
result3
.
getJSONObject
(
1
).
getString
(
"id"
).
equals
(
id
)){
success3
=
true
;
success3
=
true
;
}
}
Assert
.
assertEquals
(
success3
,
true
,
"分组的物品是停用且关闭小程序售卖的,这个分组应该不在小程序物品组列表展示"
);
Assert
.
assertEquals
(
success3
,
true
,
"分组的物品是停用且关闭小程序售卖的,这个分组应该不在小程序物品组列表展示"
);
...
@@ -143,10 +151,10 @@ public class TestListXcxGoodsGroup extends BaseTestImpl {
...
@@ -143,10 +151,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 @
7261572c
...
@@ -157,7 +157,7 @@ public class TestPurchaseGoods extends BaseTestImpl {
...
@@ -157,7 +157,7 @@ public class TestPurchaseGoods extends BaseTestImpl {
JSONObject
getDetailResult_cancel
=
orderTools
.
getDetail
(
orderId1
,
info
);
JSONObject
getDetailResult_cancel
=
orderTools
.
getDetail
(
orderId1
,
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"
,
"
C端取消物品订单后,订单状态未从待支付变更为已取消
"
);
//校验2:C端商品详情库存数+1
//校验2:C端商品详情库存数+1
...
...
src/main/java/com/xiaomai/cases/polar/goods/TestRefundGoods.java
View file @
7261572c
package
com
.
xiaomai
.
cases
.
polar
.
goods
;
package
com
.
xiaomai
.
cases
.
polar
.
goods
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.cases.lunar.goods.GoodCTools
;
import
com.xiaomai.cases.lunar.order.OrderCTools
;
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.goods.Tools.GoodTools
;
import
com.xiaomai.client.DataUserInfo
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.TimeUtils
;
import
com.xiaomai.utils.XMBaseTest
;
import
com.xiaomai.utils.XMBaseTest
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.Test
;
import
java.math.BigDecimal
;
public
class
TestRefundGoods
extends
XMBaseTest
{
public
class
TestRefundGoods
extends
XMBaseTest
{
GoodTools
goodTools
=
new
GoodTools
();
GoodCTools
goodCTools
=
new
GoodCTools
();
DataUserInfo
info
=
new
DataUserInfo
();
UserTools
userTools
=
new
UserTools
();
OrderCTools
orderCTools
=
new
OrderCTools
();
OrderTools
orderTools
=
new
OrderTools
();
FinanceDataTools
financeDataTools
=
new
FinanceDataTools
();
String
orderId1
;
String
memberId
;
@BeforeMethod
public
void
beforeTest
()
{
xmAppApi
.
setApiModule
(
ApiModule
.
Polar_Goods
)
.
setApiName
(
"API_refundGoods"
)
.
setLoginUser
(
LoginAccount
.
GYM_PROD
)
.
setTerminal
(
Terminal
.
B
);
dal
.
setCase_owner
(
"yff"
)
.
setCase_name
(
Thread
.
currentThread
().
getStackTrace
()[
1
].
getFileName
().
split
(
"\\."
)[
0
]);
super
.
beforeTest
();
}
@Test
(
description
=
"签单单规格:待支付->取消订单"
)
public
void
testModifyGoods_single
()
{
//涉及到订单的都使用存量物品数据,因为购买过物品就不能被删除了,所以不会买一次新建一个
// "id": "1874413681302990849",
// "name": "自动化禁用-购买订单单规格1元",
// "id": "1874413587237335042",
// "name": "自动化禁用-购买订单多规格1元",
// "id": "1874413193018896386",
// "name": "自动化禁用-购买订单多规格0元",
// "id": "1874411064376061954",
// "name": "自动化禁用-购买订单单规格0元",
//case1:购买多规格非0元物品生成待支付订单
//case1:购买非0订单->待支付->取消订单
//切换端位
info
.
setTerminal
(
Terminal
.
minApp
);
info
.
setLoginUser
(
LoginAccount
.
GYM_MINIAPPC
);
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//获取会员信息
//获取用户
memberId
=
userTools
.
getMemberInfo
(
info
).
getString
(
"memberId"
);
String
goodsId1
=
"1874413681302990849"
;
//获取B端商品详情
JSONObject
getDetail_goods
=
goodTools
.
getDetail_goods
(
goodsId1
);
String
id
=
getDetail_goods
.
getJSONObject
(
"result"
).
getString
(
"id"
);
String
price
=
getDetail_goods
.
getJSONObject
(
"result"
).
getJSONObject
(
"singleSpecInfo"
).
getString
(
"price"
);
int
beforeInventory
=
Integer
.
parseInt
(
getDetail_goods
.
getJSONObject
(
"result"
).
getJSONObject
(
"singleSpecInfo"
).
getString
(
"inventory"
));
try
{
Thread
.
sleep
(
3000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//获取数据中心-财务中心-营收明细-物品的确认收入
JSONObject
beforeGetCostData_type
=
financeDataTools
.
getCostData_type
(
"DAY"
,
"GOODS"
,
TimeUtils
.
getTodayTime
(),
TimeUtils
.
getTodayEndTime
());
BigDecimal
beforeConfirmedAmount
=
new
BigDecimal
(
beforeGetCostData_type
.
getJSONObject
(
"result"
).
getString
(
"confirmedAmount"
));
//确认收入
boolean
checkAllowPurchase
=
Boolean
.
parseBoolean
(
goodCTools
.
checkAllowPurchase
(
id
,
memberId
,
price
,
beforeInventory
,
info
).
getJSONObject
(
"result"
).
getString
(
"success"
));
//校验一下物品购买是否可以通过,为true才可以
if
(
checkAllowPurchase
==
true
)
{
JSONObject
purchaseGoods
=
goodCTools
.
purchaseGoods
(
"0.00"
,
null
,
memberId
,
""
,
price
,
id
,
price
,
1
,
info
);
orderId1
=
purchaseGoods
.
getJSONObject
(
"result"
).
getString
(
"id"
);
//生成待支付订单后,去B端继续收款
//获取B端订单详情:待支付状态
JSONObject
getDetailResult
=
orderTools
.
getDetail
(
orderId1
,
info
);
String
state
=
getDetailResult
.
getJSONObject
(
"result"
).
getString
(
"state"
);
Assert
.
assertEquals
(
state
,
"WAITING"
,
"未生成待支付物品订单"
);
//校验1:B端商品详情库存数-1
JSONObject
afterGetDetail_goods
=
goodTools
.
getDetail_goods
(
goodsId1
);
int
afterInventory
=
Integer
.
parseInt
(
afterGetDetail_goods
.
getJSONObject
(
"result"
).
getJSONObject
(
"singleSpecInfo"
).
getString
(
"inventory"
));
Assert
.
assertEquals
(
afterInventory
,
beforeInventory
-
1
,
"购买1个物品生成待支付订单后,应扣除1个库存数"
);
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//校验2:权益未到,数据中心的确认收入没有增加
//获取数据中心-财务中心-营收明细-物品的确认收入
JSONObject
afterGetCostData_type
=
financeDataTools
.
getCostData_type
(
"DAY"
,
"GOODS"
,
TimeUtils
.
getTodayTime
(),
TimeUtils
.
getTodayEndTime
());
BigDecimal
afterConfirmedAmount
=
new
BigDecimal
(
afterGetCostData_type
.
getJSONObject
(
"result"
).
getString
(
"confirmedAmount"
));
//确认收入
Assert
.
assertEquals
(
afterConfirmedAmount
,
beforeConfirmedAmount
,
"购买1个物品生成待支付订单后,财务中心-营收明细-物品的确认收入应无变化"
);
//B端取消物品订单
JSONObject
cancel
=
orderTools
.
cancel
(
orderId1
);
//校验1:获取B端订单详情:已取消状态
JSONObject
getDetailResult_cancel
=
orderTools
.
getDetail
(
orderId1
);
String
state_cancel
=
getDetailResult_cancel
.
getJSONObject
(
"result"
).
getString
(
"state"
);
Assert
.
assertEquals
(
state_cancel
,
"CANCEL"
,
"B端取消物品订单后,订单状态未从待支付变更为已取消"
);
//校验2:B端商品详情库存数+1
JSONObject
lastGetDetail_goods
=
goodTools
.
getDetail_goods
(
goodsId1
);
int
lastInventory
=
Integer
.
parseInt
(
lastGetDetail_goods
.
getJSONObject
(
"result"
).
getJSONObject
(
"singleSpecInfo"
).
getString
(
"inventory"
));
Assert
.
assertEquals
(
lastInventory
,
afterInventory
+
1
,
"取消购买1个物品的待支付订单后,应返回1个库存数"
);
try
{
Thread
.
sleep
(
5000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//校验3:权益未涉及,数据中心的确认收入没有变化
//获取数据中心-财务中心-营收明细-物品的确认收入
JSONObject
lastGetCostData_type
=
financeDataTools
.
getCostData_type
(
"DAY"
,
"GOODS"
,
TimeUtils
.
getTodayTime
(),
TimeUtils
.
getTodayEndTime
());
BigDecimal
lastConfirmedAmount
=
new
BigDecimal
(
lastGetCostData_type
.
getJSONObject
(
"result"
).
getString
(
"confirmedAmount"
));
//确认收入
Assert
.
assertEquals
(
lastConfirmedAmount
,
afterConfirmedAmount
,
"取消购买1个物品的待支付订单后,财务中心-营收明细-物品的确认收入应无变化"
);
}
}
//
// //继续收款
// JSONObject pay=orderTools.pay(unpaidAmount,"1",orderId1);
//
// //获取B端订单详情:待支付状态
// JSONObject getDetailResult1 = orderTools.getDetail(orderId1,info);
// String state1=getDetailResult1.getJSONObject("result").getString("state");
//
// Assert.assertEquals(state1,"PAID","继续收款后订单状态由待支付变为已完成");
@Test
(
description
=
"退单物品_多规格"
)
public
void
testModifyGoods_multiple
()
{
//涉及到订单的都使用存量物品数据,因为购买过物品就不能被删除了,所以不会买一次新建一个
// "id": "1874413681302990849",
// "name": "自动化禁用-购买订单单规格1元",
// "id": "1874413587237335042",
// "name": "自动化禁用-购买订单多规格1元",
// "id": "1874413193018896386",
// "name": "自动化禁用-购买订单多规格0元",
// "id": "1874411064376061954",
// "name": "自动化禁用-购买订单单规格0元",
//case1:购买多规格非0元物品生成待支付订单
}
}
}
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