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 87a116b8
authored
May 18, 2026
by
章家宝
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
feat:代码优化,发送全部用户防止oom
1 parent
d2e525c2
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
2 deletions
aus-core/src/main/java/com/glsx/usedcar/module/coupon/service/CouponActivityService.java
aus-core/src/main/java/com/glsx/usedcar/module/coupon/service/CouponActivityService.java
View file @
87a116b
...
...
@@ -1117,8 +1117,8 @@ public class CouponActivityService {
}
switch
(
targetType
)
{
case
ALL_CERTIFIED:
// 全部
认证用户,过滤掉已禁用账户,与标签分支行为保持一致
return
toAccountMobileMap
(
accountDao
.
findByCertifiedState
(
Account
.
CertifiedState
.
CERTIFIED
),
true
);
// 全部
用户,分页查询避免大数据量导致 OOM
return
resolveAllCertifiedTargets
(
);
case
SPECIFIED_MOBILE:
return
resolveSpecifiedMobileTargets
(
activity
,
targetPhoneNumbers
);
case
TAG:
...
...
@@ -1129,6 +1129,41 @@ public class CouponActivityService {
}
}
/**
* 解析全部认证用户目标账户(分页查询,避免大数据量 OOM)
*/
private
Map
<
Integer
,
String
>
resolveAllCertifiedTargets
()
{
Map
<
Integer
,
String
>
result
=
new
LinkedHashMap
<>();
int
page
=
0
;
int
totalPages
;
long
totalCount
=
0
;
int
size
=
1000
;
do
{
Pageable
pageable
=
PageRequest
.
of
(
page
,
size
);
Page
<
Account
>
accountPage
=
accountDao
.
findAll
(
pageable
);
totalPages
=
accountPage
.
getTotalPages
();
if
(
page
==
0
)
{
totalCount
=
accountPage
.
getTotalElements
();
log
.
info
(
"开始分页查询全部认证用户,总用户数={},总页数={},每页数量={}"
,
totalCount
,
totalPages
,
size
);
}
List
<
Account
>
accounts
=
accountPage
.
getContent
();
for
(
Account
account
:
accounts
)
{
if
(
account
!=
null
&&
account
.
isEnabled
())
{
result
.
putIfAbsent
(
account
.
getAccountId
(),
account
.
getMobile
());
}
}
page
++;
log
.
debug
(
"已处理第 {}/{} 页,当前累计用户数={}"
,
page
,
totalPages
,
result
.
size
());
}
while
(
page
<
totalPages
);
log
.
info
(
"全部认证用户查询完成,有效用户数={}"
,
result
.
size
());
return
result
;
}
private
Map
<
Integer
,
String
>
resolveSpecifiedMobileTargets
(
CouponActivity
activity
,
List
<
String
>
targetPhoneNumbers
)
{
if
(
targetPhoneNumbers
==
null
||
targetPhoneNumbers
.
isEmpty
())
{
log
.
warn
(
"指定用户发放但未提供手机号列表:activityId={}"
,
activity
.
getActivityId
());
...
...
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