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
1cf6fd96
Commit
1cf6fd96
authored
Apr 14, 2020
by
renjie
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'staging' into 'master'
Staging See merge request
!8
parents
98a14d26
daa7c1bf
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
122 additions
and
43 deletions
+122
-43
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
+44
-16
PaymentServiceImpl.java
...owserbackend/account/service/impl/PaymentServiceImpl.java
+12
-5
BrowserTask.java
...va/com/edgec/browserbackend/browser/task/BrowserTask.java
+1
-1
PromotionTask.java
.../com/edgec/browserbackend/browser/task/PromotionTask.java
+21
-12
ThreadPoolUtils.java
...om/edgec/browserbackend/common/utils/ThreadPoolUtils.java
+1
-6
No files found.
src/main/java/com/edgec/browserbackend/account/dto/BillQueryResultDto.java
View file @
1cf6fd96
...
@@ -10,11 +10,13 @@ public class BillQueryResultDto {
...
@@ -10,11 +10,13 @@ public class BillQueryResultDto {
double
parentWithdrawn
;
double
parentWithdrawn
;
double
parentBalanced
;
double
parentBalanced
;
double
parentBankTransfer
;
double
parentBankTransfer
;
double
parentBalanceUsed
;
double
childExpense
;
double
childExpense
;
double
childWithdraw
;
double
childWithdraw
;
double
childBalanced
;
double
childBalanced
;
double
childBankTransfer
;
double
childBankTransfer
;
double
childBalanceUsed
;
public
double
getParentExpense
()
{
public
double
getParentExpense
()
{
return
parentExpense
;
return
parentExpense
;
...
@@ -79,4 +81,20 @@ public class BillQueryResultDto {
...
@@ -79,4 +81,20 @@ public class BillQueryResultDto {
public
void
setChildWithdraw
(
double
childWithdraw
)
{
public
void
setChildWithdraw
(
double
childWithdraw
)
{
this
.
childWithdraw
=
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 @
1cf6fd96
...
@@ -2,6 +2,7 @@ package com.edgec.browserbackend.account.repository;
...
@@ -2,6 +2,7 @@ package com.edgec.browserbackend.account.repository;
import
com.edgec.browserbackend.account.domain.BillStatus
;
import
com.edgec.browserbackend.account.domain.BillStatus
;
import
com.edgec.browserbackend.account.domain.UserPrePaidBilling
;
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.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
...
@@ -35,6 +36,10 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai
...
@@ -35,6 +36,10 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai
List
<
UserPrePaidBilling
>
findByStatus
(
BillStatus
status
);
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
>
findByUsernameAndTimestampGreaterThanOrderByTimestampDesc
(
String
username
,
long
time
,
Pageable
pageable
);
Page
<
UserPrePaidBilling
>
findByAdministratorAndTimestampGreaterThanOrderByTimestampDesc
(
String
administrator
,
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 @
1cf6fd96
...
@@ -1199,11 +1199,28 @@ public class AccountServiceImpl implements AccountService {
...
@@ -1199,11 +1199,28 @@ public class AccountServiceImpl implements AccountService {
Account
account
=
repository
.
findByName
(
username
);
Account
account
=
repository
.
findByName
(
username
);
if
(
account
==
null
)
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
if
(
isAgree
)
if
(
isAgree
)
{
account
.
setAuthorized
(
2
);
account
.
setAuthorized
(
2
);
else
repository
.
save
(
account
);
}
else
{
account
.
setAuthorized
(
3
);
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
;
return
true
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
log
.
error
(
e
.
getMessage
());
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/AdministratorServiceImpl.java
View file @
1cf6fd96
...
@@ -11,6 +11,7 @@ import com.edgec.browserbackend.account.service.AdministratorService;
...
@@ -11,6 +11,7 @@ import com.edgec.browserbackend.account.service.AdministratorService;
import
com.edgec.browserbackend.auth.service.UserAuthService
;
import
com.edgec.browserbackend.auth.service.UserAuthService
;
import
com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode
;
import
com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode
;
import
com.edgec.browserbackend.browser.repository.IpResourceRepository
;
import
com.edgec.browserbackend.browser.repository.IpResourceRepository
;
import
com.edgec.browserbackend.common.charge.ChargeType
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
...
@@ -25,6 +26,7 @@ import org.springframework.stereotype.Service;
...
@@ -25,6 +26,7 @@ import org.springframework.stereotype.Service;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
import
java.time.YearMonth
;
import
java.time.ZoneOffset
;
import
java.time.ZoneOffset
;
import
java.time.ZonedDateTime
;
import
java.time.ZonedDateTime
;
import
java.util.*
;
import
java.util.*
;
...
@@ -123,8 +125,11 @@ public class AdministratorServiceImpl implements AdministratorService {
...
@@ -123,8 +125,11 @@ public class AdministratorServiceImpl implements AdministratorService {
double
parentwithdrawn
=
account
.
getPromotion
().
getWithdrawn
();
double
parentwithdrawn
=
account
.
getPromotion
().
getWithdrawn
();
UserBalance
userBalance
=
userBalanceRepository
.
findById
(
name
).
orElse
(
null
);
UserBalance
userBalance
=
userBalanceRepository
.
findById
(
name
).
orElse
(
null
);
double
parentbalanced
=
0
;
double
parentbalanced
=
0
;
if
(
userBalance
!=
null
)
double
parentbalanceused
=
0
;
if
(
userBalance
!=
null
)
{
parentbalanced
=
userBalance
.
getBalanced
();
parentbalanced
=
userBalance
.
getBalanced
();
parentbalanceused
=
userBalance
.
getUsed
();
}
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndPayMethod
(
name
,
3
);
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndPayMethod
(
name
,
3
);
double
parentbanktransfer
=
0
;
double
parentbanktransfer
=
0
;
if
(
userPrePaidBillings1
!=
null
)
if
(
userPrePaidBillings1
!=
null
)
...
@@ -134,19 +139,24 @@ public class AdministratorServiceImpl implements AdministratorService {
...
@@ -134,19 +139,24 @@ public class AdministratorServiceImpl implements AdministratorService {
double
childwithdrawn
=
0
;
double
childwithdrawn
=
0
;
double
childbalanced
=
0
;
double
childbalanced
=
0
;
double
childbanktransfer
=
0
;
double
childbanktransfer
=
0
;
double
childbalanceused
=
0
;
if
(
account
.
getParent
()
==
null
)
{
if
(
account
.
getParent
()
==
null
)
{
List
<
Account
>
children
=
accountRepository
.
findByParent
(
account
.
getName
());
List
<
Account
>
children
=
accountRepository
.
findByParent
(
account
.
getName
());
for
(
Account
child
:
children
)
{
if
(
children
!=
null
&&
children
.
size
()
>
0
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings_child
=
userPrePaidBillingRepository
.
findByUsernameAndPayMethodIn
(
child
.
getName
(),
Arrays
.
asList
(
1
,
2
));
for
(
Account
child
:
children
)
{
if
(
userPrePaidBillings_child
!=
null
)
List
<
UserPrePaidBilling
>
userPrePaidBillings_child
=
userPrePaidBillingRepository
.
findByUsernameAndPayMethodIn
(
child
.
getName
(),
Arrays
.
asList
(
1
,
2
));
childexpense
+=
userPrePaidBillings_child
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
if
(
userPrePaidBillings_child
!=
null
)
childwithdrawn
+=
child
.
getPromotion
().
getWithdrawn
();
childexpense
+=
userPrePaidBillings_child
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
UserBalance
userBalance_child
=
userBalanceRepository
.
findById
(
child
.
getName
()).
orElse
(
null
);
childwithdrawn
+=
child
.
getPromotion
().
getWithdrawn
();
if
(
userBalance_child
!=
null
)
UserBalance
userBalance_child
=
userBalanceRepository
.
findById
(
child
.
getName
()).
orElse
(
null
);
childbalanced
+=
userBalance_child
.
getBalanced
();
if
(
userBalance_child
!=
null
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings1_child
=
userPrePaidBillingRepository
.
findByUsernameAndPayMethod
(
child
.
getName
(),
3
);
childbalanced
+=
userBalance_child
.
getBalanced
();
if
(
userPrePaidBillings1_child
!=
null
)
childbalanceused
+=
userBalance_child
.
getUsed
();
childbanktransfer
+=
userPrePaidBillings1_child
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
}
List
<
UserPrePaidBilling
>
userPrePaidBillings1_child
=
userPrePaidBillingRepository
.
findByUsernameAndPayMethod
(
child
.
getName
(),
3
);
if
(
userPrePaidBillings1_child
!=
null
)
childbanktransfer
+=
userPrePaidBillings1_child
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
}
}
}
}
}
...
@@ -155,11 +165,13 @@ public class AdministratorServiceImpl implements AdministratorService {
...
@@ -155,11 +165,13 @@ public class AdministratorServiceImpl implements AdministratorService {
billQueryResultDto
.
setChildBankTransfer
(
childbanktransfer
);
billQueryResultDto
.
setChildBankTransfer
(
childbanktransfer
);
billQueryResultDto
.
setChildBalanced
(
childbalanced
);
billQueryResultDto
.
setChildBalanced
(
childbalanced
);
billQueryResultDto
.
setChildWithdraw
(
childwithdrawn
);
billQueryResultDto
.
setChildWithdraw
(
childwithdrawn
);
billQueryResultDto
.
setChildBalanceUsed
(
childbalanceused
);
billQueryResultDto
.
setParentExpense
(
parentexpense
);
billQueryResultDto
.
setParentExpense
(
parentexpense
);
billQueryResultDto
.
setParentBalanced
(
parentbalanced
);
billQueryResultDto
.
setParentBalanced
(
parentbalanced
);
billQueryResultDto
.
setParentBankTransfer
(
parentbanktransfer
);
billQueryResultDto
.
setParentBankTransfer
(
parentbanktransfer
);
billQueryResultDto
.
setParentWithdrawn
(
parentwithdrawn
);
billQueryResultDto
.
setParentWithdrawn
(
parentwithdrawn
);
billQueryResultDto
.
setParentBalanceUsed
(
parentbalanceused
);
return
billQueryResultDto
;
return
billQueryResultDto
;
}
}
...
@@ -392,13 +404,29 @@ public class AdministratorServiceImpl implements AdministratorService {
...
@@ -392,13 +404,29 @@ public class AdministratorServiceImpl implements AdministratorService {
List
<
Account
>
accounts
=
accountRepository
.
findAllBySignupDateBetweenAndPromotionCode
(
dateTime1
,
dateTime2
,
account
.
getPromotion
().
getCode
());
List
<
Account
>
accounts
=
accountRepository
.
findAllBySignupDateBetweenAndPromotionCode
(
dateTime1
,
dateTime2
,
account
.
getPromotion
().
getCode
());
Promotion
promotion
=
new
Promotion
();
Promotion
promotion
=
new
Promotion
();
Account
finalAccount
=
account
;
accounts
.
forEach
(
x
->
{
accounts
.
forEach
(
x
->
{
promotion
.
setInvitedUsers
(
promotion
.
getInvitedUsers
()
+
1
);
promotion
.
setInvitedUsers
(
promotion
.
getInvitedUsers
()
+
1
);
double
totalCommission
=
userPrePaidBillingRepository
.
findByUsernameAndPayMethodInAndTimestampGreaterThanAndTimestampLessThan
(
x
.
getName
(),
Arrays
.
asList
(
1
,
2
,
3
),
dateTime1
.
getTime
(),
dateTime2
.
getTime
())
promotion
.
setTotalCommission
(
promotion
.
getTotalCommission
()
+
x
.
getPromotion
().
getTotalCommission
());
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
promotion
.
setTotalCommission
(
promotion
.
getTotalCommission
()
+
(
int
)
totalCommission
);
promotion
.
setCommission
(
promotion
.
getCommission
()
+
x
.
getPromotion
().
getCommission
());
promotion
.
setCommission
(
promotion
.
getCommission
()
+
x
.
getPromotion
().
getCommission
());
promotion
.
setWithdrawn
(
promotion
.
getWithdrawn
()
+
x
.
getPromotion
().
getWithdrawn
());
double
totalwithdrawn
=
userPrePaidBillingRepository
.
findByUsernameAndChargeTypeAndTimestampGreaterThanAndTimestampLessThan
(
x
.
getName
(),
ChargeType
.
gift
,
dateTime1
.
getTime
(),
dateTime2
.
getTime
())
promotion
.
setAllGift
(
promotion
.
getAllGift
()
+
x
.
getPromotion
().
getAllGift
());
.
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
.
setGift
(
promotion
.
getGift
()
+
x
.
getPromotion
().
getGift
());
promotion
.
setCommissionLastMonth
(
promotion
.
getCommissionLastMonth
()
+
x
.
getPromotion
().
getCommissionLastMonth
());
promotion
.
setCommissionLastMonth
(
promotion
.
getCommissionLastMonth
()
+
x
.
getPromotion
().
getCommissionLastMonth
());
});
});
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/PaymentServiceImpl.java
View file @
1cf6fd96
...
@@ -209,8 +209,8 @@ public class PaymentServiceImpl implements PaymentService {
...
@@ -209,8 +209,8 @@ public class PaymentServiceImpl implements PaymentService {
if
(
byName
.
getPromotionCode
()
!=
null
)
{
if
(
byName
.
getPromotionCode
()
!=
null
)
{
Account
account
=
accountRepository
.
findByPromotion
(
byName
.
getPromotionCode
());
Account
account
=
accountRepository
.
findByPromotion
(
byName
.
getPromotionCode
());
if
(
account
!=
null
)
{
if
(
account
!=
null
)
{
byName
.
getPromotion
().
setCommission
(
byName
.
getPromotion
().
getCommission
()
+
byTradeNo
.
getAmount
());
account
.
getPromotion
().
setCommission
(
account
.
getPromotion
().
getCommission
()
+
byTradeNo
.
getAmount
());
accountRepository
.
save
(
byName
);
accountRepository
.
save
(
account
);
}
}
}
}
...
@@ -341,8 +341,8 @@ public class PaymentServiceImpl implements PaymentService {
...
@@ -341,8 +341,8 @@ public class PaymentServiceImpl implements PaymentService {
if
(
byName
.
getPromotionCode
()
!=
null
)
{
if
(
byName
.
getPromotionCode
()
!=
null
)
{
Account
account
=
accountRepository
.
findByPromotion
(
byName
.
getPromotionCode
());
Account
account
=
accountRepository
.
findByPromotion
(
byName
.
getPromotionCode
());
if
(
account
!=
null
)
{
if
(
account
!=
null
)
{
byName
.
getPromotion
().
setCommission
(
byName
.
getPromotion
().
getCommission
()
+
byTradeNo
.
getAmount
());
account
.
getPromotion
().
setCommission
(
account
.
getPromotion
().
getCommission
()
+
byTradeNo
.
getAmount
());
accountRepository
.
save
(
byName
);
accountRepository
.
save
(
account
);
}
}
}
}
}
}
...
@@ -404,7 +404,6 @@ public class PaymentServiceImpl implements PaymentService {
...
@@ -404,7 +404,6 @@ public class PaymentServiceImpl implements PaymentService {
internalOrder
.
setTransId
(
response
.
getTradeNo
());
internalOrder
.
setTransId
(
response
.
getTradeNo
());
userPaymentRepository
.
save
(
internalOrder
);
userPaymentRepository
.
save
(
internalOrder
);
log
.
error
(
response
.
getBody
());
String
form
=
response
.
getBody
();
String
form
=
response
.
getBody
();
return
form
;
return
form
;
...
@@ -518,6 +517,14 @@ public class PaymentServiceImpl implements PaymentService {
...
@@ -518,6 +517,14 @@ public class PaymentServiceImpl implements PaymentService {
userBalanceRepository
.
incrementBalance
(
userBalance
,
amount
,
0
);
userBalanceRepository
.
incrementBalance
(
userBalance
,
amount
,
0
);
}
}
if
(
account
.
getPromotionCode
()
!=
null
)
{
Account
account1
=
accountRepository
.
findByPromotion
(
account
.
getPromotionCode
());
if
(
account1
!=
null
)
{
account1
.
getPromotion
().
setCommission
(
account1
.
getPromotion
().
getCommission
()
+
amount
);
accountRepository
.
save
(
account1
);
}
}
return
userBalanceRepository
.
findById
(
username
).
orElse
(
null
);
return
userBalanceRepository
.
findById
(
username
).
orElse
(
null
);
}
}
...
...
src/main/java/com/edgec/browserbackend/browser/task/BrowserTask.java
View file @
1cf6fd96
...
@@ -181,7 +181,7 @@ public class BrowserTask {
...
@@ -181,7 +181,7 @@ public class BrowserTask {
HttpMethod
.
GET
,
entity
,
IpInfoResultDto
.
class
,
"browser"
,
ipResource
.
getAddr
());
HttpMethod
.
GET
,
entity
,
IpInfoResultDto
.
class
,
"browser"
,
ipResource
.
getAddr
());
IpInfoResultDto
ipInfoResultDto
=
result
.
getBody
();
IpInfoResultDto
ipInfoResultDto
=
result
.
getBody
();
if
(
ipInfoResultDto
!=
null
&&
StringUtils
.
isBlank
(
ipInfoResultDto
.
getErrorCode
()))
{
if
(
ipInfoResultDto
!=
null
&&
StringUtils
.
isBlank
(
ipInfoResultDto
.
getErrorCode
()))
{
if
(
ipInfoResultDto
.
getStatus
().
equals
(
"Running"
))
{
if
(
ipInfoResultDto
.
getStatus
()
!=
null
&&
ipInfoResultDto
.
getStatus
()
.
equals
(
"Running"
))
{
ipResource
.
setStatus
(
0
);
ipResource
.
setStatus
(
0
);
ipResourceRepository
.
save
(
ipResource
);
ipResourceRepository
.
save
(
ipResource
);
}
}
...
...
src/main/java/com/edgec/browserbackend/browser/task/PromotionTask.java
View file @
1cf6fd96
...
@@ -41,15 +41,17 @@ public class PromotionTask {
...
@@ -41,15 +41,17 @@ public class PromotionTask {
for
(
Account
promote
:
promotes
)
{
for
(
Account
promote
:
promotes
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
promote
.
getName
(),
List
<
UserPrePaidBilling
>
userPrePaidBillings
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
promote
.
getName
(),
YearMonth
.
now
().
minusMonths
(
1
).
getYear
(),
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
();
totalCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
if
(
account
.
getPromotion
().
isSale
()
&&
promote
.
getParent
()
==
null
)
{
if
(
account
.
getPromotion
().
isSale
()
&&
promote
.
getParent
()
==
null
)
{
List
<
Account
>
secondPromotes
=
accountRepository
.
findByPromotionCode
(
promote
.
getPromotion
().
getCode
());
List
<
Account
>
secondPromotes
=
accountRepository
.
findByPromotionCode
(
promote
.
getPromotion
().
getCode
());
for
(
Account
secondPromote
:
secondPromotes
)
{
if
(
secondPromotes
!=
null
&&
secondPromotes
.
size
()
>
0
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
promote
.
getName
(),
for
(
Account
secondPromote
:
secondPromotes
)
{
YearMonth
.
now
().
minusMonths
(
1
).
getYear
(),
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
secondPromote
.
getName
(),
YearMonth
.
now
().
minusMonths
(
1
).
getMonthValue
(),
Arrays
.
asList
(
1
,
2
,
3
));
YearMonth
.
now
().
minusMonths
(
1
).
getYear
(),
secondCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
YearMonth
.
now
().
minusMonths
(
1
).
getMonthValue
(),
Arrays
.
asList
(
1
,
2
,
3
));
secondCommission
+=
userPrePaidBillings1
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
}
}
}
}
}
}
}
...
@@ -81,15 +83,22 @@ public class PromotionTask {
...
@@ -81,15 +83,22 @@ public class PromotionTask {
totalCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
totalCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
if
(
account
.
getPromotion
().
isSale
()
&&
promote
.
getParent
()
==
null
)
{
if
(
account
.
getPromotion
().
isSale
()
&&
promote
.
getParent
()
==
null
)
{
List
<
Account
>
secondPromotes
=
accountRepository
.
findByPromotionCode
(
promote
.
getPromotion
().
getCode
());
List
<
Account
>
secondPromotes
=
accountRepository
.
findByPromotionCode
(
promote
.
getPromotion
().
getCode
());
for
(
Account
secondPromote
:
secondPromotes
)
{
if
(
secondPromotes
!=
null
&&
secondPromotes
.
size
()
>
0
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
promote
.
getName
(),
for
(
Account
secondPromote
:
secondPromotes
)
{
YearMonth
.
now
().
getYear
(),
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
secondPromote
.
getName
(),
YearMonth
.
now
().
getMonthValue
(),
Arrays
.
asList
(
1
,
2
,
3
));
YearMonth
.
now
().
getYear
(),
secondCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
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
);
accountRepository
.
save
(
account
);
}
}
}
}
...
...
src/main/java/com/edgec/browserbackend/common/utils/ThreadPoolUtils.java
View file @
1cf6fd96
...
@@ -11,11 +11,6 @@ public abstract class ThreadPoolUtils {
...
@@ -11,11 +11,6 @@ public abstract class ThreadPoolUtils {
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ThreadPoolUtils
.
class
);
private
static
final
Logger
log
=
LoggerFactory
.
getLogger
(
ThreadPoolUtils
.
class
);
private
static
final
int
SCHEDULER_POOL_COUNT
=
50
;
public
static
final
int
MAX_WAITING_TASKS
=
10
;
public
static
final
BlockingQueue
<
Runnable
>
schedulerQueue
=
new
UniquePriorityBlockingQueue
<>(
50
);
public
static
final
BlockingQueue
<
Runnable
>
schedulerQueue
=
new
UniquePriorityBlockingQueue
<>(
50
);
...
@@ -33,7 +28,7 @@ public abstract class ThreadPoolUtils {
...
@@ -33,7 +28,7 @@ public abstract class ThreadPoolUtils {
private
static
final
int
TIME_SCHEDULER_POOL_COUNT
=
20
;
private
static
final
int
TIME_SCHEDULER_POOL_COUNT
=
20
;
public
static
final
ScheduledExecutorService
queryIpTasksPool
=
Executors
.
newSchedul
edThreadPool
(
TIME_SCHEDULER_POOL_COUNT
,
new
ThreadFactory
()
{
public
static
final
ExecutorService
queryIpTasksPool
=
Executors
.
newFix
edThreadPool
(
TIME_SCHEDULER_POOL_COUNT
,
new
ThreadFactory
()
{
int
count
=
1
;
int
count
=
1
;
@Override
@Override
...
...
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