Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
usedCarAuction
/
aus
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit f83974d3
authored
May 09, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:查询优惠券详情的时候校验用户是否归属该优惠券
1 parent
d1570b53
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
aus-api/src/main/java/com/glsx/usedcar/web/api/coupon/CouponAccountController.java
aus-core/src/main/java/com/glsx/usedcar/module/coupon/service/CouponAccountService.java
aus-api/src/main/java/com/glsx/usedcar/web/api/coupon/CouponAccountController.java
View file @
f83974d
...
@@ -72,7 +72,8 @@ public class CouponAccountController {
...
@@ -72,7 +72,8 @@ public class CouponAccountController {
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
true
)
Account
account
)
{
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
true
)
Account
account
)
{
log
.
info
(
"【接口请求】获取优惠券详情,couponId={}"
,
couponId
);
log
.
info
(
"【接口请求】获取优惠券详情,couponId={}"
,
couponId
);
try
{
try
{
CouponAccountRespVO
result
=
couponAccountService
.
getCouponDetail
(
couponId
);
Integer
accountId
=
account
.
getAccountId
();
CouponAccountRespVO
result
=
couponAccountService
.
getCouponDetail
(
couponId
,
accountId
);
return
BaseResp
.
success
(
result
);
return
BaseResp
.
success
(
result
);
}
catch
(
BusinessCodeException
be
)
{
}
catch
(
BusinessCodeException
be
)
{
log
.
error
(
"【接口响应】获取优惠券详情失败,couponId={}"
,
couponId
,
be
);
log
.
error
(
"【接口响应】获取优惠券详情失败,couponId={}"
,
couponId
,
be
);
...
...
aus-core/src/main/java/com/glsx/usedcar/module/coupon/service/CouponAccountService.java
View file @
f83974d
...
@@ -178,9 +178,13 @@ public class CouponAccountService {
...
@@ -178,9 +178,13 @@ public class CouponAccountService {
/**
/**
* 获取优惠券详情
* 获取优惠券详情
*/
*/
public
CouponAccountRespVO
getCouponDetail
(
String
couponId
)
{
public
CouponAccountRespVO
getCouponDetail
(
String
couponId
,
Integer
accountId
)
{
CouponAccount
coupon
=
couponAccountRepository
.
findByCouponIdAndDeleteFlag
(
couponId
,
DeleteFlag
.
NOT_DELETED
.
getCode
())
CouponAccount
coupon
=
couponAccountRepository
.
findByCouponIdAndDeleteFlag
(
couponId
,
DeleteFlag
.
NOT_DELETED
.
getCode
())
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
COMMON_ERROR
,
"优惠券不存在"
));
.
orElseThrow
(()
->
new
BusinessCodeException
(
ErrorCodeEnum
.
COMMON_ERROR
,
"优惠券不存在"
));
// 判断是否是该用户的优惠券
if
(!
coupon
.
getAccountId
().
equals
(
accountId
))
{
throw
new
BusinessCodeException
(
ErrorCodeEnum
.
COMMON_ERROR
,
"该优惠券不属于当前用户"
);
}
return
couponConverter
.
couponAccountMapRespVO
(
coupon
);
return
couponConverter
.
couponAccountMapRespVO
(
coupon
);
}
}
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment