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
e6edc2de
Commit
e6edc2de
authored
Mar 12, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
月度肥料接口自测优化2
parent
5628e33e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
118 additions
and
73 deletions
+118
-73
AccountManager.java
...ain/java/cn/wisenergy/service/Manager/AccountManager.java
+14
-3
AccountServiceImpl.java
...ava/cn/wisenergy/service/app/impl/AccountServiceImpl.java
+43
-32
MonthTaskServiceImpl.java
...a/cn/wisenergy/service/app/impl/MonthTaskServiceImpl.java
+61
-38
No files found.
wisenergy-service/src/main/java/cn/wisenergy/service/Manager/AccountManager.java
View file @
e6edc2de
...
@@ -94,9 +94,20 @@ public class AccountManager {
...
@@ -94,9 +94,20 @@ public class AccountManager {
}
}
@Transactional
(
rollbackFor
=
Exception
.
class
)
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
updateAccountPerformanceMonth
(
List
<
TeamPerformance
>
list
)
{
public
void
updateAccountPerformanceMonth
(
List
<
TeamPerformance
>
addList
,
List
<
TeamPerformance
>
updateList
)
{
for
(
TeamPerformance
teamPerformance
:
list
)
{
teamPerformanceMapper
.
edit
(
teamPerformance
);
//1、新增
if
(!
CollectionUtils
.
isEmpty
(
addList
))
{
for
(
TeamPerformance
teamPerformance
:
addList
)
{
teamPerformanceMapper
.
add
(
teamPerformance
);
}
}
//2、更新
if
(!
CollectionUtils
.
isEmpty
(
updateList
))
{
for
(
TeamPerformance
teamPerformance
:
updateList
)
{
teamPerformanceMapper
.
edit
(
teamPerformance
);
}
}
}
}
}
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/AccountServiceImpl.java
View file @
e6edc2de
...
@@ -151,51 +151,62 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
...
@@ -151,51 +151,62 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, AccountInfo>
totalMoney
=
totalMoney
.
add
(
orderInfo
.
getPayment
());
totalMoney
=
totalMoney
.
add
(
orderInfo
.
getPayment
());
}
}
//累计用户和上级用户-团队业绩
Map
<
String
,
Double
>
tempMap
=
new
HashMap
<>();
//遍历订单
//遍历订单
for
(
Map
.
Entry
<
String
,
Double
>
entity
:
map
.
entrySet
())
{
for
(
Map
.
Entry
<
String
,
Double
>
entity
:
map
.
entrySet
())
{
List
<
TeamPerformance
>
teamPerformances
=
new
ArrayList
<>();
String
userId
=
entity
.
getKey
();
//获取用户信息
//1)、统计当前用户月度业绩
User
user
=
usersMapper
.
getByUserId
(
entity
.
getKey
());
double
userCount
=
entity
.
getValue
();
if
(
null
==
user
)
{
tempMap
.
put
(
userId
,
userCount
);
continue
;
}
//获取团队业绩信息
TeamPerformance
teamPerformance
=
teamPerformanceMapper
.
getByUserIdAndTime
(
user
.
getUserId
(),
yearMonth
);
if
(
null
==
teamPerformance
)
{
continue
;
}
//1、统计当前用户月度业绩
//2)、获取当前用户的上级用户列表
BigDecimal
userCount
=
BigDecimal
.
valueOf
(
entity
.
getValue
());
List
<
User
>
userList
=
getByList
(
userId
);
teamPerformance
.
setMonthTeamPerformance
(
userCount
);
teamPerformances
.
add
(
teamPerformance
);
//2、获取当前用户的上级用户列表 todo 邀请码等于一个固定值,停止 等于两个值 七位XXXXXXX 和 7777777
List
<
User
>
userList
=
getByList
(
user
.
getUserId
());
if
(
CollectionUtils
.
isEmpty
(
userList
))
{
if
(
CollectionUtils
.
isEmpty
(
userList
))
{
//更新当前用户月度业绩
accountManager
.
updateAccountPerformanceMonth
(
teamPerformances
);
continue
;
continue
;
}
}
for
(
User
userInfo
:
userList
)
{
for
(
User
userInfo
:
userList
)
{
//3、统计当前用户上级月度绩效
//3)、统计当前用户的上级用户团队绩效
TeamPerformance
team
=
teamPerformanceMapper
.
getByUserIdAndTime
(
userInfo
.
getUserId
(),
yearMonth
);
//key 存在 当前用户团队绩效 + 上级用户团队绩效
if
(
null
==
team
)
{
if
(
tempMap
.
containsKey
(
userInfo
.
getUserId
()))
{
continue
;
double
teamMoney
=
userCount
+
map
.
get
(
userInfo
.
getUserId
());
map
.
put
(
userInfo
.
getUserId
(),
teamMoney
);
}
else
{
//key 不存在,加入集合 当前用户团队绩效
map
.
put
(
userInfo
.
getUserId
(),
userCount
);
}
}
//1、统计当前用户月度绩效
BigDecimal
monthCount
=
team
.
getMonthTeamPerformance
().
add
(
userCount
);
log
.
info
(
"当前用户月度绩效:"
+
monthCount
);
team
.
setMonthTeamPerformance
(
monthCount
);
teamPerformances
.
add
(
team
);
}
}
}
//4、更新账户月度绩效
//3、获取用户当月绩效信息 新增 or 更新
accountManager
.
updateAccountPerformanceMonth
(
teamPerformances
);
List
<
TeamPerformance
>
addList
=
new
ArrayList
<>();
List
<
TeamPerformance
>
updateList
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
Double
>
entity
:
tempMap
.
entrySet
())
{
//获取团队业绩信息
TeamPerformance
teamPerformance
=
teamPerformanceMapper
.
getByUserIdAndTime
(
entity
.
getKey
(),
yearMonth
);
if
(
null
==
teamPerformance
)
{
//获取用户信息
User
user
=
usersMapper
.
getByUserId
(
entity
.
getKey
());
//添加用户团队业绩信息
TeamPerformance
performance
=
new
TeamPerformance
();
performance
.
setUserId
(
user
.
getUserId
());
performance
.
setMonthTeamPerformance
(
BigDecimal
.
valueOf
(
entity
.
getValue
()));
performance
.
setUserLevel
(
user
.
getUserLevel
());
performance
.
setYearMonth
(
yearMonth
);
teamPerformanceMapper
.
add
(
performance
);
addList
.
add
(
performance
);
}
else
{
teamPerformance
.
setMonthTeamPerformance
(
BigDecimal
.
valueOf
(
entity
.
getValue
()));
updateList
.
add
(
teamPerformance
);
}
}
}
//4、更新账户月度绩效
accountManager
.
updateAccountPerformanceMonth
(
addList
,
updateList
);
//5、获取所有用户,如果会员等级是黄金以上,计算月度收益
//5、获取所有用户,如果会员等级是黄金以上,计算月度收益
List
<
User
>
userList
=
usersMapper
.
getAllGoldUser
();
List
<
User
>
userList
=
usersMapper
.
getAllGoldUser
();
if
(
CollectionUtils
.
isEmpty
(
userList
))
{
if
(
CollectionUtils
.
isEmpty
(
userList
))
{
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/MonthTaskServiceImpl.java
View file @
e6edc2de
...
@@ -84,61 +84,84 @@ public class MonthTaskServiceImpl implements MonthTaskService {
...
@@ -84,61 +84,84 @@ public class MonthTaskServiceImpl implements MonthTaskService {
Date
date
=
new
Date
();
Date
date
=
new
Date
();
String
yearMonth
=
DateUtil
.
convertDateToStr
(
date
,
PATTERN
);
String
yearMonth
=
DateUtil
.
convertDateToStr
(
date
,
PATTERN
);
//计算
当
月所有订单成交额
//计算
上
月所有订单成交额
BigDecimal
totalMoney
=
new
BigDecimal
(
0
);
BigDecimal
totalMoney
=
new
BigDecimal
(
0
);
for
(
OrderInfo
orderInfo
:
list
)
{
//判断是否是本月
boolean
bool
=
publicManager
.
isThisMonth
(
orderInfo
.
getCreateTime
(),
PATTERN
);
if
(
bool
&&
orderInfo
.
getMonthlyTaskStatus
()
==
0
)
{
totalMoney
=
totalMoney
.
add
(
orderInfo
.
getPayment
());
}
}
//遍历订单 订单状态创建时间,当月时间小于当前时间
//统计出出每个用户上月订单成交额 key:userId value:用户上月订单成交额
Map
<
String
,
Double
>
map
=
new
HashMap
<>();
for
(
OrderInfo
orderInfo
:
list
)
{
for
(
OrderInfo
orderInfo
:
list
)
{
long
createTime
=
orderInfo
.
getCreated
().
getTime
();
String
userId
=
orderInfo
.
getBuyerId
();
long
time
=
System
.
currentTimeMillis
();
double
payMoney
=
orderInfo
.
getPayment
().
doubleValue
();
//获取用户信息
//key 存在 累加订单金额 到 value
User
user
=
usersMapper
.
selectById
(
orderInfo
.
getBuyerId
());
if
(
map
.
containsKey
(
userId
))
{
if
(
null
==
user
)
{
double
money
=
payMoney
+
map
.
get
(
orderInfo
.
getBuyerId
());
continue
;
map
.
put
(
orderInfo
.
getBuyerId
(),
money
);
}
else
{
//key 不存在,加入集合
map
.
put
(
userId
,
payMoney
);
}
}
List
<
TeamPerformance
>
teamPerformances
=
new
ArrayList
<>();
//累加所以订单成交额
totalMoney
=
totalMoney
.
add
(
orderInfo
.
getPayment
());
}
//获取团队业绩信息
//累计用户和上级用户-团队业绩
TeamPerformance
teamPerformance
=
teamPerformanceMapper
.
getByUserIdAndTime
(
user
.
getUserId
(),
yearMonth
);
Map
<
String
,
Double
>
tempMap
=
new
HashMap
<>();
if
(
null
==
teamPerformance
)
{
continue
;
}
//1、统计当前用户月度业绩
//遍历订单
BigDecimal
userCount
=
teamPerformance
.
getMonthTeamPerformance
().
add
(
orderInfo
.
getPayment
());
for
(
Map
.
Entry
<
String
,
Double
>
entity
:
map
.
entrySet
())
{
teamPerformance
.
setMonthTeamPerformance
(
userCount
);
String
userId
=
entity
.
getKey
();
teamPerformances
.
add
(
teamPerformance
);
//1)、统计当前用户月度业绩
double
userCount
=
entity
.
getValue
();
tempMap
.
put
(
userId
,
userCount
);
//2
、获取当前用户的上级用户列表 todo 邀请码等于一个固定值,停止 等于两个值 七位XXXXXXX 和 7777777
//2
)、获取当前用户的上级用户列表
List
<
User
>
userList
=
accountService
.
getByList
(
user
.
getUserId
()
);
List
<
User
>
userList
=
accountService
.
getByList
(
user
Id
);
if
(
CollectionUtils
.
isEmpty
(
userList
))
{
if
(
CollectionUtils
.
isEmpty
(
userList
))
{
continue
;
continue
;
}
}
//3、统计当前用户上级月度绩效
for
(
User
userInfo
:
userList
)
{
for
(
User
userInfo
:
userList
)
{
TeamPerformance
team
=
teamPerformanceMapper
.
getByUserIdAndTime
(
userInfo
.
getUserId
(),
yearMonth
);
//3)、统计当前用户的上级用户团队绩效
if
(
null
==
team
)
{
//key 存在 当前用户团队绩效 + 上级用户团队绩效
continue
;
if
(
tempMap
.
containsKey
(
userInfo
.
getUserId
()))
{
double
teamMoney
=
userCount
+
map
.
get
(
userInfo
.
getUserId
());
map
.
put
(
userInfo
.
getUserId
(),
teamMoney
);
}
else
{
//key 不存在,加入集合 当前用户团队绩效
map
.
put
(
userInfo
.
getUserId
(),
userCount
);
}
}
//1)、统计当前用户月度绩效
BigDecimal
monthCount
=
team
.
getMonthTeamPerformance
().
add
(
orderInfo
.
getPayment
());
team
.
setMonthTeamPerformance
(
monthCount
);
teamPerformances
.
add
(
team
);
}
}
}
//4、更新账户月度绩效
//3、获取用户上月绩效信息 新增 or 更新
accountManager
.
updateAccountPerformanceMonth
(
teamPerformances
);
List
<
TeamPerformance
>
addList
=
new
ArrayList
<>();
List
<
TeamPerformance
>
updateList
=
new
ArrayList
<>();
for
(
Map
.
Entry
<
String
,
Double
>
entity
:
tempMap
.
entrySet
())
{
//获取团队业绩信息
TeamPerformance
teamPerformance
=
teamPerformanceMapper
.
getByUserIdAndTime
(
entity
.
getKey
(),
yearMonth
);
if
(
null
==
teamPerformance
)
{
//获取用户信息
User
user
=
usersMapper
.
getByUserId
(
entity
.
getKey
());
//添加用户团队业绩信息
TeamPerformance
performance
=
new
TeamPerformance
();
performance
.
setUserId
(
user
.
getUserId
());
performance
.
setMonthTeamPerformance
(
BigDecimal
.
valueOf
(
entity
.
getValue
()));
performance
.
setUserLevel
(
user
.
getUserLevel
());
performance
.
setYearMonth
(
yearMonth
);
teamPerformanceMapper
.
add
(
performance
);
addList
.
add
(
performance
);
}
else
{
teamPerformance
.
setMonthTeamPerformance
(
BigDecimal
.
valueOf
(
entity
.
getValue
()));
updateList
.
add
(
teamPerformance
);
}
}
}
//4、更新账户月度绩效
accountManager
.
updateAccountPerformanceMonth
(
addList
,
updateList
);
//5、获取所有用户,如果会员等级是黄金以上,计算月度收益
//5、获取所有用户,如果会员等级是黄金以上,计算月度收益
List
<
User
>
userList
=
usersMapper
.
getAllGoldUser
();
List
<
User
>
userList
=
usersMapper
.
getAllGoldUser
();
if
(
CollectionUtils
.
isEmpty
(
userList
))
{
if
(
CollectionUtils
.
isEmpty
(
userList
))
{
...
@@ -153,7 +176,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
...
@@ -153,7 +176,7 @@ public class MonthTaskServiceImpl implements MonthTaskService {
return
R
.
ok
(
0
,
true
);
return
R
.
ok
(
0
,
true
);
}
}
//
7
、计算收益
//
6
、计算收益
boolean
bool
=
monthlyIncome
(
totalMoney
,
userList
);
boolean
bool
=
monthlyIncome
(
totalMoney
,
userList
);
if
(!
bool
)
{
if
(!
bool
)
{
return
R
.
ok
(
1
,
false
);
return
R
.
ok
(
1
,
false
);
...
...
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