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
98dfa013
Commit
98dfa013
authored
Jul 05, 2024
by
yangfangfang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
收银和在线退款相关接口
parent
407f668a
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
373 additions
and
22 deletions
+373
-22
src/main/java/com/xiaomai/cases/polar/finance/cashier/CashierTools.java
+44
-7
src/main/java/com/xiaomai/cases/polar/finance/cashier/TestCheckBeforeRefund.java
+64
-0
src/main/java/com/xiaomai/cases/polar/finance/cashier/TestGetById.java
+17
-14
src/main/java/com/xiaomai/cases/polar/finance/cashier/TestGetXmPayResult.java
+97
-0
src/main/java/com/xiaomai/cases/polar/finance/cashier/TestListRelatedRecordsById.java
+76
-0
src/main/java/com/xiaomai/cases/polar/finance/cashier/TestPageSettle.java
+0
-1
src/main/java/com/xiaomai/cases/polar/finance/cashier/TestRefundByRecord.java
+75
-0
No files found.
src/main/java/com/xiaomai/cases/polar/finance/cashier/CashierTools.java
View file @
98dfa013
...
@@ -8,6 +8,8 @@ import com.xiaomai.enums.RequestType;
...
@@ -8,6 +8,8 @@ import com.xiaomai.enums.RequestType;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.XMBaseTest
;
import
com.xiaomai.utils.XMBaseTest
;
import
java.math.BigDecimal
;
public
class
CashierTools
extends
XMBaseTest
{
public
class
CashierTools
extends
XMBaseTest
{
/**
/**
...
@@ -45,10 +47,12 @@ public class CashierTools extends XMBaseTest {
...
@@ -45,10 +47,12 @@ public class CashierTools extends XMBaseTest {
* @param
* @param
* @description: 分页筛选收银流水-筛选
* @description: 分页筛选收银流水-筛选
* @param subChannel:支付方式 [ "支付宝", "微信" ] [ ALI, WX ]
* @param subChannel:支付方式 [ "支付宝", "微信" ] [ ALI, WX ]
* @param orderType:来源[ "未知", "签单", "退单", "作废订单", "收款码", "B端短信充值", "电子合同" ][ UNKNOWN, SIGN_ORDER, REFUND_ORDER, DISCARD_ORDER, PAY_QR_CODE, B_SMS_RECHARGE, ELE_CONTRACT ]
* @param orderType:来源 [ "未知", "签单", "退单", "作废订单", "收款码", "B端短信充值", "电子合同" ][ UNKNOWN, SIGN_ORDER, REFUND_ORDER, DISCARD_ORDER, PAY_QR_CODE, B_SMS_RECHARGE, ELE_CONTRACT ]
* @param transState :状态 [ PAY_INIT: 支付初始态;PAYING: 支付中;PAY_FAIL: 支付失败;PAY_SUCCESS: 支付成功(入账中);PAY_IN: 入账成功;REFUND_INIT: 退款初始态;REFUNDING: 退款中;REFUND_SUCCESS: 退款成功;REFUND_FAIL: 退款失败; ]
* @author: yangfangfang
* @author: yangfangfang
**/
**/
public
JSONObject
page_sift
(
String
subChannel
,
String
orderType
,
DataUserInfo
...
dataUserInfos
){
public
JSONObject
page_sift
(
String
subChannel
,
String
orderType
,
String
transState
,
DataUserInfo
...
dataUserInfos
){
dataApi
.
setApiModule
(
ApiModule
.
Polar_Finance
)
dataApi
.
setApiModule
(
ApiModule
.
Polar_Finance
)
.
setApiName
(
"API_page"
)
.
setApiName
(
"API_page"
)
...
@@ -57,14 +61,13 @@ public class CashierTools extends XMBaseTest {
...
@@ -57,14 +61,13 @@ public class CashierTools extends XMBaseTest {
JSONObject
jsonObject
=
new
JSONObject
();
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"current"
,
0
);
jsonObject
.
put
(
"current"
,
0
);
jsonObject
.
put
(
"size"
,
20
);
jsonObject
.
put
(
"size"
,
20
);
jsonObject
.
put
(
"subChannel"
,
subChannel
);
//支付方式 [ "支付宝", "微信" ] [ ALI, WX ]
jsonObject
.
put
(
"subChannel"
,
subChannel
);
JSONArray
transStateList
=
new
JSONArray
();
//收款成功(入账中、入账成功),这两个状态都代表收款成功
JSONArray
transStateList
=
new
JSONArray
();
transStateList
.
add
(
"PAY_SUCCESS"
);
transStateList
.
add
(
transState
);
transStateList
.
add
(
"PAY_IN"
);
jsonObject
.
put
(
"transStateList"
,
transStateList
);
jsonObject
.
put
(
"transStateList"
,
transStateList
);
jsonObject
.
put
(
"orderType"
,
orderType
);
//来源[ "未知", "签单", "退单", "作废订单", "收款码", "B端短信充值", "电子合同" ][ UNKNOWN, SIGN_ORDER, REFUND_ORDER, DISCARD_ORDER, PAY_QR_CODE, B_SMS_RECHARGE, ELE_CONTRACT ]
jsonObject
.
put
(
"orderType"
,
orderType
);
jsonObject
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
jsonObject
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
jsonObject
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
jsonObject
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
...
@@ -76,4 +79,38 @@ public class CashierTools extends XMBaseTest {
...
@@ -76,4 +79,38 @@ public class CashierTools extends XMBaseTest {
}
}
/**
* @param
* @description: 分页筛选收银流水-筛选
* @param signId:支付流水ID
* @param actualAmount:实际可退金额
* @author: yangfangfang
**/
public
JSONObject
checkBeforeRefund
(
String
signId
,
BigDecimal
actualAmount
,
DataUserInfo
...
dataUserInfos
){
dataApi
.
setApiModule
(
ApiModule
.
Polar_Finance
)
.
setApiName
(
"API_checkBeforeRefund"
)
.
setTerminal
(
Terminal
.
B
);
super
.
beforeDataRequest
(
dataUserInfos
);
JSONObject
jsonObject
=
new
JSONObject
();
JSONArray
ids
=
new
JSONArray
();
ids
.
add
(
signId
);
jsonObject
.
put
(
"ids"
,
ids
);
jsonObject
.
put
(
"amount"
,
actualAmount
);
jsonObject
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
jsonObject
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
jsonObject
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
jsonObject
.
toJSONString
(),
dataheadrs
);
JSONObject
response
=
dataApi
.
getBodyInJSON
();
return
response
;
}
}
}
src/main/java/com/xiaomai/cases/polar/finance/cashier/TestCheckBeforeRefund.java
0 → 100644
View file @
98dfa013
package
com
.
xiaomai
.
cases
.
polar
.
finance
.
cashier
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
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
TestCheckBeforeRefund
extends
XMBaseTest
{
CashierTools
cashierTools
=
new
CashierTools
();
@BeforeMethod
public
void
beforeTest
(){
xmAppApi
.
setApiModule
(
ApiModule
.
Polar_Finance
)
.
setApiName
(
"API_checkBeforeRefund"
)
.
setLoginUser
(
LoginAccount
.
YFF_PROD
)
.
setTerminal
(
Terminal
.
B
);
dal
.
setCase_owner
(
"yff"
)
.
setCase_name
(
Thread
.
currentThread
().
getStackTrace
()[
1
].
getFileName
().
split
(
"\\."
)[
0
]);
super
.
beforeTest
();
}
@Test
(
description
=
"乐动收银退款预校验-检查流水是否可退"
)
public
void
testCheckBeforeRefund
(){
//获取交易记录(流水)列表-收款成功流水
JSONObject
result
=
cashierTools
.
page_sift
(
"WX"
,
"SIGN_ORDER"
,
"PAY_SUCCESS"
);
int
total
=
Integer
.
parseInt
(
result
.
getJSONObject
(
"result"
).
getString
(
"total"
));
if
(
total
>
0
)
{
String
signId
=
result
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
).
getJSONObject
(
0
).
getString
(
"id"
);
//流水ID
BigDecimal
actualAmount
=
new
BigDecimal
(
result
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
).
getJSONObject
(
0
).
getString
(
"actualAmount"
));
JSONObject
jsonObject
=
new
JSONObject
();
JSONArray
ids
=
new
JSONArray
();
ids
.
add
(
signId
);
jsonObject
.
put
(
"ids"
,
ids
);
jsonObject
.
put
(
"amount"
,
actualAmount
);
jsonObject
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
jsonObject
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
jsonObject
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
jsonObject
.
toJSONString
(),
headers
).
assetsSuccess
(
true
);
String
success
=
xmAppApi
.
getBodyInJSON
().
getString
(
"success"
);
Assert
.
assertEquals
(
success
,
"true"
,
"乐动收银退款预校验-检查流水是否可退失败"
);
System
.
out
.
println
(
"检查流水结果:"
+
xmAppApi
.
getBodyInJSON
().
getJSONObject
(
"result"
).
getString
(
"code"
));
//检查结果
}
}
}
src/main/java/com/xiaomai/cases/polar/finance/cashier/TestGetById.java
View file @
98dfa013
...
@@ -28,20 +28,23 @@ public class TestGetById extends XMBaseTest {
...
@@ -28,20 +28,23 @@ public class TestGetById extends XMBaseTest {
@Test
(
description
=
"查询收银流水详情"
)
@Test
(
description
=
"查询收银流水详情"
)
public
void
testGetById
(){
public
void
testGetById
(){
//10020060066--固定流水,换场馆需要按照这个手机支付0.01元 "flowIds": ["1808757176611880962"]
//获取交易记录(流水)列表-收款成功流水
JSONObject
page_select
=
cashierTools
.
page_select
(
null
,
"10020060066"
,
null
);
JSONObject
result
=
cashierTools
.
page_sift
(
"WX"
,
"SIGN_ORDER"
,
"PAY_SUCCESS"
);
String
id
=
page_select
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
).
getJSONObject
(
0
).
getString
(
"id"
);
//流水ID
int
total
=
Integer
.
parseInt
(
result
.
getJSONObject
(
"result"
).
getString
(
"total"
));
JSONObject
getById
=
new
JSONObject
();
if
(
total
>
0
)
{
getById
.
put
(
"id"
,
id
);
getById
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
String
id
=
result
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
).
getJSONObject
(
0
).
getString
(
"id"
);
//流水ID
getById
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
JSONObject
getById
=
new
JSONObject
();
getById
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
getById
.
put
(
"id"
,
id
);
getById
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
getById
.
toJSONString
(),
headers
).
assetsSuccess
(
true
);
getById
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
String
success
=
xmAppApi
.
getBodyInJSON
().
getString
(
"success"
);
getById
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
Assert
.
assertEquals
(
success
,
"true"
,
"查询收银流水详情失败"
);
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
getById
.
toJSONString
(),
headers
).
assetsSuccess
(
true
);
String
success
=
xmAppApi
.
getBodyInJSON
().
getString
(
"success"
);
Assert
.
assertEquals
(
success
,
"true"
,
"查询收银流水详情失败"
);
}
}
}
...
...
src/main/java/com/xiaomai/cases/polar/finance/cashier/TestGetXmPayResult.java
0 → 100644
View file @
98dfa013
package
com
.
xiaomai
.
cases
.
polar
.
finance
.
cashier
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.XMBaseTest
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.Test
;
public
class
TestGetXmPayResult
extends
XMBaseTest
{
CashierTools
cashierTools
=
new
CashierTools
();
@BeforeMethod
public
void
beforeTest
(){
xmAppApi
.
setApiModule
(
ApiModule
.
Polar_Finance
)
.
setApiName
(
"API_getXmPayResult"
)
.
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
testGetXmPayResult_PAY_SUCCESS
(){
//写死的关联订单支付成功的流水:1809061860383899650;必须是关联订单的,不能解除
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"id"
,
"1809061860383899650"
);
//关联订单支付成功的流水;必须是关联订单的,不能解除
jsonObject
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
jsonObject
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
jsonObject
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
jsonObject
.
toJSONString
(),
headers
).
assetsSuccess
(
true
);
String
success
=
xmAppApi
.
getBodyInJSON
().
getString
(
"success"
);
String
transState
=
xmAppApi
.
getBodyInJSON
().
getJSONObject
(
"result"
).
getString
(
"transState"
);
Assert
.
assertEquals
(
success
,
"true"
,
"查询订单使用小麦收银支付结果失败"
);
Assert
.
assertEquals
(
transState
,
"PAY_SUCCESS"
,
"支付成功流水状态未是支付成功"
);
}
@Test
(
description
=
"查询订单使用小麦收银支付结果-退款成功"
)
public
void
testGetXmPayResult_REFUND_SUCCESS
(){
//获取交易记录(流水)列表
JSONObject
result
=
cashierTools
.
page_sift
(
"WX"
,
"REFUND_ORDER"
,
"REFUND_SUCCESS"
);
int
total
=
Integer
.
parseInt
(
result
.
getJSONObject
(
"result"
).
getString
(
"total"
));
if
(
total
>
0
){
String
id
=
result
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
).
getJSONObject
(
0
).
getString
(
"id"
);
//流水ID
//查询订单使用小麦收银支付结果
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"id"
,
id
);
jsonObject
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
jsonObject
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
jsonObject
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
jsonObject
.
toJSONString
(),
headers
).
assetsSuccess
(
true
);
String
success
=
xmAppApi
.
getBodyInJSON
().
getString
(
"success"
);
String
transState
=
xmAppApi
.
getBodyInJSON
().
getJSONObject
(
"result"
).
getString
(
"transState"
);
Assert
.
assertEquals
(
success
,
"true"
,
"查询订单使用小麦收银支付结果失败"
);
Assert
.
assertEquals
(
transState
,
"REFUND_SUCCESS"
,
"退款成功流水状态未是退款成功"
);
}
}
@Test
(
description
=
"查询订单使用小麦收银支付结果-退款失败"
)
public
void
testGetXmPayResult_REFUND_FAIL
(){
//获取交易记录(流水)列表
JSONObject
result
=
cashierTools
.
page_sift
(
"WX"
,
"REFUND_ORDER"
,
"REFUND_FAIL"
);
int
total
=
Integer
.
parseInt
(
result
.
getJSONObject
(
"result"
).
getString
(
"total"
));
if
(
total
>
0
)
{
String
id
=
result
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
).
getJSONObject
(
0
).
getString
(
"id"
);
//流水ID
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"id"
,
id
);
//退款失败
jsonObject
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
jsonObject
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
jsonObject
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
jsonObject
.
toJSONString
(),
headers
).
assetsSuccess
(
true
);
String
success
=
xmAppApi
.
getBodyInJSON
().
getString
(
"success"
);
String
transState
=
xmAppApi
.
getBodyInJSON
().
getJSONObject
(
"result"
).
getString
(
"transState"
);
Assert
.
assertEquals
(
success
,
"true"
,
"查询订单使用小麦收银支付结果失败"
);
Assert
.
assertEquals
(
transState
,
"REFUND_FAIL"
,
"退款失败流水状态未是退款失败"
);
}
}
}
src/main/java/com/xiaomai/cases/polar/finance/cashier/TestListRelatedRecordsById.java
0 → 100644
View file @
98dfa013
package
com
.
xiaomai
.
cases
.
polar
.
finance
.
cashier
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.XMBaseTest
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.Test
;
public
class
TestListRelatedRecordsById
extends
XMBaseTest
{
CashierTools
cashierTools
=
new
CashierTools
();
@BeforeMethod
public
void
beforeTest
(){
xmAppApi
.
setApiModule
(
ApiModule
.
Polar_Finance
)
.
setApiName
(
"API_listRelatedRecordsById"
)
.
setLoginUser
(
LoginAccount
.
GYM_PROD
)
.
setTerminal
(
Terminal
.
B
);
dal
.
setCase_owner
(
"yff"
)
.
setCase_name
(
Thread
.
currentThread
().
getStackTrace
()[
1
].
getFileName
().
split
(
"\\."
)[
0
]);
super
.
beforeTest
();
}
@Test
(
description
=
"根据当前流水id查关联的流水"
)
public
void
testListRelatedRecordsById
(){
//获取交易记录(流水)列表-退款成功流水
JSONObject
result
=
cashierTools
.
page_sift
(
"WX"
,
"REFUND_ORDER"
,
"REFUND_SUCCESS"
);
int
total
=
Integer
.
parseInt
(
result
.
getJSONObject
(
"result"
).
getString
(
"total"
));
if
(
total
>
0
)
{
String
refundId
=
result
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
).
getJSONObject
(
0
).
getString
(
"id"
);
//流水ID
//退款成功流水查看关联交易
JSONObject
refund
=
new
JSONObject
();
refund
.
put
(
"id"
,
refundId
);
refund
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
refund
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
refund
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
refund
.
toJSONString
(),
headers
).
assetsSuccess
(
true
);
JSONObject
response
=
xmAppApi
.
getBodyInJSON
();
String
success
=
response
.
getString
(
"success"
);
String
transState
=
response
.
getJSONArray
(
"result"
).
getJSONObject
(
0
).
getString
(
"transState"
);
String
payId
=
response
.
getJSONArray
(
"result"
).
getJSONObject
(
0
).
getString
(
"id"
);
//收款流水ID
Assert
.
assertEquals
(
success
,
"true"
,
"获取退款成功流水的查看关联交易失败"
);
Assert
.
assertEquals
(
transState
,
"PAY_SUCCESS"
,
"退款成功流水的查看关联交易-收款流水的状态未是收款成功"
);
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//收款成功流水查看关联交易
JSONObject
pay
=
new
JSONObject
();
pay
.
put
(
"id"
,
payId
);
pay
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
pay
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
pay
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
pay
.
toJSONString
(),
headers
).
assetsSuccess
(
true
);
JSONObject
payResponse
=
xmAppApi
.
getBodyInJSON
();
String
paySuccess
=
payResponse
.
getString
(
"success"
);
String
payTransState
=
payResponse
.
getJSONArray
(
"result"
).
getJSONObject
(
0
).
getString
(
"transState"
);
String
relatedRefundId
=
payResponse
.
getJSONArray
(
"result"
).
getJSONObject
(
0
).
getString
(
"id"
);
//收款流水ID
Assert
.
assertEquals
(
paySuccess
,
"true"
,
"获取收款成功流水的查看关联交易失败"
);
Assert
.
assertEquals
(
payTransState
,
"REFUND_SUCCESS"
,
"收款成功流水的查看关联交易-退款流水的状态未是退款成功"
);
Assert
.
assertEquals
(
relatedRefundId
.
equals
(
refundId
),
true
,
"查看关联交易的退款成功流水和退款成功流水非同一个"
);
}
}
}
src/main/java/com/xiaomai/cases/polar/finance/cashier/TestPageSettle.java
View file @
98dfa013
...
@@ -25,7 +25,6 @@ public class TestPageSettle extends XMBaseTest {
...
@@ -25,7 +25,6 @@ public class TestPageSettle extends XMBaseTest {
@Test
(
description
=
"分页筛选结算记录"
)
@Test
(
description
=
"分页筛选结算记录"
)
public
void
testPageSettle
(){
public
void
testPageSettle
(){
JSONObject
jsonObject
=
new
JSONObject
();
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"current"
,
0
);
jsonObject
.
put
(
"current"
,
0
);
jsonObject
.
put
(
"size"
,
20
);
jsonObject
.
put
(
"size"
,
20
);
...
...
src/main/java/com/xiaomai/cases/polar/finance/cashier/TestRefundByRecord.java
0 → 100644
View file @
98dfa013
package
com
.
xiaomai
.
cases
.
polar
.
finance
.
cashier
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.LoginAccount
;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.RandomStringUtil
;
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
TestRefundByRecord
extends
XMBaseTest
{
CashierTools
cashierTools
=
new
CashierTools
();
@BeforeMethod
public
void
beforeTest
(){
xmAppApi
.
setApiModule
(
ApiModule
.
Polar_Finance
)
.
setApiName
(
"API_refundByRecord"
)
.
setLoginUser
(
LoginAccount
.
YFF_PROD
)
.
setTerminal
(
Terminal
.
B
);
dal
.
setCase_owner
(
"yff"
)
.
setCase_name
(
Thread
.
currentThread
().
getStackTrace
()[
1
].
getFileName
().
split
(
"\\."
)[
0
]);
super
.
beforeTest
();
}
@Test
(
description
=
"流水退款"
)
public
void
testRefundByRecord
(){
//此接口可真实退收款码进来的流水,只用把signId和payTransNo改成同一个收款成功流水id,transAmount改成这笔收款流水的真实可退金额即可,这些都只能写死,因为场馆不会一直有收款成功的流水;
//目前1808757176611880962这笔流水是已经结算过的收款流水,商户号下没有钱退,但是当商户号下有钱可退的时候,这个case会报错,因为可以退成功
//乐动收银退款预校验-检查流水是否可退
String
checkBeforeRefundCode
=
cashierTools
.
checkBeforeRefund
(
"1808757176611880962"
,
BigDecimal
.
valueOf
(
0.01
)).
getJSONObject
(
"result"
).
getString
(
"code"
);
try
{
Thread
.
sleep
(
1000
);
}
catch
(
InterruptedException
e
)
{
throw
new
RuntimeException
(
e
);
}
//如果校验为可退
if
(
"SUCCESS"
.
equals
(
checkBeforeRefundCode
)){
//流水退款
JSONObject
refundByRecordResult
=
new
JSONObject
();
refundByRecordResult
.
put
(
"transAmount"
,
0.01
);
refundByRecordResult
.
put
(
"refundReason"
,
RandomStringUtil
.
randomString
(
6
));
refundByRecordResult
.
put
(
"orderType"
,
"PAY_QR_CODE"
);
refundByRecordResult
.
put
(
"payTransNo"
,
"1808757176611880962"
);
refundByRecordResult
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
refundByRecordResult
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
refundByRecordResult
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
refundByRecordResult
.
toJSONString
(),
headers
).
assetsSuccess
(
true
);
String
success
=
xmAppApi
.
getBodyInJSON
().
getString
(
"success"
);
String
failCode
=
xmAppApi
.
getBodyInJSON
().
getJSONObject
(
"result"
).
getString
(
"failCode"
);
Assert
.
assertEquals
(
success
,
"true"
,
"获取流水退款失败"
);
Assert
.
assertEquals
(
failCode
,
"OTHER_ERROR"
,
"当前乐动收银余额不足,无法退款,请在线收款后再次发起退款或者线下处理退款"
);
}
else
{
Assert
.
assertEquals
(
checkBeforeRefundCode
,
"AMOUNT_LIMIT"
,
"订单关联流水可退金额不足,请修改退款金额后重试"
);
}
}
}
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