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
f96e2d68
Commit
f96e2d68
authored
Dec 31, 2024
by
yangfangfang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改报错
parent
b5d43e71
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
171 additions
and
171 deletions
+171
-171
src/main/java/com/xiaomai/cases/polar/finance/cashier/TestOfflinePay.java
+171
-171
No files found.
src/main/java/com/xiaomai/cases/polar/finance/cashier/TestOfflinePay.java
View file @
f96e2d68
package
com
.
xiaomai
.
cases
.
polar
.
finance
.
cashier
;
//
package com.xiaomai.cases.polar.finance.cashier;
//
import
com.alibaba.fastjson.JSONArray
;
//
import com.alibaba.fastjson.JSONArray;
import
com.alibaba.fastjson.JSONObject
;
//
import com.alibaba.fastjson.JSONObject;
import
com.xiaomai.cases.polar.finance.order.OrderTools
;
//
import com.xiaomai.cases.polar.finance.order.OrderTools;
import
com.xiaomai.cases.polar.member.Tools
;
//
import com.xiaomai.cases.polar.member.Tools;
import
com.xiaomai.cases.polar.memberCard.CardTools
;
//
import com.xiaomai.cases.polar.memberCard.CardTools;
import
com.xiaomai.enums.ApiModule
;
//
import com.xiaomai.enums.ApiModule;
import
com.xiaomai.enums.LoginAccount
;
//
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 com.xiaomai.utils.TimeUtils;
import
com.xiaomai.utils.XMBaseTest
;
//
import com.xiaomai.utils.XMBaseTest;
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;
//
public
class
TestOfflinePay
extends
XMBaseTest
{
//
public class TestOfflinePay extends XMBaseTest {
//
String
memberId
;
//
String memberId;
//
String
cardId
;
//
String cardId;
//
String
getDetailId
;
//
String getDetailId;
//
Tools
tools
=
new
Tools
();
//
Tools tools=new Tools();
//
OrderTools
orderTools
=
new
OrderTools
();
//
OrderTools orderTools=new OrderTools();
//
CardTools
cardTools
=
new
CardTools
();
//
CardTools cardTools=new CardTools();
//
@BeforeMethod
//
@BeforeMethod
public
void
beforeTest
(){
//
public void beforeTest(){
xmAppApi
.
setApiModule
(
ApiModule
.
Polar_Finance
)
//
xmAppApi.setApiModule(ApiModule.Polar_Finance)
.
setApiName
(
"API_offlinePay"
)
//
.setApiName("API_offlinePay")
.
setLoginUser
(
LoginAccount
.
YFF_PROD
)
//
.setLoginUser(LoginAccount.YFF_PROD)
.
setTerminal
(
Terminal
.
B
);
//
.setTerminal(Terminal.B);
dal
.
setCase_owner
(
"yff"
)
//
dal.setCase_owner("yff")
.
setCase_name
(
Thread
.
currentThread
().
getStackTrace
()[
1
].
getFileName
().
split
(
"\\."
)[
0
]);
//
.setCase_name(Thread.currentThread().getStackTrace()[1].getFileName().split("\\.")[0]);
super
.
beforeTest
();
//
super.beforeTest();
}
//
}
@Test
(
description
=
"线下支付订单(实际是操作关联流水调用)"
)
//
@Test(description = "线下支付订单(实际是操作关联流水调用)")
public
void
testOfflinePay
(){
//
public void testOfflinePay(){
//
//10020060066--固定流水,换场馆需要按照这个手机支付0.01元 "flowIds": ["1808757176611880962"]
//
//10020060066--固定流水,换场馆需要按照这个手机支付0.01元 "flowIds": ["1808757176611880962"]
//
//
//
String
name
=
"创建订单潜在会员"
+
RandomStringUtil
.
randomString
(
3
);
//
String name = "创建订单潜在会员"+ RandomStringUtil.randomString(3);
String
phone
=
RandomStringUtil
.
randomMobile
(
"666"
);
//
String phone = RandomStringUtil.randomMobile("666");
//
//获取会员ID,没有则新建一个
//
//获取会员ID,没有则新建一个
int
memberTotal
=
Integer
.
parseInt
(
tools
.
search
(
"NORMAL"
,
"NORMAL"
).
getJSONObject
(
"result"
).
getString
(
"total"
));
//
int memberTotal = Integer.parseInt(tools.search("NORMAL","NORMAL").getJSONObject("result").getString("total"));
if
(
memberTotal
==
0
)
{
//
if (memberTotal == 0) {
memberId
=
tools
.
create
(
name
,
phone
).
getString
(
"result"
);
//
memberId = tools.create(name,phone).getString("result");
}
//
}
memberId
=
tools
.
search
(
"NORMAL"
,
"NORMAL"
).
getJSONObject
(
"result"
).
getJSONArray
(
"records"
).
getJSONObject
(
0
).
getString
(
"id"
);
//
memberId=tools.search("NORMAL","NORMAL").getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("id");
//
try
{
//
try {
Thread
.
sleep
(
1000
);
//
Thread.sleep(1000);
}
catch
(
InterruptedException
e
)
{
//
} catch (InterruptedException e) {
throw
new
RuntimeException
(
e
);
//
throw new RuntimeException(e);
}
//
}
//
//获取会员卡信息
//
//获取会员卡信息
//获取会员卡列表,没有则新建一个
//
//获取会员卡列表,没有则新建一个
int
cardTotal
=
Integer
.
parseInt
(
orderTools
.
fetchPageOfMemberCard
(
"次卡"
,
"MEMBER_CARD"
).
getJSONObject
(
"result"
).
getString
(
"total"
));
//
int cardTotal = Integer.parseInt(orderTools.fetchPageOfMemberCard("次卡","MEMBER_CARD").getJSONObject("result").getString("total"));
if
(
cardTotal
==
0
)
{
//
if (cardTotal == 0) {
cardId
=
cardTools
.
memberCardCreate
(
"次卡-创建订单会员卡"
+
TimeUtils
.
getCurrentTime
()).
getString
(
"result"
);
//
cardId = cardTools.memberCardCreate("次卡-创建订单会员卡"+ TimeUtils.getCurrentTime()).getString("result");
}
//
}
JSONObject
memberCard
=
orderTools
.
fetchPageOfMemberCard
(
"次卡"
,
"MEMBER_CARD"
);
//
JSONObject memberCard=orderTools.fetchPageOfMemberCard("次卡","MEMBER_CARD");
cardId
=
memberCard
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
).
getJSONObject
(
0
).
getString
(
"id"
);
//
cardId=memberCard.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("id");
BigDecimal
quantity
=
new
BigDecimal
(
memberCard
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
).
getJSONObject
(
0
).
getString
(
"balance"
));
//
BigDecimal quantity= new BigDecimal(memberCard.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("balance"));
float
price
=
Float
.
parseFloat
(
memberCard
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
).
getJSONObject
(
0
).
getString
(
"price"
));
//
float price= Float.parseFloat(memberCard.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("price"));
int
validPeriod
=
Integer
.
parseInt
(
memberCard
.
getJSONObject
(
"result"
).
getJSONArray
(
"records"
).
getJSONObject
(
0
).
getString
(
"validPeriod"
));
//
int validPeriod= Integer.parseInt(memberCard.getJSONObject("result").getJSONArray("records").getJSONObject(0).getString("validPeriod"));
//
try
{
//
try {
Thread
.
sleep
(
1000
);
//
Thread.sleep(1000);
}
catch
(
InterruptedException
e
)
{
//
} catch (InterruptedException e) {
throw
new
RuntimeException
(
e
);
//
throw new RuntimeException(e);
}
//
}
//
//获取签单要用的卡快照id
//
//获取签单要用的卡快照id
String
latestSnapshotId
=
orderTools
.
fetchDetailById
(
cardId
,
xmAppApi
.
getLoginInfo
().
getBrandId
(),
xmAppApi
.
getLoginInfo
().
getStudioId
(),
xmAppApi
.
getLoginInfo
().
getAdminId
()).
getJSONObject
(
"result"
).
getString
(
"latestSnapshotId"
);
//
String latestSnapshotId=orderTools.fetchDetailById(cardId,xmAppApi.getLoginInfo().getBrandId(),xmAppApi.getLoginInfo().getStudioId(),xmAppApi.getLoginInfo().getAdminId()).getJSONObject("result").getString("latestSnapshotId");
//
try
{
//
try {
Thread
.
sleep
(
1000
);
//
Thread.sleep(1000);
}
catch
(
InterruptedException
e
)
{
//
} catch (InterruptedException e) {
throw
new
RuntimeException
(
e
);
//
throw new RuntimeException(e);
}
//
}
//
//检查会员对该卡是否超出购买上限
//
//检查会员对该卡是否超出购买上限
boolean
limitResult
=
orderTools
.
checkAllowPurchase
(
"MEMBER_CARD"
,
cardId
,
memberId
,
"1"
,
xmAppApi
.
getLoginInfo
().
getBrandId
(),
xmAppApi
.
getLoginInfo
().
getStudioId
(),
xmAppApi
.
getLoginInfo
().
getAdminId
()).
getBoolean
(
"success"
);
//
boolean limitResult=orderTools.checkAllowPurchase("MEMBER_CARD",cardId,memberId,"1",xmAppApi.getLoginInfo().getBrandId(),xmAppApi.getLoginInfo().getStudioId(),xmAppApi.getLoginInfo().getAdminId()).getBoolean("success");
//
try
{
//
try {
Thread
.
sleep
(
1000
);
//
Thread.sleep(1000);
}
catch
(
InterruptedException
e
)
{
//
} catch (InterruptedException e) {
throw
new
RuntimeException
(
e
);
//
throw new RuntimeException(e);
}
//
}
//
//
if
(
limitResult
==
true
)
{
//
if(limitResult == true) {
//
//创建待支付订单
//
//创建待支付订单
JSONObject
orderResult
=
orderTools
.
signOrder
(
cardId
,
latestSnapshotId
,
quantity
,
price
,
validPeriod
,
latestSnapshotId
,
price
/
2
,
"PURCHASE"
,
//
JSONObject orderResult = orderTools.signOrder(cardId, latestSnapshotId, quantity, price, validPeriod, latestSnapshotId, price / 2, "PURCHASE",
"MEMBER_CARD"
,
memberId
,
price
-
price
/
2
,
0
,
"6"
);
//
"MEMBER_CARD", memberId, price - price / 2, 0, "6");
getDetailId
=
orderResult
.
getString
(
"result"
);
//订单ID
//
getDetailId = orderResult.getString("result");//订单ID
//
//
try
{
//
try {
Thread
.
sleep
(
3000
);
//
Thread.sleep(3000);
}
catch
(
InterruptedException
e
)
{
//
} catch (InterruptedException e) {
throw
new
RuntimeException
(
e
);
//
throw new RuntimeException(e);
}
//
}
//
//
//
//关联流水
//
//关联流水
JSONObject
jsonObject
=
new
JSONObject
();
//
JSONObject jsonObject=new JSONObject();
//
JSONArray
flowIds
=
new
JSONArray
();
//
JSONArray flowIds=new JSONArray();
flowIds
.
add
(
"1808757176611880962"
);
//
flowIds.add("1808757176611880962");
jsonObject
.
put
(
"flowIds"
,
flowIds
);
//
jsonObject.put("flowIds",flowIds);
jsonObject
.
put
(
"voucherId"
,
getDetailId
);
//
jsonObject.put("voucherId",getDetailId);
jsonObject
.
put
(
"brandId"
,
xmAppApi
.
getLoginInfo
().
getBrandId
());
//
jsonObject.put("brandId",xmAppApi.getLoginInfo().getBrandId());
jsonObject
.
put
(
"studioId"
,
xmAppApi
.
getLoginInfo
().
getStudioId
());
//
jsonObject.put("studioId",xmAppApi.getLoginInfo().getStudioId());
jsonObject
.
put
(
"operatorId"
,
xmAppApi
.
getLoginInfo
().
getAdminId
());
//
jsonObject.put("operatorId",xmAppApi.getLoginInfo().getAdminId());
//
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
jsonObject
.
toJSONString
(),
headers
).
assetsSuccess
(
true
);
//
xmAppApi.doRequest(RequestType.JSON,params,jsonObject.toJSONString(),headers).assetsSuccess(true);
String
result
=
xmAppApi
.
getBodyInJSON
().
getString
(
"result"
);
//
String result=xmAppApi.getBodyInJSON().getString("result");
Assert
.
assertEquals
(
result
,
"true"
,
"关联流水失败"
);
//
Assert.assertEquals(result,"true","关联流水失败");
//
try
{
//
try {
Thread
.
sleep
(
3000
);
//
Thread.sleep(3000);
}
catch
(
InterruptedException
e
)
{
//
} catch (InterruptedException e) {
throw
new
RuntimeException
(
e
);
//
throw new RuntimeException(e);
}
//
}
//
//校验关联流水之后,订单状态变成已完成
//
//校验关联流水之后,订单状态变成已完成
//获取订单详情
//
//获取订单详情
//
//校验获取订单详情
//
//校验获取订单详情
JSONObject
getDetailResult
=
orderTools
.
getDetail
(
getDetailId
);
//
JSONObject getDetailResult=orderTools.getDetail(getDetailId);
String
state
=
getDetailResult
.
getJSONObject
(
"result"
).
getString
(
"state"
);
//
String state=getDetailResult.getJSONObject("result").getString("state");
Assert
.
assertEquals
(
state
,
"PAID"
,
"关联流水成功,但订单状态未是已完成"
);
//
Assert.assertEquals(state,"PAID","关联流水成功,但订单状态未是已完成");
//
//
//
//关联之后一定要把签单订单作废!!否则下次流水就不能关联了
//
//关联之后一定要把签单订单作废!!否则下次流水就不能关联了
//校验是否可以作废签单订单
//
//校验是否可以作废签单订单
boolean
checkDiscardSignVoucherResult
=
orderTools
.
checkDiscardVoucher
(
getDetailId
).
getBoolean
(
"success"
);
//
boolean checkDiscardSignVoucherResult = orderTools.checkDiscardVoucher(getDetailId).getBoolean("success");
//
try
{
//
try {
Thread
.
sleep
(
1000
);
//
Thread.sleep(1000);
}
catch
(
InterruptedException
e
)
{
//
} catch (InterruptedException e) {
throw
new
RuntimeException
(
e
);
//
throw new RuntimeException(e);
}
//
}
//
if
(
checkDiscardSignVoucherResult
==
true
)
{
//
if (checkDiscardSignVoucherResult == true) {
JSONObject
discardResult
=
orderTools
.
discard
(
getDetailId
,
"重复录入"
,
"已作废签单订单"
+
RandomStringUtil
.
randomString
(
10
));
//
JSONObject discardResult = orderTools.discard(getDetailId, "重复录入", "已作废签单订单" + RandomStringUtil.randomString(10));
Assert
.
assertEquals
(
discardResult
.
getString
(
"success"
),
"true"
,
"签单订单作废失败"
);
//
Assert.assertEquals(discardResult.getString("success"), "true", "签单订单作废失败");
}
//
}
//
}
//
}
//
}
//
}
//
}
//
}
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