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
5cff936b
Commit
5cff936b
authored
Mar 31, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
月度账单
获取企业认证图片
parent
d9f246c1
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
166 additions
and
73 deletions
+166
-73
AccountController.java
.../browserbackend/account/controller/AccountController.java
+0
-50
AdminController.java
...ec/browserbackend/account/controller/AdminController.java
+6
-0
AdministratorController.java
...erbackend/account/controller/AdministratorController.java
+66
-0
CompanyMonthReport.java
...gec/browserbackend/account/domain/CompanyMonthReport.java
+20
-10
UserPrePaidBilling.java
...gec/browserbackend/account/domain/UserPrePaidBilling.java
+1
-1
UserPrePaidBillingRepositoryCustom.java
...ccount/repository/UserPrePaidBillingRepositoryCustom.java
+4
-2
UserPrePaidBillingRepositoryCustomImpl.java
...nt/repository/UserPrePaidBillingRepositoryCustomImpl.java
+30
-4
PrepaidBillingCountTaskScheduler.java
...d/account/scheduler/PrepaidBillingCountTaskScheduler.java
+8
-6
PaymentServiceImpl.java
...owserbackend/account/service/impl/PaymentServiceImpl.java
+31
-0
No files found.
src/main/java/com/edgec/browserbackend/account/controller/AccountController.java
View file @
5cff936b
...
@@ -450,56 +450,6 @@ public class AccountController {
...
@@ -450,56 +450,6 @@ public class AccountController {
return
resultDto
;
return
resultDto
;
}
}
@RequestMapping
(
path
=
"/authorize/details"
,
method
=
RequestMethod
.
GET
)
public
ResultDto
getAuthorizeDetails
(
Principal
principal
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
resultDto
.
setData
(
accountService
.
getAuthorizeDetails
(
principal
.
getName
()));
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
;
}
@RequestMapping
(
path
=
"/authorize/files"
,
method
=
RequestMethod
.
GET
)
public
ResultDto
getAuthorizeFiles
(
Principal
principal
,
HttpServletResponse
response
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
File
tempFile
=
accountService
.
getAuthorizeFiles
(
principal
.
getName
());
try
(
OutputStream
os
=
response
.
getOutputStream
();
FileInputStream
fis
=
new
FileInputStream
(
tempFile
)){
response
.
setHeader
(
"content-type"
,
"application/octet-stream"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
"压缩包.zip"
,
"UTF-8"
));
int
len
=
0
;
byte
[]
bt
=
new
byte
[
5
*
1024
];
while
((
len
=
fis
.
read
(
bt
))
!=
-
1
)
{
os
.
write
(
bt
,
0
,
len
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
}
finally
{
tempFile
.
deleteOnExit
();
}
accountService
.
getAuthorizeFiles
(
principal
.
getName
());
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
;
}
@RequestMapping
(
path
=
"/ali/login"
,
method
=
RequestMethod
.
GET
)
@RequestMapping
(
path
=
"/ali/login"
,
method
=
RequestMethod
.
GET
)
public
String
save
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
public
String
save
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
//页面回调地址 必须与应用中的设置一样
//页面回调地址 必须与应用中的设置一样
...
...
src/main/java/com/edgec/browserbackend/account/controller/AdminController.java
View file @
5cff936b
...
@@ -5,12 +5,18 @@ import com.edgec.browserbackend.account.domain.AccountDto;
...
@@ -5,12 +5,18 @@ import com.edgec.browserbackend.account.domain.AccountDto;
import
com.edgec.browserbackend.account.dto.ResultDto
;
import
com.edgec.browserbackend.account.dto.ResultDto
;
import
com.edgec.browserbackend.account.dto.SubUsersRequestDto
;
import
com.edgec.browserbackend.account.dto.SubUsersRequestDto
;
import
com.edgec.browserbackend.account.service.AccountService
;
import
com.edgec.browserbackend.account.service.AccountService
;
import
com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode
;
import
com.edgec.browserbackend.browser.dto.ShopRequestDto
;
import
com.edgec.browserbackend.browser.dto.ShopRequestDto
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.OutputStream
;
import
java.net.URLEncoder
;
import
java.security.Principal
;
import
java.security.Principal
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
...
src/main/java/com/edgec/browserbackend/account/controller/AdministratorController.java
View file @
5cff936b
package
com
.
edgec
.
browserbackend
.
account
.
controller
;
package
com
.
edgec
.
browserbackend
.
account
.
controller
;
import
com.edgec.browserbackend.account.dto.ResultDto
;
import
com.edgec.browserbackend.account.service.*
;
import
com.edgec.browserbackend.account.service.*
;
import
com.edgec.browserbackend.account.domain.*
;
import
com.edgec.browserbackend.account.domain.*
;
import
com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode
;
import
com.edgec.browserbackend.common.auth.Securitys
;
import
com.edgec.browserbackend.common.auth.Securitys
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.data.domain.PageRequest
;
...
@@ -11,8 +14,16 @@ import org.springframework.data.domain.Pageable;
...
@@ -11,8 +14,16 @@ import org.springframework.data.domain.Pageable;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.web.bind.annotation.*
;
import
org.springframework.web.bind.annotation.*
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.validation.Valid
;
import
javax.validation.Valid
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.OutputStream
;
import
java.net.URLEncoder
;
import
java.security.Principal
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
@RestController
@RestController
...
@@ -35,6 +46,9 @@ public class AdministratorController {
...
@@ -35,6 +46,9 @@ public class AdministratorController {
@Autowired
@Autowired
private
UserPrePaidBillingService
userPrePaidBillingService
;
private
UserPrePaidBillingService
userPrePaidBillingService
;
@Autowired
private
AccountService
accountService
;
//--------------------------------ROOT用户操作--------------------------------------//
//--------------------------------ROOT用户操作--------------------------------------//
//管理员注册tested
//管理员注册tested
@PreAuthorize
(
Securitys
.
ROOT_EL
)
@PreAuthorize
(
Securitys
.
ROOT_EL
)
...
@@ -261,6 +275,58 @@ public class AdministratorController {
...
@@ -261,6 +275,58 @@ public class AdministratorController {
public
boolean
userbillingTransfer
()
{
public
boolean
userbillingTransfer
()
{
return
administratorService
.
userbillingTransfer
();
return
administratorService
.
userbillingTransfer
();
}
}
@PreAuthorize
(
Securitys
.
ADMIN_EL
)
@RequestMapping
(
path
=
"/0xadministrator/authorize/files"
,
method
=
RequestMethod
.
GET
)
public
ResultDto
getAuthorizeFiles
(
Principal
principal
,
@RequestParam
(
"username"
)
String
username
,
HttpServletResponse
response
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
File
tempFile
=
accountService
.
getAuthorizeFiles
(
username
);
try
(
OutputStream
os
=
response
.
getOutputStream
();
FileInputStream
fis
=
new
FileInputStream
(
tempFile
)){
response
.
setHeader
(
"content-type"
,
"application/octet-stream"
);
response
.
setHeader
(
"Content-Disposition"
,
"attachment;filename="
+
URLEncoder
.
encode
(
"Licenses.zip"
,
"UTF-8"
));
int
len
=
0
;
byte
[]
bt
=
new
byte
[
5
*
1024
];
while
((
len
=
fis
.
read
(
bt
))
!=
-
1
)
{
os
.
write
(
bt
,
0
,
len
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
}
finally
{
tempFile
.
deleteOnExit
();
}
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
;
}
@PreAuthorize
(
Securitys
.
ADMIN_EL
)
@RequestMapping
(
path
=
"/0xadministrator/authorize/details"
,
method
=
RequestMethod
.
GET
)
public
ResultDto
getAuthorizeDetails
(
Principal
principal
)
{
ResultDto
resultDto
=
new
ResultDto
();
try
{
resultDto
.
setData
(
accountService
.
getAuthorizeDetails
(
principal
.
getName
()));
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/CompanyMonthReport.java
View file @
5cff936b
...
@@ -9,9 +9,11 @@ public class CompanyMonthReport {
...
@@ -9,9 +9,11 @@ public class CompanyMonthReport {
private
int
month
;
//几月的订单
private
int
month
;
//几月的订单
private
int
prepaidB
illingCount
;
//订单的总数
private
int
b
illingCount
;
//订单的总数
private
float
prepaidBillingAmount
;
//订单的金额统计
private
float
companyIncomeAmount
;
//公司收入
private
float
companyExpenseAmount
;
//公司支出
public
int
getYear
()
{
public
int
getYear
()
{
...
@@ -30,19 +32,27 @@ public class CompanyMonthReport {
...
@@ -30,19 +32,27 @@ public class CompanyMonthReport {
this
.
month
=
month
;
this
.
month
=
month
;
}
}
public
int
getPrepaidBillingCount
()
{
public
float
getCompanyExpenseAmount
()
{
return
prepaidBillingCount
;
return
companyExpenseAmount
;
}
public
void
setCompanyExpenseAmount
(
float
companyExpenseAmount
)
{
this
.
companyExpenseAmount
=
companyExpenseAmount
;
}
public
int
getBillingCount
()
{
return
billingCount
;
}
}
public
void
set
PrepaidBillingCount
(
int
prepaidB
illingCount
)
{
public
void
set
BillingCount
(
int
b
illingCount
)
{
this
.
prepaidBillingCount
=
prepaidB
illingCount
;
this
.
billingCount
=
b
illingCount
;
}
}
public
float
get
PrepaidBilling
Amount
()
{
public
float
get
CompanyIncome
Amount
()
{
return
prepaidBilling
Amount
;
return
companyIncome
Amount
;
}
}
public
void
set
PrepaidBillingAmount
(
float
prepaidBilling
Amount
)
{
public
void
set
CompanyIncomeAmount
(
float
companyIncome
Amount
)
{
this
.
prepaidBillingAmount
=
prepaidBilling
Amount
;
this
.
companyIncomeAmount
=
companyIncome
Amount
;
}
}
}
}
src/main/java/com/edgec/browserbackend/account/domain/UserPrePaidBilling.java
View file @
5cff936b
...
@@ -43,7 +43,7 @@ public class UserPrePaidBilling {
...
@@ -43,7 +43,7 @@ public class UserPrePaidBilling {
private
boolean
isPrepaid
;
private
boolean
isPrepaid
;
private
float
total
;
private
float
total
;
//0 -- 充值, 1 -- newip, 2 -- renew, 3 -- return
//0 -- 充值, 1 -- newip, 2 -- renew, 3 -- return
, 4 -- 礼金提现
private
int
chargeType
;
private
int
chargeType
;
private
String
unit
=
"month"
;
private
String
unit
=
"month"
;
...
...
src/main/java/com/edgec/browserbackend/account/repository/UserPrePaidBillingRepositoryCustom.java
View file @
5cff936b
...
@@ -12,9 +12,11 @@ import java.util.List;
...
@@ -12,9 +12,11 @@ import java.util.List;
public
interface
UserPrePaidBillingRepositoryCustom
{
public
interface
UserPrePaidBillingRepositoryCustom
{
long
countPrepaidNum
(
int
year
,
int
month
);
long
countPrepaid
Order
Num
(
int
year
,
int
month
);
float
prepaidAmount
(
int
year
,
int
month
);
float
companyIncomeAmount
(
int
year
,
int
month
);
float
companyExpenseAmount
(
int
year
,
int
month
);
Page
<
UserPrePaidBilling
>
findByUsernameAndChargeTypes
(
Pageable
pageable
,
String
username
,
String
[]
chargeTypes
,
int
year
,
int
month
,
int
day
,
String
zoneId
);
Page
<
UserPrePaidBilling
>
findByUsernameAndChargeTypes
(
Pageable
pageable
,
String
username
,
String
[]
chargeTypes
,
int
year
,
int
month
,
int
day
,
String
zoneId
);
...
...
src/main/java/com/edgec/browserbackend/account/repository/UserPrePaidBillingRepositoryCustomImpl.java
View file @
5cff936b
...
@@ -36,9 +36,9 @@ public class UserPrePaidBillingRepositoryCustomImpl implements UserPrePaidBillin
...
@@ -36,9 +36,9 @@ public class UserPrePaidBillingRepositoryCustomImpl implements UserPrePaidBillin
@Override
@Override
public
long
countPrepaidNum
(
int
year
,
int
month
)
{
public
long
countPrepaid
Order
Num
(
int
year
,
int
month
)
{
MatchOperation
matchOperation
=
Aggregation
.
match
(
where
(
"year"
).
is
(
year
).
and
(
"month"
).
is
(
month
));
MatchOperation
matchOperation
=
Aggregation
.
match
(
where
(
"year"
).
is
(
year
).
and
(
"month"
).
is
(
month
)
.
and
(
"chargeType"
).
in
(
Arrays
.
asList
(
1
,
2
))
);
CountOperation
countOperation
=
Aggregation
.
count
().
as
(
"count"
);
CountOperation
countOperation
=
Aggregation
.
count
().
as
(
"count"
);
AggregationResults
<
HashMap
>
result
=
mongoTemplate
.
aggregate
(
Aggregation
.
newAggregation
(
matchOperation
,
countOperation
),
AggregationResults
<
HashMap
>
result
=
mongoTemplate
.
aggregate
(
Aggregation
.
newAggregation
(
matchOperation
,
countOperation
),
UserPrePaidBilling
.
class
,
HashMap
.
class
);
UserPrePaidBilling
.
class
,
HashMap
.
class
);
...
@@ -62,9 +62,35 @@ public class UserPrePaidBillingRepositoryCustomImpl implements UserPrePaidBillin
...
@@ -62,9 +62,35 @@ public class UserPrePaidBillingRepositoryCustomImpl implements UserPrePaidBillin
}
}
@Override
@Override
public
float
prepaidAmount
(
int
year
,
int
month
)
{
public
float
companyExpenseAmount
(
int
year
,
int
month
)
{
MatchOperation
matchOperation
=
Aggregation
.
match
(
where
(
"year"
).
is
(
year
).
and
(
"month"
).
is
(
month
).
and
(
"payMethod"
).
in
(
Arrays
.
asList
(
0
,
3
,
4
)));
GroupOperation
groupOperation
=
Aggregation
.
group
(
"month"
).
sum
(
"total"
).
as
(
"prepaidAmount"
);
AggregationResults
<
Map
>
totalSum
=
mongoTemplate
.
aggregate
(
Aggregation
.
newAggregation
(
matchOperation
,
groupOperation
),
UserPrePaidBilling
.
class
,
Map
.
class
);
if
(
totalSum
.
getMappedResults
()
==
null
||
totalSum
.
getMappedResults
().
size
()
==
0
)
{
return
0
;
}
else
{
Map
map
=
totalSum
.
getMappedResults
().
get
(
0
);
if
(
map
==
null
)
{
return
0
;
}
else
{
Double
sum
=
(
Double
)
map
.
get
(
"prepaidAmount"
);
if
(
sum
==
null
)
{
return
0
;
}
else
{
return
sum
.
floatValue
();
}
}
}
}
@Override
public
float
companyIncomeAmount
(
int
year
,
int
month
)
{
MatchOperation
matchOperation
=
Aggregation
.
match
(
where
(
"year"
).
is
(
year
).
and
(
"month"
).
is
(
month
));
MatchOperation
matchOperation
=
Aggregation
.
match
(
where
(
"year"
).
is
(
year
).
and
(
"month"
).
is
(
month
)
.
and
(
"payMethod"
).
in
(
Arrays
.
asList
(
1
,
2
))
);
GroupOperation
groupOperation
=
Aggregation
.
group
(
"month"
).
sum
(
"total"
).
as
(
"prepaidAmount"
);
GroupOperation
groupOperation
=
Aggregation
.
group
(
"month"
).
sum
(
"total"
).
as
(
"prepaidAmount"
);
AggregationResults
<
Map
>
totalSum
=
mongoTemplate
.
aggregate
(
Aggregation
.
newAggregation
(
matchOperation
,
groupOperation
),
AggregationResults
<
Map
>
totalSum
=
mongoTemplate
.
aggregate
(
Aggregation
.
newAggregation
(
matchOperation
,
groupOperation
),
...
...
src/main/java/com/edgec/browserbackend/account/scheduler/PrepaidBillingCountTaskScheduler.java
View file @
5cff936b
...
@@ -30,19 +30,21 @@ public class PrepaidBillingCountTaskScheduler {
...
@@ -30,19 +30,21 @@ public class PrepaidBillingCountTaskScheduler {
int
monthValue
=
lastmonth
.
getMonthValue
();
int
monthValue
=
lastmonth
.
getMonthValue
();
int
year
=
lastmonth
.
getYear
();
int
year
=
lastmonth
.
getYear
();
for
(
int
i
=
20
19
;
i
<=
year
;
i
++){
for
(
int
i
=
20
20
;
i
<=
year
;
i
++){
for
(
int
j
=
1
;
j
<=
monthValue
;
j
++){
for
(
int
j
=
1
;
j
<=
monthValue
;
j
++){
if
(
i
==
20
19
&&
j
<
5
){
if
(
i
==
20
20
&&
j
<
1
){
continue
;
continue
;
}
else
{
}
else
{
if
(
monthReportRepository
.
findByYearAndMonth
(
i
,
j
)
==
null
){
if
(
monthReportRepository
.
findByYearAndMonth
(
i
,
j
)
==
null
){
int
count
=
new
Long
(
userPrePaidBillingRepository
.
countPrepaidNum
(
i
,
j
)).
intValue
();
int
count
=
new
Long
(
userPrePaidBillingRepository
.
countPrepaidOrderNum
(
i
,
j
)).
intValue
();
float
amountSum
=
userPrePaidBillingRepository
.
prepaidAmount
(
i
,
j
);
float
companyExpenseAmount
=
userPrePaidBillingRepository
.
companyExpenseAmount
(
i
,
j
);
float
companyIncomeAmount
=
userPrePaidBillingRepository
.
companyIncomeAmount
(
i
,
j
);
CompanyMonthReport
companyMonthReport
=
new
CompanyMonthReport
();
CompanyMonthReport
companyMonthReport
=
new
CompanyMonthReport
();
companyMonthReport
.
setYear
(
i
);
companyMonthReport
.
setYear
(
i
);
companyMonthReport
.
setMonth
(
j
);
companyMonthReport
.
setMonth
(
j
);
companyMonthReport
.
setPrepaidBillingCount
(
count
);
companyMonthReport
.
setBillingCount
(
count
);
companyMonthReport
.
setPrepaidBillingAmount
(
amountSum
);
companyMonthReport
.
setCompanyExpenseAmount
(
companyExpenseAmount
);
companyMonthReport
.
setCompanyIncomeAmount
(
companyIncomeAmount
);
monthReportRepository
.
save
(
companyMonthReport
);
monthReportRepository
.
save
(
companyMonthReport
);
}
else
{
}
else
{
continue
;
continue
;
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/PaymentServiceImpl.java
View file @
5cff936b
...
@@ -442,15 +442,46 @@ public class PaymentServiceImpl implements PaymentService {
...
@@ -442,15 +442,46 @@ public class PaymentServiceImpl implements PaymentService {
userPaymentRepository
.
save
(
bankOrder
);
userPaymentRepository
.
save
(
bankOrder
);
UserBalance
userBalance
=
userBalanceRepository
.
findById
(
username
).
orElse
(
null
);
UserBalance
userBalance
=
userBalanceRepository
.
findById
(
username
).
orElse
(
null
);
UserPrePaidBilling
bill
=
new
UserPrePaidBilling
();
Account
account
=
accountRepository
.
findByName
(
username
);
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
);
bill
.
setUnit
(
null
);
bill
.
setPeriod
(
0
);
bill
.
setPayMethod
(
3
);
bill
.
setUsername
(
username
);
bill
.
setTotal
((
float
)
amount
);
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
);
if
(
userBalance
==
null
)
{
if
(
userBalance
==
null
)
{
userBalance
=
new
UserBalance
();
userBalance
=
new
UserBalance
();
userBalance
.
setUsername
(
username
);
userBalance
.
setUsername
(
username
);
userBalance
.
setUsed
(
0
);
userBalance
.
setUsed
(
0
);
userBalance
.
setBalanced
(
amount
);
userBalance
.
setBalanced
(
amount
);
bill
.
setBalanced
(
userBalance
.
getBalanced
()
+
amount
);
userPrePaidBillingRepository
.
save
(
bill
);
return
userBalanceRepository
.
save
(
userBalance
);
return
userBalanceRepository
.
save
(
userBalance
);
}
else
{
}
else
{
bill
.
setBalanced
(
userBalance
.
getBalanced
()
+
amount
);
userPrePaidBillingRepository
.
save
(
bill
);
userBalanceRepository
.
incrementBalance
(
userBalance
,
amount
,
0
);
userBalanceRepository
.
incrementBalance
(
userBalance
,
amount
,
0
);
}
}
return
userBalanceRepository
.
findById
(
username
).
orElse
(
null
);
return
userBalanceRepository
.
findById
(
username
).
orElse
(
null
);
}
}
...
...
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