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
dd894e14
Commit
dd894e14
authored
Mar 12, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
微信,支付宝充值
parent
25b93810
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
2 deletions
+51
-2
PaymentServiceImpl.java
...owserbackend/account/service/impl/PaymentServiceImpl.java
+49
-0
IpResourceServiceImpl.java
...erbackend/browser/service/Impl/IpResourceServiceImpl.java
+2
-2
No files found.
src/main/java/com/edgec/browserbackend/account/service/impl/PaymentServiceImpl.java
View file @
dd894e14
...
...
@@ -10,11 +10,13 @@ import com.alipay.api.response.AlipayTradeQueryResponse;
import
com.edgec.browserbackend.account.exception.AccountErrorCode
;
import
com.edgec.browserbackend.account.repository.UserBalanceRepository
;
import
com.edgec.browserbackend.account.repository.UserPaymentRepository
;
import
com.edgec.browserbackend.account.repository.UserPrePaidBillingRepository
;
import
com.edgec.browserbackend.account.service.AccountService
;
import
com.edgec.browserbackend.account.service.PaymentService
;
import
com.edgec.browserbackend.account.controller.AccountController
;
import
com.edgec.browserbackend.account.domain.*
;
import
com.edgec.browserbackend.account.service.SmsUtils
;
import
com.edgec.browserbackend.account.service.UserPrePaidBillingService
;
import
com.edgec.browserbackend.alipay.AlipayConfig
;
import
com.edgec.browserbackend.alipay.CloudamAlipayConfig
;
import
com.edgec.browserbackend.alipay.VpsAlipayConfig
;
...
...
@@ -26,6 +28,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import
org.springframework.context.annotation.ComponentScan
;
import
org.springframework.stereotype.Service
;
import
java.time.Instant
;
import
java.time.YearMonth
;
import
java.util.HashMap
;
import
java.util.Map
;
...
...
@@ -43,6 +47,9 @@ public class PaymentServiceImpl implements PaymentService {
@Autowired
private
AccountService
accountService
;
@Autowired
private
UserPrePaidBillingRepository
userPrePaidBillingRepository
;
@Override
public
String
wechatPayCallback
(
String
tradno
)
{
...
...
@@ -140,6 +147,28 @@ public class PaymentServiceImpl implements PaymentService {
balance
.
setUsername
(
byTradeNo
.
getUsername
());
}
UserPrePaidBilling
bill
=
new
UserPrePaidBilling
();
bill
.
setChargeType
(
0
);
bill
.
setAmount
(
0
);
bill
.
setUnit
(
null
);
bill
.
setPeriod
(
0
);
bill
.
setPayMethod
(
2
);
bill
.
setUsername
(
byTradeNo
.
getUsername
());
bill
.
setTotal
((
float
)
byTradeNo
.
getAmount
());
bill
.
setStatus
(
BillStatus
.
PAID
);
bill
.
setPrepaid
(
true
);
bill
.
setTimestamp
(
Instant
.
now
().
toEpochMilli
());
final
YearMonth
lastmonth
=
YearMonth
.
now
();
int
monthValue
=
lastmonth
.
getMonthValue
();
int
year
=
lastmonth
.
getYear
();
bill
.
setYear
(
year
);
bill
.
setMonth
(
monthValue
);
userPrePaidBillingRepository
.
save
(
bill
);
balance
.
setBalanced
(
balance
.
getBalanced
()
+
byTradeNo
.
getAmount
());
userBalanceRepository
.
save
(
balance
);
}
...
...
@@ -222,6 +251,26 @@ public class PaymentServiceImpl implements PaymentService {
balance
.
setUsername
(
byTradeNo
.
getUsername
());
}
UserPrePaidBilling
bill
=
new
UserPrePaidBilling
();
bill
.
setChargeType
(
0
);
bill
.
setAmount
(
0
);
bill
.
setUnit
(
null
);
bill
.
setPeriod
(
0
);
bill
.
setPayMethod
(
1
);
bill
.
setUsername
(
byTradeNo
.
getUsername
());
bill
.
setTotal
((
float
)
byTradeNo
.
getAmount
());
bill
.
setStatus
(
BillStatus
.
PAID
);
bill
.
setPrepaid
(
true
);
bill
.
setTimestamp
(
Instant
.
now
().
toEpochMilli
());
final
YearMonth
lastmonth
=
YearMonth
.
now
();
int
monthValue
=
lastmonth
.
getMonthValue
();
int
year
=
lastmonth
.
getYear
();
bill
.
setYear
(
year
);
bill
.
setMonth
(
monthValue
);
balance
.
setBalanced
(
balance
.
getBalanced
()
+
byTradeNo
.
getAmount
());
userBalanceRepository
.
save
(
balance
);
}
...
...
src/main/java/com/edgec/browserbackend/browser/service/Impl/IpResourceServiceImpl.java
View file @
dd894e14
...
...
@@ -199,7 +199,7 @@ public class IpResourceServiceImpl implements IpResourceService {
}
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
0
);
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
1
);
accountService
.
chargeByMoney
(
username
,
Double
.
valueOf
(
price
),
ipChargeRequestDto
);
return
ipResourceDtos
;
}
...
...
@@ -244,7 +244,7 @@ public class IpResourceServiceImpl implements IpResourceService {
.
filter
(
vendorprice
->
Vendor
.
valueOf
(
ipResourceRequestDto
.
getVendor
()).
getValue
().
equals
(
vendorprice
.
substring
(
0
,
vendorprice
.
indexOf
(
"-"
))))
.
map
(
vendorprice
->
vendorprice
.
substring
(
vendorprice
.
lastIndexOf
(
"-"
)
+
1
)).
collect
(
Collectors
.
joining
());
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
0
);
IpChargeRequestDto
ipChargeRequestDto
=
buildIpChargeRequestDto
(
ipResourceRequestDto
,
2
);
accountService
.
chargeByMoney
(
username
,
Double
.
valueOf
(
price
),
ipChargeRequestDto
);
ipResource
.
setValidTime
(
Instant
.
parse
(
x
.
getValidTill
()).
toEpochMilli
());
...
...
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