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 e8142515
authored
Apr 14, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:【优惠券需求】小程序优惠券获取或者获取弹窗通知,将所有的弹窗置为已读
1 parent
e3aa5617
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
47 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/dao/CouponPopupNotificationRepository.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 @
e814251
...
...
@@ -91,26 +91,6 @@ public class CouponAccountController {
}
}
@Operation
(
summary
=
"确认弹窗已读"
,
description
=
"用户点击弹窗后,标记为已确认"
)
@PostMapping
(
"/popup/confirm"
)
public
BaseResp
<
Void
>
confirmPopup
(
@Parameter
(
description
=
"通知 ID"
,
required
=
true
)
@RequestParam
(
"notificationId"
)
String
notificationId
,
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
false
)
Account
account
)
{
log
.
info
(
"【接口请求】确认弹窗已读,notificationId={}"
,
notificationId
);
try
{
Integer
accountId
=
account
.
getAccountId
();
couponAccountService
.
confirmPopup
(
accountId
,
notificationId
);
return
BaseResp
.
success
();
}
catch
(
BusinessCodeException
be
)
{
log
.
error
(
"【接口响应】确认弹窗失败,notificationId={}"
,
notificationId
,
be
);
return
BaseResp
.
fail
(
be
.
getCode
().
toString
(),
be
.
getMessage
());
}
catch
(
Exception
e
)
{
log
.
error
(
"【接口响应】确认弹窗异常,notificationId={}"
,
notificationId
,
e
);
return
BaseResp
.
fail
(
"系统异常:确认弹窗失败"
);
}
}
@Operation
(
summary
=
"统计各状态优惠券数量"
,
description
=
"统计用户待使用、已核销、已过期优惠券数量"
)
@GetMapping
(
"/count"
)
public
BaseResp
<
CouponAccountRespVO
.
CouponCountVO
>
countCoupons
(
@RequestAttribute
(
value
=
LOGIN_ACCOUNT
,
required
=
false
)
Account
account
)
{
...
...
aus-core/src/main/java/com/glsx/usedcar/module/coupon/dao/CouponPopupNotificationRepository.java
View file @
e814251
...
...
@@ -2,6 +2,7 @@ package com.glsx.usedcar.module.coupon.dao;
import
com.glsx.usedcar.module.coupon.entity.CouponPopupNotification
;
import
org.springframework.data.jpa.repository.JpaRepository
;
import
org.springframework.data.jpa.repository.Modifying
;
import
org.springframework.data.jpa.repository.Query
;
import
org.springframework.data.repository.query.Param
;
import
org.springframework.stereotype.Repository
;
...
...
@@ -61,4 +62,25 @@ public interface CouponPopupNotificationRepository extends JpaRepository<CouponP
* @return 弹窗通知列表
*/
List
<
CouponPopupNotification
>
findBySourceTypeAndSourceIdAndDeleteFlag
(
String
sourceType
,
String
sourceId
,
String
deleteFlag
);
/**
* 批量更新用户弹窗通知状态为已确认
*
* @param accountId 用户 ID
* @param oldStatus 原状态
* @param newStatus 新状态
* @param deleteFlag 删除标识
* @param confirmTime 确认时间
* @return 更新的记录数
*/
@Modifying
@Query
(
"UPDATE CouponPopupNotification n SET n.status = :newStatus, n.confirmTime = :confirmTime "
+
"WHERE n.accountId = :accountId AND n.status = :oldStatus AND n.deleteFlag = :deleteFlag"
)
int
batchUpdateStatusByAccountId
(
@Param
(
"accountId"
)
Integer
accountId
,
@Param
(
"oldStatus"
)
Integer
oldStatus
,
@Param
(
"newStatus"
)
Integer
newStatus
,
@Param
(
"deleteFlag"
)
String
deleteFlag
,
@Param
(
"confirmTime"
)
LocalDateTime
confirmTime
);
}
aus-core/src/main/java/com/glsx/usedcar/module/coupon/service/CouponAccountService.java
View file @
e814251
...
...
@@ -37,7 +37,11 @@ public class CouponAccountService {
/**
* 获取我的优惠券列表
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
List
<
CouponAccountRespVO
>
getMyCoupons
(
Integer
accountId
,
Integer
status
)
{
// 将该用户下所有弹窗通知置为已读
markAllPopupsAsRead
(
accountId
);
List
<
CouponAccount
>
coupons
;
if
(
status
==
null
)
{
coupons
=
couponAccountRepository
.
findByAccountIdAndDeleteFlag
(
accountId
,
"N"
);
...
...
@@ -62,6 +66,7 @@ public class CouponAccountService {
/**
* 获取待展示弹窗
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
CouponPopupRespVO
getPendingPopup
(
Integer
accountId
)
{
LocalDateTime
now
=
LocalDateTime
.
now
();
...
...
@@ -73,6 +78,9 @@ public class CouponAccountService {
return
null
;
}
// 将该用户下所有弹窗通知置为已读
markAllPopupsAsRead
(
accountId
);
// 构建弹窗响应
CouponPopupRespVO
popupVO
=
new
CouponPopupRespVO
();
popupVO
.
setPopupType
(
determinePopupType
(
pendingCoupons
));
...
...
@@ -84,6 +92,23 @@ public class CouponAccountService {
}
/**
* 将用户所有弹窗通知置为已读
*
* @param accountId 用户 ID
*/
private
void
markAllPopupsAsRead
(
Integer
accountId
)
{
LocalDateTime
now
=
LocalDateTime
.
now
();
// 批量更新状态为 0(待通知) 或 1(已展示) 的弹窗通知为 2(已确认)
int
updatedCount
=
popupNotificationRepository
.
batchUpdateStatusByAccountId
(
accountId
,
0
,
2
,
DeleteFlag
.
NOT_DELETED
.
getCode
(),
now
);
updatedCount
+=
popupNotificationRepository
.
batchUpdateStatusByAccountId
(
accountId
,
1
,
2
,
DeleteFlag
.
NOT_DELETED
.
getCode
(),
now
);
if
(
updatedCount
>
0
)
{
log
.
info
(
"批量标记弹窗已读成功:accountId={}, updatedCount={}"
,
accountId
,
updatedCount
);
}
}
/**
* 确认弹窗已读
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
...
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