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
25401d34
Commit
25401d34
authored
Apr 11, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
admin接口
parent
1939c414
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
166 additions
and
6 deletions
+166
-6
AdministratorController.java
...erbackend/account/controller/AdministratorController.java
+21
-0
Promotion.java
...va/com/edgec/browserbackend/account/domain/Promotion.java
+1
-1
AccountPromotionDto.java
...edgec/browserbackend/account/dto/AccountPromotionDto.java
+38
-0
PromotionQueryResultDto.java
...c/browserbackend/account/dto/PromotionQueryResultDto.java
+53
-0
AccountRepository.java
.../browserbackend/account/repository/AccountRepository.java
+4
-0
AdministratorService.java
.../browserbackend/account/service/AdministratorService.java
+2
-1
AdministratorServiceImpl.java
...ackend/account/service/impl/AdministratorServiceImpl.java
+47
-4
No files found.
src/main/java/com/edgec/browserbackend/account/controller/AdministratorController.java
View file @
25401d34
...
...
@@ -405,6 +405,27 @@ public class AdministratorController {
return
resultDto
;
}
//统计推广码下消费
@PreAuthorize
(
Securitys
.
ADMIN_EL
)
@RequestMapping
(
path
=
"/0xadministrator/promotioncode/query"
,
method
=
RequestMethod
.
GET
)
public
ResultDto
queryPromotion
(
Principal
principal
,
@RequestParam
(
value
=
"page"
)
int
page
,
@RequestParam
(
value
=
"size"
)
int
size
,
@RequestParam
(
value
=
"strDate1"
)
String
strDate1
,
@RequestParam
(
value
=
"strDate2"
)
String
strDate2
,
@RequestParam
(
value
=
"username"
,
required
=
false
)
String
username
,
@RequestParam
(
value
=
"promotionCode"
,
required
=
false
)
String
promotionCode
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
Pageable
pageable
=
PageRequest
.
of
(
page
,
size
);
resultDto
.
setData
(
administratorService
.
queryPromotion
(
pageable
,
username
,
promotionCode
,
strDate1
,
strDate2
));
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
;
}
}
...
...
src/main/java/com/edgec/browserbackend/account/domain/Promotion.java
View file @
25401d34
...
...
@@ -11,7 +11,7 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
public
class
Promotion
{
private
String
code
;
private
int
invitedUsers
;
//好友总消费
//好友
本月以前
总消费
private
int
totalCommission
;
//好友当月消费
private
int
commission
;
...
...
src/main/java/com/edgec/browserbackend/account/dto/AccountPromotionDto.java
0 → 100644
View file @
25401d34
package
com
.
edgec
.
browserbackend
.
account
.
dto
;
import
com.edgec.browserbackend.account.domain.Account
;
import
com.edgec.browserbackend.account.domain.Promotion
;
import
java.util.Date
;
public
class
AccountPromotionDto
{
private
String
username
;
private
Date
signupDate
;
private
Promotion
promotion
;
public
AccountPromotionDto
()
{
}
public
AccountPromotionDto
(
Account
account
)
{
this
.
username
=
account
.
getName
();
this
.
signupDate
=
account
.
getSignupDate
();
this
.
promotion
=
account
.
getPromotion
();
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
Date
getSignupDate
()
{
return
signupDate
;
}
public
void
setSignupDate
(
Date
signupDate
)
{
this
.
signupDate
=
signupDate
;
}
}
src/main/java/com/edgec/browserbackend/account/dto/PromotionQueryResultDto.java
0 → 100644
View file @
25401d34
package
com
.
edgec
.
browserbackend
.
account
.
dto
;
import
com.edgec.browserbackend.account.domain.Account
;
import
com.edgec.browserbackend.account.domain.Promotion
;
import
org.springframework.data.domain.Page
;
public
class
PromotionQueryResultDto
{
private
String
username
;
private
String
code
;
Page
<
AccountPromotionDto
>
users
;
Promotion
promotion
;
public
PromotionQueryResultDto
(){
}
public
PromotionQueryResultDto
(
Account
account
){
this
.
username
=
account
.
getName
();
this
.
code
=
account
.
getPromotion
().
getCode
();
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
String
getCode
()
{
return
code
;
}
public
void
setCode
(
String
code
)
{
this
.
code
=
code
;
}
public
Promotion
getPromotion
()
{
return
promotion
;
}
public
void
setPromotion
(
Promotion
promotion
)
{
this
.
promotion
=
promotion
;
}
public
Page
<
AccountPromotionDto
>
getUsers
()
{
return
users
;
}
public
void
setUsers
(
Page
<
AccountPromotionDto
>
users
)
{
this
.
users
=
users
;
}
}
src/main/java/com/edgec/browserbackend/account/repository/AccountRepository.java
View file @
25401d34
...
...
@@ -29,6 +29,10 @@ public interface AccountRepository extends MongoRepository<Account, String>, Acc
Page
<
Account
>
findAllBySignupDateBetween
(
Pageable
pageable
,
Date
startDate
,
Date
endDate
);
List
<
Account
>
findAllBySignupDateBetweenAndPromotionCode
(
Date
startDate
,
Date
endDate
,
String
promotionCode
);
Page
<
Account
>
findAllBySignupDateBetweenAndPromotionCodeAndParentIsNull
(
Pageable
pageable
,
Date
startDate
,
Date
endDate
,
String
promotionCode
);
Page
<
Account
>
findAllBySignupDateBetweenAndParentIsNull
(
Pageable
pageable
,
Date
startDate
,
Date
endDate
);
Page
<
Account
>
findAllBySignupDateBetweenAndParentIsNullAndAuthorizedNot
(
Pageable
pageable
,
Date
startDate
,
Date
endDate
,
int
authorized
);
...
...
src/main/java/com/edgec/browserbackend/account/service/AdministratorService.java
View file @
25401d34
...
...
@@ -3,6 +3,7 @@ package com.edgec.browserbackend.account.service;
import
com.edgec.browserbackend.account.domain.*
;
import
com.edgec.browserbackend.account.dto.BillQueryResultDto
;
import
com.edgec.browserbackend.account.dto.IpCountQueryResultDto
;
import
com.edgec.browserbackend.account.dto.PromotionQueryResultDto
;
import
com.edgec.browserbackend.browser.domain.IpResource
;
import
com.edgec.browserbackend.browser.dto.IpResourceDto
;
import
org.springframework.data.domain.Page
;
...
...
@@ -56,7 +57,7 @@ public interface AdministratorService {
IpCountQueryResultDto
queyrIpCount
(
String
username
);
HashMap
queryGift
(
String
username
);
PromotionQueryResultDto
queryPromotion
(
Pageable
pageable
,
String
username
,
String
promotionCode
,
String
strDate1
,
String
strDate2
);
void
addWhiteList
(
String
website
);
}
src/main/java/com/edgec/browserbackend/account/service/impl/AdministratorServiceImpl.java
View file @
25401d34
package
com
.
edgec
.
browserbackend
.
account
.
service
.
impl
;
import
com.edgec.browserbackend.account.domain.*
;
import
com.edgec.browserbackend.account.dto.AccountPromotionDto
;
import
com.edgec.browserbackend.account.dto.BillQueryResultDto
;
import
com.edgec.browserbackend.account.dto.IpCountQueryResultDto
;
import
com.edgec.browserbackend.account.dto.PromotionQueryResultDto
;
import
com.edgec.browserbackend.account.exception.AccountErrorCode
;
import
com.edgec.browserbackend.account.repository.*
;
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.commons.error.ClientRequestException
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -15,17 +18,16 @@ import org.slf4j.LoggerFactory;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageImpl
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.Pageable
;
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.*
;
import
java.util.stream.DoubleStream
;
@Service
...
...
@@ -363,8 +365,49 @@ public class AdministratorServiceImpl implements AdministratorService {
}
@Override
public
HashMap
queryGift
(
String
username
)
{
return
null
;
public
PromotionQueryResultDto
queryPromotion
(
Pageable
pageable
,
String
username
,
String
promotionCode
,
String
strDate1
,
String
strDate2
)
{
if
(
StringUtils
.
isBlank
(
username
)
&&
StringUtils
.
isBlank
(
promotionCode
))
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
Account
account
=
null
;
if
(!
StringUtils
.
isBlank
(
username
))
account
=
accountRepository
.
findByName
(
username
);
else
account
=
accountRepository
.
findByPromotion
(
promotionCode
);
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
if
(
account
.
getParent
()
!=
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
PromotionQueryResultDto
promotionQueryResultDto
=
new
PromotionQueryResultDto
(
account
);
promotionQueryResultDto
.
setUsername
(
username
);
try
{
Date
dateTime1
=
formatter
.
parse
(
strDate1
);
Date
dateTime2
=
formatter
.
parse
(
strDate2
);
Page
<
Account
>
accountPage
=
accountRepository
.
findAllBySignupDateBetweenAndPromotionCodeAndParentIsNull
(
pageable
,
dateTime1
,
dateTime2
,
account
.
getPromotion
().
getCode
());
List
<
AccountPromotionDto
>
accountPromotionDtos
=
new
ArrayList
<>();
accountPage
.
get
().
forEach
(
account1
->
{
accountPromotionDtos
.
add
(
new
AccountPromotionDto
(
account1
));
});
Page
<
AccountPromotionDto
>
accountPromotionDtoPage
=
new
PageImpl
<
AccountPromotionDto
>(
accountPromotionDtos
);
promotionQueryResultDto
.
setUsers
(
accountPromotionDtoPage
);
List
<
Account
>
accounts
=
accountRepository
.
findAllBySignupDateBetweenAndPromotionCode
(
dateTime1
,
dateTime2
,
account
.
getPromotion
().
getCode
());
Promotion
promotion
=
new
Promotion
();
accounts
.
forEach
(
x
->
{
promotion
.
setInvitedUsers
(
promotion
.
getInvitedUsers
()
+
1
);
promotion
.
setTotalCommission
(
promotion
.
getTotalCommission
()
+
x
.
getPromotion
().
getTotalCommission
());
promotion
.
setCommission
(
promotion
.
getCommission
()
+
x
.
getPromotion
().
getCommission
());
promotion
.
setWithdrawn
(
promotion
.
getWithdrawn
()
+
x
.
getPromotion
().
getWithdrawn
());
promotion
.
setAllGift
(
promotion
.
getAllGift
()
+
x
.
getPromotion
().
getAllGift
());
promotion
.
setGift
(
promotion
.
getGift
()
+
x
.
getPromotion
().
getGift
());
promotion
.
setCommissionLastMonth
(
promotion
.
getCommissionLastMonth
()
+
x
.
getPromotion
().
getCommissionLastMonth
());
});
promotionQueryResultDto
.
setPromotion
(
promotion
);
return
promotionQueryResultDto
;
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
());
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
}
}
@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