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
9a6088da
Commit
9a6088da
authored
Jun 05, 2020
by
jim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ip
parent
97cad9d7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
79 additions
and
83 deletions
+79
-83
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+30
-28
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+49
-55
No files found.
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
9a6088da
...
...
@@ -204,9 +204,9 @@ public class IpResourceServiceImpl implements IpResourceService {
if
(!
ipResourceRequestDto
.
getVendor
().
equals
(
"own"
))
{
List
<
String
>
vendorPrices
=
priceList
.
get
(
ipResourceRequestDto
.
getRegionCn
());
String
price
=
vendorPrices
.
stream
()
.
filter
(
x
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()).
getValue
().
equals
(
x
.
substring
(
0
,
x
.
indexOf
(
"-"
))))
.
filter
(
x
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()).
getValue
().
equals
(
x
.
substring
(
0
,
x
.
indexOf
(
"-"
))))
.
map
(
x
->
x
.
substring
(
x
.
lastIndexOf
(
"-"
)
+
1
)).
collect
(
Collectors
.
joining
());
newprice
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
Integer
.
valueOf
(
price
)
/
3
)
:
Integer
.
valueOf
(
price
);
newprice
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
Integer
.
valueOf
(
price
)
/
3
)
:
Integer
.
valueOf
(
price
);
}
IpChargeResultDto
ipChargeResultDto
=
accountService
.
preChargeByMoney
(
username
,
newprice
*
ipResourceRequestDto
.
getAmount
()
*
ipResourceRequestDto
.
getPeriod
());
...
...
@@ -290,7 +290,7 @@ public class IpResourceServiceImpl implements IpResourceService {
ipResource
.
setProxyUsername
(
ipResource
.
getAddr
());
ipResource
.
setProxyPassword
(
genRandom
(
3
,
12
));
ipResource
.
setSpecialLine
(
true
);
ipResource
.
setHealthLockTimestamp
(
Instant
.
now
().
minusSeconds
(
60
*
20
).
toEpochMilli
());
ipResource
.
setHealthLockTimestamp
(
Instant
.
now
().
minusSeconds
(
60
*
20
).
toEpochMilli
());
}
ipResource
.
setRegionCn
(
ipResourceRequestDto
.
getRegionCn
());
ipResource
.
setProtocol
(
protocol
);
...
...
@@ -322,7 +322,7 @@ public class IpResourceServiceImpl implements IpResourceService {
@Override
public
IpOperationResultDto
renewIp
(
String
username
,
IpResourceRequestDto
ipResourceRequestDto
)
{
String
URL
=
(
profiles
.
equals
(
"dev"
)
||
profiles
.
equals
(
"staging"
))?
TESTURL
:
CLOUDAMURL
;
String
URL
=
(
profiles
.
equals
(
"dev"
)
||
profiles
.
equals
(
"staging"
))
?
TESTURL
:
CLOUDAMURL
;
Account
account
=
accountRepository
.
findByName
(
username
);
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
...
...
@@ -343,12 +343,13 @@ public class IpResourceServiceImpl implements IpResourceService {
else
prices
=
priceList
.
get
(
"自有"
);
}
for
(
String
vendorprice:
prices
)
{
for
(
String
vendorprice
:
prices
)
{
if
(
ipResource
.
getVendor
().
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
totalprice
.
updateAndGet
(
v
->
new
Double
(
v
+
Double
.
valueOf
(
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
))));
}
});
totalprice
.
updateAndGet
(
v
->
new
Double
(
v
+
Double
.
valueOf
(
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
))));
}
});
double
newprice
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
int
)
(
totalprice
.
get
()
/
3
)
:
totalprice
.
get
().
intValue
();
double
newprice
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
int
)
(
totalprice
.
get
()
/
3
)
:
totalprice
.
get
().
intValue
();
IpChargeResultDto
ipChargeResultDto
=
accountService
.
preChargeByMoney
(
username
,
newprice
*
ipResourceRequestDto
.
getPeriod
()
*
ipResourceRequestDto
.
getAmount
());
if
(!
ipChargeResultDto
.
isSuccess
())
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOTENOUGHBALANCE
);
...
...
@@ -386,7 +387,7 @@ public class IpResourceServiceImpl implements IpResourceService {
.
filter
(
vendorprice
->
ipResource
.
getVendor
().
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
.
map
(
vendorprice
->
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
)).
collect
(
Collectors
.
joining
());
double
newprice1
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
Integer
.
valueOf
(
price
)
/
3
)
:
Integer
.
valueOf
(
price
);
double
newprice1
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
Integer
.
valueOf
(
price
)
/
3
)
:
Integer
.
valueOf
(
price
);
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
2
,
ipResourceRequestDto
.
getPayMethod
());
accountService
.
chargeByMoney
(
username
,
newprice1
*
ipResourceRequestDto
.
getPeriod
()
*
ipResourceRequestDto
.
getAmount
(),
ipChargeRequestDto
);
...
...
@@ -440,7 +441,7 @@ public class IpResourceServiceImpl implements IpResourceService {
@Override
public
IpOperationResultDto
deleteIp
(
String
username
,
IpResourceRequestDto
ipResourceRequestDto
)
{
String
URL
=
(
profiles
.
equals
(
"dev"
)
||
profiles
.
equals
(
"staging"
))?
TESTURL
:
CLOUDAMURL
;
String
URL
=
(
profiles
.
equals
(
"dev"
)
||
profiles
.
equals
(
"staging"
))
?
TESTURL
:
CLOUDAMURL
;
Account
account
=
accountRepository
.
findByName
(
username
);
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
...
...
@@ -591,10 +592,17 @@ public class IpResourceServiceImpl implements IpResourceService {
break
;
case
4
:
if
(!
isParent
)
notUsed
=
ipResourceRepository
.
findByOwnerAndStatusIsNotInAndIsDeletedAndBind
(
username
,
Arrays
.
asList
(
3
,
5
,
6
),
false
,
false
);
notUsed
=
ipResourceRepository
.
findByOwnerAndStatusIsNotInAndIsDeletedAndBind
(
username
,
Arrays
.
asList
(
3
,
5
,
6
),
false
,
false
);
else
notUsed
=
ipResourceRepository
.
findByOwnerInAndStatusIsNotInAndIsDeletedAndBind
(
children
,
Arrays
.
asList
(
3
,
5
,
6
),
false
,
false
);
break
;
case
5
:
ipResources
=
ipResourceRepository
.
findShopIdInList
(
shopIds
,
false
);
if
(!
isParent
)
notUsed
=
ipResourceRepository
.
findByOwnerAndStatusIsNotInAndIsDeletedAndBind
(
username
,
Arrays
.
asList
(
0
,
2
,
4
,
8
),
false
,
false
);
else
notUsed
=
ipResourceRepository
.
findByOwnerInAndStatusIsNotInAndIsDeletedAndBind
(
children
,
Arrays
.
asList
(
0
,
2
,
4
,
8
),
false
,
false
);
break
;
}
if
(
notUsed
!=
null
)
ipResources
.
addAll
(
notUsed
);
...
...
@@ -603,13 +611,11 @@ public class IpResourceServiceImpl implements IpResourceService {
Page
<
IpResource
>
ipResources1
=
null
;
if
(
ipFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
ipFilterDto
.
getRegion
()))
{
ipResources1
=
ipResourceRepository
.
findByIsDeletedAndIdInAndRegionCnLikeOrderByPurchasedTimeDesc
(
false
,
allIpIds
,
ipFilterDto
.
getRegion
(),
pageable
);
}
else
if
(
ipFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
ipFilterDto
.
getAddr
()))
{
}
else
if
(
ipFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
ipFilterDto
.
getAddr
()))
{
ipResources1
=
ipResourceRepository
.
findByIsDeletedAndIdInAndAddrLikeOrderByPurchasedTimeDesc
(
false
,
allIpIds
,
ipFilterDto
.
getAddr
(),
pageable
);
}
else
if
(
ipFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
ipFilterDto
.
getVendor
()))
{
}
else
if
(
ipFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
ipFilterDto
.
getVendor
()))
{
ipResources1
=
ipResourceRepository
.
findByIsDeletedAndIdInAndVendorCnLikeOrderByPurchasedTimeDesc
(
false
,
allIpIds
,
ipFilterDto
.
getVendor
(),
pageable
);
}
else
{
}
else
{
ipResources1
=
ipResourceRepository
.
findByIdInAndIsDeletedOrderByPurchasedTimeDesc
(
allIpIds
,
false
,
pageable
);
}
if
(
ipResources1
!=
null
)
{
...
...
@@ -628,13 +634,11 @@ public class IpResourceServiceImpl implements IpResourceService {
if
(
StringUtils
.
isNotBlank
(
x
.
getAddr
()))
{
if
(
x
.
getLockTimestamp
()
>=
Instant
.
now
().
minusSeconds
(
120
).
toEpochMilli
()
&&
x
.
getIpType
()
==
IpType
.
VENDOR
&&
(
x
.
getStatus
()
==
0
||
x
.
getStatus
()
==
2
))
{
x
.
setStatus
(
3
);
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
x
.
getStatus
()
!=
5
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
ipResourceRepository
.
updateStatus
(
x
.
getId
(),
2
);
}
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
if
(
x
.
getIpType
()
==
IpType
.
VENDOR
)
{
IpResourceRequestDto
ipResourceRequestDto
=
new
IpResourceRequestDto
();
ipResourceRequestDto
.
setAddr
(
Arrays
.
asList
(
x
.
getAddr
()));
...
...
@@ -645,19 +649,17 @@ public class IpResourceServiceImpl implements IpResourceService {
deleteIp
(
username
,
ipResourceRequestDto
);
}
return
;
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
toEpochMilli
()
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
toEpochMilli
()
&&
x
.
getStatus
()
!=
3
&&
x
.
getStatus
()
!=
6
)
{
ipResourceRepository
.
updateStatus
(
x
.
getId
(),
1
);
}
else
{
}
else
{
if
((
x
.
getStatus
()
==
0
||
x
.
getStatus
()
==
1
||
x
.
getStatus
()
==
2
)
&&
!
x
.
getVendor
().
equals
(
Vendor
.
local
))
{
ipResourceRepository
.
updateStatus
(
x
.
getId
(),
0
);
}
else
if
(
x
.
getIpType
().
equals
(
IpType
.
LOCAL
)
&&
(
x
.
getStatus
()
==
1
||
x
.
getStatus
()
==
2
)
&&
x
.
getAddr
().
equals
(
"本地Ip未使用"
)
)
{
}
else
if
(
x
.
getIpType
().
equals
(
IpType
.
LOCAL
)
&&
(
x
.
getStatus
()
==
1
||
x
.
getStatus
()
==
2
)
&&
x
.
getAddr
().
equals
(
"本地Ip未使用"
))
{
ipResourceRepository
.
updateStatus
(
x
.
getId
(),
4
);
}
}
}
if
(
x
.
getStatus
()
==
6
||
(
x
.
isSpecialLine
()
&&
x
.
getPurchasedTime
()
>
(
Instant
.
now
().
toEpochMilli
()
-
12
*
60
*
1000
)))
if
(
x
.
getStatus
()
==
6
||
(
x
.
isSpecialLine
()
&&
x
.
getPurchasedTime
()
>
(
Instant
.
now
().
toEpochMilli
()
-
12
*
60
*
1000
)))
x
.
setStatus
(
3
);
if
(
x
.
getStatus
()
==
3
)
{
x
.
setAddr
(
""
);
...
...
@@ -717,7 +719,7 @@ public class IpResourceServiceImpl implements IpResourceService {
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
IpSummary
ipSummary
=
new
IpSummary
();
List
<
String
>
shopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
().
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
used
=
ipResourceRepository
.
findShopIdInList
(
shopIds
,
false
).
stream
().
map
(
x
->
x
.
getId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
used
=
ipResourceRepository
.
findShopIdInList
(
shopIds
,
false
).
stream
().
map
(
x
->
x
.
getId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
unbind
=
ipResourceRepository
.
findByOwnerAndIsDeletedAndBind
(
username
,
false
,
false
).
stream
().
map
(
x
->
x
.
getId
()).
collect
(
Collectors
.
toList
());
ipSummary
.
setUnbind
(
unbind
.
size
());
unbind
.
addAll
(
used
);
...
...
@@ -822,7 +824,7 @@ public class IpResourceServiceImpl implements IpResourceService {
@Override
public
void
releaseDeletedIp
()
{
String
URL
=
(
profiles
.
equals
(
"dev"
)
||
profiles
.
equals
(
"staging"
))?
TESTURL
:
CLOUDAMURL
;
String
URL
=
(
profiles
.
equals
(
"dev"
)
||
profiles
.
equals
(
"staging"
))
?
TESTURL
:
CLOUDAMURL
;
RestTemplate
restTemplate
=
new
RestTemplate
();
HttpHeaders
headers
=
buildGetHeader
();
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
9a6088da
...
...
@@ -106,7 +106,7 @@ public class ShopServiceImpl implements ShopService {
//可以优化
account
.
setShopCount
(
account
.
getShopCount
()
+
1
);
accountRepository
.
save
(
account
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
}
return
id
;
...
...
@@ -170,7 +170,7 @@ public class ShopServiceImpl implements ShopService {
account
.
setShopCount
(
account
.
getShopCount
()
+
1
);
accountRepository
.
save
(
account
);
ids
.
add
(
id
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"fail to add shops"
,
e
.
getMessage
());
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
}
...
...
@@ -197,7 +197,7 @@ public class ShopServiceImpl implements ShopService {
try
{
shop_old
=
shop_old
.
of
(
shopResultDto
);
shopRepository
.
save
(
shop_old
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"fail to update"
,
e
.
getMessage
());
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
}
...
...
@@ -277,8 +277,7 @@ public class ShopServiceImpl implements ShopService {
if
(
accounts
==
null
||
accounts
.
size
()
!=
users
.
size
())
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
for
(
Account
ac
:
accounts
)
{
if
(
ac
.
getParent
()
==
null
||
!
ac
.
getParent
().
equals
(
username
))
{
if
(
ac
.
getParent
()
==
null
||
!
ac
.
getParent
().
equals
(
username
))
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOPERMISSION
);
}
}
...
...
@@ -294,7 +293,7 @@ public class ShopServiceImpl implements ShopService {
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"fail to assign"
,
e
.
getMessage
());
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
}
}
else
{
shops
.
stream
().
forEach
(
shop
->
{
...
...
@@ -308,7 +307,7 @@ public class ShopServiceImpl implements ShopService {
}
}
catch
(
Exception
e
)
{
logger
.
error
(
"fail to assign"
,
e
.
getMessage
());
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
}
});
}
...
...
@@ -336,8 +335,7 @@ public class ShopServiceImpl implements ShopService {
if
(
ipResource
.
isSpecialLine
())
{
SpecialLine
specialLine
=
specialLineRepository
.
findAll
().
get
(
0
);
shopResultDto
=
ShopResultDto
.
of
(
shop
,
group
,
new
IpResourceDto
(
ipResource
,
null
,
false
,
specialLine
));
}
else
}
else
shopResultDto
=
ShopResultDto
.
of
(
shop
,
group
,
new
IpResourceDto
(
ipResource
,
null
,
false
));
return
shopResultDto
;
}
...
...
@@ -369,11 +367,10 @@ public class ShopServiceImpl implements ShopService {
.
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
shopIds
=
ipResourceRepository
.
findShopIdInList
(
allIds
,
false
)
.
stream
().
flatMap
((
x
->
x
.
getShopIds
().
stream
())).
collect
(
Collectors
.
toList
());
}
else
{
}
else
{
List
<
String
>
allIds
=
userShopRepository
.
findByUsername
(
username
).
stream
()
.
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
for
(
String
id
:
allIds
)
{
for
(
String
id
:
allIds
)
{
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
id
,
false
);
if
(
ipResource
==
null
)
{
shopIds
.
add
(
id
);
...
...
@@ -389,11 +386,10 @@ public class ShopServiceImpl implements ShopService {
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
shopIds
=
ipResourceRepository
.
findShopIdInList
(
allIds
,
false
)
.
stream
().
flatMap
((
x
->
x
.
getShopIds
().
stream
())).
collect
(
Collectors
.
toList
());
}
else
{
}
else
{
List
<
String
>
allIds
=
userShopRepository
.
findByUsernameAndGroupId
(
username
,
groupId
).
stream
()
.
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
for
(
String
id
:
allIds
)
{
for
(
String
id
:
allIds
)
{
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
id
,
false
);
if
(
ipResource
==
null
)
shopIds
.
add
(
id
);
...
...
@@ -405,8 +401,7 @@ public class ShopServiceImpl implements ShopService {
List
<
String
>
filter
=
ipResourceRepository
.
findShopIdInListAndRegionLike
(
shopIds
,
false
,
shopFilterDto
.
getIpRegion
())
.
stream
().
flatMap
((
x
->
x
.
getShopIds
().
stream
())).
collect
(
Collectors
.
toList
());
shops
=
shopRepository
.
findByShopIdInOrderByCreateTimeDesc
(
filter
,
pageable
);
}
else
if
(
shopFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
shopFilterDto
.
getShopAccount
()))
}
else
if
(
shopFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
shopFilterDto
.
getShopAccount
()))
shops
=
shopRepository
.
findByShopIdInAndShopAccountLikeOrderByCreateTimeDesc
(
shopIds
,
shopFilterDto
.
getShopAccount
(),
pageable
);
else
if
(
shopFilterDto
!=
null
&&
StringUtils
.
isNotBlank
(
shopFilterDto
.
getShopName
()))
shops
=
shopRepository
.
findByShopIdInAndShopNameLikeOrderByCreateTimeDesc
(
shopIds
,
shopFilterDto
.
getShopName
(),
pageable
);
...
...
@@ -417,55 +412,54 @@ public class ShopServiceImpl implements ShopService {
List
<
ShopResultDto
>
shopResultDtos
=
new
ArrayList
<>();
shops
.
getContent
().
stream
().
forEach
(
x
->
{
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
x
.
getShopId
(),
false
);
if
(
ipResource
!=
null
)
{
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getAddr
()))
{
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
ipResource
.
getStatus
()
!=
5
&&
ipResource
.
getStatus
()
!=
3
&&
ipResource
.
getStatus
()
!=
6
)
{
if
(
ipResource
!=
null
)
{
if
(
StringUtils
.
isNotBlank
(
ipResource
.
getAddr
()))
{
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
ipResource
.
getStatus
()
!=
5
&&
ipResource
.
getStatus
()
!=
3
&&
ipResource
.
getStatus
()
!=
6
)
{
ipResource
.
setStatus
(
2
);
ipResourceRepository
.
save
(
ipResource
);
}
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getStatus
()
!=
3
&&
ipResource
.
getStatus
()
!=
6
)
{
if
(
ipResource
.
getIpType
()
==
IpType
.
VENDOR
)
{
IpResourceRequestDto
ipResourceRequestDto1
=
new
IpResourceRequestDto
();
ipResourceRequestDto1
.
setAddr
(
Arrays
.
asList
(
ipResource
.
getAddr
()));
try
{
ipResourceService
.
deleteIp
(
username
,
ipResourceRequestDto1
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
else
{
IpResourceRequestDto
ipResourceRequestDto1
=
new
IpResourceRequestDto
();
ipResourceRequestDto1
.
setIpId
(
Arrays
.
asList
(
ipResource
.
getId
()));
try
{
ipResourceService
.
deleteIp
(
username
,
ipResourceRequestDto1
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
return
;
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
toEpochMilli
()
&&
ipResource
.
getStatus
()
!=
3
&&
ipResource
.
getStatus
()
!=
6
)
{
}
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
ipResource
.
getStatus
()
!=
3
&&
ipResource
.
getStatus
()
!=
6
)
{
if
(
ipResource
.
getIpType
()
==
IpType
.
VENDOR
)
{
IpResourceRequestDto
ipResourceRequestDto1
=
new
IpResourceRequestDto
();
ipResourceRequestDto1
.
setAddr
(
Arrays
.
asList
(
ipResource
.
getAddr
()));
try
{
ipResourceService
.
deleteIp
(
username
,
ipResourceRequestDto1
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
else
{
IpResourceRequestDto
ipResourceRequestDto1
=
new
IpResourceRequestDto
();
ipResourceRequestDto1
.
setIpId
(
Arrays
.
asList
(
ipResource
.
getId
()));
try
{
ipResourceService
.
deleteIp
(
username
,
ipResourceRequestDto1
);
}
catch
(
Exception
e
)
{
logger
.
error
(
e
.
getMessage
(),
e
);
}
}
return
;
}
else
if
(
ipResource
.
getValidTime
()
<=
Instant
.
now
().
toEpochMilli
()
&&
ipResource
.
getStatus
()
!=
3
&&
ipResource
.
getStatus
()
!=
6
)
{
ipResource
.
setStatus
(
1
);
ipResourceRepository
.
save
(
ipResource
);
}
else
{
if
((
ipResource
.
getStatus
()
==
0
||
ipResource
.
getStatus
()
==
1
||
ipResource
.
getStatus
()
==
2
)
&&
ipResource
.
getVendor
()
!=
Vendor
.
local
)
{
}
else
{
if
((
ipResource
.
getStatus
()
==
0
||
ipResource
.
getStatus
()
==
1
||
ipResource
.
getStatus
()
==
2
)
&&
ipResource
.
getVendor
()
!=
Vendor
.
local
)
{
ipResource
.
setStatus
(
0
);
ipResourceRepository
.
save
(
ipResource
);
}
else
if
(
ipResource
.
getIpType
().
equals
(
IpType
.
LOCAL
)
&&
(
ipResource
.
getStatus
()
==
1
||
ipResource
.
getStatus
()
==
2
)
&&
ipResource
.
getAddr
().
equals
(
"本地Ip未使用"
))
{
}
else
if
(
ipResource
.
getIpType
().
equals
(
IpType
.
LOCAL
)
&&
(
ipResource
.
getStatus
()
==
1
||
ipResource
.
getStatus
()
==
2
)
&&
ipResource
.
getAddr
().
equals
(
"本地Ip未使用"
))
{
ipResource
.
setStatus
(
4
);
ipResourceRepository
.
save
(
ipResource
);
}
}
}
}
if
(
ipResource
==
null
)
ipResource
=
new
IpResource
();
}
}
if
(
ipResource
==
null
)
ipResource
=
new
IpResource
();
String
group1
=
userShopRepository
.
findByUsernameAndShopId
(
username
,
x
.
getShopId
()).
getGroupId
();
ShopResultDto
shopResultDto
=
null
;
if
(
ipResource
.
isSpecialLine
())
{
SpecialLine
specialLine
=
specialLineRepository
.
findAll
().
get
(
0
);
if
(
ipResource
.
isSpecialLine
())
{
SpecialLine
specialLine
=
specialLineRepository
.
findAll
().
get
(
0
);
shopResultDto
=
ShopResultDto
.
of
(
x
,
group1
,
new
IpResourceDto
(
ipResource
,
null
,
false
,
specialLine
));
}
else
}
else
shopResultDto
=
ShopResultDto
.
of
(
x
,
group1
,
new
IpResourceDto
(
ipResource
,
null
,
false
));
shopResultDtos
.
add
(
shopResultDto
);
});
...
...
@@ -489,7 +483,7 @@ public class ShopServiceImpl implements ShopService {
List
<
String
>
allShopIds
=
userShopRepository
.
findByUsername
(
username
).
stream
().
map
(
x
->
x
.
getShopId
()).
collect
(
Collectors
.
toList
());
List
<
String
>
unbind
=
new
ArrayList
<>();
if
(
allShopIds
!=
null
&&
allShopIds
.
size
()
>
0
)
{
for
(
String
id
:
allShopIds
)
{
for
(
String
id
:
allShopIds
)
{
IpResource
ipResource
=
ipResourceRepository
.
findFirstByShopIdsIsAndIsDeleted
(
id
,
false
);
if
(
ipResource
==
null
)
{
unbind
.
add
(
id
);
...
...
@@ -529,7 +523,7 @@ public class ShopServiceImpl implements ShopService {
if
(
shopIds
!=
null
&&
shopIds
.
size
()
>
0
)
{
String
maxShopId
=
null
;
int
max
=
0
;
for
(
String
shopId
:
shopIds
)
{
for
(
String
shopId
:
shopIds
)
{
int
userCount
=
userShopRepository
.
countByShopId
(
shopId
);
if
(
userCount
>
max
)
{
max
=
userCount
;
...
...
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