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
f52a1158
Commit
f52a1158
authored
Sep 25, 2024
by
yangjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优惠券自动化补充
parent
6ceddc91
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
212 additions
and
0 deletions
+212
-0
src/main/java/com/xiaomai/cases/polar/coupon/CouponMInTools.java
+143
-0
src/main/java/com/xiaomai/cases/polar/coupon/CouponTools.java
+1
-0
src/main/java/com/xiaomai/cases/polar/coupon/TestListMemberReceivedCoupon.java
+68
-0
No files found.
src/main/java/com/xiaomai/cases/polar/coupon/CouponMInTools.java
0 → 100644
View file @
f52a1158
package
com
.
xiaomai
.
cases
.
polar
.
coupon
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.client.DataUserInfo
;
import
com.xiaomai.enums.ApiModule
;
import
com.xiaomai.enums.RequestType
;
import
com.xiaomai.enums.Terminal
;
import
com.xiaomai.utils.XMBaseTest
;
import
org.springframework.stereotype.Component
;
import
java.util.ArrayList
;
import
java.util.List
;
@Component
(
"couponMinTools"
)
public
class
CouponMInTools
extends
XMBaseTest
{
/**
* @param
* @description:小程序查看我的优惠券
* @author: yangjian
* @param status 我的优惠券列表
**/
public
JSONObject
listMemberReceivedCoupon
(
String
receiverId
,
String
status
,
DataUserInfo
...
dataUserInfos
)
{
dataApi
.
setApiModule
(
ApiModule
.
Lunar_Coupon
)
.
setApiName
(
"API_listMemberReceivedCoupon"
)
.
setTerminal
(
Terminal
.
minApp
);
super
.
beforeDataRequest
(
dataUserInfos
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"receiverId"
,
receiverId
);
jsonObject
.
put
(
"status"
,
status
);
//AVAILABLE待使用;USED已使用;EXPIRED已过期
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
jsonObject
.
toJSONString
(),
dataheadrs
).
assetsSuccess
(
true
);
JSONObject
response
=
dataApi
.
getBodyInJSON
();
return
response
;
}
/**
* @param
* @description:首页-优惠券查看更多列表
* @author: yangjian
* @param id 优惠券id
**/
public
JSONObject
pageStudioCoupon
(
String
id
,
DataUserInfo
...
dataUserInfos
)
{
dataApi
.
setApiModule
(
ApiModule
.
Lunar_Coupon
)
.
setApiName
(
"API_pageStudioCoupon"
)
.
setTerminal
(
Terminal
.
minApp
);
super
.
beforeDataRequest
(
dataUserInfos
);
List
<
String
>
ids
=
new
ArrayList
<>();
ids
.
add
(
id
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"current"
,
0
);
jsonObject
.
put
(
"size"
,
50
);
jsonObject
.
put
(
"ids"
,
ids
);
jsonObject
.
put
(
"nameLike"
,
""
);
jsonObject
.
put
(
"status"
,
"CLAIMABLE"
);
jsonObject
.
put
(
"studioId"
,
dataApi
.
getLoginInfo
().
getStudioId
());
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
jsonObject
.
toJSONString
(),
dataheadrs
).
assetsSuccess
(
true
);
JSONObject
response
=
dataApi
.
getBodyInJSON
();
return
response
;
}
/**
* @param
* @description:小程序主动领取优惠券
* @author: yangjian
* @param couponId 优惠券id
* @param receiverId
**/
public
JSONObject
claim
(
String
couponId
,
String
receiverId
,
DataUserInfo
...
dataUserInfos
)
{
dataApi
.
setApiModule
(
ApiModule
.
Lunar_Coupon
)
.
setApiName
(
"API_claim"
)
.
setTerminal
(
Terminal
.
minApp
);
super
.
beforeDataRequest
(
dataUserInfos
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"couponId"
,
couponId
);
jsonObject
.
put
(
"receiverId"
,
receiverId
);
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
jsonObject
.
toJSONString
(),
dataheadrs
).
assetsSuccess
(
true
);
JSONObject
response
=
dataApi
.
getBodyInJSON
();
return
response
;
}
/**
* @param
* @description:小程序优惠券详情
* @author: yangjian
* @param id 优惠券id
**/
public
JSONObject
coupon_get
(
String
id
,
DataUserInfo
...
dataUserInfos
)
{
dataApi
.
setApiModule
(
ApiModule
.
Lunar_Coupon
)
.
setApiName
(
"API_coupon_get"
)
.
setTerminal
(
Terminal
.
minApp
);
super
.
beforeDataRequest
(
dataUserInfos
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"id"
,
id
);
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
jsonObject
.
toJSONString
(),
dataheadrs
).
assetsSuccess
(
true
);
JSONObject
response
=
dataApi
.
getBodyInJSON
();
return
response
;
}
/**
* @param
* @description:首页获取信息
* @author: yangjian
**/
public
JSONObject
getPageConfig
(
DataUserInfo
...
dataUserInfos
)
{
dataApi
.
setApiModule
(
ApiModule
.
Lunar_Coupon
)
.
setApiName
(
"API_getPageConfig"
)
.
setTerminal
(
Terminal
.
minApp
);
super
.
beforeDataRequest
(
dataUserInfos
);
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"pageKey"
,
"HOME"
);
jsonObject
.
put
(
"tenantId"
,
dataApi
.
getLoginInfo
().
getStudioId
());
jsonObject
.
put
(
"tenantType"
,
"STUDIO"
);
dataApi
.
doRequest
(
RequestType
.
JSON
,
dataparams
,
jsonObject
.
toJSONString
(),
dataheadrs
).
assetsSuccess
(
true
);
JSONObject
response
=
dataApi
.
getBodyInJSON
();
return
response
;
}
}
src/main/java/com/xiaomai/cases/polar/coupon/CouponTools.java
View file @
f52a1158
...
...
@@ -48,6 +48,7 @@ public class CouponTools extends BaseTestImpl {
* @param quantity 发放数量
* @param validPeriodType 使用有效期方式:1固定期限 ABSOLUTE 2领取后生效 RELATIVE
* @param memo 备注
* @return 优惠券ID
*/
public
String
createCoupon
(
String
useThresholdType
,
String
receiveTimesUpperType
,
List
<
String
>
memberStatusLimits
,
String
couponName
,
...
...
src/main/java/com/xiaomai/cases/polar/coupon/TestListMemberReceivedCoupon.java
0 → 100644
View file @
f52a1158
package
com
.
xiaomai
.
cases
.
polar
.
coupon
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.xiaomai.cases.lunar.user.UserTools
;
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
com.xiaomai.utils.XMJSONPath
;
import
org.testng.Assert
;
import
org.testng.annotations.BeforeMethod
;
import
org.testng.annotations.Test
;
public
class
TestListMemberReceivedCoupon
extends
XMBaseTest
{
@BeforeMethod
public
void
beforeTest
(){
xmAppApi
.
setApiModule
(
ApiModule
.
Lunar_Coupon
)
.
setApiName
(
"API_listMemberReceivedCoupon"
)
.
setLoginUser
(
LoginAccount
.
GYM_MINIAPPC
)
.
setTerminal
(
Terminal
.
minApp
);
dal
.
setCase_owner
(
"yj"
)
.
setCase_name
(
Thread
.
currentThread
().
getStackTrace
()[
1
].
getFileName
().
split
(
"\\."
)[
0
]);
super
.
beforeTest
();
}
@Test
(
description
=
"小程序我的优惠券"
)
public
void
fetchOrderWaitUse
()
{
CouponMInTools
CouponMIntools
=
new
CouponMInTools
();
CouponMIntools
.
getPageConfig
();
//首页获取首页的配置
Assert
.
assertTrue
(
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.moduleConfigList[11].config.ids[0]"
).
equals
(
"1823600619080667137"
),
"非目标优惠券"
);
String
id
=
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.moduleConfigList[11].config.ids[0]"
);
//小程序首页,拿配置返回的优惠券id
CouponMIntools
.
pageStudioCoupon
(
id
);
//优惠券查看更多列表
Assert
.
assertTrue
(
XMJSONPath
.
readPath
(
dataApi
.
getApi_response
(),
"$.result.records[0].id"
).
equals
(
"1823600619080667137"
),
"第一张非目标优惠券,可能没有配置,可能剩余张数不足"
);
JSONObject
Result
=
CouponMIntools
.
coupon_get
(
id
);
//查看优惠券详情
int
inventory
=
Integer
.
parseInt
(
Result
.
getJSONObject
(
"result"
).
getString
(
"inventory"
));
Assert
.
assertEquals
(
inventory
>=
1
,
true
,
"自动化小程序优惠券(勿),剩余张数不足,需要去B端修改剩余张数"
);
UserTools
userTools
=
new
UserTools
();
String
receiverId
=
userTools
.
getMemberInfo
().
getString
(
"memberId"
);
//同memberId,获取receiverId
CouponMIntools
.
listMemberReceivedCoupon
(
receiverId
,
"AVAILABLE"
);
int
count
=
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
).
size
();
CouponMIntools
.
claim
(
id
,
receiverId
);
//领取优惠券
JSONObject
Result1
=
CouponMIntools
.
coupon_get
(
id
);
//查看优惠券详情
int
inventory1
=
Integer
.
parseInt
(
Result1
.
getJSONObject
(
"result"
).
getString
(
"inventory"
));
//获取领取优惠券后,剩余张数
Assert
.
assertEquals
(
inventory
,
inventory1
+
1
);
//领取优惠券后,断言优惠券张数-1
JSONObject
jsonObject
=
new
JSONObject
();
jsonObject
.
put
(
"receiverId"
,
receiverId
);
jsonObject
.
put
(
"status"
,
"AVAILABLE"
);
//AVAILABLE待使用;USED已使用;EXPIRED已过期
xmAppApi
.
doRequest
(
RequestType
.
JSON
,
params
,
jsonObject
.
toJSONString
(),
headers
).
assetsSuccess
(
true
);
CouponMIntools
.
listMemberReceivedCoupon
(
receiverId
,
"AVAILABLE"
);
int
count1
=
XMJSONPath
.
getJSONArrayByReadPath
(
dataApi
.
getApi_response
(),
"$.result"
).
size
();
Assert
.
assertEquals
(
count1
,
count
+
1
);
//领取优惠券后,我的优惠券列表+1
}
}
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