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
0a169770
Commit
0a169770
authored
Jun 30, 2020
by
xuxin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码修改以及bug修复
parent
b6f8a32c
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
40 additions
and
24 deletions
+40
-24
AccountController.java
.../browserbackend/account/controller/AccountController.java
+6
-1
PaymentServiceImpl.java
...owserbackend/account/service/impl/PaymentServiceImpl.java
+0
-0
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+25
-18
ShopServiceImpl.java
.../browserbackend/browser/service/Impl/ShopServiceImpl.java
+2
-2
PaymentTask.java
...va/com/edgec/browserbackend/browser/task/PaymentTask.java
+7
-3
No files found.
src/main/java/com/edgec/browserbackend/account/controller/AccountController.java
View file @
0a169770
...
...
@@ -263,6 +263,9 @@ public class AccountController {
return
paymentService
.
wechatPayCallback
(
tradno
);
}
/**
* 使用微信进行账户充值成功后,微信会调用该接口
*/
@RequestMapping
(
path
=
"/0xwxcheckorderstatus/{tradno}/{chargeType}"
,
method
=
RequestMethod
.
GET
)
public
UserPaymentDto
wechatCheckOrderStatus
(
Principal
principal
,
@PathVariable
String
tradno
,
@PathVariable
int
chargeType
)
{
return
paymentService
.
wxCheckOrderStatus
(
tradno
,
chargeType
);
...
...
@@ -281,6 +284,9 @@ public class AccountController {
paymentService
.
alipaCallback
(
tradno
);
}
/**
* 使用 支付宝 充值 成功后回调
*/
@RequestMapping
(
path
=
"/0xalicheckorderstatus/{tradno}/{chargeType}"
,
method
=
RequestMethod
.
GET
)
public
UserPaymentDto
alipayCheckOrderStatus
(
Principal
principal
,
@PathVariable
(
required
=
false
)
String
tradno
,
@PathVariable
int
chargeType
)
{
return
paymentService
.
aliCheckOrderStatus
(
tradno
,
chargeType
);
...
...
@@ -292,7 +298,6 @@ public class AccountController {
*/
@RequestMapping
(
path
=
"/0xalipay/{amount}"
,
method
=
RequestMethod
.
GET
)
public
void
alipayPutOrder
(
HttpServletRequest
request
,
HttpServletResponse
response
,
@PathVariable
int
amount
)
throws
Exception
{
String
by
=
request
.
getParameter
(
"by"
);
String
form
=
paymentService
.
alipayPutPayOrder
(
request
.
getUserPrincipal
().
getName
(),
amount
,
by
);
response
.
setContentType
(
"text/html;charset=utf-8"
);
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/PaymentServiceImpl.java
View file @
0a169770
This diff is collapsed.
Click to expand it.
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
0a169770
...
...
@@ -159,10 +159,8 @@ public class IpResourceServiceImpl implements IpResourceService {
@Override
public
List
<
String
>
buyIp
(
String
username
,
IpResourceRequestDto
ipResourceRequestDto
)
throws
Exception
{
if
(
ipResourceRequestDto
.
getRegion
()
==
null
)
{
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
}
if
(
ipResourceRequestDto
.
getRegionCn
()
==
null
)
{
// 1. 数据校验
if
(
ipResourceRequestDto
.
getRegion
()
==
null
||
ipResourceRequestDto
.
getRegionCn
()
==
null
)
{
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
}
Account
account
=
accountRepository
.
findByName
(
username
).
orElseThrow
(()
->
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
));
...
...
@@ -171,6 +169,7 @@ public class IpResourceServiceImpl implements IpResourceService {
}
// 2. 计算 ip 单价信息
double
newprice
=
0
;
if
(!
"own"
.
equals
(
ipResourceRequestDto
.
getVendor
()))
{
Map
<
String
,
List
<
String
>>
priceList
=
ipOptionsRepository
.
findAll
().
get
(
0
).
getIpPlatForm
();
...
...
@@ -182,12 +181,15 @@ public class IpResourceServiceImpl implements IpResourceService {
newprice
=
"week"
.
equals
(
ipResourceRequestDto
.
getUnit
())
?
(
Integer
.
valueOf
(
price
)
/
3
)
:
Integer
.
valueOf
(
price
);
}
// 3. 计算总共需要花费多少钱 并 校验账户余额 够不够扣费
IpChargeResultDto
ipChargeResultDto
=
accountService
.
preChargeByMoney
(
username
,
newprice
*
ipResourceRequestDto
.
getAmount
()
*
ipResourceRequestDto
.
getPeriod
());
if
(!
ipChargeResultDto
.
isSuccess
())
{
throw
new
ClientRequestException
(
AccountErrorCode
.
NOTENOUGHBALANCE
);
}
// 生成随机密码
String
password
=
StringUtils
.
isNotBlank
(
ipResourceRequestDto
.
getPassword
())
?
ipResourceRequestDto
.
getPassword
()
:
genRandom
(
3
,
12
);
List
<
IpResourceDto
>
ipResourceDtos
=
new
ArrayList
<>();
List
<
String
>
ipIds
=
new
ArrayList
<>();
...
...
@@ -195,19 +197,22 @@ public class IpResourceServiceImpl implements IpResourceService {
IpResource
ipResource
=
new
IpResource
();
ipResource
.
setPeriod
(
ipResourceRequestDto
.
getPeriod
());
//充6送1
if
(
ipResourceRequestDto
.
getUnit
().
equals
(
"month"
)
&&
ipResourceRequestDto
.
getPeriod
()
==
6
)
{
ipResource
.
setPeriod
(
7
);
}
else
if
(
ipResourceRequestDto
.
getUnit
().
equals
(
"month"
)
&&
ipResourceRequestDto
.
getPeriod
()
==
12
)
{
ipResource
.
setPeriod
(
14
);
if
(
ipResourceRequestDto
.
getUnit
().
equals
(
"month"
))
{
if
(
ipResourceRequestDto
.
getPeriod
()
==
6
)
{
ipResource
.
setPeriod
(
7
);
}
if
(
ipResourceRequestDto
.
getPeriod
()
==
12
)
{
ipResource
.
setPeriod
(
14
);
}
}
// 根据 ip 的 vendor 来封装部分的 ipResource 信息
if
(
ipResourceRequestDto
.
getVendor
().
equals
(
"local"
))
{
ipResource
.
setAddr
(
"本地Ip未使用"
);
ipResource
.
setIpType
(
IpType
.
LOCAL
);
ipResource
.
setVendor
(
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()));
ipResource
.
setVendorCn
(
"本地"
);
ipResource
.
setStatus
(
4
);
ipResource
.
setUsername
(
USERNAME
);
long
validTime
=
0
;
if
(
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
))
{
...
...
@@ -216,12 +221,10 @@ public class IpResourceServiceImpl implements IpResourceService {
validTime
=
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
plusMonths
(
ipResource
.
getPeriod
()).
toInstant
().
toEpochMilli
();
}
ipResource
.
setValidTime
(
validTime
);
ipResource
.
setUsername
(
USERNAME
);
ipResource
.
setPort
(
port
);
}
else
if
(
ipResourceRequestDto
.
getVendor
().
equals
(
"own"
))
{
if
(
ipResourceRequestDto
.
getAddr
()
==
null
||
ipResourceRequestDto
.
getAddr
().
isEmpty
())
{
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
}
if
(
StringUtils
.
isBlank
(
ipResourceRequestDto
.
getAddr
().
get
(
i
)))
{
if
(
ipResourceRequestDto
.
getAddr
()
==
null
||
ipResourceRequestDto
.
getAddr
().
isEmpty
()
||
StringUtils
.
isBlank
(
ipResourceRequestDto
.
getAddr
().
get
(
i
)))
{
throw
new
ClientRequestException
(
BrowserErrorCode
.
INFORMATIONNOTCOMPELETE
);
}
...
...
@@ -252,18 +255,18 @@ public class IpResourceServiceImpl implements IpResourceService {
break
;
}
ipResource
.
setStatus
(
6
);
long
validTime
=
0
;
if
(
ipResourceRequestDto
.
getUnit
().
equals
(
"week"
))
{
ipResource
.
setValidTime
(
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
plusWeeks
(
ipResource
.
getPeriod
()).
toInstant
().
toEpochMilli
()
);
validTime
=
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
plusWeeks
(
ipResource
.
getPeriod
()).
toInstant
().
toEpochMilli
(
);
}
else
{
ipResource
.
setValidTime
(
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
plusMonths
(
ipResource
.
getPeriod
()).
toInstant
().
toEpochMilli
()
);
validTime
=
Instant
.
now
().
atZone
(
ZoneOffset
.
UTC
).
plusMonths
(
ipResource
.
getPeriod
()).
toInstant
().
toEpochMilli
(
);
}
ipResource
.
setValidTime
(
validTime
);
ipResource
.
setUsername
(
USERNAME
);
ipResource
.
setPort
(
port
);
}
ipResource
.
setPurchasedTime
(
Instant
.
now
().
toEpochMilli
());
if
(
account
.
getParent
()
!=
null
)
{
ipResource
.
setUserParent
(
account
.
getParent
());
}
...
...
@@ -279,6 +282,7 @@ public class IpResourceServiceImpl implements IpResourceService {
ipResource
.
setHealthLockTimestamp
(
Instant
.
now
().
minusSeconds
(
60
*
20
).
toEpochMilli
());
}
ipResource
.
setPurchasedTime
(
Instant
.
now
().
toEpochMilli
());
ipResource
.
setRegionCn
(
ipResourceRequestDto
.
getRegionCn
());
ipResource
.
setProtocol
(
protocol
);
ipResource
.
setPassword
(
password
);
...
...
@@ -296,10 +300,13 @@ public class IpResourceServiceImpl implements IpResourceService {
}
if
(!
ipResourceRequestDto
.
getVendor
().
equals
(
"own"
))
{
// 封装购买 ip 的费用 信息
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
1
,
ipResourceRequestDto
.
getPayMethod
());
// 用来记录购买与消费的操作 userbalance 与 费用明细 userprepaidbilling
accountService
.
chargeByMoney
(
username
,
newprice
*
ipChargeRequestDto
.
getAmount
()
*
ipChargeRequestDto
.
getPeriod
(),
ipChargeRequestDto
);
}
// 如果ip需要绑定店铺,则将店铺与ip绑定
if
(
ipResourceRequestDto
.
getShopId
()
!=
null
)
{
ShopRequestDto
shopRequestDto
=
new
ShopRequestDto
();
shopRequestDto
.
setIpId
(
ipResourceDtos
.
get
(
0
).
getId
());
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/ShopServiceImpl.java
View file @
0a169770
...
...
@@ -234,14 +234,14 @@ public class ShopServiceImpl implements ShopService {
ipAndShopService
.
unBindShop
(
username
,
shopRequestDto
);
}
// 4. 删除当前店铺关联的所有的 usershop信息
// 4. 获取当前店铺关联的所有的 usershop信息 并删除数据库中 usershop信息
List
<
UserShop
>
userShops
=
userShopRepository
.
findByShopId
(
shopId
);
boolean
result
=
userShopRepository
.
deleteByShopId
(
shopId
);
if
(
result
)
{
// 5. 删除当前店铺,并更新 account信息 todo
shopRepository
.
deleteById
(
shopId
);
// 6. 更新 和店铺关联的所有的 account 的信息
List
<
UserShop
>
userShops
=
userShopRepository
.
findByShopId
(
shopId
);
List
<
Account
>
accountList
=
accountRepository
.
findByNameIn
(
userShops
.
stream
().
map
(
UserShop:
:
getUsername
).
collect
(
Collectors
.
toList
()));
for
(
Account
a
:
accountList
)
{
a
.
setShopCount
(
account
.
getShopCount
()
-
1
);
...
...
src/main/java/com/edgec/browserbackend/browser/task/PaymentTask.java
View file @
0a169770
...
...
@@ -43,13 +43,17 @@ public class PaymentTask {
payment
->
{
PaymentMethod
paymentMethod
=
payment
.
getPaymentMethod
();
try
{
// 自动调用 微信或者支付宝的支付接口来确认 支付状态
/*
* 自动调用 微信或者支付宝的支付接口来确认 支付状态
* chargeType 取值范围为 0-4
* 此处设置为 100 仅仅只是为了避免 wxCheckOrderStatus() 方法中 chargeType == 0 相关代码块
*/
if
(
PaymentMethod
.
WECHAT
.
equals
(
paymentMethod
))
{
paymentService
.
wxCheckOrderStatus
(
payment
.
getTradeNo
());
paymentService
.
wxCheckOrderStatus
(
payment
.
getTradeNo
()
,
100
);
}
if
(
PaymentMethod
.
ALIPAY
.
equals
(
paymentMethod
))
{
paymentService
.
aliCheckOrderStatus
(
payment
.
getTradeNo
());
paymentService
.
aliCheckOrderStatus
(
payment
.
getTradeNo
()
,
100
);
}
}
catch
(
Exception
e
)
{
log
.
error
(
"checkPayments"
,
e
);
...
...
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