Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
D
data-server
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
data-server
Commits
b56b10bd
Commit
b56b10bd
authored
Apr 08, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
定时任务优化
parent
412a09fe
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
101 additions
and
77 deletions
+101
-77
DayTaskServiceImpl.java
...ava/cn/wisenergy/service/app/impl/DayTaskServiceImpl.java
+72
-59
MonthTaskServiceImpl.java
...a/cn/wisenergy/service/app/impl/MonthTaskServiceImpl.java
+29
-18
No files found.
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/DayTaskServiceImpl.java
View file @
b56b10bd
...
...
@@ -200,7 +200,7 @@ public class DayTaskServiceImpl implements DayTaskService {
}
}
//4、更新账户月度
绩效
//4、更新账户月度
团队业绩
boolean
updateBool
=
accountManager
.
updateAccountPerformanceMonth
(
addList
,
updateList
);
if
(!
updateBool
)
{
return
R
.
ok
(
1
,
false
);
...
...
@@ -228,12 +228,20 @@ public class DayTaskServiceImpl implements DayTaskService {
Date
date
=
new
Date
();
String
yearMonth
=
DateUtil
.
convertDateToStr
(
date
,
PATTERN
);
//获取当月所有人业绩总额
List
<
OrderInfo
>
orderList
=
orderMapper
.
getByCreateTime
(
new
Date
());
if
(
CollectionUtils
.
isEmpty
(
orderList
))
{
return
R
.
ok
(
0
,
true
);
}
BigDecimal
totalMoney
=
new
BigDecimal
(
0
);
for
(
OrderInfo
orderInfo
:
orderList
)
{
totalMoney
=
totalMoney
.
add
(
orderInfo
.
getPayment
());
}
double
number
=
Math
.
floor
(
totalMoney
.
doubleValue
()
/
3980
/
12
);
//1、判断当前月是否是业绩开始的第一个月
List
<
TeamPerformance
>
teamPerformances
=
teamPerformanceMapper
.
getByBeforeTime
(
yearMonth
);
//获取当月所有人业绩总额
Double
totalMoney
=
teamPerformanceMapper
.
countByTime
(
yearMonth
);
double
number
=
Math
.
floor
(
totalMoney
/
3980
/
12
);
//2、集合为空 是业绩开始的第一个月
if
(
CollectionUtils
.
isEmpty
(
teamPerformances
))
{
if
(
number
!=
0
)
{
...
...
@@ -356,6 +364,7 @@ public class DayTaskServiceImpl implements DayTaskService {
if
(
null
!=
user
&&
!
StringUtils
.
isBlank
(
user
.
getBeInvitedCode
()))
{
user
=
usersMapper
.
getByBeInvitedCode
(
user
.
getBeInvitedCode
());
if
(
null
!=
user
)
{
//todo 被邀请码=1 或 888888
if
(
user
.
getBeInvitedCode
().
equals
(
user
.
getInviteCode
()))
{
return
;
}
...
...
@@ -396,8 +405,10 @@ public class DayTaskServiceImpl implements DayTaskService {
double
last
=
lastMonth
.
getMonthTeamPerformance
().
doubleValue
();
if
(
last
>=
month
)
{
growthRate
=
0.00
;
}
else
if
(
last
==
0
)
{
growthRate
=
0.00
;
}
else
{
growthRate
=
(
month
-
last
)
/
month
;
growthRate
=
(
month
-
last
)
/
last
;
}
}
teamVo
.
setGrowthRate
(
growthRate
);
...
...
@@ -446,62 +457,64 @@ public class DayTaskServiceImpl implements DayTaskService {
}
else
{
lastMonthAward
=
monthManure
.
getManureAward
();
}
if
(
moneyMonth
==
0
)
{
return
true
;
}
for
(
User
user
:
userList
)
{
if
(
moneyMonth
!=
0
)
{
//获取等级优惠百分比
MemberPercent
memberPercent
=
memberPercentMapper
.
getByLevelAndType
(
user
.
getUserLevel
(),
2
);
if
(
null
!=
memberPercent
)
{
//获取本月团队总金额
TeamPerformance
teamPerformance
=
teamPerformanceMapper
.
getByUserIdAndTime
(
user
.
getUserId
(),
yearMonth
);
//获取该等级团队总金额
Double
teamTotal
=
teamPerformanceMapper
.
countTeamMoney
(
user
.
getUserLevel
(),
yearMonth
);
if
(
null
!=
teamPerformance
&&
null
!=
teamTotal
)
{
double
month
=
teamPerformance
.
getMonthTeamPerformance
().
doubleValue
();
double
percent
=
memberPercent
.
getPercent
().
doubleValue
();
//计算收益
double
teamMoney
=
(
moneyMonth
+
lastMonthAward
)
*
3980
*
percent
*
month
;
DecimalFormat
df
=
new
DecimalFormat
(
"######0.00"
);
double
income
=
Double
.
parseDouble
(
df
.
format
(
teamMoney
/
teamTotal
));
//获取账户信息
AccountInfo
accountInfo
=
accountMapper
.
getByUserId
(
user
.
getUserId
());
BigDecimal
bigDecimal
=
new
BigDecimal
(
income
).
setScale
(
2
,
RoundingMode
.
HALF_UP
);
//获取本月培育奖信息
TradeRecord
tradeRecordMonth
=
tradeRecordMapper
.
getByUserIdAndTypeAndStatus
(
user
.
getUserId
(),
TradeRecordEnum
.
CULTIVATING_PRIZE
.
getCode
(),
new
Date
(),
TradeStatusEnum
.
NO_SETTLE_ACCOUNTS
.
getCode
());
BigDecimal
tradeMoney
=
new
BigDecimal
(
0
);
if
(
null
!=
tradeRecordMonth
)
{
tradeMoney
=
tradeRecordMonth
.
getMoney
();
}
//获取用户本月收益=可提现金额+ 本月肥料收益+培育奖收益
BigDecimal
performanceMonth
=
accountInfo
.
getExtractMoney
().
add
(
bigDecimal
).
add
(
tradeMoney
);
accountInfo
.
setEarningsMonth
(
performanceMonth
);
//获取用户上月总收益
LastMonthAccount
lastMonthAccount
=
lastAccountMapper
.
getByUserIdAndTime
(
user
.
getUserId
(),
yearMonthTime
);
BigDecimal
lastTotalMonth
;
if
(
null
==
lastMonthAccount
||
null
==
lastMonthAccount
.
getEarningsTotal
())
{
lastTotalMonth
=
new
BigDecimal
(
"0.00"
);
}
else
{
lastTotalMonth
=
lastMonthAccount
.
getEarningsTotal
();
}
//用户总收益=上月总收益+本月收益
BigDecimal
performanceTotal
=
lastTotalMonth
.
add
(
performanceMonth
);
accountInfo
.
setEarningsTotal
(
performanceTotal
);
accountInfoList
.
add
(
accountInfo
);
//5、添加交易流水记录
TradeRecord
tradeRecord
=
new
TradeRecord
();
tradeRecord
.
setUserId
(
user
.
getUserId
());
tradeRecord
.
setTradeType
(
TradeRecordEnum
.
MONTHLY_FERTILIZER
.
getCode
());
tradeRecord
.
setTradeNo
(
null
);
tradeRecord
.
setStatus
(
TradeStatusEnum
.
NO_SETTLE_ACCOUNTS
.
getCode
());
tradeRecordList
.
add
(
tradeRecord
);
//获取等级优惠百分比
MemberPercent
memberPercent
=
memberPercentMapper
.
getByLevelAndType
(
user
.
getUserLevel
(),
2
);
if
(
null
!=
memberPercent
)
{
//获取本月团队总金额
TeamPerformance
teamPerformance
=
teamPerformanceMapper
.
getByUserIdAndTime
(
user
.
getUserId
(),
yearMonth
);
//获取该等级团队总金额
Double
teamTotal
=
teamPerformanceMapper
.
countTeamMoney
(
user
.
getUserLevel
(),
yearMonth
);
if
(
null
!=
teamPerformance
&&
null
!=
teamTotal
)
{
double
month
=
teamPerformance
.
getMonthTeamPerformance
().
doubleValue
();
double
percent
=
memberPercent
.
getPercent
().
doubleValue
();
//计算收益 todo
double
teamMoney
=
((
moneyMonth
*
3980
)
+
lastMonthAward
)
*
percent
*
month
;
DecimalFormat
df
=
new
DecimalFormat
(
"######0.00"
);
double
income
=
Double
.
parseDouble
(
df
.
format
(
teamMoney
/
teamTotal
));
//获取账户信息
AccountInfo
accountInfo
=
accountMapper
.
getByUserId
(
user
.
getUserId
());
BigDecimal
bigDecimal
=
new
BigDecimal
(
income
).
setScale
(
2
,
RoundingMode
.
HALF_UP
);
//获取本月培育奖信息
TradeRecord
tradeRecordMonth
=
tradeRecordMapper
.
getByUserIdAndTypeAndStatus
(
user
.
getUserId
(),
TradeRecordEnum
.
CULTIVATING_PRIZE
.
getCode
(),
new
Date
(),
TradeStatusEnum
.
NO_SETTLE_ACCOUNTS
.
getCode
());
BigDecimal
tradeMoney
=
new
BigDecimal
(
0
);
if
(
null
!=
tradeRecordMonth
)
{
tradeMoney
=
tradeRecordMonth
.
getMoney
();
}
//获取用户本月收益=可提现金额+ 本月肥料收益+培育奖收益
BigDecimal
performanceMonth
=
accountInfo
.
getExtractMoney
().
add
(
bigDecimal
).
add
(
tradeMoney
);
accountInfo
.
setEarningsMonth
(
performanceMonth
);
//获取用户上月总收益
LastMonthAccount
lastMonthAccount
=
lastAccountMapper
.
getByUserIdAndTime
(
user
.
getUserId
(),
yearMonthTime
);
BigDecimal
lastTotalMonth
;
if
(
null
==
lastMonthAccount
||
null
==
lastMonthAccount
.
getEarningsTotal
())
{
lastTotalMonth
=
new
BigDecimal
(
"0.00"
);
}
else
{
lastTotalMonth
=
lastMonthAccount
.
getEarningsTotal
();
}
//用户总收益=上月总收益+本月收益
BigDecimal
performanceTotal
=
lastTotalMonth
.
add
(
performanceMonth
);
accountInfo
.
setEarningsTotal
(
performanceTotal
);
accountInfoList
.
add
(
accountInfo
);
//5、添加交易流水记录
TradeRecord
tradeRecord
=
new
TradeRecord
();
tradeRecord
.
setUserId
(
user
.
getUserId
());
tradeRecord
.
setTradeType
(
TradeRecordEnum
.
MONTHLY_FERTILIZER
.
getCode
());
tradeRecord
.
setTradeNo
(
null
);
tradeRecord
.
setStatus
(
TradeStatusEnum
.
NO_SETTLE_ACCOUNTS
.
getCode
());
tradeRecordList
.
add
(
tradeRecord
);
}
}
}
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/MonthTaskServiceImpl.java
View file @
b56b10bd
...
...
@@ -133,15 +133,15 @@ public class MonthTaskServiceImpl implements MonthTaskService {
continue
;
}
for
(
User
U
ser
:
userList
)
{
for
(
User
u
ser
:
userList
)
{
//3)、统计当前用户的上级用户团队绩效
//key 存在 当前用户团队绩效 + 上级用户团队绩效
if
(
tempMap
.
containsKey
(
U
ser
.
getUserId
()))
{
double
teamMoney
=
userCount
+
tempMap
.
get
(
U
ser
.
getUserId
());
tempMap
.
put
(
U
ser
.
getUserId
(),
teamMoney
);
if
(
tempMap
.
containsKey
(
u
ser
.
getUserId
()))
{
double
teamMoney
=
userCount
+
tempMap
.
get
(
u
ser
.
getUserId
());
tempMap
.
put
(
u
ser
.
getUserId
(),
teamMoney
);
}
else
{
//key 不存在,加入集合 当前用户团队绩效
tempMap
.
put
(
U
ser
.
getUserId
(),
userCount
);
tempMap
.
put
(
u
ser
.
getUserId
(),
userCount
);
}
}
}
...
...
@@ -178,7 +178,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
//5、获取所有用户,如果会员等级是黄金以上,计算月度收益
List
<
User
>
userList
=
usersMapper
.
getAllGoldUser
();
if
(
CollectionUtils
.
isEmpty
(
userList
))
{
//添加月度肥料剩余奖金
//添加月度肥料剩余奖金
todo /3980/12*3980*(黄金以上比列相加)
MonthManure
monthManure
=
new
MonthManure
();
monthManure
.
setManureAward
(
totalMoney
.
doubleValue
());
monthManure
.
setYearMonth
(
yearMonth
);
...
...
@@ -203,13 +203,21 @@ public class MonthTaskServiceImpl implements MonthTaskService {
log
.
info
(
"shop-mall[]MonthTaskServiceImpl[]performanceCount[]input.method"
);
Date
date
=
DateUtil
.
getLastMonth
(
new
Date
());
String
lastMonth
=
DateUtil
.
convertDateToStr
(
date
,
PATTERN
);
//获取当月所有人业绩总额
List
<
OrderInfo
>
orderList
=
orderMapper
.
getByCreateTime
(
date
);
if
(
CollectionUtils
.
isEmpty
(
orderList
))
{
return
R
.
ok
(
0
,
true
);
}
//获取上月月所有人业绩总额
BigDecimal
totalMoney
=
new
BigDecimal
(
0
);
for
(
OrderInfo
orderInfo
:
orderList
)
{
totalMoney
=
totalMoney
.
add
(
orderInfo
.
getPayment
());
}
double
number
=
Math
.
floor
(
totalMoney
.
doubleValue
()
/
3980
/
12
);
//1、判断上月是否是业绩开始的第一个月
List
<
TeamPerformance
>
teamPerformances
=
teamPerformanceMapper
.
getByBeforeTime
(
lastMonth
);
//获取上月月所有人业绩总额
Double
totalMoney
=
teamPerformanceMapper
.
countByTime
(
lastMonth
);
double
number
=
Math
.
floor
(
totalMoney
/
3980
/
12
);
//2、集合为空 是业绩开始的第一个月
if
(
CollectionUtils
.
isEmpty
(
teamPerformances
))
{
if
(
number
!=
0
)
{
...
...
@@ -523,15 +531,18 @@ public class MonthTaskServiceImpl implements MonthTaskService {
}
else
{
lastMonthAward
=
monthManure
.
getManureAward
();
}
moneyMonth
=
moneyMonth
+
lastMonthAward
;
//1、判断每个等级是否都有用户,没有用户的,记录下剩余奖金
MonthManure
manure
=
checkUserLevel
(
moneyMonth
);
MonthManure
manure
=
checkUserLevel
(
moneyMonth
,
lastMonthAward
);
//获取上月是否有月度剩余奖金信息
MonthManure
lastMonthManure
=
monthManureMapper
.
queryByTime
(
lastMonth
);
List
<
AccountInfo
>
accountInfoList
=
new
ArrayList
<>();
List
<
TradeRecord
>
tradeRecordList
=
new
ArrayList
<>();
if
(
moneyMonth
==
0
)
{
return
true
;
}
for
(
User
user
:
userList
)
{
if
(
moneyMonth
!=
0
)
{
//获取等级优惠百分比
...
...
@@ -547,7 +558,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
double
month
=
teamPerformance
.
getMonthTeamPerformance
().
doubleValue
();
double
percent
=
memberPercent
.
getPercent
().
doubleValue
();
//计算收益
double
income
=
moneyMonth
*
3980
*
percent
*
month
/
teamTotal
;
double
income
=
((
moneyMonth
*
3980
)
+
lastMonthAward
)
*
percent
*
month
/
teamTotal
;
//获取账户信息
AccountInfo
accountInfo
=
accountMapper
.
getByUserId
(
user
.
getUserId
());
...
...
@@ -595,7 +606,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
* @param moneyMonth 奖金总额
* @return 月度肥料奖金
*/
private
MonthManure
checkUserLevel
(
double
moneyMonth
)
{
private
MonthManure
checkUserLevel
(
double
moneyMonth
,
double
lastMonthAward
)
{
MonthManure
monthManure
=
new
MonthManure
();
double
total
=
0.00
;
//1、判断是否有黄金等级的用户
...
...
@@ -609,7 +620,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
//计算该等级剩余奖金
double
goldAward
;
if
(
moneyMonth
!=
0
)
{
goldAward
=
moneyMonth
*
3980
*
percent
;
goldAward
=
((
moneyMonth
*
3980
)
+
lastMonthAward
)
*
percent
;
total
=
total
+
goldAward
;
}
}
...
...
@@ -625,7 +636,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
//计算该等级剩余奖金
double
goldAward
;
if
(
moneyMonth
!=
0
)
{
goldAward
=
moneyMonth
*
3980
*
percent
;
goldAward
=
((
moneyMonth
*
3980
)
+
lastMonthAward
)
*
percent
;
total
=
total
+
goldAward
;
}
}
...
...
@@ -641,7 +652,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
//计算该等级剩余奖金
double
goldAward
;
if
(
moneyMonth
!=
0
)
{
goldAward
=
moneyMonth
*
3980
*
percent
;
goldAward
=
((
moneyMonth
*
3980
)
+
lastMonthAward
)
*
percent
;
total
=
total
+
goldAward
;
}
}
...
...
@@ -657,7 +668,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
//计算该等级剩余奖金
double
goldAward
;
if
(
moneyMonth
!=
0
)
{
goldAward
=
moneyMonth
*
3980
*
percent
;
goldAward
=
((
moneyMonth
*
3980
)
+
lastMonthAward
)
*
percent
;
total
=
total
+
goldAward
;
}
}
...
...
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