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
66826d80
Commit
66826d80
authored
Aug 28, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'staging' into 'master'
Staging See merge request
!167
parents
da5c9260
9921e4ce
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
41 additions
and
16 deletions
+41
-16
AccountRepository.java
.../browserbackend/account/repository/AccountRepository.java
+3
-0
AdministratorServiceImpl.java
...ackend/account/service/impl/AdministratorServiceImpl.java
+28
-10
IpResourceRepositoryCustomImpl.java
...nd/browser/repository/IpResourceRepositoryCustomImpl.java
+3
-4
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+6
-2
PromotionTask.java
.../com/edgec/browserbackend/browser/task/PromotionTask.java
+1
-0
No files found.
src/main/java/com/edgec/browserbackend/account/repository/AccountRepository.java
View file @
66826d80
...
...
@@ -31,6 +31,8 @@ public interface AccountRepository extends MongoRepository<Account, String>, Acc
List
<
Account
>
findAllBySignupDateBetweenAndPromotionCodeAndParentIsNull
(
Date
startDate
,
Date
endDate
,
String
promotionCode
);
List
<
Account
>
findAllByPromotionCodeAndParentIsNull
(
String
code
);
Page
<
Account
>
findAllBySignupDateBetweenAndPromotionCodeAndParentIsNull
(
Pageable
pageable
,
Date
startDate
,
Date
endDate
,
String
promotionCode
);
Page
<
Account
>
findAllBySignupDateBetweenAndParentIsNull
(
Pageable
pageable
,
Date
startDate
,
Date
endDate
);
...
...
@@ -45,4 +47,5 @@ public interface AccountRepository extends MongoRepository<Account, String>, Acc
List
<
Account
>
findByPromotionCodeAndParentIsNull
(
String
code
);
int
countByPromotionCodeAndParentIsNull
(
String
promotionCode
);
}
src/main/java/com/edgec/browserbackend/account/service/impl/AdministratorServiceImpl.java
View file @
66826d80
...
...
@@ -407,16 +407,24 @@ public class AdministratorServiceImpl implements AdministratorService {
@Override
public
PromotionQueryResultDto
queryPromotion
(
Pageable
pageable
,
String
username
,
String
promotionCode
,
String
strDate1
,
String
strDate2
)
{
if
(
StringUtils
.
isBlank
(
username
)
&&
StringUtils
.
isBlank
(
promotionCode
))
if
(
StringUtils
.
isBlank
(
username
)
&&
StringUtils
.
isBlank
(
promotionCode
))
{
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
}
Account
account
=
null
;
if
(!
StringUtils
.
isBlank
(
username
))
if
(!
StringUtils
.
isBlank
(
username
))
{
account
=
accountRepository
.
findByName
(
username
).
orElseThrow
(()
->
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
));
else
account
=
accountRepository
.
findByPromotion
(
promotionCode
);
if
(
account
==
null
)
}
else
{
account
=
accountRepository
.
findByPromotion
(
promotionCode
);
}
if
(
account
==
null
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
if
(
account
.
getParent
()
!=
null
)
}
if
(
account
.
getParent
()
!=
null
)
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
}
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
PromotionQueryResultDto
promotionQueryResultDto
=
new
PromotionQueryResultDto
(
account
);
promotionQueryResultDto
.
setUsername
(
username
);
...
...
@@ -434,25 +442,34 @@ public class AdministratorServiceImpl implements AdministratorService {
Page
<
AccountPromotionDto
>
accountPromotionDtoPage
=
new
PageImpl
<
AccountPromotionDto
>(
accountPromotionDtos
);
promotionQueryResultDto
.
setUsers
(
accountPromotionDtoPage
);
List
<
Account
>
accounts
=
accountRepository
.
findAllBySignupDateBetweenAndPromotionCodeAndParentIsNull
(
dateTime1
,
dateTime2
,
account
.
getPromotion
().
getCode
());
// 查询在指定的日期通过邀请码注册的账户
// List<Account> accounts = accountRepository.findAllBySignupDateBetweenAndPromotionCodeAndParentIsNull(dateTime1, dateTime2, account.getPromotion().getCode());
// 从上面的 改为查询 某用户邀请的所有账户
List
<
Account
>
accounts
=
accountRepository
.
findAllByPromotionCodeAndParentIsNull
(
account
.
getPromotion
().
getCode
());
Promotion
promotion
=
new
Promotion
();
Account
finalAccount
=
account
;
AtomicLong
ipCount
=
new
AtomicLong
();
if
(
accounts
!=
null
&&
accounts
.
size
()
>
0
)
{
accounts
.
forEach
(
x
->
{
promotion
.
setInvitedUsers
(
promotion
.
getInvitedUsers
()
+
1
);
// 查询账户在指定日期充值记录
List
<
UserPrePaidBilling
>
userPrePaidBillings
=
userPrePaidBillingRepository
.
findByAdministratorAndPayMethodInAndTimestampBetween
(
x
.
getName
(),
Arrays
.
asList
(
1
,
2
,
3
),
dateTime1
.
getTime
(),
dateTime2
.
getTime
());
double
totalCommission
=
0
;
if
(
userPrePaidBillings
!=
null
&&
userPrePaidBillings
.
size
()
>
0
)
if
(
userPrePaidBillings
!=
null
&&
userPrePaidBillings
.
size
()
>
0
)
{
totalCommission
=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
}
promotion
.
setTotalCommission
(
promotion
.
getTotalCommission
()
+
(
int
)
totalCommission
);
promotion
.
setCommission
(
promotion
.
getCommission
()
+
x
.
getPromotion
().
getCommission
());
double
secondCommission
=
0
;
ipCount
.
addAndGet
(
ipResourceRepository
.
countAllByOwnerAndIsDeletedAndValidTimeGreaterThan
(
x
.
getName
(),
false
,
Instant
.
now
().
toEpochMilli
()));
List
<
Account
>
children
=
accountRepository
.
findByParent
(
x
.
getName
());
if
(
children
!=
null
&&
children
.
size
()
>
0
)
{
ipCount
.
addAndGet
(
ipResourceRepository
.
countAllByOwnerInAndIsDeletedAndValidTimeGreaterThan
(
children
.
stream
().
map
(
Account:
:
getName
).
collect
(
Collectors
.
toList
()),
false
,
Instant
.
now
().
toEpochMilli
()));
}
double
secondCommission
=
0
;
if
(
finalAccount
.
getPromotion
().
isSale
()
&&
x
.
getParent
()
==
null
)
{
List
<
Account
>
secondPromotes
=
accountRepository
.
findByPromotionCodeAndParentIsNull
(
x
.
getPromotion
().
getCode
());
if
(
secondPromotes
!=
null
&&
secondPromotes
.
size
()
>
0
)
{
...
...
@@ -470,10 +487,11 @@ public class AdministratorServiceImpl implements AdministratorService {
}
}
}
if
(
finalAccount
.
getPromotion
().
isSale
())
if
(
finalAccount
.
getPromotion
().
isSale
())
{
promotion
.
setAllGift
(
promotion
.
getAllGift
()
+
totalCommission
*
0.1
+
secondCommission
*
0.02
);
else
}
else
{
promotion
.
setAllGift
(
promotion
.
getAllGift
()
+
totalCommission
*
0.08
);
}
promotion
.
setWithdrawn
(
promotion
.
getWithdrawn
()
+
secondCommission
);
promotion
.
setGift
(
promotion
.
getGift
()
+
x
.
getPromotion
().
getGift
());
promotion
.
setCommissionLastMonth
(
promotion
.
getCommissionLastMonth
()
+
x
.
getPromotion
().
getCommissionLastMonth
());
...
...
src/main/java/com/edgec/browserbackend/browser/repository/IpResourceRepositoryCustomImpl.java
View file @
66826d80
...
...
@@ -135,14 +135,13 @@ public class IpResourceRepositoryCustomImpl implements IpResourceRepositoryCusto
Document
doc
=
new
Document
();
BasicQuery
basicQuery
=
new
BasicQuery
(
doc
);
basicQuery
.
addCriteria
(
where
(
"id"
).
is
(
id
).
and
(
"isDeleted"
).
is
(
false
));
Update
update
=
new
Update
();
update
.
set
(
"status"
,
status
);
UpdateResult
result
=
mongoTemplate
.
updateFirst
(
basicQuery
,
update
,
IpResource
.
class
);
if
(
result
.
getModifiedCount
()
<
1
)
return
false
;
else
return
true
;
return
result
.
getModifiedCount
()
>=
1
;
}
@Override
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
66826d80
...
...
@@ -693,6 +693,7 @@ public class IpResourceServiceImpl implements IpResourceService {
// 1.4 ip资源到期,且 ip 资源的状态不是 3(正在分配)、6(未分配),则设置 ip 资源的状态为 1(已过期)
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
toEpochMilli
()
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
// 这个地方可变参数随便传啥都行
ipResourceRepository
.
updateStatus
(
x
.
getId
(),
1
);
// 1.5 其他
...
...
@@ -974,8 +975,11 @@ public class IpResourceServiceImpl implements IpResourceService {
}
break
;
case
5
:
// 已分配
ipResources
=
ipResourceRepository
.
findShopIdInList
(
shopIds
,
false
);
// 已分配且未过期
ipResources
=
ipResourceRepository
.
findShopIdInList
(
shopIds
,
false
)
.
stream
()
.
filter
(
x
->
x
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
.
collect
(
Collectors
.
toList
());
if
(!
isParent
)
notUsed
=
ipResourceRepository
.
findByOwnerAndStatusInAndIsDeletedAndBind
(
username
,
Arrays
.
asList
(
0
,
2
,
4
,
8
),
false
,
false
);
else
...
...
src/main/java/com/edgec/browserbackend/browser/task/PromotionTask.java
View file @
66826d80
...
...
@@ -87,6 +87,7 @@ public class PromotionTask {
log
.
info
(
"End scheduled task:Scheduled.countGift..."
);
}
// @SchedulerLock:标识使用分布式锁。name:用来标注一个定时服务的名字,被用于写入数据库作为区分不同服务的标识
@SchedulerLock
(
name
=
"countCommission"
,
lockAtLeastForString
=
"PT1H"
,
lockAtMostForString
=
"PT2H"
)
@Scheduled
(
cron
=
"0 0 3 * * ?"
)
public
void
countCommission
()
{
...
...
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