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