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
b5d443a3
Commit
b5d443a3
authored
Apr 14, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
admin更新
parent
93e35613
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
96 additions
and
21 deletions
+96
-21
BillQueryResultDto.java
.../edgec/browserbackend/account/dto/BillQueryResultDto.java
+18
-0
UserPrePaidBillingRepository.java
...kend/account/repository/UserPrePaidBillingRepository.java
+5
-0
AccountServiceImpl.java
...owserbackend/account/service/impl/AccountServiceImpl.java
+20
-3
AdministratorServiceImpl.java
...ackend/account/service/impl/AdministratorServiceImpl.java
+32
-6
PromotionTask.java
.../com/edgec/browserbackend/browser/task/PromotionTask.java
+21
-12
No files found.
src/main/java/com/edgec/browserbackend/account/dto/BillQueryResultDto.java
View file @
b5d443a3
...
...
@@ -10,11 +10,13 @@ public class BillQueryResultDto {
double
parentWithdrawn
;
double
parentBalanced
;
double
parentBankTransfer
;
double
parentBalanceUsed
;
double
childExpense
;
double
childWithdraw
;
double
childBalanced
;
double
childBankTransfer
;
double
childBalanceUsed
;
public
double
getParentExpense
()
{
return
parentExpense
;
...
...
@@ -79,4 +81,20 @@ public class BillQueryResultDto {
public
void
setChildWithdraw
(
double
childWithdraw
)
{
this
.
childWithdraw
=
childWithdraw
;
}
public
double
getChildBalanceUsed
()
{
return
childBalanceUsed
;
}
public
void
setChildBalanceUsed
(
double
childBalanceUsed
)
{
this
.
childBalanceUsed
=
childBalanceUsed
;
}
public
double
getParentBalanceUsed
()
{
return
parentBalanceUsed
;
}
public
void
setParentBalanceUsed
(
double
parentBalanceUsed
)
{
this
.
parentBalanceUsed
=
parentBalanceUsed
;
}
}
src/main/java/com/edgec/browserbackend/account/repository/UserPrePaidBillingRepository.java
View file @
b5d443a3
...
...
@@ -2,6 +2,7 @@ package com.edgec.browserbackend.account.repository;
import
com.edgec.browserbackend.account.domain.BillStatus
;
import
com.edgec.browserbackend.account.domain.UserPrePaidBilling
;
import
org.omg.PortableServer.LIFESPAN_POLICY_ID
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
...
...
@@ -35,6 +36,10 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai
List
<
UserPrePaidBilling
>
findByStatus
(
BillStatus
status
);
List
<
UserPrePaidBilling
>
findByUsernameAndPayMethodInAndTimestampGreaterThanAndTimestampLessThan
(
String
username
,
List
<
Integer
>
payMehtods
,
long
time1
,
long
time2
);
List
<
UserPrePaidBilling
>
findByUsernameAndChargeTypeAndTimestampGreaterThanAndTimestampLessThan
(
String
username
,
int
chargeType
,
long
time1
,
long
time2
);
Page
<
UserPrePaidBilling
>
findByUsernameAndTimestampGreaterThanOrderByTimestampDesc
(
String
username
,
long
time
,
Pageable
pageable
);
Page
<
UserPrePaidBilling
>
findByAdministratorAndTimestampGreaterThanOrderByTimestampDesc
(
String
administrator
,
long
time
,
Pageable
pageable
);
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/AccountServiceImpl.java
View file @
b5d443a3
...
...
@@ -1199,11 +1199,28 @@ public class AccountServiceImpl implements AccountService {
Account
account
=
repository
.
findByName
(
username
);
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
if
(
isAgree
)
if
(
isAgree
)
{
account
.
setAuthorized
(
2
);
else
repository
.
save
(
account
);
}
else
{
account
.
setAuthorized
(
3
);
repository
.
save
(
account
);
repository
.
save
(
account
);
CompanyAuthorize
companyAuthorize
=
companyAuthorizeRepository
.
findByUsername
(
username
);
if
(
companyAuthorize
!=
null
)
{
if
(
companyAuthorize
.
getCompanyLicenseId
()
!=
null
)
companyAuthorizeRepository
.
deleteFile
(
companyAuthorize
.
getCompanyLicenseId
());
if
(
companyAuthorize
.
getCoporationLicenseFront
()
!=
null
)
companyAuthorizeRepository
.
deleteFile
(
companyAuthorize
.
getCoporationLicenseFront
());
if
(
companyAuthorize
.
getCoporationLicenseBack
()
!=
null
)
companyAuthorizeRepository
.
deleteFile
(
companyAuthorize
.
getCoporationLicenseBack
());
if
(
companyAuthorize
.
getAgencyFront
()
!=
null
)
companyAuthorizeRepository
.
deleteFile
(
companyAuthorize
.
getAgencyFront
());
if
(
companyAuthorize
.
getAgencyBack
()
!=
null
)
companyAuthorizeRepository
.
deleteFile
(
companyAuthorize
.
getAgencyBack
());
companyAuthorizeRepository
.
delete
(
companyAuthorize
);
}
}
return
true
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/AdministratorServiceImpl.java
View file @
b5d443a3
...
...
@@ -11,6 +11,7 @@ import com.edgec.browserbackend.account.service.AdministratorService;
import
com.edgec.browserbackend.auth.service.UserAuthService
;
import
com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode
;
import
com.edgec.browserbackend.browser.repository.IpResourceRepository
;
import
com.edgec.browserbackend.common.charge.ChargeType
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
...
...
@@ -25,6 +26,7 @@ import org.springframework.stereotype.Service;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.time.YearMonth
;
import
java.time.ZoneOffset
;
import
java.time.ZonedDateTime
;
import
java.util.*
;
...
...
@@ -123,8 +125,11 @@ public class AdministratorServiceImpl implements AdministratorService {
double
parentwithdrawn
=
account
.
getPromotion
().
getWithdrawn
();
UserBalance
userBalance
=
userBalanceRepository
.
findById
(
name
).
orElse
(
null
);
double
parentbalanced
=
0
;
if
(
userBalance
!=
null
)
double
parentbalanceused
=
0
;
if
(
userBalance
!=
null
)
{
parentbalanced
=
userBalance
.
getBalanced
();
parentbalanceused
=
userBalance
.
getUsed
();
}
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndPayMethod
(
name
,
3
);
double
parentbanktransfer
=
0
;
if
(
userPrePaidBillings1
!=
null
)
...
...
@@ -134,6 +139,7 @@ public class AdministratorServiceImpl implements AdministratorService {
double
childwithdrawn
=
0
;
double
childbalanced
=
0
;
double
childbanktransfer
=
0
;
double
childbalanceused
=
0
;
if
(
account
.
getParent
()
==
null
)
{
List
<
Account
>
children
=
accountRepository
.
findByParent
(
account
.
getName
());
for
(
Account
child
:
children
)
{
...
...
@@ -142,8 +148,10 @@ public class AdministratorServiceImpl implements AdministratorService {
childexpense
+=
userPrePaidBillings_child
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
childwithdrawn
+=
child
.
getPromotion
().
getWithdrawn
();
UserBalance
userBalance_child
=
userBalanceRepository
.
findById
(
child
.
getName
()).
orElse
(
null
);
if
(
userBalance_child
!=
null
)
if
(
userBalance_child
!=
null
)
{
childbalanced
+=
userBalance_child
.
getBalanced
();
childbalanceused
+=
userBalance_child
.
getUsed
();
}
List
<
UserPrePaidBilling
>
userPrePaidBillings1_child
=
userPrePaidBillingRepository
.
findByUsernameAndPayMethod
(
child
.
getName
(),
3
);
if
(
userPrePaidBillings1_child
!=
null
)
childbanktransfer
+=
userPrePaidBillings1_child
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
...
...
@@ -155,11 +163,13 @@ public class AdministratorServiceImpl implements AdministratorService {
billQueryResultDto
.
setChildBankTransfer
(
childbanktransfer
);
billQueryResultDto
.
setChildBalanced
(
childbalanced
);
billQueryResultDto
.
setChildWithdraw
(
childwithdrawn
);
billQueryResultDto
.
setChildBalanceUsed
(
childbalanceused
);
billQueryResultDto
.
setParentExpense
(
parentexpense
);
billQueryResultDto
.
setParentBalanced
(
parentbalanced
);
billQueryResultDto
.
setParentBankTransfer
(
parentbanktransfer
);
billQueryResultDto
.
setParentWithdrawn
(
parentwithdrawn
);
billQueryResultDto
.
setParentBalanceUsed
(
parentbalanceused
);
return
billQueryResultDto
;
}
...
...
@@ -392,13 +402,29 @@ public class AdministratorServiceImpl implements AdministratorService {
List
<
Account
>
accounts
=
accountRepository
.
findAllBySignupDateBetweenAndPromotionCode
(
dateTime1
,
dateTime2
,
account
.
getPromotion
().
getCode
());
Promotion
promotion
=
new
Promotion
();
Account
finalAccount
=
account
;
accounts
.
forEach
(
x
->
{
promotion
.
setInvitedUsers
(
promotion
.
getInvitedUsers
()
+
1
);
promotion
.
setTotalCommission
(
promotion
.
getTotalCommission
()
+
x
.
getPromotion
().
getTotalCommission
());
double
totalCommission
=
userPrePaidBillingRepository
.
findByUsernameAndPayMethodInAndTimestampGreaterThanAndTimestampLessThan
(
x
.
getName
(),
Arrays
.
asList
(
1
,
2
,
3
),
dateTime1
.
getTime
(),
dateTime2
.
getTime
())
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
promotion
.
setTotalCommission
(
promotion
.
getTotalCommission
()
+
(
int
)
totalCommission
);
promotion
.
setCommission
(
promotion
.
getCommission
()
+
x
.
getPromotion
().
getCommission
());
promotion
.
setWithdrawn
(
promotion
.
getWithdrawn
()
+
x
.
getPromotion
().
getWithdrawn
());
promotion
.
setAllGift
(
promotion
.
getAllGift
()
+
x
.
getPromotion
().
getAllGift
());
double
totalwithdrawn
=
userPrePaidBillingRepository
.
findByUsernameAndChargeTypeAndTimestampGreaterThanAndTimestampLessThan
(
x
.
getName
(),
ChargeType
.
gift
,
dateTime1
.
getTime
(),
dateTime2
.
getTime
())
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
promotion
.
setWithdrawn
(
promotion
.
getWithdrawn
()
+
totalwithdrawn
);
double
secondCommission
=
0
;
if
(
finalAccount
.
getPromotion
().
isSale
()
&&
x
.
getParent
()
==
null
)
{
List
<
Account
>
secondPromotes
=
accountRepository
.
findByPromotionCode
(
x
.
getPromotion
().
getCode
());
if
(
secondPromotes
!=
null
&&
secondPromotes
.
size
()
>
0
)
{
for
(
Account
secondPromote
:
secondPromotes
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
secondPromote
.
getName
(),
YearMonth
.
now
().
minusMonths
(
1
).
getYear
(),
YearMonth
.
now
().
minusMonths
(
1
).
getMonthValue
(),
Arrays
.
asList
(
1
,
2
,
3
));
secondCommission
+=
userPrePaidBillings1
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
}
}
}
promotion
.
setAllGift
(
promotion
.
getAllGift
()
+
totalCommission
*
0.1
+
secondCommission
*
0.02
);
promotion
.
setGift
(
promotion
.
getGift
()
+
x
.
getPromotion
().
getGift
());
promotion
.
setCommissionLastMonth
(
promotion
.
getCommissionLastMonth
()
+
x
.
getPromotion
().
getCommissionLastMonth
());
});
...
...
src/main/java/com/edgec/browserbackend/browser/task/PromotionTask.java
View file @
b5d443a3
...
...
@@ -41,15 +41,17 @@ public class PromotionTask {
for
(
Account
promote
:
promotes
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
promote
.
getName
(),
YearMonth
.
now
().
minusMonths
(
1
).
getYear
(),
YearMonth
.
now
().
minusMonths
(
1
).
getMonthValue
(),
Arrays
.
asList
(
1
,
2
));
YearMonth
.
now
().
minusMonths
(
1
).
getMonthValue
(),
Arrays
.
asList
(
1
,
2
,
3
));
totalCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
if
(
account
.
getPromotion
().
isSale
()
&&
promote
.
getParent
()
==
null
)
{
List
<
Account
>
secondPromotes
=
accountRepository
.
findByPromotionCode
(
promote
.
getPromotion
().
getCode
());
for
(
Account
secondPromote
:
secondPromotes
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
promote
.
getName
(),
YearMonth
.
now
().
minusMonths
(
1
).
getYear
(),
YearMonth
.
now
().
minusMonths
(
1
).
getMonthValue
(),
Arrays
.
asList
(
1
,
2
,
3
));
secondCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
if
(
secondPromotes
!=
null
&&
secondPromotes
.
size
()
>
0
)
{
for
(
Account
secondPromote
:
secondPromotes
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
secondPromote
.
getName
(),
YearMonth
.
now
().
minusMonths
(
1
).
getYear
(),
YearMonth
.
now
().
minusMonths
(
1
).
getMonthValue
(),
Arrays
.
asList
(
1
,
2
,
3
));
secondCommission
+=
userPrePaidBillings1
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
}
}
}
}
...
...
@@ -81,15 +83,22 @@ public class PromotionTask {
totalCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
if
(
account
.
getPromotion
().
isSale
()
&&
promote
.
getParent
()
==
null
)
{
List
<
Account
>
secondPromotes
=
accountRepository
.
findByPromotionCode
(
promote
.
getPromotion
().
getCode
());
for
(
Account
secondPromote
:
secondPromotes
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
promote
.
getName
(),
YearMonth
.
now
().
getYear
(),
YearMonth
.
now
().
getMonthValue
(),
Arrays
.
asList
(
1
,
2
,
3
));
secondCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
if
(
secondPromotes
!=
null
&&
secondPromotes
.
size
()
>
0
)
{
for
(
Account
secondPromote
:
secondPromotes
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
secondPromote
.
getName
(),
YearMonth
.
now
().
getYear
(),
YearMonth
.
now
().
getMonthValue
(),
Arrays
.
asList
(
1
,
2
,
3
));
secondCommission
+=
userPrePaidBillings1
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
}
}
}
}
account
.
getPromotion
().
setCommission
((
int
)
totalCommission
);
Promotion
promotion
=
account
.
getPromotion
();
promotion
.
setCommission
((
int
)
totalCommission
);
promotion
.
setGift
(
totalCommission
*
0.08
);
if
(
account
.
getPromotion
().
isSale
())
{
promotion
.
setGift
(
totalCommission
*
0.1
+
secondCommission
*
0.02
);
}
accountRepository
.
save
(
account
);
}
}
...
...
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