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
168395c9
Commit
168395c9
authored
Mar 25, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
本地ip bug
parent
02f88ce8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
89 additions
and
4 deletions
+89
-4
UserPrePaidBilling.java
...gec/browserbackend/account/domain/UserPrePaidBilling.java
+9
-1
UserPrePaidBillingRequestDto.java
...wserbackend/account/dto/UserPrePaidBillingRequestDto.java
+44
-0
UserPrePaidBillingRepository.java
...kend/account/repository/UserPrePaidBillingRepository.java
+2
-0
AccountService.java
.../edgec/browserbackend/account/service/AccountService.java
+2
-0
AccountServiceImpl.java
...owserbackend/account/service/impl/AccountServiceImpl.java
+25
-0
PaymentServiceImpl.java
...owserbackend/account/service/impl/PaymentServiceImpl.java
+4
-0
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+3
-1
ChargeType.java
...va/com/edgec/browserbackend/common/charge/ChargeType.java
+0
-2
No files found.
src/main/java/com/edgec/browserbackend/account/domain/UserPrePaidBilling.java
View file @
168395c9
...
@@ -45,7 +45,7 @@ public class UserPrePaidBilling {
...
@@ -45,7 +45,7 @@ public class UserPrePaidBilling {
private
String
user
;
private
String
user
;
private
float
total
;
private
float
total
;
//0 -- 充值, 1 -- newip, 2 --
renew, 3 --ipkeptfee, 4 --deleteip,
//0 -- 充值, 1 -- newip, 2 --
renew, 3 -- return
private
int
chargeType
;
private
int
chargeType
;
private
String
unit
=
"month"
;
private
String
unit
=
"month"
;
...
@@ -193,4 +193,12 @@ public class UserPrePaidBilling {
...
@@ -193,4 +193,12 @@ public class UserPrePaidBilling {
public
void
setPayMethod
(
int
payMethod
)
{
public
void
setPayMethod
(
int
payMethod
)
{
this
.
payMethod
=
payMethod
;
this
.
payMethod
=
payMethod
;
}
}
public
String
getTradeNo
()
{
return
tradeNo
;
}
public
void
setTradeNo
(
String
tradeNo
)
{
this
.
tradeNo
=
tradeNo
;
}
}
}
src/main/java/com/edgec/browserbackend/account/dto/UserPrePaidBillingRequestDto.java
0 → 100644
View file @
168395c9
package
com
.
edgec
.
browserbackend
.
account
.
dto
;
import
com.fasterxml.jackson.annotation.JsonIgnoreProperties
;
@JsonIgnoreProperties
(
ignoreUnknown
=
true
)
public
class
UserPrePaidBillingRequestDto
{
private
int
day
;
private
int
page
;
private
int
amount
;
// 0 -- 全部, 1 -- 充值, 2 -- 余额扣费, 3 -- 微信扣费, 4 -- 支付宝扣费
private
int
tradeType
;
public
int
getDay
()
{
return
day
;
}
public
void
setDay
(
int
day
)
{
this
.
day
=
day
;
}
public
int
getPage
()
{
return
page
;
}
public
void
setPage
(
int
page
)
{
this
.
page
=
page
;
}
public
int
getAmount
()
{
return
amount
;
}
public
void
setAmount
(
int
amount
)
{
this
.
amount
=
amount
;
}
public
int
getTradeType
()
{
return
tradeType
;
}
public
void
setTradeType
(
int
tradeType
)
{
this
.
tradeType
=
tradeType
;
}
}
src/main/java/com/edgec/browserbackend/account/repository/UserPrePaidBillingRepository.java
View file @
168395c9
...
@@ -24,4 +24,6 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai
...
@@ -24,4 +24,6 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai
List
<
UserPrePaidBilling
>
findByStatus
(
BillStatus
status
);
List
<
UserPrePaidBilling
>
findByStatus
(
BillStatus
status
);
Page
<
UserPrePaidBilling
>
findByUsernameAndTimestampGreaterThanOrderByTimestamp
(
String
username
,
long
time
,
Pageable
pageable
);
}
}
src/main/java/com/edgec/browserbackend/account/service/AccountService.java
View file @
168395c9
...
@@ -66,6 +66,8 @@ public interface AccountService {
...
@@ -66,6 +66,8 @@ public interface AccountService {
List
<
UserBillList
>
getUserBills
(
String
name
,
Services
services
);
List
<
UserBillList
>
getUserBills
(
String
name
,
Services
services
);
Page
<
UserPrePaidBilling
>
getUserPrePaidBills
(
String
name
,
UserPrePaidBillingRequestDto
userPrePaidBillingRequestDto
);
void
resetPasswordWithOtp
(
UserDto
user
);
void
resetPasswordWithOtp
(
UserDto
user
);
IpChargeResultDto
preChargeByMoney
(
String
name
,
double
money
);
IpChargeResultDto
preChargeByMoney
(
String
name
,
double
money
);
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/AccountServiceImpl.java
View file @
168395c9
...
@@ -8,6 +8,7 @@ import com.edgec.browserbackend.account.domain.*;
...
@@ -8,6 +8,7 @@ import com.edgec.browserbackend.account.domain.*;
import
com.edgec.browserbackend.account.exception.AccountErrorCode
;
import
com.edgec.browserbackend.account.exception.AccountErrorCode
;
import
com.edgec.browserbackend.account.repository.*
;
import
com.edgec.browserbackend.account.repository.*
;
import
com.edgec.browserbackend.account.service.EmailService
;
import
com.edgec.browserbackend.account.service.EmailService
;
import
com.edgec.browserbackend.account.service.SmsUtils
;
import
com.edgec.browserbackend.account.utils.AccountServicePool
;
import
com.edgec.browserbackend.account.utils.AccountServicePool
;
import
com.edgec.browserbackend.auth.exception.AuthErrorCode
;
import
com.edgec.browserbackend.auth.exception.AuthErrorCode
;
import
com.edgec.browserbackend.auth.repository.UserRepository
;
import
com.edgec.browserbackend.auth.repository.UserRepository
;
...
@@ -35,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
...
@@ -35,6 +36,7 @@ import org.springframework.transaction.annotation.Transactional;
import
org.springframework.util.Assert
;
import
org.springframework.util.Assert
;
import
org.thymeleaf.util.StringUtils
;
import
org.thymeleaf.util.StringUtils
;
import
java.text.SimpleDateFormat
;
import
java.time.Instant
;
import
java.time.Instant
;
import
java.time.YearMonth
;
import
java.time.YearMonth
;
import
java.time.ZoneOffset
;
import
java.time.ZoneOffset
;
...
@@ -140,6 +142,28 @@ public class AccountServiceImpl implements AccountService {
...
@@ -140,6 +142,28 @@ public class AccountServiceImpl implements AccountService {
return
result
;
return
result
;
}
}
@Override
public
Page
<
UserPrePaidBilling
>
getUserPrePaidBills
(
String
name
,
UserPrePaidBillingRequestDto
userPrePaidBillingRequestDto
)
{
if
(
userPrePaidBillingRequestDto
.
getAmount
()
>
100
)
userPrePaidBillingRequestDto
.
setAmount
(
100
);
Pageable
pageable
=
PageRequest
.
of
(
userPrePaidBillingRequestDto
.
getPage
(),
userPrePaidBillingRequestDto
.
getAmount
());
long
time
=
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
minusDays
(
userPrePaidBillingRequestDto
.
getDay
()).
toInstant
().
toEpochMilli
();
Page
<
UserPrePaidBilling
>
userPrePaidBillings
;
switch
(
userPrePaidBillingRequestDto
.
getTradeType
())
{
case
0
:
userPrePaidBillings
=
prePaidBillingRepository
.
findByUsernameAndTimestampGreaterThanOrderByTimestamp
(
name
,
time
,
pageable
);
break
;
case
1
:
default
:
userPrePaidBillings
=
prePaidBillingRepository
.
findByUsernameAndTimestampGreaterThanOrderByTimestamp
(
name
,
time
,
pageable
);
break
;
}
return
userPrePaidBillings
;
}
@Override
@Override
public
IpChargeResultDto
chargeByMoney
(
String
name
,
double
money
,
IpChargeRequestDto
requestDto
)
{
public
IpChargeResultDto
chargeByMoney
(
String
name
,
double
money
,
IpChargeRequestDto
requestDto
)
{
IpChargeResultDto
charge
=
new
IpChargeResultDto
();
IpChargeResultDto
charge
=
new
IpChargeResultDto
();
...
@@ -165,6 +189,7 @@ public class AccountServiceImpl implements AccountService {
...
@@ -165,6 +189,7 @@ public class AccountServiceImpl implements AccountService {
charge
.
setSuccess
(
true
);
charge
.
setSuccess
(
true
);
UserPrePaidBilling
bill
=
new
UserPrePaidBilling
();
UserPrePaidBilling
bill
=
new
UserPrePaidBilling
();
bill
.
setTradeNo
(
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
).
format
(
new
Date
())+
SmsUtils
.
createRandom
(
true
,
4
));
bill
.
setChargeType
(
requestDto
.
getChargeType
());
bill
.
setChargeType
(
requestDto
.
getChargeType
());
bill
.
setAmount
(
requestDto
.
getAmount
());
bill
.
setAmount
(
requestDto
.
getAmount
());
bill
.
setUnit
(
requestDto
.
getUnit
());
bill
.
setUnit
(
requestDto
.
getUnit
());
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/PaymentServiceImpl.java
View file @
168395c9
...
@@ -30,8 +30,10 @@ import org.springframework.beans.factory.annotation.Autowired;
...
@@ -30,8 +30,10 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.stereotype.Service
;
import
org.springframework.stereotype.Service
;
import
java.text.SimpleDateFormat
;
import
java.time.Instant
;
import
java.time.Instant
;
import
java.time.YearMonth
;
import
java.time.YearMonth
;
import
java.util.Date
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -154,6 +156,7 @@ public class PaymentServiceImpl implements PaymentService {
...
@@ -154,6 +156,7 @@ public class PaymentServiceImpl implements PaymentService {
if
(
chargeType
==
0
)
{
if
(
chargeType
==
0
)
{
UserPrePaidBilling
bill
=
new
UserPrePaidBilling
();
UserPrePaidBilling
bill
=
new
UserPrePaidBilling
();
bill
.
setTradeNo
(
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
).
format
(
new
Date
())+
SmsUtils
.
createRandom
(
true
,
4
));
bill
.
setChargeType
(
0
);
bill
.
setChargeType
(
0
);
bill
.
setAmount
(
0
);
bill
.
setAmount
(
0
);
bill
.
setUnit
(
null
);
bill
.
setUnit
(
null
);
...
@@ -262,6 +265,7 @@ public class PaymentServiceImpl implements PaymentService {
...
@@ -262,6 +265,7 @@ public class PaymentServiceImpl implements PaymentService {
if
(
chargeType
==
0
)
{
if
(
chargeType
==
0
)
{
UserPrePaidBilling
bill
=
new
UserPrePaidBilling
();
UserPrePaidBilling
bill
=
new
UserPrePaidBilling
();
bill
.
setTradeNo
(
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
).
format
(
new
Date
())+
SmsUtils
.
createRandom
(
true
,
4
));
bill
.
setChargeType
(
0
);
bill
.
setChargeType
(
0
);
bill
.
setAmount
(
0
);
bill
.
setAmount
(
0
);
bill
.
setUnit
(
null
);
bill
.
setUnit
(
null
);
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
168395c9
...
@@ -571,9 +571,11 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -571,9 +571,11 @@ public class IpResourceServiceImpl implements IpResourceService {
}
}
if
(
StringUtils
.
isNotBlank
(
x
.
getAddr
()))
{
if
(
StringUtils
.
isNotBlank
(
x
.
getAddr
()))
{
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
plusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
()
&&
x
.
getValidTime
()
>
Instant
.
now
().
toEpochMilli
())
{
if
(
x
.
getStatus
()
!=
5
)
{
x
.
setStatus
(
2
);
x
.
setStatus
(
2
);
ipResourceRepository
.
save
(
x
);
ipResourceRepository
.
save
(
x
);
}
}
}
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
())
{
else
if
(
x
.
getValidTime
()
<=
Instant
.
now
().
minusSeconds
(
60
*
60
*
24
*
7
).
toEpochMilli
())
{
if
(
x
.
getIpType
()
==
IpType
.
VENDOR
)
{
if
(
x
.
getIpType
()
==
IpType
.
VENDOR
)
{
IpResourceRequestDto
ipResourceRequestDto
=
new
IpResourceRequestDto
();
IpResourceRequestDto
ipResourceRequestDto
=
new
IpResourceRequestDto
();
...
@@ -591,7 +593,7 @@ public class IpResourceServiceImpl implements IpResourceService {
...
@@ -591,7 +593,7 @@ public class IpResourceServiceImpl implements IpResourceService {
ipResourceRepository
.
save
(
x
);
ipResourceRepository
.
save
(
x
);
}
}
else
{
else
{
if
(
x
.
getStatus
()
!=
4
&&
x
.
getStatus
()
!=
5
)
{
if
(
x
.
getStatus
()
==
0
&&
x
.
getStatus
()
==
1
&&
x
.
getStatus
()
==
2
)
{
x
.
setStatus
(
0
);
x
.
setStatus
(
0
);
ipResourceRepository
.
save
(
x
);
ipResourceRepository
.
save
(
x
);
}
}
...
...
src/main/java/com/edgec/browserbackend/common/charge/ChargeType.java
View file @
168395c9
...
@@ -4,8 +4,6 @@ package com.edgec.browserbackend.common.charge;
...
@@ -4,8 +4,6 @@ package com.edgec.browserbackend.common.charge;
public
interface
ChargeType
{
public
interface
ChargeType
{
//0 -- 充值, 1 -- newip, 2 --renew, 3 --ipkeptfee, 4 --deleteip,
int
payment
=
0
;
// 充值
int
payment
=
0
;
// 充值
int
newip
=
1
;
// 购买vps, ip
int
newip
=
1
;
// 购买vps, ip
int
renew
=
2
;
// 续费ip
int
renew
=
2
;
// 续费ip
...
...
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