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
30c62028
Commit
30c62028
authored
Jul 20, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'staging' into 'master'
Staging See merge request
!153
parents
25d269e9
3f484a2b
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
349 additions
and
435 deletions
+349
-435
pom.xml
pom.xml
+2
-2
AdminController.java
...ec/browserbackend/account/controller/AdminController.java
+4
-9
AdministratorController.java
...erbackend/account/controller/AdministratorController.java
+86
-67
PaymentServiceImpl.java
...owserbackend/account/service/impl/PaymentServiceImpl.java
+6
-0
UserServiceImpl.java
...gec/browserbackend/auth/service/Impl/UserServiceImpl.java
+4
-3
TempController.java
...gec/browserbackend/browser/controller/TempController.java
+4
-0
IpResource.java
...a/com/edgec/browserbackend/browser/domain/IpResource.java
+93
-6
IpResourceUnwindResultDto.java
...browserbackend/browser/dto/IpResourceUnwindResultDto.java
+57
-262
IpResourceRepositoryCustomImpl.java
...nd/browser/repository/IpResourceRepositoryCustomImpl.java
+34
-64
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+14
-7
TempServiceImpl.java
.../browserbackend/browser/service/Impl/TempServiceImpl.java
+23
-0
TempService.java
...com/edgec/browserbackend/browser/service/TempService.java
+2
-0
BrowserTask.java
...va/com/edgec/browserbackend/browser/task/BrowserTask.java
+15
-13
PaymentTask.java
...va/com/edgec/browserbackend/browser/task/PaymentTask.java
+1
-0
Set3proxyTask.java
.../com/edgec/browserbackend/browser/task/Set3proxyTask.java
+1
-1
Trans.java
...ain/java/com/edgec/browserbackend/common/utils/Trans.java
+3
-1
No files found.
pom.xml
View file @
30c62028
...
...
@@ -103,12 +103,12 @@
<artifactId>
alipay-sdk-java
</artifactId>
<version>
3.7.110.ALL
</version>
</dependency>
<dependency>
<
!--<
dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>1.50.3</version>
<scope>test</scope>
</dependency>
</dependency>
-->
<dependency>
<groupId>
com.jayway.jsonpath
</groupId>
<artifactId>
json-path
</artifactId>
...
...
src/main/java/com/edgec/browserbackend/account/controller/AdminController.java
View file @
30c62028
...
...
@@ -5,18 +5,12 @@ import com.edgec.browserbackend.account.domain.AccountDto;
import
com.edgec.browserbackend.account.dto.ResultDto
;
import
com.edgec.browserbackend.account.dto.SubUsersRequestDto
;
import
com.edgec.browserbackend.account.service.AccountService
;
import
com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode
;
import
com.edgec.browserbackend.browser.dto.ShopRequestDto
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.Valid
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.OutputStream
;
import
java.net.URLEncoder
;
import
java.security.Principal
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -28,6 +22,7 @@ public class AdminController {
@Autowired
AccountService
accountService
;
@RequestMapping
(
path
=
"/subuser/addone"
,
method
=
RequestMethod
.
POST
)
public
ResultDto
createSubAccount
(
Principal
principal
,
@Valid
@RequestBody
AccountDto
user
)
{
ResultDto
resultDto
=
new
ResultDto
();
...
...
@@ -68,7 +63,7 @@ public class AdminController {
ResultDto
resultDto
=
new
ResultDto
();
try
{
LimitedUsers
.
filterIfLimitedUser
(
principal
);
Account
account1
=
accountService
.
saveSub
(
principal
.
getName
(),
user
);
Account
account1
=
accountService
.
saveSub
(
principal
.
getName
(),
user
);
resultDto
.
setStatus
(
0
);
resultDto
.
setData
(
account1
);
}
catch
(
ClientRequestException
e
)
{
...
...
@@ -105,7 +100,7 @@ public class AdminController {
LimitedUsers
.
filterIfLimitedUser
(
principal
);
accountService
.
deleteSub
(
principal
.
getName
(),
child
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
...
...
@@ -123,7 +118,7 @@ public class AdminController {
LimitedUsers
.
filterIfLimitedUser
(
principal
);
resultDto
.
setData
(
accountService
.
getSubUserList
(
principal
.
getName
(),
shopRequestDto
.
getPage
(),
shopRequestDto
.
getAmount
()));
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
...
...
src/main/java/com/edgec/browserbackend/account/controller/AdministratorController.java
View file @
30c62028
package
com
.
edgec
.
browserbackend
.
account
.
controller
;
import
com.edgec.browserbackend.account.domain.*
;
import
com.edgec.browserbackend.account.dto.BillQueryResultDto
;
import
com.edgec.browserbackend.account.dto.ResultDto
;
import
com.edgec.browserbackend.account.dto.UserUsedDto
;
import
com.edgec.browserbackend.account.service.*
;
import
com.edgec.browserbackend.account.domain.*
;
import
com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode
;
import
com.edgec.browserbackend.browser.service.TempService
;
import
com.edgec.browserbackend.common.auth.Securitys
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -61,26 +61,29 @@ public class AdministratorController {
@Autowired
private
AccountService
accountService
;
@Autowired
private
TempService
tempService
;
//--------------------------------ROOT用户操作--------------------------------------//
//管理员注册tested
@PreAuthorize
(
Securitys
.
ROOT_EL
)
@RequestMapping
(
path
=
"/0xadministrator"
,
method
=
RequestMethod
.
POST
)
public
Administrator
createNewAdministrator
(
@Valid
@RequestBody
Administrator
administrator
){
@RequestMapping
(
path
=
"/0xadministrator"
,
method
=
RequestMethod
.
POST
)
public
Administrator
createNewAdministrator
(
@Valid
@RequestBody
Administrator
administrator
)
{
return
administratorService
.
createAdministrator
(
administrator
);
}
//删除管理员testing
@PreAuthorize
(
Securitys
.
ROOT_EL
)
@RequestMapping
(
path
=
"/0xadministrator/{name}"
,
method
=
RequestMethod
.
DELETE
)
public
void
deleteAdmin
(
@PathVariable
String
name
)
{
public
void
deleteAdmin
(
@PathVariable
String
name
)
{
administratorService
.
deleteAdministrator
(
name
);
}
// 查询所有的管理员
@PreAuthorize
(
Securitys
.
ROOT_EL
)
@RequestMapping
(
path
=
"/0xadministrator"
,
method
=
RequestMethod
.
GET
)
public
List
<
Administrator
>
getALLAdministrator
(){
@RequestMapping
(
path
=
"/0xadministrator"
,
method
=
RequestMethod
.
GET
)
public
List
<
Administrator
>
getALLAdministrator
()
{
return
administratorService
.
getAllAdministrator
();
}
...
...
@@ -88,8 +91,8 @@ public class AdministratorController {
//修改管理员权限tested
@PreAuthorize
(
Securitys
.
ROOT_EL
)
@RequestMapping
(
path
=
"/0xadministrator/{name}"
,
method
=
RequestMethod
.
PUT
)
public
Administrator
updateAgencyInfo
(
@PathVariable
String
name
,
@Valid
@RequestBody
String
string
){
return
administratorService
.
updateAdministrator
(
name
,
string
);
public
Administrator
updateAgencyInfo
(
@PathVariable
String
name
,
@Valid
@RequestBody
String
string
)
{
return
administratorService
.
updateAdministrator
(
name
,
string
);
}
//用户通过银行转账,手动插入余额记录
...
...
@@ -109,17 +112,15 @@ public class AdministratorController {
//--------------------------------用户--------------------------------------//
//根据用户的性名,或者电话,或者邮件,查询用户的信息tested
@PreAuthorize
(
"hasRole('ADMIN')"
)
@RequestMapping
(
path
=
"/0xadministrator/searchuser/{target}"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
path
=
"/0xadministrator/searchuser/{target}"
,
method
=
RequestMethod
.
GET
)
public
Account
getAccountByTarget
(
@RequestParam
(
"by"
)
String
by
,
@PathVariable
String
target
)
{
Account
searchAccount
=
new
Account
();
if
(
"name"
.
equals
(
by
))
{
if
(
"name"
.
equals
(
by
))
{
searchAccount
=
administratorService
.
getAccountByName
(
target
);
}
else
if
(
"phoneNumber"
.
equals
(
by
)){
}
else
if
(
"phoneNumber"
.
equals
(
by
))
{
searchAccount
=
administratorService
.
getAccountByPhoneNumber
(
target
);
}
else
if
(
"email"
.
equals
(
by
)){
}
else
if
(
"email"
.
equals
(
by
))
{
searchAccount
=
administratorService
.
getAccountByEmail
(
target
);
}
...
...
@@ -129,26 +130,25 @@ public class AdministratorController {
//根据用户名查询用户账单tested
@PreAuthorize
(
"hasRole('ADMIN')"
)
@RequestMapping
(
path
=
"/0xadministrator/searchuserbill/{name}"
,
method
=
RequestMethod
.
GET
)
public
BillQueryResultDto
getUserBillByName
(
@PathVariable
String
name
,
@RequestParam
(
"page"
)
int
page
,
@RequestParam
(
"size"
)
int
size
){
@RequestMapping
(
path
=
"/0xadministrator/searchuserbill/{name}"
,
method
=
RequestMethod
.
GET
)
public
BillQueryResultDto
getUserBillByName
(
@PathVariable
String
name
,
@RequestParam
(
"page"
)
int
page
,
@RequestParam
(
"size"
)
int
size
)
{
return
administratorService
.
getUserBillingByName
(
name
);
}
//给用户激活未激活或者被锁住的账户tested
@PreAuthorize
(
"hasRole('ADMIN')"
)
@RequestMapping
(
path
=
"/0xadministrator/unlockaccount/{name}"
,
method
=
RequestMethod
.
PUT
)
public
Account
unLockAccount
(
@PathVariable
String
name
,
@Valid
@RequestBody
Account
account
)
{
return
administratorService
.
unLockLockedAccount
(
name
,
account
);
@RequestMapping
(
path
=
"/0xadministrator/unlockaccount/{name}"
,
method
=
RequestMethod
.
PUT
)
public
Account
unLockAccount
(
@PathVariable
String
name
,
@Valid
@RequestBody
Account
account
)
{
return
administratorService
.
unLockLockedAccount
(
name
,
account
);
}
//锁住异常用户tested
@PreAuthorize
(
"hasRole('ADMIN')"
)
@RequestMapping
(
path
=
"/0xadministrator/lockaccount/{name}"
,
method
=
RequestMethod
.
PUT
)
public
Account
lockAccount
(
@PathVariable
String
name
,
@Valid
@RequestBody
Account
account
)
{
return
administratorService
.
lockAbnormalAccount
(
name
,
account
);
@RequestMapping
(
path
=
"/0xadministrator/lockaccount/{name}"
,
method
=
RequestMethod
.
PUT
)
public
Account
lockAccount
(
@PathVariable
String
name
,
@Valid
@RequestBody
Account
account
)
{
return
administratorService
.
lockAbnormalAccount
(
name
,
account
);
}
//查询用户余额
...
...
@@ -190,32 +190,32 @@ public class AdministratorController {
//查看所有的用户<分页查询> tested
@PreAuthorize
(
"hasRole('ADMIN')"
)
@RequestMapping
(
path
=
"/0xadministrator/searchalluser"
,
method
=
RequestMethod
.
GET
)
public
Page
<
Account
>
searchAllUser
(
@RequestParam
(
value
=
"page"
)
int
page
,
@RequestParam
(
value
=
"size"
)
int
size
)
{
//(@PathVariable int page){
Pageable
pageable
=
PageRequest
.
of
(
page
,
size
);
@RequestMapping
(
path
=
"/0xadministrator/searchalluser"
,
method
=
RequestMethod
.
GET
)
public
Page
<
Account
>
searchAllUser
(
@RequestParam
(
value
=
"page"
)
int
page
,
@RequestParam
(
value
=
"size"
)
int
size
)
{
//(@PathVariable int page){
Pageable
pageable
=
PageRequest
.
of
(
page
,
size
);
return
administratorService
.
searchAllUserPage
(
pageable
);
}
//查询某时段内增加的用户
@PreAuthorize
(
"hasRole('ADMIN')"
)
@RequestMapping
(
path
=
"/0xadministrator/searchperioduser"
,
method
=
RequestMethod
.
GET
)
public
Page
<
Account
>
searchCreateAccount
(
@RequestParam
(
value
=
"page"
)
int
page
,
@RequestParam
(
value
=
"size"
)
int
size
,
@RequestParam
(
value
=
"strDate1"
)
String
strDate1
,
@RequestParam
(
value
=
"strDate2"
)
String
strDate2
,
@RequestParam
(
value
=
"isAuthorized"
,
defaultValue
=
"5"
)
int
isAuthorized
)
{
@RequestMapping
(
path
=
"/0xadministrator/searchperioduser"
,
method
=
RequestMethod
.
GET
)
public
Page
<
Account
>
searchCreateAccount
(
@RequestParam
(
value
=
"page"
)
int
page
,
@RequestParam
(
value
=
"size"
)
int
size
,
@RequestParam
(
value
=
"strDate1"
)
String
strDate1
,
@RequestParam
(
value
=
"strDate2"
)
String
strDate2
,
@RequestParam
(
value
=
"isAuthorized"
,
defaultValue
=
"5"
)
int
isAuthorized
)
{
Pageable
pageable
=
PageRequest
.
of
(
page
,
size
);
return
administratorService
.
searchCreateAccountBetween
(
pageable
,
strDate1
,
strDate2
,
isAuthorized
);
return
administratorService
.
searchCreateAccountBetween
(
pageable
,
strDate1
,
strDate2
,
isAuthorized
);
}
// 查询所有用户消费
@PreAuthorize
(
Securitys
.
ADMIN_EL
)
@RequestMapping
(
path
=
"/0xadministrator/allused"
,
method
=
RequestMethod
.
GET
)
public
Page
<
UserUsedDto
>
findAllused
(
@RequestParam
(
value
=
"page"
)
int
page
,
@RequestParam
(
value
=
"size"
)
int
size
)
{
public
Page
<
UserUsedDto
>
findAllused
(
@RequestParam
(
value
=
"page"
)
int
page
,
@RequestParam
(
value
=
"size"
)
int
size
)
{
Pageable
pageable
=
PageRequest
.
of
(
page
,
size
);
return
administratorService
.
getAllUserUsed
(
pageable
);
}
//search company earnings detail by month tested
@PreAuthorize
(
"hasRole('ADMIN')"
)
@RequestMapping
(
path
=
"/0xadministrator/companyearning/{stringdate}"
,
method
=
RequestMethod
.
GET
)
public
List
<
CompanyEarningsDto
>
getCompanyEarning
(
@PathVariable
String
stringdate
)
{
@RequestMapping
(
path
=
"/0xadministrator/companyearning/{stringdate}"
,
method
=
RequestMethod
.
GET
)
public
List
<
CompanyEarningsDto
>
getCompanyEarning
(
@PathVariable
String
stringdate
)
{
return
administratorService
.
getCompanyEarningDetail
(
stringdate
);
}
...
...
@@ -230,17 +230,18 @@ public class AdministratorController {
//查找某个用户或者代理有没有被锁住
@PreAuthorize
(
"hasRole('ADMIN')"
)
@RequestMapping
(
path
=
"/0xadministrator/lockstate/{name}"
,
method
=
RequestMethod
.
GET
)
public
boolean
getLockState
(
@PathVariable
String
name
){
@RequestMapping
(
path
=
"/0xadministrator/lockstate/{name}"
,
method
=
RequestMethod
.
GET
)
public
boolean
getLockState
(
@PathVariable
String
name
)
{
return
administratorService
.
getUserLockState
(
name
);
}
//对欠费用户强制停机
/** 用户费率 */
/**
* 用户费率
*/
// 设置费率
@PreAuthorize
(
Securitys
.
ADMIN_EL
)
...
...
@@ -252,7 +253,7 @@ public class AdministratorController {
@PreAuthorize
(
Securitys
.
ADMIN_EL
)
@RequestMapping
(
path
=
"/0xadministrator/adduserrate"
,
method
=
RequestMethod
.
POST
)
public
void
insertUserRate
(
@RequestBody
UserRate
userRate
){
public
void
insertUserRate
(
@RequestBody
UserRate
userRate
)
{
userRateService
.
addUserRate
(
userRate
);
}
...
...
@@ -290,10 +291,10 @@ public class AdministratorController {
//每月预付费统计分页展示
@PreAuthorize
(
Securitys
.
ADMIN_EL
)
@RequestMapping
(
path
=
"/0xadministrator/listReport"
,
method
=
RequestMethod
.
GET
)
public
Page
<
CompanyMonthReport
>
listMonthReport
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"0"
)
int
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
)
int
size
)
{
public
Page
<
CompanyMonthReport
>
listMonthReport
(
@RequestParam
(
value
=
"page"
,
defaultValue
=
"0"
)
int
page
,
@RequestParam
(
value
=
"size"
,
defaultValue
=
"10"
)
int
size
)
{
Pageable
pageable
=
PageRequest
.
of
(
page
,
size
);
Pageable
pageable
=
PageRequest
.
of
(
page
,
size
);
return
monthReportService
.
listMonthReport
(
pageable
);
}
...
...
@@ -308,29 +309,29 @@ public class AdministratorController {
//获取用户企业认证的图片
@PreAuthorize
(
Securitys
.
ADMIN_EL
)
@RequestMapping
(
path
=
"/0xadministrator/authorize/files"
,
method
=
RequestMethod
.
GET
)
public
ResultDto
getAuthorizeFiles
(
Principal
principal
,
@RequestParam
(
"username"
)
String
username
,
HttpServletResponse
response
)
{
public
ResultDto
getAuthorizeFiles
(
Principal
principal
,
@RequestParam
(
"username"
)
String
username
,
HttpServletResponse
response
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
File
tempFile
=
accountService
.
getAuthorizeFiles
(
username
);
try
(
OutputStream
os
=
response
.
getOutputStream
();
FileInputStream
fis
=
new
FileInputStream
(
tempFile
))
{
try
(
OutputStream
os
=
response
.
getOutputStream
();
FileInputStream
fis
=
new
FileInputStream
(
tempFile
))
{
response
.
setHeader
(
"content-type"
,
"application/octet-stream"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
"Licenses.zip"
,
"UTF-8"
));
int
len
=
0
;
byte
[]
bt
=
new
byte
[
5
*
1024
];
while
((
len
=
fis
.
read
(
bt
))
!=
-
1
)
{
os
.
write
(
bt
,
0
,
len
);
int
len
=
0
;
byte
[]
bt
=
new
byte
[
5
*
1024
];
while
((
len
=
fis
.
read
(
bt
))
!=
-
1
)
{
os
.
write
(
bt
,
0
,
len
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
}
finally
{
}
finally
{
tempFile
.
delete
();
}
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
...
...
@@ -348,7 +349,7 @@ public class AdministratorController {
try
{
resultDto
.
setData
(
accountService
.
getAuthorizeDetails
(
username
));
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
...
...
@@ -366,7 +367,7 @@ public class AdministratorController {
try
{
resultDto
.
setData
(
accountService
.
setAuthorize
(
username
,
isAgree
));
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
...
...
@@ -385,7 +386,7 @@ public class AdministratorController {
try
{
administratorService
.
addPromotionCode
(
username
,
promotionCode
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
...
...
@@ -403,7 +404,7 @@ public class AdministratorController {
try
{
administratorService
.
addWhiteList
(
website
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
...
...
@@ -421,7 +422,7 @@ public class AdministratorController {
try
{
administratorService
.
addUserWhiteList
(
username
,
website
);
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
...
...
@@ -439,7 +440,7 @@ public class AdministratorController {
try
{
resultDto
.
setData
(
administratorService
.
queyrIpCount
(
username
));
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
...
...
@@ -452,15 +453,15 @@ public class AdministratorController {
//统计推广码下消费
@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
,
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
)
{
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
...
...
@@ -477,18 +478,18 @@ public class AdministratorController {
if
(
StringUtils
.
isNotBlank
(
key
)
&&
key
.
equals
(
mykey
))
file
=
administratorService
.
getProxyConfig
();
if
(
file
!=
null
)
{
try
(
OutputStream
os
=
response
.
getOutputStream
();
FileInputStream
fis
=
new
FileInputStream
(
file
))
{
try
(
OutputStream
os
=
response
.
getOutputStream
();
FileInputStream
fis
=
new
FileInputStream
(
file
))
{
response
.
setHeader
(
"content-type"
,
"application/octet-stream"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
"3proxy.cfg"
,
"UTF-8"
));
int
len
=
0
;
byte
[]
bt
=
new
byte
[
50
*
1024
];
while
((
len
=
fis
.
read
(
bt
))
!=
-
1
)
{
os
.
write
(
bt
,
0
,
len
);
int
len
=
0
;
byte
[]
bt
=
new
byte
[
50
*
1024
];
while
((
len
=
fis
.
read
(
bt
))
!=
-
1
)
{
os
.
write
(
bt
,
0
,
len
);
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
e
.
getMessage
(),
e
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
}
finally
{
...
...
@@ -499,6 +500,24 @@ public class AdministratorController {
}
}
/**
* 专线回落
*/
@PutMapping
(
value
=
"/0xadministrator/updateip/{addr}/{flag}"
)
public
ResultDto
updateIp
(
@PathVariable
String
addr
,
@PathVariable
String
flag
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
tempService
.
saveIpResource
(
addr
,
flag
);
resultDto
.
setStatus
(
0
);
}
catch
(
Exception
e
)
{
resultDto
.
setStatus
(-
1
);
resultDto
.
setData
(
e
.
getMessage
());
}
return
resultDto
;
}
}
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/PaymentServiceImpl.java
View file @
30c62028
...
...
@@ -70,6 +70,7 @@ public class PaymentServiceImpl implements PaymentService {
// 当微信回调该接口时,说明微信那边已经充值成功,这个时候需要更新系统中 userpayment 充值状态
UserPayment
byTradeNo
=
userPaymentRepository
.
findByTradeNo
(
tradno
);
if
(
byTradeNo
!=
null
&&
!
byTradeNo
.
isSucceed
())
{
log
.
info
(
"微信支付回调确认订单"
+
byTradeNo
.
getTradeNo
()
+
"支付状态,此时chargeType为 0"
);
wxCheckOrderStatus
(
byTradeNo
.
getTradeNo
(),
0
);
}
return
"<xml>\n"
+
...
...
@@ -83,6 +84,7 @@ public class PaymentServiceImpl implements PaymentService {
public
void
alipaCallback
(
String
tradno
)
{
UserPayment
byTradeNo
=
userPaymentRepository
.
findByTradeNo
(
tradno
);
if
(
byTradeNo
!=
null
&&
!
byTradeNo
.
isSucceed
())
{
log
.
info
(
"支付宝支付回调确认订单"
+
byTradeNo
.
getTradeNo
()
+
"支付状态,此时chargeType为 0"
);
aliCheckOrderStatus
(
byTradeNo
.
getTradeNo
(),
0
);
}
}
...
...
@@ -791,6 +793,7 @@ public class PaymentServiceImpl implements PaymentService {
// 2.1 更新 userPayment 的支付状态为成功
boolean
b
=
userPaymentRepository
.
updatePaymentResult
(
byTradeNo
,
true
);
if
(
b
)
{
log
.
info
(
"订单 "
+
byTradeNo
.
getTradeNo
()
+
" 的支付状态更新为成功"
);
// 2.2 获取充值优惠赠送
PayBack
payBack
=
payBackRepository
.
findByPay
(
byTradeNo
.
getAmount
());
if
(
payBack
==
null
)
{
...
...
@@ -802,11 +805,13 @@ public class PaymentServiceImpl implements PaymentService {
// 2.3 构建用户充值信息并保存
UserPrePaidBilling
bill
=
getUserPrePaidBilling
(
byTradeNo
,
byName
,
balance
,
payBack
);
userPrePaidBillingRepository
.
save
(
bill
);
log
.
info
(
"构建订单 "
+
byTradeNo
.
getTradeNo
()
+
" 的充值信息成功"
);
}
// 2.4 更新账户余额 userBalance
balance
.
setBalanced
(
balance
.
getBalanced
()
+
byTradeNo
.
getAmount
()
+
payBack
.
getBack
());
userBalanceRepository
.
save
(
balance
);
log
.
info
(
"更新充值订单 "
+
byTradeNo
.
getTradeNo
()
+
" 所对应的账户 "
+
balance
.
getUsername
()
+
" 的余额成功"
);
// 2.5 如果当前用户通过邀请码注册的,则更新邀请人的佣金
if
(
byName
.
getPromotionCode
()
!=
null
)
{
...
...
@@ -814,6 +819,7 @@ public class PaymentServiceImpl implements PaymentService {
if
(
account
!=
null
)
{
account
.
getPromotion
().
setCommission
(
account
.
getPromotion
().
getCommission
()
+
byTradeNo
.
getAmount
());
accountRepository
.
save
(
account
);
log
.
info
(
"更新邀请人的佣金成功"
);
}
}
}
...
...
src/main/java/com/edgec/browserbackend/auth/service/Impl/UserServiceImpl.java
View file @
30c62028
...
...
@@ -107,13 +107,14 @@ public class UserServiceImpl implements UserService {
}
);
String
hash
=
encoder
.
encode
(
user
.
getPassword
());
user
.
setPassword
(
hash
);
String
password
=
user
.
getPassword
();
String
hash
=
encoder
.
encode
(
password
);
user
.
setPassword
(
hash
);
repository
.
save
(
user
);
// 保存明文密码
userCodeRepository
.
save
(
new
UserCode
(
user
.
getUsername
(),
user
.
getPassword
()
));
userCodeRepository
.
save
(
new
UserCode
(
user
.
getUsername
(),
password
));
log
.
info
(
"new user has been created: {}"
,
user
.
getUsername
());
}
...
...
src/main/java/com/edgec/browserbackend/browser/controller/TempController.java
View file @
30c62028
...
...
@@ -18,8 +18,12 @@ public class TempController {
@Autowired
private
TempService
tempService
;
/**
* 记住用户明文密码
*/
@PostMapping
(
value
=
"/usercode"
)
public
void
addUserCode
(
@RequestBody
UserCode
userCode
)
{
tempService
.
save
(
userCode
);
}
}
src/main/java/com/edgec/browserbackend/browser/domain/IpResource.java
View file @
30c62028
...
...
@@ -21,42 +21,129 @@ public class IpResource implements Serializable {
@Id
private
String
id
;
/**
* ip 地址
*/
private
String
addr
;
/**
* ip 类型,默认是 ip代理 模式
*/
private
IpType
ipType
=
IpType
.
VENDOR
;
/**
* ip 的具体代理使用
*/
private
Vendor
vendor
;
private
String
vendorCn
;
/**
* ip 地域
*/
private
String
region
;
private
String
regionCn
;
//0:正常, 1:已过期, 2:即将过期, 3:正在分配, 4:未使用, 5:已失效, 6:未分配, 7:未缴费, 8:分配成功
/**
* ip 的状态
* 0:正常, 1:已过期, 2:即将过期, 3:正在分配, 4:未使用, 5:已失效, 6:未分配, 7:未缴费, 8:分配成功
*/
private
int
status
;
/**
* ip 端口号
*/
private
List
<
String
>
port
;
/**
* ip的购买时间点
*/
private
long
purchasedTime
;
/**
* ip的过期的时间点
*/
private
long
validTime
;
private
String
details
;
/**
* ip的绑定历史
*/
private
List
<
BindHistory
>
bindHistory
=
new
ArrayList
<>();
/**
* ip的状态
* 当 ip 资源过期的时候,系统不会直接删除 ip 资源,而是将 isDeleted 设置为 true
* 过期7天后再删除这个ip资源
*/
private
boolean
isDeleted
;
/**
* 如果 使用的 ip 资源 是在我们系统申请的,则默认为 fangguanlianbrowser
*/
private
String
username
;
/**
* ip 资源的购买者(拥有者)
*/
private
String
owner
;
private
String
userParent
;
/**
* ip访问协议
*/
private
List
<
String
>
protocol
;
private
String
password
;
private
double
price
;
private
boolean
specialLine
;
//是否使用专线
private
boolean
usingSpecialLine
;
//是否正在使用专线
//专线数据
private
String
proxyUsername
;
//专线的代理用户名
private
String
proxyPassword
;
//专线的代理密码
/**
* 是否使用专线
*/
private
boolean
specialLine
;
/**
* 是否正在使用专线
*/
private
boolean
usingSpecialLine
;
/**
* 专线的代理用户名
*/
private
String
proxyUsername
;
/**
* 专线的代理密码
*/
private
String
proxyPassword
;
/**
* ip 资源绑定的 商铺号
*/
private
String
shopId
;
private
List
<
String
>
shopIds
=
new
ArrayList
<>();
/**
* 绑定状态
*/
private
boolean
bind
;
private
boolean
isLocked
;
private
long
lockTimestamp
;
private
long
healthLockTimestamp
;
/**
* 购买方式(按月、按周)
*/
private
String
unit
;
/**
* 购买数量
* 例如 购买了 2 个月 的 ip资源,则
* period:2
* unit:month
*/
private
int
period
;
@Override
...
...
src/main/java/com/edgec/browserbackend/browser/dto/IpResourceUnwindResultDto.java
View file @
30c62028
...
...
@@ -4,11 +4,15 @@ import com.edgec.browserbackend.browser.domain.BindHistory;
import
com.edgec.browserbackend.browser.domain.IpResource
;
import
com.edgec.browserbackend.browser.domain.IpType
;
import
com.edgec.browserbackend.browser.domain.Vendor
;
import
org.springframework.data.annotation.Id
;
import
lombok.Getter
;
import
lombok.Setter
;
import
org.springframework.util.StringUtils
;
import
java.util.ArrayList
;
import
java.util.List
;
@Getter
@Setter
public
class
IpResourceUnwindResultDto
{
private
String
id
;
private
String
addr
;
...
...
@@ -39,6 +43,13 @@ public class IpResourceUnwindResultDto {
private
String
proxyPassword
;
//专线的代理密码
private
String
shopId
;
/**
* 对应 IpResource 中 shopIds 的展开字段
*/
private
String
shopIds
;
private
boolean
bind
;
private
boolean
isLocked
;
...
...
@@ -49,299 +60,83 @@ public class IpResourceUnwindResultDto {
private
int
period
;
public
String
getDetails
()
{
return
details
;
}
public
void
setDetails
(
String
details
)
{
this
.
details
=
details
;
}
public
String
getId
()
{
return
id
;
}
public
void
setId
(
String
id
)
{
this
.
id
=
id
;
}
public
String
getRegion
()
{
return
region
;
}
public
void
setRegion
(
String
region
)
{
this
.
region
=
region
;
}
public
String
getRegionCn
()
{
return
regionCn
;
}
public
void
setRegionCn
(
String
regionCn
)
{
this
.
regionCn
=
regionCn
;
}
public
int
getStatus
()
{
return
status
;
}
public
void
setStatus
(
int
status
)
{
this
.
status
=
status
;
}
public
IpType
getIpType
()
{
return
ipType
;
}
public
void
setIpType
(
IpType
ipType
)
{
this
.
ipType
=
ipType
;
}
public
List
<
BindHistory
>
getBindHistory
()
{
return
bindHistory
;
}
public
void
setBindHistory
(
List
<
BindHistory
>
bindHistory
)
{
this
.
bindHistory
=
bindHistory
;
}
public
long
getPurchasedTime
()
{
return
purchasedTime
;
}
public
void
setPurchasedTime
(
long
purchasedTime
)
{
this
.
purchasedTime
=
purchasedTime
;
}
public
long
getValidTime
()
{
return
validTime
;
}
public
void
setValidTime
(
long
validTime
)
{
this
.
validTime
=
validTime
;
}
public
Vendor
getVendor
()
{
return
vendor
;
}
public
void
setVendor
(
Vendor
vendor
)
{
this
.
vendor
=
vendor
;
}
public
boolean
isDeleted
()
{
return
isDeleted
;
}
public
void
setDeleted
(
boolean
deleted
)
{
isDeleted
=
deleted
;
}
public
String
getUsername
()
{
return
username
;
}
public
void
setUsername
(
String
username
)
{
this
.
username
=
username
;
}
public
List
<
String
>
getPort
()
{
return
port
;
}
public
void
setPort
(
List
<
String
>
port
)
{
this
.
port
=
port
;
}
public
String
getAddr
()
{
return
addr
;
}
public
void
setAddr
(
String
addr
)
{
this
.
addr
=
addr
;
}
public
String
getUserParent
()
{
return
userParent
;
}
public
void
setUserParent
(
String
userParent
)
{
this
.
userParent
=
userParent
;
}
public
List
<
String
>
getProtocol
()
{
return
protocol
;
}
public
void
setProtocol
(
List
<
String
>
protocol
)
{
this
.
protocol
=
protocol
;
}
public
String
getPassword
()
{
return
password
;
}
public
void
setPassword
(
String
password
)
{
this
.
password
=
password
;
}
public
String
getOwner
()
{
return
owner
;
}
public
void
setOwner
(
String
owner
)
{
this
.
owner
=
owner
;
}
public
boolean
isLocked
()
{
return
isLocked
;
}
public
void
setLocked
(
boolean
locked
)
{
isLocked
=
locked
;
}
public
long
getLockTimestamp
()
{
return
lockTimestamp
;
}
public
void
setLockTimestamp
(
long
lockTimestamp
)
{
this
.
lockTimestamp
=
lockTimestamp
;
}
public
String
getUnit
()
{
return
unit
;
}
public
void
setUnit
(
String
unit
)
{
this
.
unit
=
unit
;
}
public
int
getPeriod
()
{
return
period
;
}
public
void
setPeriod
(
int
period
)
{
this
.
period
=
period
;
}
public
double
getPrice
()
{
return
price
;
}
public
void
setPrice
(
double
price
)
{
this
.
price
=
price
;
}
public
String
getShopId
()
{
return
shopId
;
}
public
void
setShopId
(
String
shopId
)
{
this
.
shopId
=
shopId
;
}
public
String
getVendorCn
()
{
return
vendorCn
;
}
public
IpResource
toResource
()
{
IpResource
ipResource
=
new
IpResource
();
ipResource
.
setId
(
getId
());
public
void
setVendorCn
(
String
vendorCn
)
{
this
.
vendorCn
=
vendorCn
;
if
(!
StringUtils
.
isEmpty
(
getShopIds
()))
{
ipResource
.
setShopId
(
getShopIds
());
ipResource
.
getShopIds
().
add
(
getShopIds
());
}
public
String
getProxyPassword
()
{
return
proxyPassword
;
ipResource
.
setHealthLockTimestamp
(
getHealthLockTimestamp
());
ipResource
.
setUsingSpecialLine
(
isUsingSpecialLine
());
ipResource
.
setPeriod
(
getPeriod
());
ipResource
.
setSpecialLine
(
isSpecialLine
());
if
(
addr
!=
null
)
{
ipResource
.
setAddr
(
getAddr
());
}
public
void
setProxyPassword
(
String
proxyPassword
)
{
this
.
proxyPassword
=
proxyPassword
;
ipResource
.
setStatus
(
getStatus
());
if
(
proxyPassword
!=
null
)
{
ipResource
.
setProxyPassword
(
getProxyPassword
());
}
public
String
getProxyUsername
(
)
{
return
proxyUsername
;
if
(
proxyUsername
!=
null
)
{
ipResource
.
setProxyUsername
(
getProxyUsername
())
;
}
public
void
setProxyUsername
(
String
proxyUsername
)
{
this
.
proxyUsername
=
proxyUsername
;
ipResource
.
setLockTimestamp
(
getLockTimestamp
());
if
(
username
!=
null
)
{
ipResource
.
setUsername
(
getUsername
());
}
public
boolean
isSpecialLine
(
)
{
return
specialLine
;
if
(
regionCn
!=
null
)
{
ipResource
.
setRegionCn
(
getRegionCn
())
;
}
public
void
setSpecialLine
(
boolean
specialLine
)
{
this
.
specialLine
=
specialLine
;
if
(
vendorCn
!=
null
)
{
ipResource
.
setVendorCn
(
getVendorCn
())
;
}
public
long
getHealthLockTimestamp
(
)
{
return
healthLockTimestamp
;
if
(
password
!=
null
)
{
ipResource
.
setPassword
(
getPassword
())
;
}
public
void
setHealthLockTimestamp
(
long
healthLockTimestamp
)
{
this
.
healthLockTimestamp
=
healthLockTimestamp
;
if
(
unit
!=
null
)
{
ipResource
.
setUnit
(
getUnit
())
;
}
public
boolean
isUsingSpecialLine
()
{
return
usingSpecialLine
;
ipResource
.
setLocked
(
isLocked
());
ipResource
.
setValidTime
(
getValidTime
());
if
(
bindHistory
!=
null
)
{
ipResource
.
setBindHistory
(
getBindHistory
());
}
public
void
setUsingSpecialLine
(
boolean
usingSpecialLine
)
{
this
.
usingSpecialLine
=
usingSpecialLine
;
ipResource
.
setDeleted
(
isDeleted
());
if
(
owner
!=
null
)
{
ipResource
.
setOwner
(
getOwner
());
}
public
boolean
isBind
(
)
{
return
bind
;
if
(
protocol
!=
null
)
{
ipResource
.
setProtocol
(
getProtocol
())
;
}
public
void
setBind
(
boolean
bind
)
{
this
.
bind
=
bind
;
if
(
userParent
!=
null
)
{
ipResource
.
setUserParent
(
getUserParent
())
;
}
public
IpResource
toResource
()
{
IpResource
ipResource
=
new
IpResource
();
ipResource
.
setId
(
getId
());
if
(
shopId
!=
null
)
ipResource
.
getShopIds
().
add
(
getShopId
());
ipResource
.
setHealthLockTimestamp
(
getHealthLockTimestamp
());
ipResource
.
setUsingSpecialLine
(
isUsingSpecialLine
());
ipResource
.
setPeriod
(
getPeriod
());
ipResource
.
setSpecialLine
(
isSpecialLine
());
if
(
addr
!=
null
)
ipResource
.
setAddr
(
getAddr
());
ipResource
.
setStatus
(
getStatus
());
if
(
proxyPassword
!=
null
)
ipResource
.
setProxyPassword
(
getProxyPassword
());
if
(
proxyUsername
!=
null
)
ipResource
.
setProxyUsername
(
getProxyUsername
());
ipResource
.
setLockTimestamp
(
getLockTimestamp
());
if
(
username
!=
null
)
ipResource
.
setUsername
(
getUsername
());
if
(
regionCn
!=
null
)
ipResource
.
setRegionCn
(
getRegionCn
());
if
(
vendorCn
!=
null
)
ipResource
.
setVendorCn
(
getVendorCn
());
if
(
password
!=
null
)
ipResource
.
setPassword
(
getPassword
());
if
(
unit
!=
null
)
ipResource
.
setUnit
(
getUnit
());
ipResource
.
setLocked
(
isLocked
());
ipResource
.
setValidTime
(
getValidTime
());
if
(
bindHistory
!=
null
)
ipResource
.
setBindHistory
(
getBindHistory
());
ipResource
.
setDeleted
(
isDeleted
());
if
(
owner
!=
null
)
ipResource
.
setOwner
(
getOwner
());
if
(
protocol
!=
null
)
ipResource
.
setProtocol
(
getProtocol
());
if
(
userParent
!=
null
)
ipResource
.
setUserParent
(
getUserParent
());
ipResource
.
setPurchasedTime
(
getPurchasedTime
());
ipResource
.
setIpType
(
getIpType
());
if
(
port
!=
null
)
if
(
port
!=
null
)
{
ipResource
.
setPort
(
getPort
());
}
ipResource
.
setPrice
(
getPrice
());
if
(
details
!=
null
)
if
(
details
!=
null
)
{
ipResource
.
setDetails
(
getDetails
());
}
return
ipResource
;
}
}
src/main/java/com/edgec/browserbackend/browser/repository/IpResourceRepositoryCustomImpl.java
View file @
30c62028
...
...
@@ -66,8 +66,10 @@ public class IpResourceRepositoryCustomImpl implements IpResourceRepositoryCusto
@Override
public
List
<
IpResource
>
sampleTasks
(
int
status
,
long
timestamp
)
{
Criteria
matchCriteria
=
new
Criteria
();
matchCriteria
.
orOperator
(
where
(
"status"
).
is
(
status
).
and
(
"isLocked"
).
is
(
false
).
and
(
"isDeleted"
).
is
(
false
),
where
(
"status"
).
is
(
status
).
and
(
"isLocked"
).
is
(
true
).
and
(
"lockTimestamp"
).
lte
(
timestamp
).
and
(
"isDeleted"
).
is
(
false
));
matchCriteria
.
orOperator
(
where
(
"status"
).
is
(
status
).
and
(
"isLocked"
).
is
(
false
).
and
(
"isDeleted"
).
is
(
false
),
where
(
"status"
).
is
(
status
).
and
(
"isLocked"
).
is
(
true
).
and
(
"lockTimestamp"
).
lte
(
timestamp
).
and
(
"isDeleted"
).
is
(
false
)
);
MatchOperation
match
=
Aggregation
.
match
(
matchCriteria
);
...
...
@@ -81,8 +83,10 @@ public class IpResourceRepositoryCustomImpl implements IpResourceRepositoryCusto
@Override
public
List
<
IpResource
>
sampleTasks
(
List
<
Integer
>
status
)
{
Criteria
matchCriteria
=
new
Criteria
();
matchCriteria
.
orOperator
(
where
(
"status"
).
in
(
status
).
and
(
"isLocked"
).
is
(
false
).
and
(
"validTime"
).
gt
(
Instant
.
now
().
toEpochMilli
()).
and
(
"isDeleted"
).
is
(
false
).
and
(
"healthLockTimestamp"
).
lte
(
Instant
.
now
().
minusSeconds
(
60
*
30
).
toEpochMilli
()),
where
(
"status"
).
in
(
status
).
and
(
"isLocked"
).
is
(
true
).
and
(
"healthLockTimestamp"
).
lte
(
Instant
.
now
().
minusSeconds
(
600
).
toEpochMilli
()).
and
(
"isDeleted"
).
is
(
false
));
matchCriteria
.
orOperator
(
where
(
"status"
).
in
(
status
).
and
(
"isLocked"
).
is
(
false
).
and
(
"isDeleted"
).
is
(
false
).
and
(
"healthLockTimestamp"
).
lte
(
Instant
.
now
().
minusSeconds
(
60
*
30
).
toEpochMilli
()).
and
(
"validTime"
).
gt
(
Instant
.
now
().
toEpochMilli
()),
where
(
"status"
).
in
(
status
).
and
(
"isLocked"
).
is
(
true
).
and
(
"isDeleted"
).
is
(
false
).
and
(
"healthLockTimestamp"
).
lte
(
Instant
.
now
().
minusSeconds
(
60
*
10
).
toEpochMilli
())
);
MatchOperation
match
=
Aggregation
.
match
(
matchCriteria
);
...
...
@@ -157,79 +161,52 @@ public class IpResourceRepositoryCustomImpl implements IpResourceRepositoryCusto
@Override
public
List
<
IpResource
>
findShopIdInList
(
List
<
String
>
shopIds
,
boolean
isDeleted
)
{
MatchOperation
matchOperation
=
Aggregation
.
match
(
where
(
"isDeleted"
).
is
(
isDeleted
));
UnwindOperation
unwind
=
Aggregation
.
unwind
(
"shopIds"
);
MatchOperation
matchshopId
=
Aggregation
.
match
(
where
(
"shopIds"
).
in
(
shopIds
));
List
<
IpResourceUnwindResultDto
>
ipResourceUnwindResultDtos
=
mongoTemplate
.
aggregate
(
Aggregation
.
newAggregation
(
matchOperation
,
unwind
,
matchshopId
),
IpResource
.
class
,
IpResourceUnwindResultDto
.
class
).
getMappedResults
();
if
(
ipResourceUnwindResultDtos
.
isEmpty
())
{
return
new
ArrayList
<>();
}
HashMap
<
String
,
IpResource
>
ipResourceHashMap
=
new
HashMap
<>();
ipResourceUnwindResultDtos
.
forEach
(
x
->
{
if
(
ipResourceHashMap
.
containsKey
(
x
.
getId
()))
{
ipResourceHashMap
.
get
(
x
.
getId
()).
getShopIds
().
add
(
x
.
getShopId
());
}
else
{
ipResourceHashMap
.
put
(
x
.
getId
(),
x
.
toResource
());
}
}
);
List
<
IpResource
>
result
=
new
ArrayList
<>();
Set
<
Map
.
Entry
<
String
,
IpResource
>>
entry
=
ipResourceHashMap
.
entrySet
();
for
(
Map
.
Entry
<
String
,
IpResource
>
e
:
entry
)
{
result
.
add
(
e
.
getValue
());
}
return
result
;
return
getResult
(
matchOperation
,
shopIds
);
}
@Override
public
List
<
IpResource
>
findShopIdInListAndStatus
(
List
<
String
>
shopIds
,
boolean
isDeleted
,
int
status
)
{
MatchOperation
matchOperation
=
Aggregation
.
match
(
where
(
"isDeleted"
).
is
(
isDeleted
).
and
(
"status"
).
is
(
status
));
UnwindOperation
unwind
=
Aggregation
.
unwind
(
"shopIds"
);
MatchOperation
matchshopId
=
Aggregation
.
match
(
where
(
"shopIds"
).
in
(
shopIds
));
List
<
IpResourceUnwindResultDto
>
ipResourceUnwindResultDtos
=
mongoTemplate
.
aggregate
(
Aggregation
.
newAggregation
(
matchOperation
,
unwind
,
matchshopId
),
IpResource
.
class
,
IpResourceUnwindResultDto
.
class
).
getMappedResults
();
if
(
ipResourceUnwindResultDtos
.
isEmpty
())
{
return
new
ArrayList
<>();
}
HashMap
<
String
,
IpResource
>
ipResourceHashMap
=
new
HashMap
<>();
ipResourceUnwindResultDtos
.
forEach
(
x
->
{
if
(
ipResourceHashMap
.
containsKey
(
x
.
getId
()))
{
ipResourceHashMap
.
get
(
x
.
getId
()).
getShopIds
().
add
(
x
.
getShopId
());
}
else
{
ipResourceHashMap
.
put
(
x
.
getId
(),
x
.
toResource
());
}
});
List
<
IpResource
>
result
=
new
ArrayList
<>();
Set
<
Map
.
Entry
<
String
,
IpResource
>>
entry
=
ipResourceHashMap
.
entrySet
();
for
(
Map
.
Entry
<
String
,
IpResource
>
e
:
entry
)
{
result
.
add
(
e
.
getValue
());
}
return
result
;
return
getResult
(
matchOperation
,
shopIds
);
}
@Override
public
List
<
IpResource
>
findShopIdInListAndRegionLike
(
List
<
String
>
shopIds
,
boolean
isDeleted
,
String
region
)
{
MatchOperation
matchOperation
=
Aggregation
.
match
(
where
(
"isDeleted"
).
is
(
isDeleted
).
and
(
"regionCn"
).
regex
(
".*?\\"
+
region
+
".*"
));
return
getResult
(
matchOperation
,
shopIds
);
}
@Override
public
List
<
IpResource
>
findIds
()
{
BasicQuery
basicQuery
=
new
BasicQuery
(
new
Document
());
basicQuery
.
fields
().
include
(
"id"
);
return
mongoTemplate
.
find
(
basicQuery
,
IpResource
.
class
);
}
private
List
<
IpResource
>
getResult
(
MatchOperation
matchOperation
,
List
<
String
>
shopIds
)
{
UnwindOperation
unwind
=
Aggregation
.
unwind
(
"shopIds"
);
MatchOperation
matchshopId
=
Aggregation
.
match
(
where
(
"shopIds"
).
in
(
shopIds
));
List
<
IpResourceUnwindResultDto
>
ipResourceUnwindResultDtos
=
mongoTemplate
.
aggregate
(
Aggregation
.
newAggregation
(
matchOperation
,
unwind
,
matchshopId
),
IpResource
.
class
,
IpResourceUnwindResultDto
.
class
).
getMappedResults
();
Aggregation
.
newAggregation
(
matchOperation
,
unwind
,
matchshopId
),
IpResource
.
class
,
IpResourceUnwindResultDto
.
class
).
getMappedResults
();
List
<
IpResource
>
result
=
new
ArrayList
<>();
if
(
ipResourceUnwindResultDtos
.
isEmpty
())
{
return
new
ArrayList
<>()
;
return
result
;
}
HashMap
<
String
,
IpResource
>
ipResourceHashMap
=
new
HashMap
<>();
ipResourceUnwindResultDtos
.
forEach
(
x
->
{
ipResourceUnwindResultDtos
.
forEach
(
x
->
{
if
(
ipResourceHashMap
.
containsKey
(
x
.
getId
()))
{
ipResourceHashMap
.
get
(
x
.
getId
()).
getShopIds
().
add
(
x
.
getShopId
());
ipResourceHashMap
.
get
(
x
.
getId
()).
getShopIds
().
add
(
x
.
getShopIds
());
}
else
{
ipResourceHashMap
.
put
(
x
.
getId
(),
x
.
toResource
());
}
});
List
<
IpResource
>
result
=
new
ArrayList
<>();
}
);
Set
<
Map
.
Entry
<
String
,
IpResource
>>
entry
=
ipResourceHashMap
.
entrySet
();
for
(
Map
.
Entry
<
String
,
IpResource
>
e
:
entry
)
{
result
.
add
(
e
.
getValue
());
...
...
@@ -237,12 +214,5 @@ public class IpResourceRepositoryCustomImpl implements IpResourceRepositoryCusto
return
result
;
}
@Override
public
List
<
IpResource
>
findIds
()
{
BasicQuery
basicQuery
=
new
BasicQuery
(
new
Document
());
basicQuery
.
fields
().
include
(
"id"
);
return
mongoTemplate
.
find
(
basicQuery
,
IpResource
.
class
);
}
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
30c62028
...
...
@@ -407,15 +407,14 @@ public class ShopServiceImpl implements ShopService {
List
<
String
>
shopIds
=
null
;
if
(
shopFilterDto
.
getBindIp
()
==
0
)
{
shopIds
=
allIds
;
// 这个地方有点奇怪,为啥不去 userShop 中找,而是在 ipresource 中找? 可以查看下删除绑定状态的逻辑
}
else
if
(
shopFilterDto
.
getBindIp
()
==
1
)
{
// ip资源已经分配了 的店铺
}
// 绑定了 ip 资源的店铺
if
(
shopFilterDto
.
getBindIp
()
==
1
)
{
shopIds
=
ipResourceRepository
.
findShopIdInList
(
allIds
,
false
).
stream
()
.
flatMap
((
x
->
x
.
getShopIds
().
stream
())).
collect
(
Collectors
.
toList
());
// 这个地方的其他情况是指什么情况
}
else
{
}
// 未绑定 ip 资源的店铺
if
(
shopFilterDto
.
getBindIp
()
==
2
)
{
// 店铺绑定的 ip 资源被删除的 店铺
for
(
String
id
:
allIds
)
{
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
id
,
true
);
...
...
@@ -425,6 +424,14 @@ public class ShopServiceImpl implements ShopService {
}
}
// 临时试用一下
if
(
shopFilterDto
.
getBindIp
()
==
3
)
{
List
<
String
>
shopIds2
=
ipResourceRepository
.
findShopIdInList
(
allIds
,
false
).
stream
()
.
flatMap
((
x
->
x
.
getShopIds
().
stream
())).
collect
(
Collectors
.
toList
());
allIds
.
removeAll
(
shopIds2
);
shopIds
=
allIds
;
}
amount
=
amount
>
100
?
100
:
amount
;
Pageable
pageable
=
PageRequest
.
of
(
pageNum
,
amount
);
// 5. 根据过滤后的商铺ids 与 其他过滤条件 得到商铺信息并分页
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/TempServiceImpl.java
View file @
30c62028
package
com
.
edgec
.
browserbackend
.
browser
.
service
.
Impl
;
import
com.edgec.browserbackend.browser.domain.IpResource
;
import
com.edgec.browserbackend.browser.domain.UserCode
;
import
com.edgec.browserbackend.browser.repository.IpResourceRepository
;
import
com.edgec.browserbackend.browser.repository.UserCodeRepository
;
import
com.edgec.browserbackend.browser.service.TempService
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
/**
*
*/
@Slf4j
@Service
public
class
TempServiceImpl
implements
TempService
{
@Autowired
private
UserCodeRepository
userCodeRepository
;
@Autowired
private
IpResourceRepository
ipResourceRepository
;
@Override
public
void
save
(
UserCode
userCode
)
{
userCodeRepository
.
save
(
userCode
);
}
@Override
public
void
saveIpResource
(
String
addr
,
String
flag
)
{
IpResource
ipResource
=
ipResourceRepository
.
findByAddr
(
addr
);
if
(
"true"
.
equals
(
flag
))
{
ipResource
.
setSpecialLine
(
true
);
}
if
(
"false"
.
equals
(
flag
))
{
ipResource
.
setSpecialLine
(
false
);
}
ipResourceRepository
.
save
(
ipResource
);
log
.
info
(
"ip地址为:"
+
addr
+
"专线状态更改为:"
+
flag
);
}
}
src/main/java/com/edgec/browserbackend/browser/service/TempService.java
View file @
30c62028
...
...
@@ -7,4 +7,6 @@ import com.edgec.browserbackend.browser.domain.UserCode;
*/
public
interface
TempService
{
void
save
(
UserCode
userCode
);
void
saveIpResource
(
String
addr
,
String
flag
);
}
src/main/java/com/edgec/browserbackend/browser/task/BrowserTask.java
View file @
30c62028
...
...
@@ -206,7 +206,6 @@ public class BrowserTask {
()
->
{
if
(
ipResourceRepository
.
lockTask
(
ipResource
))
{
try
{
log
.
error
(
"test"
);
String
url
=
URL
+
"/ecc/ipinfo?accountId=browser&ip="
+
ipResource
.
getAddr
();
Map
<
String
,
String
>
header
=
buildGetHeader
();
String
rs
=
HttpClientutils
.
doGet
(
url
,
header
);
...
...
@@ -217,9 +216,6 @@ public class BrowserTask {
log
.
error
(
"fail to pars json {}"
,
rs
,
e
);
}
if
(
ipInfoResultDto
!=
null
&&
StringUtils
.
isBlank
(
ipInfoResultDto
.
getErrorCode
()))
{
log
.
error
(
ipInfoResultDto
.
getErrorCode
());
log
.
error
(
ipInfoResultDto
.
getStatus
());
log
.
error
(
ipInfoResultDto
.
getEipIPAddr
());
if
(
StringUtils
.
isNotEmpty
(
ipInfoResultDto
.
getStatus
()))
{
ipResourceRepository
.
updateStatus
(
ipResource
.
getId
(),
0
);
}
...
...
@@ -247,25 +243,31 @@ public class BrowserTask {
@Scheduled
(
cron
=
"0 0/5 * * * ?"
)
public
void
healthCheck
()
{
// 1. 随机获取未被删除的 20 个 ip 做健康检查
List
<
IpResource
>
ipResources
=
ipResourceRepository
.
sampleTasks
(
Arrays
.
asList
(
0
,
2
));
for
(
IpResource
ipResource
:
ipResources
)
{
long
start
=
System
.
currentTimeMillis
();
// todo ipResourceRepository.healthLock(ipResource) 始终为 true,感觉有些多余
if
(
ipResourceRepository
.
healthLock
(
ipResource
))
{
try
{
int
failTime
=
0
;
// 获取查询 ip 地址的 5个网址
List
<
QueryIpUrlList
>
queryIpUrlLists
=
queryIpUrlListRepository
.
findAll
();
final
int
maxRetry
=
Math
.
max
(
queryIpUrlLists
.
size
(),
5
);
// 如果 ip 已经失效,且 ip 的状态不是 3:正在分配 和 6:未分配,则将 ip 的状态设置为 1 已过期
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
toEpochMilli
()
&&
ipResource
.
getStatus
()
!=
3
&&
ipResource
.
getStatus
()
!=
6
)
{
ipResource
.
setStatus
(
1
);
ipResourceRepository
.
save
(
ipResource
);
// 如果 ip 为专线 ip,或者 ip 为用户自己的,但是使用了系统的专线功能
}
else
if
(
ipResource
.
isSpecialLine
()
||
(
ipResource
.
getIpType
()
==
IpType
.
OWN
&&
ipResource
.
isUsingSpecialLine
()))
{
Trans
trans
=
new
Trans
(
ipResource
.
getProxyUsername
(),
ipResource
.
getProxyPassword
());
String
sp_result
=
trans
.
get
(
getNextUrl
(
queryIpUrlLists
,
failTime
).
getUrl
());
while
(!
sp_result
.
contains
(
ipResource
.
getAddr
()))
{
if
(
failTime
>
maxRetry
)
{
NotifyUtils
.
sendMessage
(
"防关联浏览器 ip "
+
ipResource
.
getAddr
()
+
" 专线代理异常:"
+
ipResource
.
getIpType
(),
NotifyUtils
.
MsgType
.
WEBHOOK
);
NotifyUtils
.
sendMessage
(
"防关联浏览器 ip "
+
ipResource
.
getAddr
()
+
" 专线代理异常:"
+
ipResource
.
getIpType
(),
NotifyUtils
.
MsgType
.
WEBHOOK
);
log
.
error
(
"防关联浏览器 ip "
+
ipResource
.
getAddr
()
+
" 专线代理异常 "
+
sp_result
);
break
;
}
...
...
@@ -273,16 +275,15 @@ public class BrowserTask {
Thread
.
sleep
(
2000
);
sp_result
=
trans
.
get
(
getNextUrl
(
queryIpUrlLists
,
failTime
).
getUrl
());
}
}
else
if
(
ipResource
.
getIpType
()
==
IpType
.
VENDOR
||
(
ipResource
.
getIpType
()
==
IpType
.
OWN
&&
!
ipResource
.
isUsingSpecialLine
()))
{
String
result
;
// 如果 ip 类型为 vendor
}
else
if
(
ipResource
.
getIpType
()
==
IpType
.
VENDOR
)
{
Trans
trans
=
new
Trans
(
ipResource
.
getAddr
(),
Integer
.
valueOf
(
ipResource
.
getPort
().
size
()
>
1
?
ipResource
.
getPort
().
get
(
1
)
:
ipResource
.
getPort
().
get
(
0
)),
ipResource
.
getUsername
(),
ipResource
.
getPassword
());
result
=
trans
.
get
(
getNextUrl
(
queryIpUrlLists
,
failTime
).
getUrl
());
String
result
=
trans
.
get
(
getNextUrl
(
queryIpUrlLists
,
failTime
).
getUrl
());
if
(!
result
.
contains
(
ipResource
.
getAddr
()))
{
while
(!
result
.
contains
(
ipResource
.
getAddr
()))
{
if
(
failTime
>
maxRetry
)
{
NotifyUtils
.
sendMessage
(
"防关联浏览器 ip "
+
ipResource
.
getAddr
()
+
" 代理异常:"
+
ipResource
.
getIpType
(),
NotifyUtils
.
MsgType
.
WEBHOOK
);
NotifyUtils
.
sendMessage
(
"防关联浏览器 ip "
+
ipResource
.
getAddr
()
+
" 代理异常:"
+
ipResource
.
getIpType
(),
NotifyUtils
.
MsgType
.
WEBHOOK
);
log
.
error
(
"防关联浏览器 ip "
+
ipResource
.
getAddr
()
+
" 代理异常 "
+
result
);
break
;
}
...
...
@@ -293,7 +294,8 @@ public class BrowserTask {
}
}
}
catch
(
Exception
e
)
{
NotifyUtils
.
sendMessage
(
"防关联浏览器 ip "
+
ipResource
.
getAddr
()
+
" 代理异常"
,
e
,
NotifyUtils
.
MsgType
.
WEBHOOK
);
// todo 将代理异常改为 健康检查异常
NotifyUtils
.
sendMessage
(
"防关联浏览器 ip "
+
ipResource
.
getAddr
()
+
" 健康检查异常"
,
e
,
NotifyUtils
.
MsgType
.
WEBHOOK
);
log
.
error
(
e
.
getMessage
(),
e
);
}
finally
{
long
end
=
System
.
currentTimeMillis
();
...
...
src/main/java/com/edgec/browserbackend/browser/task/PaymentTask.java
View file @
30c62028
...
...
@@ -48,6 +48,7 @@ public class PaymentTask {
* chargeType 取值范围为 0-4
* 此处设置为 100 仅仅只是为了避免 wxCheckOrderStatus() 方法中 chargeType == 0 相关代码块
*/
log
.
info
(
"主动确认订单"
+
payment
.
getTradeNo
()
+
"支付状态,此时chargeType为 100"
);
if
(
PaymentMethod
.
WECHAT
.
equals
(
paymentMethod
))
{
paymentService
.
wxCheckOrderStatus
(
payment
.
getTradeNo
(),
100
);
}
...
...
src/main/java/com/edgec/browserbackend/browser/task/Set3proxyTask.java
View file @
30c62028
...
...
@@ -92,7 +92,7 @@ public class Set3proxyTask {
bw
.
write
(
"\nallow none\nproxy -p20004\nsocks -p20005\n"
);
bw
.
flush
();
bw
.
close
();
log
.
error
(
"成功写入文件"
);
log
.
info
(
"成功写入文件"
);
if
(
proxyConfigRepository
.
count
()
>
0
)
{
ProxyConfig
proxyConfig
=
proxyConfigRepository
.
findAll
().
get
(
0
);
...
...
src/main/java/com/edgec/browserbackend/common/utils/Trans.java
View file @
30c62028
...
...
@@ -59,7 +59,9 @@ public class Trans {
String
url
=
"http://free.ipwhois.io/json/"
;
Trans
trans
=
new
Trans
(
"112.74.47.217"
,
20001
,
"fangguanlianbrowser"
,
"5D753F36QKqIaA1"
);
String
rs
=
trans
.
get
(
url
);
System
.
out
.
println
(
rs
);
System
.
out
.
println
(
rs
.
contains
(
"112.74.47.217"
));
}
/**
...
...
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