Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
browser-backend
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
Administrator
browser-backend
Commits
59c9cae9
Commit
59c9cae9
authored
Sep 18, 2020
by
xuxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
管理员界面-推广码下线查询 性能优化
parent
7d3e1115
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
8 deletions
+28
-8
AccountRepository.java
.../browserbackend/account/repository/AccountRepository.java
+2
-0
AdministratorServiceImpl.java
...ackend/account/service/impl/AdministratorServiceImpl.java
+26
-8
No files found.
src/main/java/com/edgec/browserbackend/account/repository/AccountRepository.java
View file @
59c9cae9
...
@@ -50,6 +50,8 @@ public interface AccountRepository extends MongoRepository<Account, String>, Acc
...
@@ -50,6 +50,8 @@ public interface AccountRepository extends MongoRepository<Account, String>, Acc
List
<
Account
>
findByPromotionCodeAndParentIsNull
(
String
code
);
List
<
Account
>
findByPromotionCodeAndParentIsNull
(
String
code
);
List
<
Account
>
findByPromotionCodeInAndParentIsNull
(
List
<
String
>
code
);
int
countByPromotionCodeAndParentIsNull
(
String
promotionCode
);
int
countByPromotionCodeAndParentIsNull
(
String
promotionCode
);
}
}
src/main/java/com/edgec/browserbackend/account/service/impl/AdministratorServiceImpl.java
View file @
59c9cae9
...
@@ -521,10 +521,10 @@ public class AdministratorServiceImpl implements AdministratorService {
...
@@ -521,10 +521,10 @@ public class AdministratorServiceImpl implements AdministratorService {
// promotion 用来存储所有用户的消费信息
// promotion 用来存储所有用户的消费信息
PromotionInfoDto
promotionInfoDto
=
new
PromotionInfoDto
();
PromotionInfoDto
promotionInfoDto
=
new
PromotionInfoDto
();
promotionInfoDto
.
setFirstLevelCommission
(
0
);
/*
promotionInfoDto.setFirstLevelCommission(0);
promotionInfoDto.setFirstLevelIps(0);
promotionInfoDto.setFirstLevelIps(0);
promotionInfoDto.setSecondLevelCommission(0);
promotionInfoDto.setSecondLevelCommission(0);
promotionInfoDto
.
setSecondLevelIps
(
0
);
promotionInfoDto.setSecondLevelIps(0);
*/
Account
finalAccount
=
account
;
Account
finalAccount
=
account
;
try
{
try
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
...
@@ -535,8 +535,8 @@ public class AdministratorServiceImpl implements AdministratorService {
...
@@ -535,8 +535,8 @@ public class AdministratorServiceImpl implements AdministratorService {
if
(
accounts
!=
null
&&
accounts
.
size
()
>
0
)
{
if
(
accounts
!=
null
&&
accounts
.
size
()
>
0
)
{
// 邀请的一级用户数
// 邀请的一级用户数
promotionInfoDto
.
setFirstLevelInvitedUsers
(
accounts
.
size
());
promotionInfoDto
.
setFirstLevelInvitedUsers
(
accounts
.
size
());
int
i
=
3
,
j
=
0
;
accounts
.
forEach
(
x
->
{
/*
accounts.forEach(x -> {
long start2 = System.currentTimeMillis();
long start2 = System.currentTimeMillis();
int[] arr1 = getCommissionAndIps(beginTime, endTime, x);
int[] arr1 = getCommissionAndIps(beginTime, endTime, x);
log.info("===>countPromotionInfos step-3-{} consume time {}", accounts.indexOf(x) + 1, (System.currentTimeMillis() - start2));
log.info("===>countPromotionInfos step-3-{} consume time {}", accounts.indexOf(x) + 1, (System.currentTimeMillis() - start2));
...
@@ -548,14 +548,14 @@ public class AdministratorServiceImpl implements AdministratorService {
...
@@ -548,14 +548,14 @@ public class AdministratorServiceImpl implements AdministratorService {
// 获取当前账户的下级账户
// 获取当前账户的下级账户
List<Account> secondPromotes = accountRepository.findByPromotionCodeAndParentIsNull(x.getPromotion().getCode());
List<Account> secondPromotes = accountRepository.findByPromotionCodeAndParentIsNull(x.getPromotion().getCode());
if (secondPromotes != null && secondPromotes.size() > 0) {
if (secondPromotes != null && secondPromotes.size() > 0) {
/*for (Account secondPromote : secondPromotes) {
*/
/*for (Account secondPromote : secondPromotes) {
// 将下级账户及下级账户的子账户中未过期的ip统计到 ipCount中
// 将下级账户及下级账户的子账户中未过期的ip统计到 ipCount中
long start3 = System.currentTimeMillis();
long start3 = System.currentTimeMillis();
int[] arr2 = getCommissionAndIps(beginTime, endTime, secondPromote);
int[] arr2 = getCommissionAndIps(beginTime, endTime, secondPromote);
log.info("===>countPromotionInfos step-3-{}-{} consume time {}", accounts.indexOf(x) + 1, secondPromotes.indexOf(secondPromote) + 1, (System.currentTimeMillis() - start3));
log.info("===>countPromotionInfos step-3-{}-{} consume time {}", accounts.indexOf(x) + 1, secondPromotes.indexOf(secondPromote) + 1, (System.currentTimeMillis() - start3));
promotionInfoDto.setSecondLevelCommission(promotionInfoDto.getSecondLevelCommission() + arr2[0]);
promotionInfoDto.setSecondLevelCommission(promotionInfoDto.getSecondLevelCommission() + arr2[0]);
promotionInfoDto.setSecondLevelIps(promotionInfoDto.getSecondLevelIps() + arr2[1]);
promotionInfoDto.setSecondLevelIps(promotionInfoDto.getSecondLevelIps() + arr2[1]);
}*/
}*/
/*
long start3 = System.currentTimeMillis();
long start3 = System.currentTimeMillis();
int[] arr2 = getCommissionAndIps(beginTime, endTime, secondPromotes.stream().map(Account::getName).collect(Collectors.toList()));
int[] arr2 = getCommissionAndIps(beginTime, endTime, secondPromotes.stream().map(Account::getName).collect(Collectors.toList()));
log.info("===>countPromotionInfos step-3-{}-{} consume time {}", accounts.indexOf(x) + 1, "1", (System.currentTimeMillis() - start3));
log.info("===>countPromotionInfos step-3-{}-{} consume time {}", accounts.indexOf(x) + 1, "1", (System.currentTimeMillis() - start3));
...
@@ -563,7 +563,25 @@ public class AdministratorServiceImpl implements AdministratorService {
...
@@ -563,7 +563,25 @@ public class AdministratorServiceImpl implements AdministratorService {
promotionInfoDto.setSecondLevelIps(promotionInfoDto.getSecondLevelIps() + arr2[1]);
promotionInfoDto.setSecondLevelIps(promotionInfoDto.getSecondLevelIps() + arr2[1]);
}
}
}
}
});
});*/
long
start2
=
System
.
currentTimeMillis
();
int
[]
arr1
=
getCommissionAndIps
(
beginTime
,
endTime
,
accounts
.
stream
().
map
(
Account:
:
getName
).
collect
(
Collectors
.
toList
()));
log
.
info
(
"===>countPromotionInfos step-3-1 consume time {}"
,
(
System
.
currentTimeMillis
()
-
start2
));
promotionInfoDto
.
setFirstLevelCommission
(
arr1
[
0
]);
promotionInfoDto
.
setFirstLevelIps
(
arr1
[
1
]);
List
<
String
>
codeList
=
accounts
.
stream
().
filter
(
x
->
x
.
getParent
()
==
null
).
map
(
x
->
x
.
getPromotion
().
getCode
()).
collect
(
Collectors
.
toList
());
if
(
finalAccount
.
getPromotion
().
isSale
())
{
List
<
Account
>
secondPromotes
=
accountRepository
.
findByPromotionCodeInAndParentIsNull
(
codeList
);
if
(
secondPromotes
!=
null
&&
secondPromotes
.
size
()
>
0
)
{
long
start3
=
System
.
currentTimeMillis
();
int
[]
arr2
=
getCommissionAndIps
(
beginTime
,
endTime
,
secondPromotes
.
stream
().
map
(
Account:
:
getName
).
collect
(
Collectors
.
toList
()));
log
.
info
(
"===>countPromotionInfos step-3-2 consume time {}"
,
(
System
.
currentTimeMillis
()
-
start3
));
promotionInfoDto
.
setSecondLevelCommission
(
arr2
[
0
]);
promotionInfoDto
.
setSecondLevelIps
(
arr2
[
1
]);
}
}
}
}
log
.
info
(
"===>countPromotionInfos step-4 consume time {}"
,
System
.
currentTimeMillis
()
-
start
);
log
.
info
(
"===>countPromotionInfos step-4 consume time {}"
,
System
.
currentTimeMillis
()
-
start
);
// 设置总ip
// 设置总ip
...
@@ -665,7 +683,7 @@ public class AdministratorServiceImpl implements AdministratorService {
...
@@ -665,7 +683,7 @@ public class AdministratorServiceImpl implements AdministratorService {
return
arr
;
return
arr
;
}
}
// 计算当前用户的
所有下级用户的消费 countAllByOwnerInAndIsDeletedAndValidTimeGreaterThan
// 计算当前用户的
购买的 所有ip 与 消费
private
int
[]
getCommissionAndIps
(
Date
beginTime
,
Date
endTime
,
List
<
String
>
nameList
)
{
private
int
[]
getCommissionAndIps
(
Date
beginTime
,
Date
endTime
,
List
<
String
>
nameList
)
{
Integer
ownIps
=
(
int
)
ipResourceRepository
.
countAllByOwnerInAndIsDeletedAndValidTimeGreaterThan
(
nameList
,
false
,
Instant
.
now
().
toEpochMilli
());
Integer
ownIps
=
(
int
)
ipResourceRepository
.
countAllByOwnerInAndIsDeletedAndValidTimeGreaterThan
(
nameList
,
false
,
Instant
.
now
().
toEpochMilli
());
List
<
Account
>
children
=
accountRepository
.
findByParentIn
(
nameList
);
List
<
Account
>
children
=
accountRepository
.
findByParentIn
(
nameList
);
...
...
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