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
1939c414
Commit
1939c414
authored
Apr 11, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
admin接口
parent
4cdeb0e2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
101 additions
and
4 deletions
+101
-4
AdministratorController.java
...erbackend/account/controller/AdministratorController.java
+19
-1
Promotion.java
...va/com/edgec/browserbackend/account/domain/Promotion.java
+10
-0
AdministratorService.java
.../browserbackend/account/service/AdministratorService.java
+5
-0
AccountServiceImpl.java
...owserbackend/account/service/impl/AccountServiceImpl.java
+1
-1
AdministratorServiceImpl.java
...ackend/account/service/impl/AdministratorServiceImpl.java
+15
-0
PaymentServiceImpl.java
...owserbackend/account/service/impl/PaymentServiceImpl.java
+19
-0
PromotionTask.java
.../com/edgec/browserbackend/browser/task/PromotionTask.java
+32
-2
No files found.
src/main/java/com/edgec/browserbackend/account/controller/AdministratorController.java
View file @
1939c414
...
@@ -369,7 +369,25 @@ public class AdministratorController {
...
@@ -369,7 +369,25 @@ public class AdministratorController {
return
resultDto
;
return
resultDto
;
}
}
//添加推广码
//添加白名单
@PreAuthorize
(
Securitys
.
ADMIN_EL
)
@RequestMapping
(
path
=
"/0xadministrator/whitelist/add"
,
method
=
RequestMethod
.
PUT
)
public
ResultDto
addWhiteList
(
Principal
principal
,
@RequestParam
(
"website"
)
String
website
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
administratorService
.
addWhiteList
(
website
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
return
resultDto
;
}
//统计ip数量
@PreAuthorize
(
Securitys
.
ADMIN_EL
)
@PreAuthorize
(
Securitys
.
ADMIN_EL
)
@RequestMapping
(
path
=
"/0xadministrator/ip/count"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
path
=
"/0xadministrator/ip/count"
,
method
=
RequestMethod
.
GET
)
public
ResultDto
getIpCount
(
Principal
principal
,
@RequestParam
(
value
=
"username"
,
defaultValue
=
""
)
String
username
)
{
public
ResultDto
getIpCount
(
Principal
principal
,
@RequestParam
(
value
=
"username"
,
defaultValue
=
""
)
String
username
)
{
...
...
src/main/java/com/edgec/browserbackend/account/domain/Promotion.java
View file @
1939c414
...
@@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
...
@@ -11,6 +11,8 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
public
class
Promotion
{
public
class
Promotion
{
private
String
code
;
private
String
code
;
private
int
invitedUsers
;
private
int
invitedUsers
;
//好友总消费
private
int
totalCommission
;
//好友当月消费
//好友当月消费
private
int
commission
;
private
int
commission
;
//好友上月总消费
//好友上月总消费
...
@@ -85,4 +87,12 @@ public class Promotion {
...
@@ -85,4 +87,12 @@ public class Promotion {
public
void
setWithdrawn
(
double
withdrawn
)
{
public
void
setWithdrawn
(
double
withdrawn
)
{
this
.
withdrawn
=
withdrawn
;
this
.
withdrawn
=
withdrawn
;
}
}
public
int
getTotalCommission
()
{
return
totalCommission
;
}
public
void
setTotalCommission
(
int
totalCommission
)
{
this
.
totalCommission
=
totalCommission
;
}
}
}
src/main/java/com/edgec/browserbackend/account/service/AdministratorService.java
View file @
1939c414
...
@@ -8,6 +8,7 @@ import com.edgec.browserbackend.browser.dto.IpResourceDto;
...
@@ -8,6 +8,7 @@ import com.edgec.browserbackend.browser.dto.IpResourceDto;
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
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
public
interface
AdministratorService
{
public
interface
AdministratorService
{
...
@@ -54,4 +55,8 @@ public interface AdministratorService {
...
@@ -54,4 +55,8 @@ public interface AdministratorService {
void
addPromotionCode
(
String
username
,
String
promotionCode
);
void
addPromotionCode
(
String
username
,
String
promotionCode
);
IpCountQueryResultDto
queyrIpCount
(
String
username
);
IpCountQueryResultDto
queyrIpCount
(
String
username
);
HashMap
queryGift
(
String
username
);
void
addWhiteList
(
String
website
);
}
}
src/main/java/com/edgec/browserbackend/account/service/impl/AccountServiceImpl.java
View file @
1939c414
...
@@ -402,7 +402,7 @@ public class AccountServiceImpl implements AccountService {
...
@@ -402,7 +402,7 @@ public class AccountServiceImpl implements AccountService {
for
(
Account
promote
:
promotes
)
{
for
(
Account
promote
:
promotes
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings
=
prePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
promote
.
getName
(),
List
<
UserPrePaidBilling
>
userPrePaidBillings
=
prePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
promote
.
getName
(),
YearMonth
.
now
().
getYear
(),
YearMonth
.
now
().
getYear
(),
YearMonth
.
now
().
getMonthValue
(),
Arrays
.
asList
(
1
,
2
));
YearMonth
.
now
().
getMonthValue
(),
Arrays
.
asList
(
1
,
2
,
3
));
totalCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
totalCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
}
}
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/AdministratorServiceImpl.java
View file @
1939c414
...
@@ -55,6 +55,9 @@ public class AdministratorServiceImpl implements AdministratorService {
...
@@ -55,6 +55,9 @@ public class AdministratorServiceImpl implements AdministratorService {
@Autowired
@Autowired
private
IpResourceRepository
ipResourceRepository
;
private
IpResourceRepository
ipResourceRepository
;
@Autowired
private
WhiteSiteRepository
whiteSiteRepository
;
@Override
@Override
public
Administrator
createAdministrator
(
Administrator
administrator
)
{
public
Administrator
createAdministrator
(
Administrator
administrator
)
{
Administrator
administrator1
=
new
Administrator
();
Administrator
administrator1
=
new
Administrator
();
...
@@ -358,6 +361,18 @@ public class AdministratorServiceImpl implements AdministratorService {
...
@@ -358,6 +361,18 @@ public class AdministratorServiceImpl implements AdministratorService {
}
}
return
ipCountQueryResultDto
;
return
ipCountQueryResultDto
;
}
}
@Override
public
HashMap
queryGift
(
String
username
)
{
return
null
;
}
@Override
public
void
addWhiteList
(
String
website
)
{
WhiteSite
whiteSite
=
new
WhiteSite
();
whiteSite
.
setWhite
(
website
);
whiteSiteRepository
.
save
(
whiteSite
);
}
}
}
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/PaymentServiceImpl.java
View file @
1939c414
...
@@ -102,6 +102,8 @@ public class PaymentServiceImpl implements PaymentService {
...
@@ -102,6 +102,8 @@ public class PaymentServiceImpl implements PaymentService {
try
{
try
{
UserPayment
byTradeNo
=
userPaymentRepository
.
findByTradeNo
(
tradeno
);
UserPayment
byTradeNo
=
userPaymentRepository
.
findByTradeNo
(
tradeno
);
if
(
byTradeNo
==
null
)
return
result
;
if
(
PaymentMethod
.
ALIPAY
.
equals
(
byTradeNo
.
getPaymentMethod
()))
if
(
PaymentMethod
.
ALIPAY
.
equals
(
byTradeNo
.
getPaymentMethod
()))
return
aliCheckOrderStatus
(
tradeno
,
chargeType
);
return
aliCheckOrderStatus
(
tradeno
,
chargeType
);
...
@@ -203,6 +205,15 @@ public class PaymentServiceImpl implements PaymentService {
...
@@ -203,6 +205,15 @@ public class PaymentServiceImpl implements PaymentService {
balance
.
setBalanced
(
balance
.
getBalanced
()
+
byTradeNo
.
getAmount
()
+
payBack
.
getBack
());
balance
.
setBalanced
(
balance
.
getBalanced
()
+
byTradeNo
.
getAmount
()
+
payBack
.
getBack
());
userBalanceRepository
.
save
(
balance
);
userBalanceRepository
.
save
(
balance
);
if
(
byName
.
getPromotionCode
()
!=
null
)
{
Account
account
=
accountRepository
.
findByPromotion
(
byName
.
getPromotionCode
());
if
(
account
!=
null
)
{
byName
.
getPromotion
().
setCommission
(
byName
.
getPromotion
().
getCommission
()
+
byTradeNo
.
getAmount
());
accountRepository
.
save
(
byName
);
}
}
}
}
result
.
setBalance
(
Math
.
round
(
balance
.
getBalanced
()));
result
.
setBalance
(
Math
.
round
(
balance
.
getBalanced
()));
...
@@ -326,6 +337,14 @@ public class PaymentServiceImpl implements PaymentService {
...
@@ -326,6 +337,14 @@ public class PaymentServiceImpl implements PaymentService {
balance
.
setBalanced
(
balance
.
getBalanced
()
+
byTradeNo
.
getAmount
()
+
payBack
.
getBack
());
balance
.
setBalanced
(
balance
.
getBalanced
()
+
byTradeNo
.
getAmount
()
+
payBack
.
getBack
());
userBalanceRepository
.
save
(
balance
);
userBalanceRepository
.
save
(
balance
);
if
(
byName
.
getPromotionCode
()
!=
null
)
{
Account
account
=
accountRepository
.
findByPromotion
(
byName
.
getPromotionCode
());
if
(
account
!=
null
)
{
byName
.
getPromotion
().
setCommission
(
byName
.
getPromotion
().
getCommission
()
+
byTradeNo
.
getAmount
());
accountRepository
.
save
(
byName
);
}
}
}
}
result
.
setBalance
(
Math
.
round
(
balance
.
getBalanced
()));
result
.
setBalance
(
Math
.
round
(
balance
.
getBalanced
()));
...
...
src/main/java/com/edgec/browserbackend/browser/task/PromotionTask.java
View file @
1939c414
...
@@ -31,7 +31,7 @@ public class PromotionTask {
...
@@ -31,7 +31,7 @@ public class PromotionTask {
@SchedulerLock
(
name
=
"transferExpiredScalingGroups"
,
lockAtLeastForString
=
"PT1H"
,
lockAtMostForString
=
"PT2H"
)
@SchedulerLock
(
name
=
"transferExpiredScalingGroups"
,
lockAtLeastForString
=
"PT1H"
,
lockAtMostForString
=
"PT2H"
)
@Scheduled
(
cron
=
"0 0 1 1 * ?"
)
@Scheduled
(
cron
=
"0 0 1 1 * ?"
)
public
void
count
Commission
()
{
public
void
count
Gift
()
{
List
<
Account
>
accounts
=
accountRepository
.
findByParentIsNull
();
List
<
Account
>
accounts
=
accountRepository
.
findByParentIsNull
();
for
(
Account
account
:
accounts
)
{
for
(
Account
account
:
accounts
)
{
String
code
=
account
.
getPromotion
().
getCode
();
String
code
=
account
.
getPromotion
().
getCode
();
...
@@ -48,12 +48,13 @@ public class PromotionTask {
...
@@ -48,12 +48,13 @@ public class PromotionTask {
for
(
Account
secondPromote
:
secondPromotes
)
{
for
(
Account
secondPromote
:
secondPromotes
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
promote
.
getName
(),
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
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
));
secondCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
secondCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
}
}
}
}
}
}
Promotion
promotion
=
account
.
getPromotion
();
Promotion
promotion
=
account
.
getPromotion
();
promotion
.
setTotalCommission
((
int
)(
promotion
.
getTotalCommission
()
+
totalCommission
));
promotion
.
setCommissionLastMonth
((
int
)
totalCommission
);
promotion
.
setCommissionLastMonth
((
int
)
totalCommission
);
promotion
.
setGift
(
totalCommission
*
0.08
);
promotion
.
setGift
(
totalCommission
*
0.08
);
if
(
account
.
getPromotion
().
isSale
())
{
if
(
account
.
getPromotion
().
isSale
())
{
...
@@ -63,4 +64,33 @@ public class PromotionTask {
...
@@ -63,4 +64,33 @@ public class PromotionTask {
accountRepository
.
save
(
account
);
accountRepository
.
save
(
account
);
}
}
}
}
@SchedulerLock
(
name
=
"transferExpiredScalingGroups"
,
lockAtLeastForString
=
"PT1H"
,
lockAtMostForString
=
"PT2H"
)
@Scheduled
(
cron
=
"0 0 1 * * ?"
)
public
void
countCommission
()
{
List
<
Account
>
accounts
=
accountRepository
.
findByParentIsNull
();
for
(
Account
account
:
accounts
)
{
String
code
=
account
.
getPromotion
().
getCode
();
List
<
Account
>
promotes
=
accountRepository
.
findByPromotionCode
(
code
);
double
totalCommission
=
0
;
double
secondCommission
=
0
;
for
(
Account
promote
:
promotes
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
promote
.
getName
(),
YearMonth
.
now
().
getYear
(),
YearMonth
.
now
().
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
().
getYear
(),
YearMonth
.
now
().
getMonthValue
(),
Arrays
.
asList
(
1
,
2
,
3
));
secondCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
}
}
}
account
.
getPromotion
().
setCommission
((
int
)
totalCommission
);
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