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
badce8a8
Commit
badce8a8
authored
Oct 12, 2020
by
huangjiamin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
购买失败处理以及注释
parent
2b52de95
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
113 additions
and
4 deletions
+113
-4
Account.java
...java/com/edgec/browserbackend/account/domain/Account.java
+4
-2
IpChargeRequestDto.java
...gec/browserbackend/account/domain/IpChargeRequestDto.java
+23
-2
IpResource.java
...a/com/edgec/browserbackend/browser/domain/IpResource.java
+38
-0
IpResourceRepository.java
...owserbackend/browser/repository/IpResourceRepository.java
+10
-0
IpAndShopService.java
...dgec/browserbackend/browser/service/IpAndShopService.java
+4
-0
BrowserTask.java
...va/com/edgec/browserbackend/browser/task/BrowserTask.java
+34
-0
No files found.
src/main/java/com/edgec/browserbackend/account/domain/Account.java
View file @
badce8a8
...
@@ -30,7 +30,6 @@ public class Account {
...
@@ -30,7 +30,6 @@ public class Account {
*/
*/
private
String
parent
;
private
String
parent
;
/**
/**
* 子用户使用的密码
* 子用户使用的密码
*/
*/
...
@@ -87,7 +86,10 @@ public class Account {
...
@@ -87,7 +86,10 @@ public class Account {
private
int
shopCount
=
0
;
private
int
shopCount
=
0
;
private
int
authorized
;
// 0: 未认证; 1: 认证中; 2: 已认证;
/**
* 0: 未认证; 1: 认证中; 2: 已认证;
*/
private
int
authorized
;
private
List
<
String
>
queryIpUrlList
=
new
ArrayList
<>();
private
List
<
String
>
queryIpUrlList
=
new
ArrayList
<>();
...
...
src/main/java/com/edgec/browserbackend/account/domain/IpChargeRequestDto.java
View file @
badce8a8
...
@@ -7,7 +7,9 @@ public class IpChargeRequestDto {
...
@@ -7,7 +7,9 @@ public class IpChargeRequestDto {
private
String
unit
=
"month"
;
private
String
unit
=
"month"
;
private
String
target
;
private
String
target
;
//0 -- 充值, 1 -- newip, 2 --renew, 3 -- 退还
/**
* 0 -- 充值, 1 -- newip, 2 --renew, 3 -- 退还
*/
private
int
chargeType
=
0
;
private
int
chargeType
=
0
;
/**
/**
...
@@ -16,7 +18,9 @@ public class IpChargeRequestDto {
...
@@ -16,7 +18,9 @@ public class IpChargeRequestDto {
private
String
chargeIp
;
private
String
chargeIp
;
//0 -- 余额, 1 -- 支付宝, 2 -- 微信
/**
* 0 -- 余额, 1 -- 支付宝, 2 -- 微信
*/
private
int
payMethod
=
0
;
private
int
payMethod
=
0
;
private
float
daysPerMonth
=
0
;
private
float
daysPerMonth
=
0
;
...
@@ -112,4 +116,21 @@ public class IpChargeRequestDto {
...
@@ -112,4 +116,21 @@ public class IpChargeRequestDto {
public
void
setChargeIp
(
String
chargeIp
)
{
public
void
setChargeIp
(
String
chargeIp
)
{
this
.
chargeIp
=
chargeIp
;
this
.
chargeIp
=
chargeIp
;
}
}
@Override
public
String
toString
()
{
return
"IpChargeRequestDto{"
+
"period="
+
period
+
", amount="
+
amount
+
", region='"
+
region
+
'\''
+
", unit='"
+
unit
+
'\''
+
", target='"
+
target
+
'\''
+
", chargeType="
+
chargeType
+
", chargeIp='"
+
chargeIp
+
'\''
+
", payMethod="
+
payMethod
+
", daysPerMonth="
+
daysPerMonth
+
", tradeNo='"
+
tradeNo
+
'\''
+
", services='"
+
services
+
'\''
+
'}'
;
}
}
}
src/main/java/com/edgec/browserbackend/browser/domain/IpResource.java
View file @
badce8a8
...
@@ -168,6 +168,44 @@ public class IpResource implements Serializable {
...
@@ -168,6 +168,44 @@ public class IpResource implements Serializable {
return
Objects
.
hash
(
getId
());
return
Objects
.
hash
(
getId
());
}
}
@Override
public
String
toString
()
{
return
"IpResource{"
+
"id='"
+
id
+
'\''
+
", addr='"
+
addr
+
'\''
+
", ipType="
+
ipType
+
", vendor="
+
vendor
+
", vendorCn='"
+
vendorCn
+
'\''
+
", region='"
+
region
+
'\''
+
", regionCn='"
+
regionCn
+
'\''
+
", status="
+
status
+
", port="
+
port
+
", purchasedTime="
+
purchasedTime
+
", validTime="
+
validTime
+
", details='"
+
details
+
'\''
+
", bindHistory="
+
bindHistory
+
", isDeleted="
+
isDeleted
+
", username='"
+
username
+
'\''
+
", owner='"
+
owner
+
'\''
+
", userParent='"
+
userParent
+
'\''
+
", protocol="
+
protocol
+
", password='"
+
password
+
'\''
+
", price="
+
price
+
", specialLine="
+
specialLine
+
", usingSpecialLine="
+
usingSpecialLine
+
", proxyUsername='"
+
proxyUsername
+
'\''
+
", proxyPassword='"
+
proxyPassword
+
'\''
+
", shopId='"
+
shopId
+
'\''
+
", shopIds="
+
shopIds
+
", bind="
+
bind
+
", isLocked="
+
isLocked
+
", lockTimestamp="
+
lockTimestamp
+
", healthLockTimestamp="
+
healthLockTimestamp
+
", unit='"
+
unit
+
'\''
+
", period="
+
period
+
", secondaryProxyPort='"
+
secondaryProxyPort
+
'\''
+
'}'
;
}
}
}
...
...
src/main/java/com/edgec/browserbackend/browser/repository/IpResourceRepository.java
View file @
badce8a8
...
@@ -70,4 +70,14 @@ public interface IpResourceRepository extends MongoRepository<IpResource, String
...
@@ -70,4 +70,14 @@ public interface IpResourceRepository extends MongoRepository<IpResource, String
IpResource
findFirstByAddrOrderByPurchasedTimeDesc
(
String
addr
);
IpResource
findFirstByAddrOrderByPurchasedTimeDesc
(
String
addr
);
/**
* 查询出未分配成功的数据
*
* @param status 状态
* @param isDeleted 是否被删除
* @param isLocked 是否被锁定
* @return list
*/
List
<
IpResource
>
findByStatusInAndIsDeletedAndIsLocked
(
List
<
Integer
>
status
,
boolean
isDeleted
,
boolean
isLocked
);
}
}
src/main/java/com/edgec/browserbackend/browser/service/IpAndShopService.java
View file @
badce8a8
...
@@ -2,6 +2,8 @@ package com.edgec.browserbackend.browser.service;
...
@@ -2,6 +2,8 @@ package com.edgec.browserbackend.browser.service;
import
com.edgec.browserbackend.browser.dto.ShopRequestDto
;
import
com.edgec.browserbackend.browser.dto.ShopRequestDto
;
import
java.util.List
;
public
interface
IpAndShopService
{
public
interface
IpAndShopService
{
void
bindShop
(
String
username
,
ShopRequestDto
shopRequestDto
);
void
bindShop
(
String
username
,
ShopRequestDto
shopRequestDto
);
...
@@ -9,4 +11,6 @@ public interface IpAndShopService {
...
@@ -9,4 +11,6 @@ public interface IpAndShopService {
void
unBindShop
(
String
username
,
ShopRequestDto
shopRequestDto
);
void
unBindShop
(
String
username
,
ShopRequestDto
shopRequestDto
);
void
unBindShops
(
String
username
,
ShopRequestDto
shopRequestDto
);
void
unBindShops
(
String
username
,
ShopRequestDto
shopRequestDto
);
//void unBindShops(String username, String id, List<String> shopIds);
}
}
src/main/java/com/edgec/browserbackend/browser/task/BrowserTask.java
View file @
badce8a8
...
@@ -199,6 +199,40 @@ public class BrowserTask {
...
@@ -199,6 +199,40 @@ public class BrowserTask {
CompletableFuture
.
allOf
(
futureList
.
toArray
(
new
CompletableFuture
[
0
])).
join
();
CompletableFuture
.
allOf
(
futureList
.
toArray
(
new
CompletableFuture
[
0
])).
join
();
}
}
private
static
int
OVER40MIN
=
40
*
60
*
1000
;
/**
* 购买失败处理
* 购买后,长时间未能成功的ip资源视为购买失败。
* 每半个小时进行一次,将状态为3、购买时长超过40分钟的ip资源释放,
* 并将购买花销退回账户余额
*/
@Scheduled
(
cron
=
"0 0/1 * * * ?"
)
public
void
purchaseFailureHandling
()
{
long
now
=
Instant
.
now
().
minusSeconds
(
300
).
toEpochMilli
();
//List<IpResource> ipResources = ipResourceRepository.findByStatusInAndIsDeletedAndIsLocked(Arrays.asList(3, 6));
List
<
IpResource
>
ipResources
=
ipResourceRepository
.
findByStatusInAndIsDeletedAndIsLocked
(
Arrays
.
asList
(
3
,
6
),
false
,
false
);
ipResources
.
forEach
(
ipResource
->
{
if
(
ipResourceRepository
.
lockTask
(
ipResource
))
{
if
((
now
-
ipResource
.
getPurchasedTime
())
>
OVER40MIN
){
String
username
=
ipResource
.
getUsername
();
String
id
=
ipResource
.
getId
();
List
<
String
>
shopIds
=
ipResource
.
getShopIds
();
log
.
error
(
"Ip resource purchase failure, {}"
,
ipResource
);
log
.
error
(
"charge by money, {}, {}, {}"
,
username
,
-
ipResource
.
getPrice
(),
buildIpChargeRequestDto
(
ipResource
,
3
,
0
));
//accountService.chargeByMoney(username, -ipResource.getPrice(), buildIpChargeRequestDto(ipResource, 3, 0));
if
(
shopIds
!=
null
&&
shopIds
.
size
()
>
0
)
{
log
.
error
(
"unbind Shops, {}, {}, {}"
,
username
,
id
,
shopIds
);
//ipAndShopService.unBindShops(username, ipResource.getId(), shopIds);
}
log
.
error
(
"delete ip resource, {}"
,
id
);
//ipResourceRepository.deleteById(id);
}
}
ipResourceRepository
.
unLockTask
(
ipResource
.
getId
());
});
}
@Scheduled
(
cron
=
"0 0/1 * * * ?"
)
@Scheduled
(
cron
=
"0 0/1 * * * ?"
)
public
void
queryIpTasks
()
{
public
void
queryIpTasks
()
{
String
URL
=
(
profiles
.
equals
(
"dev"
)
||
profiles
.
equals
(
"staging"
))
?
TESTURL
:
CLOUDAMURL
;
String
URL
=
(
profiles
.
equals
(
"dev"
)
||
profiles
.
equals
(
"staging"
))
?
TESTURL
:
CLOUDAMURL
;
...
...
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