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
d89e4fd4
Commit
d89e4fd4
authored
Mar 26, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
费用明细
parent
ff3dde2e
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
108 additions
and
31 deletions
+108
-31
AccountController.java
.../browserbackend/account/controller/AccountController.java
+15
-4
UserPrePaidBilling.java
...gec/browserbackend/account/domain/UserPrePaidBilling.java
+11
-13
PrePaidBillingPageResultDto.java
...owserbackend/account/dto/PrePaidBillingPageResultDto.java
+26
-0
UserPrePaidBillingRequestDto.java
...wserbackend/account/dto/UserPrePaidBillingRequestDto.java
+1
-1
UserPrePaidBillingRepository.java
...kend/account/repository/UserPrePaidBillingRepository.java
+9
-0
AccountService.java
.../edgec/browserbackend/account/service/AccountService.java
+1
-1
AccountServiceImpl.java
...owserbackend/account/service/impl/AccountServiceImpl.java
+31
-11
AdministratorServiceImpl.java
...ackend/account/service/impl/AdministratorServiceImpl.java
+0
-1
PaymentServiceImpl.java
...owserbackend/account/service/impl/PaymentServiceImpl.java
+14
-0
No files found.
src/main/java/com/edgec/browserbackend/account/controller/AccountController.java
View file @
d89e4fd4
...
...
@@ -4,6 +4,7 @@ import com.edgec.browserbackend.account.domain.*;
import
com.edgec.browserbackend.account.dto.MobileDto
;
import
com.edgec.browserbackend.account.dto.ResultDto
;
import
com.edgec.browserbackend.account.dto.BillQueryCriteriaDto
;
import
com.edgec.browserbackend.account.dto.UserPrePaidBillingRequestDto
;
import
com.edgec.browserbackend.common.auth.Securitys
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
com.edgec.browserbackend.common.commons.utils.DateConverter
;
...
...
@@ -160,10 +161,20 @@ public class AccountController {
}
// 消费总览
@RequestMapping
(
path
=
"/current/userbilling"
,
method
=
RequestMethod
.
GET
)
@Deprecated
public
List
<
UserBillList
>
getUserBills0
(
Principal
principal
)
{
return
accountService
.
getUserBills0
(
principal
.
getName
());
@RequestMapping
(
path
=
"/userbilling"
,
method
=
RequestMethod
.
POST
)
public
ResultDto
getUserBills0
(
Principal
principal
,
@RequestBody
UserPrePaidBillingRequestDto
userPrePaidBillingRequestDto
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
resultDto
.
setData
(
accountService
.
getUserPrePaidBills
(
principal
.
getName
(),
userPrePaidBillingRequestDto
));
resultDto
.
setStatus
(
0
);
}
catch
(
ClientRequestException
e
)
{
resultDto
.
setStatus
(-
1
);
Map
<
String
,
Object
>
statusInfo
=
new
HashMap
<>();
statusInfo
.
put
(
"code"
,
e
.
getErrorCode
());
statusInfo
.
put
(
"message"
,
e
.
getMessage
());
resultDto
.
setStatusInfo
(
statusInfo
);
}
return
resultDto
;
}
// 消费总览
...
...
src/main/java/com/edgec/browserbackend/account/domain/UserPrePaidBilling.java
View file @
d89e4fd4
...
...
@@ -37,19 +37,19 @@ public class UserPrePaidBilling {
private
BillStatus
status
;
//0 -- 余额,
2 -- 支付宝, 3
-- 微信
//0 -- 余额,
1 -- 支付宝, 2
-- 微信
private
int
payMethod
;
private
boolean
isPrepaid
;
private
String
user
;
private
float
total
;
//0 -- 充值, 1 -- newip, 2 -- renew, 3 -- return
private
int
chargeType
;
private
String
unit
=
"month"
;
private
String
administrator
;
private
List
<
DeductionRecord
>
deductionRecords
=
new
ArrayList
<>();
public
float
getRate
()
{
...
...
@@ -176,16 +176,6 @@ public class UserPrePaidBilling {
this
.
period
=
period
;
}
public
String
getUser
()
{
if
(
StringUtils
.
isEmpty
(
user
))
return
username
;
return
user
;
}
public
void
setUser
(
String
user
)
{
this
.
user
=
user
;
}
public
int
getPayMethod
()
{
return
payMethod
;
}
...
...
@@ -201,4 +191,12 @@ public class UserPrePaidBilling {
public
void
setTradeNo
(
String
tradeNo
)
{
this
.
tradeNo
=
tradeNo
;
}
public
String
getAdministrator
()
{
return
administrator
;
}
public
void
setAdministrator
(
String
administrator
)
{
this
.
administrator
=
administrator
;
}
}
src/main/java/com/edgec/browserbackend/account/dto/PrePaidBillingPageResultDto.java
0 → 100644
View file @
d89e4fd4
package
com
.
edgec
.
browserbackend
.
account
.
dto
;
import
com.edgec.browserbackend.browser.dto.PageInfo
;
import
java.util.List
;
public
class
PrePaidBillingPageResultDto
<
T
>
{
List
<
T
>
billingList
;
PageInfo
billingPage
;
public
List
<
T
>
getBillingList
()
{
return
billingList
;
}
public
void
setBillingList
(
List
<
T
>
billingList
)
{
this
.
billingList
=
billingList
;
}
public
PageInfo
getBillingPage
()
{
return
billingPage
;
}
public
void
setBillingPage
(
PageInfo
billingPage
)
{
this
.
billingPage
=
billingPage
;
}
}
src/main/java/com/edgec/browserbackend/account/dto/UserPrePaidBillingRequestDto.java
View file @
d89e4fd4
...
...
@@ -7,7 +7,7 @@ public class UserPrePaidBillingRequestDto {
private
int
day
;
private
int
page
;
private
int
amount
;
// 0 -- 全部, 1 -- 充值, 2 -- 余额扣费, 3 --
微信扣费, 4 -- 支付宝
扣费
// 0 -- 全部, 1 -- 充值, 2 -- 余额扣费, 3 --
支付宝扣费, 4 -- 微信
扣费
private
int
tradeType
;
public
int
getDay
()
{
...
...
src/main/java/com/edgec/browserbackend/account/repository/UserPrePaidBillingRepository.java
View file @
d89e4fd4
...
...
@@ -26,4 +26,13 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai
Page
<
UserPrePaidBilling
>
findByUsernameAndTimestampGreaterThanOrderByTimestamp
(
String
username
,
long
time
,
Pageable
pageable
);
Page
<
UserPrePaidBilling
>
findByAdministratorAndTimestampGreaterThanOrderByTimestamp
(
String
administrator
,
long
time
,
Pageable
pageable
);
Page
<
UserPrePaidBilling
>
findByUsernameAndTimestampGreaterThanAndChargeTypeOrderByTimestamp
(
String
username
,
long
time
,
int
chargeType
,
Pageable
pageable
);
Page
<
UserPrePaidBilling
>
findByAdministratorAndTimestampGreaterThanAndChargeTypeOrderByTimestamp
(
String
administrator
,
long
time
,
int
chargeType
,
Pageable
pageable
);
Page
<
UserPrePaidBilling
>
findByUsernameAndTimestampGreaterThanAndChargeTypeIsNotAndPayMethodOrderByTimestamp
(
String
username
,
long
time
,
int
chargeType
,
int
payMethod
,
Pageable
pageable
);
Page
<
UserPrePaidBilling
>
findByAdministratorAndTimestampGreaterThanAndChargeTypeIsNotAndPayMethodOrderByTimestamp
(
String
administrator
,
long
time
,
int
chargeType
,
int
payMethod
,
Pageable
pageable
);
}
src/main/java/com/edgec/browserbackend/account/service/AccountService.java
View file @
d89e4fd4
...
...
@@ -66,7 +66,7 @@ public interface AccountService {
List
<
UserBillList
>
getUserBills
(
String
name
,
Services
services
);
P
age
<
UserPrePaidBilling
>
getUserPrePaidBills
(
String
name
,
UserPrePaidBillingRequestDto
userPrePaidBillingRequestDto
);
P
rePaidBillingPageResultDto
getUserPrePaidBills
(
String
name
,
UserPrePaidBillingRequestDto
userPrePaidBillingRequestDto
);
void
resetPasswordWithOtp
(
UserDto
user
);
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/AccountServiceImpl.java
View file @
d89e4fd4
...
...
@@ -143,25 +143,42 @@ public class AccountServiceImpl implements AccountService {
}
@Override
public
Page
<
UserPrePaidBilling
>
getUserPrePaidBills
(
String
name
,
UserPrePaidBillingRequestDto
userPrePaidBillingRequestDto
)
{
public
PrePaidBillingPageResultDto
getUserPrePaidBills
(
String
name
,
UserPrePaidBillingRequestDto
userPrePaidBillingRequestDto
)
{
Account
account
=
repository
.
findByName
(
name
);
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
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
:
if
(
userPrePaidBillingRequestDto
.
getTradeType
()
==
1
)
{
if
(
account
.
getParent
()
!=
null
)
userPrePaidBillings
=
prePaidBillingRepository
.
findByUsernameAndTimestampGreaterThanAndChargeTypeOrderByTimestamp
(
name
,
time
,
0
,
pageable
);
else
userPrePaidBillings
=
prePaidBillingRepository
.
findByAdministratorAndTimestampGreaterThanAndChargeTypeOrderByTimestamp
(
name
,
time
,
0
,
pageable
);
}
else
if
(
userPrePaidBillingRequestDto
.
getTradeType
()
==
2
||
userPrePaidBillingRequestDto
.
getTradeType
()
==
3
||
userPrePaidBillingRequestDto
.
getTradeType
()
==
4
)
{
if
(
account
.
getParent
()
!=
null
)
userPrePaidBillings
=
prePaidBillingRepository
.
findByUsernameAndTimestampGreaterThanAndChargeTypeIsNotAndPayMethodOrderByTimestamp
(
name
,
time
,
0
,
0
,
pageable
);
else
userPrePaidBillings
=
prePaidBillingRepository
.
findByAdministratorAndTimestampGreaterThanAndChargeTypeIsNotAndPayMethodOrderByTimestamp
(
name
,
time
,
0
,
0
,
pageable
);
}
else
{
if
(
account
.
getParent
()
!=
null
)
userPrePaidBillings
=
prePaidBillingRepository
.
findByUsernameAndTimestampGreaterThanOrderByTimestamp
(
name
,
time
,
pageable
);
break
;
else
userPrePaidBillings
=
prePaidBillingRepository
.
findByAdministratorAndTimestampGreaterThanOrderByTimestamp
(
name
,
time
,
pageable
);
}
return
userPrePaidBillings
;
PrePaidBillingPageResultDto
prePaidBillingPageResultDto
=
new
PrePaidBillingPageResultDto
();
prePaidBillingPageResultDto
.
setBillingList
(
userPrePaidBillings
.
getContent
());
PageInfo
pageInfo
=
new
PageInfo
();
pageInfo
.
setTotalItems
((
int
)
userPrePaidBillings
.
getTotalElements
());
pageInfo
.
setTotalPages
(
userPrePaidBillings
.
getTotalPages
());
pageInfo
.
setCurrentPage
(
userPrePaidBillings
.
getNumber
());
prePaidBillingPageResultDto
.
setBillingPage
(
pageInfo
);
return
prePaidBillingPageResultDto
;
}
@Override
...
...
@@ -189,6 +206,10 @@ public class AccountServiceImpl implements AccountService {
charge
.
setSuccess
(
true
);
UserPrePaidBilling
bill
=
new
UserPrePaidBilling
();
if
(
account
.
getParent
()
!=
null
)
bill
.
setAdministrator
(
account
.
getParent
());
else
bill
.
setAdministrator
(
account
.
getName
());
bill
.
setTradeNo
(
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
).
format
(
new
Date
())+
SmsUtils
.
createRandom
(
true
,
4
));
bill
.
setChargeType
(
requestDto
.
getChargeType
());
bill
.
setAmount
(
requestDto
.
getAmount
());
...
...
@@ -201,7 +222,6 @@ public class AccountServiceImpl implements AccountService {
bill
.
setPrepaid
(
true
);
bill
.
setTimestamp
(
Instant
.
now
().
toEpochMilli
());
final
YearMonth
lastmonth
=
YearMonth
.
now
();
int
monthValue
=
lastmonth
.
getMonthValue
();
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/AdministratorServiceImpl.java
View file @
d89e4fd4
...
...
@@ -276,7 +276,6 @@ public class AdministratorServiceImpl implements AdministratorService {
userPrePaidBilling
.
setPrepaid
(
false
);
userPrePaidBilling
.
setChargeType
(
9
);
userPrePaidBilling
.
setUnit
(
"month"
);
userPrePaidBilling
.
setUser
(
userBilling
.
getUsername
());
userPrePaidBilling
.
setUsername
(
userBilling
.
getUsername
());
userPrePaidBillingRepository
.
save
(
userPrePaidBilling
);
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/PaymentServiceImpl.java
View file @
d89e4fd4
...
...
@@ -8,6 +8,7 @@ import com.alipay.api.request.AlipayTradeQueryRequest;
import
com.alipay.api.response.AlipayTradePagePayResponse
;
import
com.alipay.api.response.AlipayTradeQueryResponse
;
import
com.edgec.browserbackend.account.exception.AccountErrorCode
;
import
com.edgec.browserbackend.account.repository.AccountRepository
;
import
com.edgec.browserbackend.account.repository.UserBalanceRepository
;
import
com.edgec.browserbackend.account.repository.UserPaymentRepository
;
import
com.edgec.browserbackend.account.repository.UserPrePaidBillingRepository
;
...
...
@@ -57,6 +58,9 @@ public class PaymentServiceImpl implements PaymentService {
@Autowired
private
UserPrePaidBillingRepository
userPrePaidBillingRepository
;
@Autowired
private
AccountRepository
accountRepository
;
@Override
public
String
wechatPayCallback
(
String
tradno
)
{
...
...
@@ -156,6 +160,11 @@ public class PaymentServiceImpl implements PaymentService {
if
(
chargeType
==
0
)
{
UserPrePaidBilling
bill
=
new
UserPrePaidBilling
();
Account
account
=
accountRepository
.
findByName
(
byTradeNo
.
getUsername
());
if
(
account
!=
null
&&
account
.
getParent
()
!=
null
)
bill
.
setAdministrator
(
account
.
getParent
());
else
bill
.
setAdministrator
(
account
.
getName
());
bill
.
setTradeNo
(
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
).
format
(
new
Date
())+
SmsUtils
.
createRandom
(
true
,
4
));
bill
.
setChargeType
(
0
);
bill
.
setAmount
(
0
);
...
...
@@ -265,6 +274,11 @@ public class PaymentServiceImpl implements PaymentService {
if
(
chargeType
==
0
)
{
UserPrePaidBilling
bill
=
new
UserPrePaidBilling
();
Account
account
=
accountRepository
.
findByName
(
byTradeNo
.
getUsername
());
if
(
account
!=
null
&&
account
.
getParent
()
!=
null
)
bill
.
setAdministrator
(
account
.
getParent
());
else
bill
.
setAdministrator
(
account
.
getName
());
bill
.
setTradeNo
(
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
).
format
(
new
Date
())+
SmsUtils
.
createRandom
(
true
,
4
));
bill
.
setChargeType
(
0
);
bill
.
setAmount
(
0
);
...
...
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