Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
shop-Mall
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
licc
shop-Mall
Commits
e26204ed
Commit
e26204ed
authored
Apr 07, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化最大进步奖
parent
6a860a91
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
118 additions
and
106 deletions
+118
-106
TeamPerformanceMapper.xml
...apper/src/main/resources/mapper/TeamPerformanceMapper.xml
+2
-1
AccountManager.java
...ain/java/cn/wisenergy/service/Manager/AccountManager.java
+31
-70
DayTaskServiceImpl.java
...ava/cn/wisenergy/service/app/impl/DayTaskServiceImpl.java
+53
-18
MonthTaskServiceImpl.java
...a/cn/wisenergy/service/app/impl/MonthTaskServiceImpl.java
+32
-17
No files found.
wisenergy-mapper/src/main/resources/mapper/TeamPerformanceMapper.xml
View file @
e26204ed
...
...
@@ -120,8 +120,9 @@
from
<include
refid=
"table"
/>
<where>
user_level>0
<if
test=
"yearMonth != null"
>
`year_month` = #{yearMonth}
and
`year_month` = #{yearMonth}
</if>
</where>
</select>
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/Manager/AccountManager.java
View file @
e26204ed
...
...
@@ -123,91 +123,52 @@ public class AccountManager {
/**
* 修改 或新增 删除 最大进步奖实体类
*
* @param
listVo
最新的进步奖 对象
* @param
addList
最新的进步奖 对象
* @param accountInfoList 要更新的最大进步奖账户收益
* @param prizes 上一次统计的进步奖 对象
*/
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Boolean
updateOrSavePrize
(
List
<
TeamPerformanceSortVo
>
listVo
,
List
<
AccountInfo
>
accountInfoList
,
List
<
ProgressPrize
>
prizes
,
int
flag
)
{
Date
date
=
new
Date
();
String
yearMonth
=
DateUtil
.
convertDateToStr
(
date
,
PATTERN
);
public
Boolean
updateOrSavePrize
(
List
<
AccountInfo
>
accountInfoList
,
List
<
ProgressPrize
>
prizes
,
List
<
ProgressPrize
>
addList
,
List
<
ProgressPrize
>
updateList
,
int
flag
)
{
//构造一个map key:userId value progressPrize
Map
<
String
,
ProgressPrize
>
map
=
new
HashMap
<>(
32
);
for
(
ProgressPrize
progressPrize
:
prizes
)
{
map
.
put
(
progressPrize
.
getUserId
(),
progressPrize
);
}
//1、存在的修改,不存在的新增,多余的,删除
List
<
String
>
userIds
=
prizes
.
stream
().
map
(
ProgressPrize:
:
getUserId
).
collect
(
Collectors
.
toList
());
List
<
ProgressPrize
>
deleteList
=
new
ArrayList
<>();
//1、判断 prizes 是否为空集合,是新增
//新增
if
(
CollectionUtils
.
isEmpty
(
prizes
))
{
for
(
TeamPerformanceSortVo
sortVo
:
listVo
)
{
String
userId
=
sortVo
.
getTeamPerformance
().
getUserId
();
ProgressPrize
progressPrize
=
new
ProgressPrize
();
progressPrize
.
setUserId
(
userId
);
progressPrize
.
setGrowthRate
(
sortVo
.
getGrowthRate
());
progressPrize
.
setAwardMoney
(
sortVo
.
getMonthPerformance
());
progressPrize
.
setYearMonth
(
yearMonth
);
int
count
=
progressPrizeMapper
.
add
(
progressPrize
);
if
(
count
==
0
)
{
return
false
;
}
}
}
else
{
//2、不为空。存在的修改,不存在的新增,多余的,删除
List
<
ProgressPrize
>
updateList
=
new
ArrayList
<>();
List
<
ProgressPrize
>
addList
=
new
ArrayList
<>();
List
<
String
>
userIds
=
prizes
.
stream
().
map
(
ProgressPrize:
:
getUserId
).
collect
(
Collectors
.
toList
());
//遍历 筛选出要修改、新增、删除 对象
for
(
TeamPerformanceSortVo
sortVo
:
listVo
)
{
if
(
userIds
.
contains
(
sortVo
.
getUserId
()))
{
//修改
ProgressPrize
prize
=
map
.
get
(
sortVo
.
getUserId
());
prize
.
setGrowthRate
(
sortVo
.
getGrowthRate
());
prize
.
setAwardMoney
(
sortVo
.
getMonthPerformance
());
updateList
.
add
(
prize
);
//移除要修改的
prizes
.
remove
(
prize
);
}
else
{
//新增
String
userId
=
sortVo
.
getTeamPerformance
().
getUserId
();
ProgressPrize
progress
=
new
ProgressPrize
();
progress
.
setUserId
(
userId
);
progress
.
setGrowthRate
(
sortVo
.
getGrowthRate
());
progress
.
setAwardMoney
(
sortVo
.
getMonthPerformance
());
progress
.
setYearMonth
(
yearMonth
);
addList
.
add
(
progress
);
}
//遍历:要删除的数据
for
(
ProgressPrize
progressPrize
:
prizes
)
{
if
(!
userIds
.
contains
(
progressPrize
.
getUserId
()))
{
deleteList
.
add
(
progressPrize
);
}
}
//剩余的是要删除的
List
<
ProgressPrize
>
deleteList
=
new
ArrayList
<>(
prizes
);
for
(
ProgressPrize
updatePrize
:
updateList
)
{
int
count
=
progressPrizeMapper
.
edit
(
updatePrize
);
log
.
info
(
"更新最大进步奖用户"
+
updatePrize
.
getUserId
()
+
"奖金为:"
+
updatePrize
.
getAwardMoney
());
if
(
count
==
0
)
{
return
false
;
}
for
(
ProgressPrize
deletePrize
:
deleteList
)
{
int
count
=
progressPrizeMapper
.
delById
(
deletePrize
.
getId
());
if
(
count
==
0
)
{
return
false
;
}
}
for
(
ProgressPrize
addPrize
:
addList
)
{
int
count
=
progressPrizeMapper
.
add
(
addPrize
);
log
.
info
(
"新增最大进步奖用户"
+
addPrize
.
getUserId
()
+
"奖金:"
+
addPrize
.
getAwardMoney
()
);
if
(
count
==
0
)
{
return
false
;
}
//更新
for
(
ProgressPrize
updatePrize
:
updateList
)
{
int
count
=
progressPrizeMapper
.
edit
(
updatePrize
);
log
.
info
(
"更新最大进步奖用户"
+
updatePrize
.
getUserId
()
+
"奖金为:"
+
updatePrize
.
getAwardMoney
());
if
(
count
==
0
)
{
return
false
;
}
}
for
(
ProgressPrize
deletePrize
:
deleteList
)
{
int
count
=
progressPrizeMapper
.
delById
(
deletePrize
.
getId
());
if
(
count
==
0
)
{
return
false
;
}
//新增
for
(
ProgressPrize
addPrize
:
addList
)
{
int
count
=
progressPrizeMapper
.
add
(
addPrize
);
log
.
info
(
"新增最大进步奖用户"
+
addPrize
.
getUserId
()
+
"奖金:"
+
addPrize
.
getAwardMoney
());
if
(
count
==
0
)
{
return
false
;
}
}
//3、添加账户获得的收益
for
(
AccountInfo
accountInfo
:
accountInfoList
)
{
accountMapper
.
edit
(
accountInfo
);
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/DayTaskServiceImpl.java
View file @
e26204ed
...
...
@@ -315,6 +315,9 @@ public class DayTaskServiceImpl implements DayTaskService {
return
R
.
ok
(
0
,
true
);
}
//如果用户的团队业绩不存在的,新增本月团队业绩
addTeamPerformance
(
userList
);
//4计算每个用户本月的业绩增长率 如果集合大于20 ,取前二十名,小于,取全部
List
<
TeamPerformanceSortVo
>
listVo
=
progressPrizeStatistics
(
userList
);
if
(
listVo
.
size
()
>=
TWENTY
)
{
...
...
@@ -399,7 +402,6 @@ public class DayTaskServiceImpl implements DayTaskService {
}
teamVo
.
setGrowthRate
(
growthRate
);
double
monthPerformance
;
assert
teamPerformance
!=
null
;
if
(
null
==
teamPerformance
.
getMonthTeamPerformance
())
{
monthPerformance
=
0.00
;
}
else
{
...
...
@@ -516,42 +518,75 @@ public class DayTaskServiceImpl implements DayTaskService {
private
boolean
totalPerformanceIncome
(
List
<
TeamPerformanceSortVo
>
listVo
,
double
number
,
double
total
)
{
//要更新的账户列表
List
<
AccountInfo
>
updateAccountList
=
new
ArrayList
<>();
String
yearMonth
=
DateUtil
.
convertDateToStr
(
new
Date
(),
"yyyy-MM"
);
BigDecimal
sum
=
new
BigDecimal
(
0
);
for
(
int
i
=
0
;
i
<
listVo
.
size
();
i
++)
{
String
userId
=
listVo
.
get
(
i
).
getTeamPerformance
().
getUserId
();
Integer
userLevel
=
listVo
.
get
(
i
).
getTeamPerformance
().
getUserLevel
();
List
<
ProgressPrize
>
addList
=
new
ArrayList
<>();
List
<
ProgressPrize
>
updateList
=
new
ArrayList
<>();
for
(
TeamPerformanceSortVo
teamVo
:
listVo
)
{
String
userId
=
teamVo
.
getTeamPerformance
().
getUserId
();
Integer
userLevel
=
teamVo
.
getTeamPerformance
().
getUserLevel
();
//获取最大进步奖 百分比
MemberPercent
memberPercent
=
memberPercentMapper
.
getByLevelAndType
(
userLevel
,
3
);
//计算收益
double
userTeamPerformance
=
listVo
.
get
(
i
)
.
getTeamPerformance
().
getMonthTeamPerformance
().
doubleValue
();
double
userTeamPerformance
=
teamVo
.
getTeamPerformance
().
getMonthTeamPerformance
().
doubleValue
();
double
percent
=
memberPercent
.
getPercent
().
doubleValue
();
double
income
=
number
*
3980
*
percent
*
userTeamPerformance
/
total
;
//获取账户信息
AccountInfo
accountInfo
=
accountMapper
.
getByUserId
(
userId
);
BigDecimal
bigDecimal
;
if
(
i
==
listVo
.
size
()
-
1
)
{
bigDecimal
=
new
BigDecimal
(
total
).
subtract
(
sum
);
//用户月收益 =其他收益+最大进步奖收益
BigDecimal
earningsMonth
=
accountInfo
.
getEarningsMonth
().
add
(
BigDecimal
.
valueOf
(
income
));
accountInfo
.
setEarningsMonth
(
earningsMonth
);
//用户总收益 =其他总收益 + 最大进步奖收益
BigDecimal
earningsTotal
=
accountInfo
.
getEarningsTotal
().
add
(
BigDecimal
.
valueOf
(
income
));
accountInfo
.
setEarningsTotal
(
earningsTotal
);
updateAccountList
.
add
(
accountInfo
);
//最大进步奖信息
ProgressPrize
progressPrize
=
progressPrizeMapper
.
getByUserIdYearMonth
(
userId
,
yearMonth
);
if
(
null
==
progressPrize
)
{
//新增
ProgressPrize
addPrize
=
new
ProgressPrize
();
addPrize
.
setAwardMoney
(
income
);
addPrize
.
setYearMonth
(
yearMonth
);
addPrize
.
setGrowthRate
(
0.0
);
addPrize
.
setUserId
(
userId
);
addList
.
add
(
addPrize
);
}
else
{
bigDecimal
=
accountInfo
.
getEarningsMonth
().
add
(
new
BigDecimal
(
income
));
sum
=
sum
.
add
(
new
BigDecimal
(
income
));
progressPrize
.
setGrowthRate
(
teamVo
.
getGrowthRate
());
progressPrize
.
setAwardMoney
(
income
);
progressPrize
.
setGrowthRate
(
teamVo
.
getGrowthRate
());
updateList
.
add
(
progressPrize
);
}
accountInfo
.
setEarningsMonth
(
bigDecimal
);
updateAccountList
.
add
(
accountInfo
);
}
//判断本月是否有最大进步奖数据 无,新增 有,修改或删除
Date
date
=
new
Date
();
String
yearMonth
=
DateUtil
.
convertDateToStr
(
date
,
PATTERN
);
//获取本月已经存在的最大进步奖列表
List
<
ProgressPrize
>
prizes
=
progressPrizeMapper
.
getByYearMonth
(
yearMonth
);
//修改或保存最大进步奖信息
// flag 1: 日定时任务 2:月定时任务
int
flag
=
1
;
return
accountManager
.
updateOrSavePrize
(
listVo
,
updateAccountList
,
prizes
,
flag
);
return
accountManager
.
updateOrSavePrize
(
updateAccountList
,
prizes
,
addList
,
updateList
,
flag
);
}
private
void
addTeamPerformance
(
List
<
User
>
userList
)
{
String
yearMonth
=
DateUtil
.
convertDateToStr
(
new
Date
(),
"yyyy-MM"
);
if
(!
CollectionUtils
.
isEmpty
(
userList
))
{
for
(
User
user
:
userList
)
{
//获取团队业绩信息
TeamPerformance
teamPerformance
=
teamPerformanceMapper
.
getByUserIdAndTime
(
user
.
getUserId
(),
yearMonth
);
if
(
null
==
teamPerformance
)
{
TeamPerformance
addTeam
=
new
TeamPerformance
();
addTeam
.
setMonthTeamPerformance
(
new
BigDecimal
(
0
));
addTeam
.
setYearMonth
(
yearMonth
);
addTeam
.
setUserLevel
(
user
.
getUserLevel
());
addTeam
.
setUserId
(
user
.
getUserId
());
teamPerformanceMapper
.
add
(
addTeam
);
}
}
}
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/MonthTaskServiceImpl.java
View file @
e26204ed
...
...
@@ -735,41 +735,56 @@ public class MonthTaskServiceImpl implements MonthTaskService {
private
boolean
totalPerformanceIncome
(
List
<
TeamPerformanceSortVo
>
listVo
,
double
number
,
double
total
)
{
//要更新的账户列表
List
<
AccountInfo
>
updateAccountList
=
new
ArrayList
<>();
Date
lastMonth
=
DateUtil
.
getLastMonth
(
new
Date
());
String
yearMonth
=
DateUtil
.
convertDateToStr
(
lastMonth
,
PATTERN
);
List
<
ProgressPrize
>
addList
=
new
ArrayList
<>();
List
<
ProgressPrize
>
updateList
=
new
ArrayList
<>();
BigDecimal
sum
=
new
BigDecimal
(
0
);
for
(
int
i
=
0
;
i
<
listVo
.
size
();
i
++)
{
String
userId
=
listVo
.
get
(
i
).
getTeamPerformance
().
getUserId
();
Integer
userLevel
=
listVo
.
get
(
i
).
getTeamPerformance
().
getUserLevel
();
for
(
TeamPerformanceSortVo
teamPerformanceSortVo
:
listVo
)
{
String
userId
=
teamPerformanceSortVo
.
getTeamPerformance
().
getUserId
();
Integer
userLevel
=
teamPerformanceSortVo
.
getTeamPerformance
().
getUserLevel
();
//获取最大进步奖 百分比
MemberPercent
memberPercent
=
memberPercentMapper
.
getByLevelAndType
(
userLevel
,
3
);
//计算收益
double
userTeamPerformance
=
listVo
.
get
(
i
)
.
getTeamPerformance
().
getMonthTeamPerformance
().
doubleValue
();
double
userTeamPerformance
=
teamPerformanceSortVo
.
getTeamPerformance
().
getMonthTeamPerformance
().
doubleValue
();
double
percent
=
memberPercent
.
getPercent
().
doubleValue
();
double
income
=
number
*
3980
*
percent
*
userTeamPerformance
/
total
;
//获取账户信息
AccountInfo
accountInfo
=
accountMapper
.
getByUserId
(
userId
);
BigDecimal
bigDecimal
;
if
(
i
==
listVo
.
size
()
-
1
)
{
bigDecimal
=
new
BigDecimal
(
total
).
subtract
(
sum
);
//用户月收益 =其他收益+最大进步奖收益
BigDecimal
earningsMonth
=
accountInfo
.
getEarningsMonth
().
add
(
BigDecimal
.
valueOf
(
income
));
accountInfo
.
setEarningsMonth
(
earningsMonth
);
//用户总收益 =其他总收益 + 最大进步奖收益
BigDecimal
earningsTotal
=
accountInfo
.
getEarningsTotal
().
add
(
BigDecimal
.
valueOf
(
income
));
accountInfo
.
setEarningsTotal
(
earningsTotal
);
updateAccountList
.
add
(
accountInfo
);
//最大进步奖信息
ProgressPrize
progressPrize
=
progressPrizeMapper
.
getByUserIdYearMonth
(
userId
,
yearMonth
);
if
(
null
==
progressPrize
)
{
//新增
ProgressPrize
addPrize
=
new
ProgressPrize
();
addPrize
.
setAwardMoney
(
income
);
addPrize
.
setYearMonth
(
yearMonth
);
addPrize
.
setGrowthRate
(
0.0
);
addPrize
.
setUserId
(
userId
);
addList
.
add
(
addPrize
);
}
else
{
bigDecimal
=
accountInfo
.
getEarningsMonth
().
add
(
new
BigDecimal
(
income
));
sum
=
sum
.
add
(
new
BigDecimal
(
income
));
progressPrize
.
setGrowthRate
(
teamPerformanceSortVo
.
getGrowthRate
());
progressPrize
.
setAwardMoney
(
income
);
updateList
.
add
(
progressPrize
);
}
accountInfo
.
setEarningsMonth
(
bigDecimal
);
updateAccountList
.
add
(
accountInfo
);
}
//判断本月是否有最大进步奖数据 无,新增 有,修改或删除
Date
date
=
new
Date
();
String
yearMonth
=
DateUtil
.
convertDateToStr
(
date
,
PATTERN
);
//获取本月存在的最大进步奖列表
List
<
ProgressPrize
>
prizes
=
progressPrizeMapper
.
getByYearMonth
(
yearMonth
);
//修改或保存最大进步奖信息
// flag 1: 日定时任务 2:月定时任务
int
flag
=
2
;
return
accountManager
.
updateOrSavePrize
(
listVo
,
updateAccountList
,
prizes
,
flag
);
return
accountManager
.
updateOrSavePrize
(
updateAccountList
,
prizes
,
addList
,
updateList
,
flag
);
}
}
\ 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