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
a0f11293
Commit
a0f11293
authored
Apr 29, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
自有ip
parent
85756f9e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
24 deletions
+29
-24
IpResource.java
...a/com/edgec/browserbackend/browser/domain/IpResource.java
+9
-9
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+20
-15
No files found.
src/main/java/com/edgec/browserbackend/browser/domain/IpResource.java
View file @
a0f11293
...
...
@@ -48,7 +48,7 @@ public class IpResource implements Serializable {
private
String
unit
;
private
int
period
;
private
String
tid
;
private
boolean
specialLine
;
public
String
getDetails
()
{
return
details
;
...
...
@@ -226,14 +226,6 @@ public class IpResource implements Serializable {
this
.
period
=
period
;
}
public
String
getTid
()
{
return
tid
;
}
public
void
setTid
(
String
tid
)
{
this
.
tid
=
tid
;
}
public
double
getPrice
()
{
return
price
;
}
...
...
@@ -281,4 +273,12 @@ public class IpResource implements Serializable {
public
void
setProxyUsername
(
String
proxyUsername
)
{
this
.
proxyUsername
=
proxyUsername
;
}
public
boolean
isSpecialLine
()
{
return
specialLine
;
}
public
void
setSpecialLine
(
boolean
specialLine
)
{
this
.
specialLine
=
specialLine
;
}
}
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
a0f11293
...
...
@@ -174,15 +174,15 @@ public class IpResourceServiceImpl implements IpResourceService {
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
if
(
ipResourceRequestDto
.
getRegionCn
()
==
null
)
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
List
<
String
>
vendorPrices
;
if
(!
ipResourceRequestDto
.
getVendor
().
equals
(
"own"
))
vendorPrices
=
priceList
.
get
(
ipResourceRequestDto
.
getRegionCn
());
else
vendorPrices
=
priceList
.
get
(
"自有"
);
String
price
=
vendorPrices
.
stream
()
.
filter
(
x
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()).
getValue
().
equals
(
x
.
substring
(
0
,
x
.
indexOf
(
"-"
))))
.
map
(
x
->
x
.
substring
(
x
.
lastIndexOf
(
"-"
)
+
1
)).
collect
(
Collectors
.
joining
());
double
newprice
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
Integer
.
valueOf
(
price
)/
3
)
:
Integer
.
valueOf
(
price
);
double
newprice
=
0
;
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
(
"-"
))))
.
map
(
x
->
x
.
substring
(
x
.
lastIndexOf
(
"-"
)
+
1
)).
collect
(
Collectors
.
joining
());
newprice
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
Integer
.
valueOf
(
price
)/
3
)
:
Integer
.
valueOf
(
price
);
}
IpChargeResultDto
ipChargeResultDto
=
accountService
.
preChargeByMoney
(
username
,
newprice
*
ipResourceRequestDto
.
getAmount
()
*
ipResourceRequestDto
.
getPeriod
());
if
(!
ipChargeResultDto
.
isSuccess
())
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOTENOUGHBALANCE
);
...
...
@@ -219,10 +219,7 @@ public class IpResourceServiceImpl implements IpResourceService {
ipResource
.
setVendorCn
(
"自有"
);
ipResource
.
setStatus
(
4
);
ipResource
.
setUsername
(
ipResourceRequestDto
.
getAccount
());
if
(
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
))
ipResource
.
setValidTime
(
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
plusWeeks
(
ipResourceRequestDto
.
getPeriod
()).
toInstant
().
toEpochMilli
());
else
ipResource
.
setValidTime
(
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
plusMonths
(
ipResourceRequestDto
.
getPeriod
()).
toInstant
().
toEpochMilli
());
ipResource
.
setValidTime
(
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
toInstant
().
toEpochMilli
());
}
else
{
ipResource
.
setAddr
(
""
);
ipResource
.
setIpType
(
IpType
.
VENDOR
);
...
...
@@ -290,7 +287,11 @@ public class IpResourceServiceImpl implements IpResourceService {
AtomicReference
<
Double
>
totalprice
=
new
AtomicReference
<>((
double
)
0
);
ipResourceRequestDto
.
getAddr
().
stream
().
map
(
x
->
ipResourceRepository
.
findByAddrAndIsDeleted
(
x
,
false
))
.
forEach
(
ipResource
->
{
List
<
String
>
prices
=
priceList
.
get
(
ipResource
.
getRegionCn
());
List
<
String
>
prices
;
if
(!
ipResourceRequestDto
.
getVendor
().
equals
(
"own"
))
prices
=
priceList
.
get
(
ipResource
.
getRegionCn
());
else
prices
=
priceList
.
get
(
"自有"
);
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
))));
...
...
@@ -348,7 +349,11 @@ public class IpResourceServiceImpl implements IpResourceService {
if
(
ipResourceRequestDto
.
getIpId
()
!=
null
&&
ipResourceRequestDto
.
getIpId
().
size
()
>
0
)
{
ipResourceRequestDto
.
getIpId
().
forEach
(
x
->
{
IpResource
ipResource
=
ipResourceRepository
.
findByIdAndIsDeleted
(
x
,
false
);
List
<
String
>
vendorPrices
=
priceList
.
get
(
ipResource
.
getRegionCn
());
List
<
String
>
vendorPrices
;
if
(!
ipResourceRequestDto
.
getVendor
().
equals
(
"own"
))
vendorPrices
=
priceList
.
get
(
ipResource
.
getRegionCn
());
else
vendorPrices
=
priceList
.
get
(
"自有"
);
String
price
=
vendorPrices
.
stream
()
.
filter
(
vendorprice
->
ipResource
.
getVendor
().
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
.
map
(
vendorprice
->
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
)).
collect
(
Collectors
.
joining
());
...
...
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