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 d1570b53
authored
May 09, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:代码优化
1 parent
2e94c9b5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
20 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/CouponActivityService.java
aus-api/src/main/java/com/glsx/usedcar/web/api/coupon/CouponAccountController.java
View file @
d1570b5
...
@@ -46,10 +46,10 @@ public class CouponAccountController {
...
@@ -46,10 +46,10 @@ public class CouponAccountController {
@Operation
(
summary
=
"获取我的优惠券列表"
,
description
=
"查询当前登录用户的优惠券列表,支持按状态筛选"
)
@Operation
(
summary
=
"获取我的优惠券列表"
,
description
=
"查询当前登录用户的优惠券列表,支持按状态筛选"
)
@GetMapping
(
"/list"
)
@GetMapping
(
"/list"
)
public
BaseResp
<
List
<
CouponAccountRespVO
>>
getMyCoupons
(
public
BaseResp
<
List
<
CouponAccountRespVO
>>
list
(
@Parameter
(
description
=
"状态 (1:待使用;2:已核销;3:已过期)"
,
example
=
"1"
)
@Parameter
(
description
=
"状态 (1:待使用;2:已核销;3:已过期)"
,
example
=
"1"
)
@RequestParam
(
name
=
"status"
,
required
=
false
)
Integer
status
,
@RequestParam
(
name
=
"status"
,
required
=
false
)
Integer
status
,
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
fals
e
)
Account
account
)
{
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
tru
e
)
Account
account
)
{
log
.
info
(
"【接口请求】获取我的优惠券列表,status={}"
,
status
);
log
.
info
(
"【接口请求】获取我的优惠券列表,status={}"
,
status
);
try
{
try
{
Integer
accountId
=
account
.
getAccountId
();
Integer
accountId
=
account
.
getAccountId
();
...
@@ -69,7 +69,7 @@ public class CouponAccountController {
...
@@ -69,7 +69,7 @@ public class CouponAccountController {
public
BaseResp
<
CouponAccountRespVO
>
getCouponDetail
(
public
BaseResp
<
CouponAccountRespVO
>
getCouponDetail
(
@Parameter
(
description
=
"优惠券实例 ID"
,
required
=
true
)
@Parameter
(
description
=
"优惠券实例 ID"
,
required
=
true
)
@PathVariable
(
"couponId"
)
String
couponId
,
@PathVariable
(
"couponId"
)
String
couponId
,
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
fals
e
)
Account
account
)
{
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
tru
e
)
Account
account
)
{
log
.
info
(
"【接口请求】获取优惠券详情,couponId={}"
,
couponId
);
log
.
info
(
"【接口请求】获取优惠券详情,couponId={}"
,
couponId
);
try
{
try
{
CouponAccountRespVO
result
=
couponAccountService
.
getCouponDetail
(
couponId
);
CouponAccountRespVO
result
=
couponAccountService
.
getCouponDetail
(
couponId
);
...
@@ -85,7 +85,7 @@ public class CouponAccountController {
...
@@ -85,7 +85,7 @@ public class CouponAccountController {
@Operation
(
summary
=
"获取待展示弹窗"
,
description
=
"查询当前用户有待展示的优惠券弹窗(用于首页弹窗)"
)
@Operation
(
summary
=
"获取待展示弹窗"
,
description
=
"查询当前用户有待展示的优惠券弹窗(用于首页弹窗)"
)
@GetMapping
(
"/popup"
)
@GetMapping
(
"/popup"
)
public
BaseResp
<
CouponPopupRespVO
>
getPendingPopup
(
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
fals
e
)
Account
account
)
{
public
BaseResp
<
CouponPopupRespVO
>
getPendingPopup
(
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
tru
e
)
Account
account
)
{
log
.
info
(
"【接口请求】获取待展示弹窗"
);
log
.
info
(
"【接口请求】获取待展示弹窗"
);
try
{
try
{
Integer
accountId
=
account
.
getAccountId
();
Integer
accountId
=
account
.
getAccountId
();
...
@@ -102,7 +102,7 @@ public class CouponAccountController {
...
@@ -102,7 +102,7 @@ public class CouponAccountController {
@Operation
(
summary
=
"统计各状态优惠券数量"
,
description
=
"统计用户待使用、已核销、已过期优惠券数量"
)
@Operation
(
summary
=
"统计各状态优惠券数量"
,
description
=
"统计用户待使用、已核销、已过期优惠券数量"
)
@GetMapping
(
"/count"
)
@GetMapping
(
"/count"
)
public
BaseResp
<
CouponCountRespVO
>
countCoupons
(
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
fals
e
)
Account
account
)
{
public
BaseResp
<
CouponCountRespVO
>
countCoupons
(
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
tru
e
)
Account
account
)
{
log
.
info
(
"【接口请求】统计各状态优惠券数量"
);
log
.
info
(
"【接口请求】统计各状态优惠券数量"
);
try
{
try
{
Integer
accountId
=
account
.
getAccountId
();
Integer
accountId
=
account
.
getAccountId
();
...
@@ -120,7 +120,7 @@ public class CouponAccountController {
...
@@ -120,7 +120,7 @@ public class CouponAccountController {
@Operation
(
summary
=
"核销优惠券"
,
description
=
"订单支付时使用优惠券进行核销"
)
@Operation
(
summary
=
"核销优惠券"
,
description
=
"订单支付时使用优惠券进行核销"
)
@PostMapping
(
"/verify"
)
@PostMapping
(
"/verify"
)
public
BaseResp
<
CouponVerifyRespVO
>
verifyCoupon
(
public
BaseResp
<
CouponVerifyRespVO
>
verifyCoupon
(
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
fals
e
)
Account
account
,
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
tru
e
)
Account
account
,
@Valid
@RequestBody
CouponVerifyReqVO
reqVO
)
{
@Valid
@RequestBody
CouponVerifyReqVO
reqVO
)
{
log
.
info
(
"【接口请求】核销优惠券,accountId={}, orderId={}, couponId={}"
,
log
.
info
(
"【接口请求】核销优惠券,accountId={}, orderId={}, couponId={}"
,
account
.
getAccountId
(),
reqVO
.
getOrderId
(),
reqVO
.
getCouponId
());
account
.
getAccountId
(),
reqVO
.
getOrderId
(),
reqVO
.
getCouponId
());
...
@@ -157,7 +157,7 @@ public class CouponAccountController {
...
@@ -157,7 +157,7 @@ public class CouponAccountController {
public
BaseResp
<
List
<
OrderCouponRespVO
>>
getOrderCoupons
(
public
BaseResp
<
List
<
OrderCouponRespVO
>>
getOrderCoupons
(
@Parameter
(
description
=
"订单 ID"
,
required
=
true
,
example
=
"123"
)
@Parameter
(
description
=
"订单 ID"
,
required
=
true
,
example
=
"123"
)
@PathVariable
(
"orderId"
)
Integer
orderId
,
@PathVariable
(
"orderId"
)
Integer
orderId
,
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
fals
e
)
Account
account
)
{
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
tru
e
)
Account
account
)
{
log
.
info
(
"【接口请求】获取订单可用优惠券列表,orderId={}"
,
orderId
);
log
.
info
(
"【接口请求】获取订单可用优惠券列表,orderId={}"
,
orderId
);
try
{
try
{
Integer
accountId
=
account
.
getAccountId
();
Integer
accountId
=
account
.
getAccountId
();
...
@@ -213,7 +213,7 @@ public class CouponAccountController {
...
@@ -213,7 +213,7 @@ public class CouponAccountController {
@Operation
(
summary
=
"查询红点状态"
,
description
=
"查询当前用户是否有待通知的优惠券弹窗(用于前端展示红点)"
)
@Operation
(
summary
=
"查询红点状态"
,
description
=
"查询当前用户是否有待通知的优惠券弹窗(用于前端展示红点)"
)
@GetMapping
(
"/red-dot"
)
@GetMapping
(
"/red-dot"
)
public
BaseResp
<
CouponRedDotRespVO
>
checkRedDotStatus
(
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
fals
e
)
Account
account
)
{
public
BaseResp
<
CouponRedDotRespVO
>
checkRedDotStatus
(
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
tru
e
)
Account
account
)
{
log
.
info
(
"【接口请求】查询红点状态"
);
log
.
info
(
"【接口请求】查询红点状态"
);
try
{
try
{
Integer
accountId
=
account
.
getAccountId
();
Integer
accountId
=
account
.
getAccountId
();
...
...
aus-core/src/main/java/com/glsx/usedcar/module/coupon/service/CouponActivityService.java
View file @
d1570b5
...
@@ -1077,7 +1077,7 @@ public class CouponActivityService {
...
@@ -1077,7 +1077,7 @@ public class CouponActivityService {
try
{
try
{
for
(
int
i
=
0
;
i
<
quantity
;
i
++)
{
for
(
int
i
=
0
;
i
<
quantity
;
i
++)
{
distributeCoupon
(
activity
,
template
,
accountId
,
mobile
,
distributeCoupon
(
activity
,
template
,
accountId
,
mobile
,
CouponDistributionTypeEnum
.
DIRECT_ACTIVITY
.
getCode
(),
opId
,
opName
,
now
);
CouponDistributionTypeEnum
.
DIRECT_ACTIVITY
.
getCode
(),
opId
,
opName
,
now
,
activity
.
getSendNotification
()
==
1
);
}
}
distributedAccountIds
.
add
(
accountId
);
distributedAccountIds
.
add
(
accountId
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -1228,7 +1228,7 @@ public class CouponActivityService {
...
@@ -1228,7 +1228,7 @@ public class CouponActivityService {
try
{
try
{
for
(
int
i
=
0
;
i
<
activity
.
getDistributionQuantity
();
i
++)
{
for
(
int
i
=
0
;
i
<
activity
.
getDistributionQuantity
();
i
++)
{
distributeCoupon
(
activity
,
template
,
target
.
getAccountId
(),
target
.
getAccountMobile
(),
distributeCoupon
(
activity
,
template
,
target
.
getAccountId
(),
target
.
getAccountMobile
(),
CouponDistributionTypeEnum
.
DIRECT_ACTIVITY
.
getCode
(),
0
,
"系统定时任务"
,
now
);
CouponDistributionTypeEnum
.
DIRECT_ACTIVITY
.
getCode
(),
0
,
"系统定时任务"
,
now
,
activity
.
getSendNotification
()
==
1
);
}
}
// 更新发放状态
// 更新发放状态
target
.
setIsDistributed
(
1
);
target
.
setIsDistributed
(
1
);
...
@@ -1251,7 +1251,7 @@ public class CouponActivityService {
...
@@ -1251,7 +1251,7 @@ public class CouponActivityService {
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
distributeCoupon
(
CouponActivity
activity
,
CouponTemplate
template
,
public
void
distributeCoupon
(
CouponActivity
activity
,
CouponTemplate
template
,
Integer
accountId
,
String
mobile
,
Integer
distributionType
,
Integer
accountId
,
String
mobile
,
Integer
distributionType
,
Integer
opId
,
String
opName
,
LocalDateTime
now
)
{
Integer
opId
,
String
opName
,
LocalDateTime
now
,
boolean
sendNotification
)
{
// 计算有效期
// 计算有效期
LocalDateTime
validStartTime
=
now
;
LocalDateTime
validStartTime
=
now
;
...
@@ -1327,14 +1327,17 @@ public class CouponActivityService {
...
@@ -1327,14 +1327,17 @@ public class CouponActivityService {
distributionRecordRepository
.
save
(
record
);
distributionRecordRepository
.
save
(
record
);
// 保存活动发放弹窗通知记录
// 保存活动发放弹窗通知记录
couponPopupNotificationService
.
saveNotification
(
if
(
sendNotification
)
{
accountId
,
couponPopupNotificationService
.
saveNotification
(
CouponPopupTypeEnum
.
ACTIVITY_DISTRIBUTION
.
getCode
(),
accountId
,
CouponNotificationSourceTypeEnum
.
ACTIVITY
.
getCode
(),
CouponPopupTypeEnum
.
ACTIVITY_DISTRIBUTION
.
getCode
(),
activity
!=
null
?
activity
.
getActivityId
()
:
record
.
getRecordId
(),
CouponNotificationSourceTypeEnum
.
ACTIVITY
.
getCode
(),
couponId
,
activity
!=
null
?
activity
.
getActivityId
()
:
record
.
getRecordId
(),
now
,
couponId
,
opName
);
now
,
opName
);
}
log
.
info
(
"优惠券发放成功:accountId={}, couponId={}, templateId={}"
,
accountId
,
couponId
,
template
.
getId
());
log
.
info
(
"优惠券发放成功:accountId={}, couponId={}, templateId={}"
,
accountId
,
couponId
,
template
.
getId
());
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
@@ -1664,7 +1667,8 @@ public class CouponActivityService {
...
@@ -1664,7 +1667,8 @@ public class CouponActivityService {
CouponDistributionTypeEnum
.
AUTO_TRIGGER
.
getCode
(),
CouponDistributionTypeEnum
.
AUTO_TRIGGER
.
getCode
(),
null
,
null
,
"系统自动发放"
,
"系统自动发放"
,
now
now
,
activity
.
getSendNotification
()
==
1
);
);
log
.
info
(
"自动发放优惠券成功:accountId={}, activityId={}, templateId={}, transactionPrice={}"
,
log
.
info
(
"自动发放优惠券成功:accountId={}, activityId={}, templateId={}, transactionPrice={}"
,
...
...
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