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
39b0ad42
Commit
39b0ad42
authored
Mar 20, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
续费bug
parent
cc4de4e4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+14
-5
No files found.
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
39b0ad42
...
...
@@ -34,6 +34,7 @@ import java.time.Instant;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.concurrent.atomic.AtomicInteger
;
import
java.util.concurrent.atomic.AtomicReference
;
import
java.util.stream.Collectors
;
@Service
...
...
@@ -300,11 +301,19 @@ public class IpResourceServiceImpl implements IpResourceService {
Map
<
String
,
List
<
String
>>
priceList
=
ipOptionsRepository
.
findAll
().
get
(
0
).
getIpPlatForm
();
double
totalprice
=
ipResourceRequestDto
.
getAddr
().
stream
().
map
(
x
->
ipResourceRepository
.
findByAddrAndIsDeleted
(
x
,
false
)).
map
(
ipResource
->
priceList
.
get
(
ipResource
.
getRegionCn
())).
map
(
vendorPrices
->
vendorPrices
.
stream
()
.
filter
(
vendorprice
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()).
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
.
map
(
vendorprice
->
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
)).
collect
(
Collectors
.
joining
())).
mapToDouble
(
Double:
:
valueOf
).
sum
();
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
());
for
(
String
vendorprice:
prices
)
{
logger
.
error
(
vendorprice
);
if
(
ipResource
.
getVendor
().
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
totalprice
.
updateAndGet
(
v
->
new
Double
(
v
+
Double
.
valueOf
(
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
))));
}
});
double
newprice
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
int
)
(
totalprice
/
3
)
:
(
int
)
totalprice
;
logger
.
error
(
totalprice
.
get
()
+
""
);
double
newprice
=
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
)
?
(
int
)
(
totalprice
.
get
()
/
3
)
:
totalprice
.
get
().
intValue
();
IpChargeResultDto
ipChargeResultDto
=
accountService
.
preChargeByMoney
(
username
,
newprice
);
if
(!
ipChargeResultDto
.
isSuccess
())
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOTENOUGHBALANCE
);
...
...
@@ -332,7 +341,7 @@ public class IpResourceServiceImpl implements IpResourceService {
IpResource
ipResource
=
ipResourceRepository
.
findByAddrAndIsDeleted
(
x
.
getIp
(),
false
);
List
<
String
>
vendorPrices
=
priceList
.
get
(
ipResource
.
getRegionCn
());
String
price
=
vendorPrices
.
stream
()
.
filter
(
vendorprice
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()
).
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
.
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
);
...
...
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