Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yd-csf
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
xingmin
yd-csf
Commits
8e9addf8
Commit
8e9addf8
authored
May 06, 2026
by
zhangxingmin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
push
parent
897ed66a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
10 deletions
+24
-10
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/MemberGradeConfigServiceImpl.java
+24
-10
No files found.
yd-csf-service/src/main/java/com/yd/csf/service/service/impl/MemberGradeConfigServiceImpl.java
View file @
8e9addf8
...
...
@@ -45,8 +45,18 @@ public class MemberGradeConfigServiceImpl extends ServiceImpl<MemberGradeConfigM
return
Collections
.
emptyMap
();
}
// 按 minValue 升序排序,确保后续匹配的稳定性
allGrades
.
sort
(
Comparator
.
comparing
(
MemberGradeConfig:
:
getMinValue
));
// 打印 min_value 为空的数据告警(业务上 min_value 应有值)
allGrades
.
stream
()
.
filter
(
g
->
g
.
getMinValue
()
==
null
)
.
forEach
(
g
->
log
.
error
(
"等级配置 {} 的 min_value 为空,请检查数据!"
,
g
.
getId
()));
// 按 min_value 升序,max_value 为 null 的排在最后(null 视为无穷大)
allGrades
.
sort
(
Comparator
.
comparing
(
MemberGradeConfig:
:
getMinValue
,
Comparator
.
nullsFirst
(
BigDecimal:
:
compareTo
))
.
thenComparing
(
MemberGradeConfig:
:
getMaxValue
,
Comparator
.
nullsLast
(
BigDecimal:
:
compareTo
))
);
// 构建结果 Map
Map
<
String
,
MemberGradeConfig
>
resultMap
=
new
HashMap
<>();
...
...
@@ -59,10 +69,10 @@ public class MemberGradeConfigServiceImpl extends ServiceImpl<MemberGradeConfigM
continue
;
}
// 在内存中匹配等级(左闭右开区间)
// 在内存中匹配等级(左闭右开区间
,null 表示无限制
)
MemberGradeConfig
matched
=
allGrades
.
stream
()
.
filter
(
g
->
g
.
getMinValue
().
compareTo
(
promotionValue
)
<=
0
&&
g
.
getMaxValue
().
compareTo
(
promotionValue
)
>
0
)
.
filter
(
g
->
(
g
.
getMinValue
()
==
null
||
g
.
getMinValue
().
compareTo
(
promotionValue
)
<=
0
)
&&
(
g
.
getMaxValue
()
==
null
||
g
.
getMaxValue
().
compareTo
(
promotionValue
)
>
0
)
)
.
findFirst
()
.
orElse
(
null
);
...
...
@@ -80,14 +90,17 @@ public class MemberGradeConfigServiceImpl extends ServiceImpl<MemberGradeConfigM
}
/**
* 检查等级区间是否有重叠
(用于运维告警)
* 检查等级区间是否有重叠
*/
private
void
checkGradeOverlap
(
List
<
MemberGradeConfig
>
allGrades
,
List
<
GradeQueryParam
>
paramList
)
{
//
简单检查:
遍历参数,统计每个积分值匹配到的配置数量,超过1则告警
// 遍历参数,统计每个积分值匹配到的配置数量,超过1则告警
for
(
GradeQueryParam
param
:
paramList
)
{
if
(
param
.
getPromotionValue
()
==
null
)
{
continue
;
}
long
count
=
allGrades
.
stream
()
.
filter
(
g
->
g
.
getMinValue
().
compareTo
(
param
.
getPromotionValue
())
<=
0
&&
g
.
getMaxValue
().
compareTo
(
param
.
getPromotionValue
())
>
0
)
.
filter
(
g
->
(
g
.
getMinValue
()
==
null
||
g
.
getMinValue
().
compareTo
(
param
.
getPromotionValue
())
<=
0
)
&&
(
g
.
getMaxValue
()
==
null
||
g
.
getMaxValue
().
compareTo
(
param
.
getPromotionValue
())
>
0
)
)
.
count
();
if
(
count
>
1
)
{
log
.
error
(
"配置错误:业务员 {} 的积分 {} 匹配到 {} 个等级配置,请检查区间重叠!"
,
...
...
@@ -95,4 +108,4 @@ public class MemberGradeConfigServiceImpl extends ServiceImpl<MemberGradeConfigM
}
}
}
}
}
\ No newline at end of file
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