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
34530148
Commit
34530148
authored
Apr 09, 2020
by
renjie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
admin接口
推广礼金提现
parent
7e4e6398
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
366 additions
and
101 deletions
+366
-101
AccountController.java
.../browserbackend/account/controller/AccountController.java
+35
-20
AdministratorController.java
...erbackend/account/controller/AdministratorController.java
+4
-4
AliTransfer.java
.../com/edgec/browserbackend/account/domain/AliTransfer.java
+94
-0
Promotion.java
...va/com/edgec/browserbackend/account/domain/Promotion.java
+10
-0
UserPrePaidBilling.java
...gec/browserbackend/account/domain/UserPrePaidBilling.java
+1
-1
BillQueryResultDto.java
.../edgec/browserbackend/account/dto/BillQueryResultDto.java
+61
-15
AccountRepository.java
.../browserbackend/account/repository/AccountRepository.java
+2
-0
UserPrePaidBillingRepository.java
...kend/account/repository/UserPrePaidBillingRepository.java
+2
-0
UserWithdrawRepository.java
...serbackend/account/repository/UserWithdrawRepository.java
+8
-0
AdministratorService.java
.../browserbackend/account/service/AdministratorService.java
+2
-2
PaymentService.java
.../edgec/browserbackend/account/service/PaymentService.java
+1
-1
AdministratorServiceImpl.java
...ackend/account/service/impl/AdministratorServiceImpl.java
+50
-18
PaymentServiceImpl.java
...owserbackend/account/service/impl/PaymentServiceImpl.java
+80
-37
AlipaySubmit.java
...in/java/com/edgec/browserbackend/alipay/AlipaySubmit.java
+1
-1
ResourceServerConfiguration.java
...owserbackend/auth/config/ResourceServerConfiguration.java
+1
-1
PromotionTask.java
.../com/edgec/browserbackend/browser/task/PromotionTask.java
+14
-1
No files found.
src/main/java/com/edgec/browserbackend/account/controller/AccountController.java
View file @
34530148
...
...
@@ -412,7 +412,6 @@ public class AccountController {
@RequestParam
(
value
=
"coporationPlace"
)
String
coporationPlace
,
@RequestParam
(
value
=
"coporationLicense_front"
)
MultipartFile
coporationLicense_front
,
@RequestParam
(
value
=
"coporationLicense_back"
)
MultipartFile
coporationLicense_back
,
@RequestParam
(
value
=
"realController"
,
defaultValue
=
"0"
)
int
realController
,
@RequestParam
(
value
=
"writePerson"
,
defaultValue
=
"0"
)
int
writePerson
,
@RequestParam
(
value
=
"agency_front"
,
required
=
false
)
MultipartFile
agency_front
,
@RequestParam
(
value
=
"agency_back"
,
required
=
false
)
MultipartFile
agency_back
)
{
...
...
@@ -453,7 +452,7 @@ public class AccountController {
@RequestMapping
(
path
=
"/ali/login"
,
method
=
RequestMethod
.
GET
)
public
String
save
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
//页面回调地址 必须与应用中的设置一样
String
return_url
=
"http://
localhost:1729/alipay
/withdraw"
;
String
return_url
=
"http://
https://www.fangguanlian.cn/ali
/withdraw"
;
//回调地址必须经encode
return_url
=
java
.
net
.
URLEncoder
.
encode
(
return_url
);
//重定向到授权页面
...
...
@@ -461,25 +460,41 @@ public class AccountController {
return
"redirect:"
+
VpsAlipayConfig
.
ALIPAY_AUTH_URL
+
"?app_id="
+
alipayConfig
.
getAPPID
()
+
"&scope=auth_user&redirect_uri="
+
return_url
;
}
@RequestMapping
(
path
=
"/ali/withdraw"
)
public
void
alipayWithdraw
(
HttpServletRequest
request
,
HttpServletResponse
response
)
{
//获取支付宝GET过来反馈信息
Map
<
String
,
String
>
params
=
new
HashMap
<
String
,
String
>();
Map
requestParams
=
request
.
getParameterMap
();
for
(
Iterator
iter
=
requestParams
.
keySet
().
iterator
();
iter
.
hasNext
();)
{
String
name
=
(
String
)
iter
.
next
();
String
[]
values
=
(
String
[])
requestParams
.
get
(
name
);
String
valueStr
=
""
;
for
(
int
i
=
0
;
i
<
values
.
length
;
i
++)
{
valueStr
=
(
i
==
(
values
.
length
-
1
))
?
valueStr
+
values
[
i
]:
valueStr
+
values
[
i
]
+
","
;
}
params
.
put
(
name
,
valueStr
);
}
@RequestMapping
(
path
=
"/ali/withdraw"
,
method
=
RequestMethod
.
PUT
)
public
ResultDto
alipayWithdraw
(
Principal
principal
,
@RequestParam
(
"account"
)
String
account
,
@RequestParam
(
"realName"
)
String
realName
,
@RequestParam
(
"amount"
)
int
amount
)
{
// //获取支付宝GET过来反馈信息
// Map<String,String> params = new HashMap<String,String>();
// Map requestParams = request.getParameterMap();
// for (Iterator iter = requestParams.keySet().iterator(); iter.hasNext();) {
// String name = (String) iter.next();
// String[] values = (String[]) requestParams.get(name);
// String valueStr = "";
// for (int i = 0; i < values.length; i++) {
// valueStr = (i == (values.length-1)) ? valueStr + values[i]:valueStr + values[i] + ",";
// }
// params.put(name, valueStr);
// }
//
// String accessToken= AlipaySubmit.buildRequest(params);
// if(accessToken!=null && accessToken!=""){
// String uid = AlipaySubmit.get(accessToken);
// logger.error(uid);
// paymentService.alipayWithdraw(request.getUserPrincipal().getName(), uid, )
// }
String
accessToken
=
AlipaySubmit
.
buildRequest
(
params
);
if
(
accessToken
!=
null
&&
accessToken
!=
""
){
String
imf
=
AlipaySubmit
.
get
(
accessToken
);
System
.
out
.
println
(
imf
);
ResultDto
resultDto
=
new
ResultDto
();
try
{
if
(
paymentService
.
alipayWithdraw
(
principal
.
getName
(),
account
,
realName
,
amount
))
resultDto
.
setStatus
(
0
);
else
resultDto
.
setStatus
(-
1
);
}
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/controller/AdministratorController.java
View file @
34530148
...
...
@@ -114,7 +114,7 @@ public class AdministratorController {
@PreAuthorize
(
"hasRole('ADMIN')"
)
@RequestMapping
(
path
=
"/0xadministrator/searchuserbill/{name}"
,
method
=
RequestMethod
.
GET
)
public
BillQueryResultDto
getUserBillByName
(
@PathVariable
String
name
,
@RequestParam
(
"page"
)
int
page
,
@RequestParam
(
"size"
)
int
size
){
return
administratorService
.
getUserBillingByName
(
name
,
page
,
size
);
return
administratorService
.
getUserBillingByName
(
name
);
}
...
...
@@ -181,9 +181,9 @@ public class AdministratorController {
//查询某时段内增加的用户
@PreAuthorize
(
"hasRole('ADMIN')"
)
@RequestMapping
(
path
=
"/0xadministrator/searchperioduser"
,
method
=
RequestMethod
.
GET
)
public
Page
<
Account
>
searchCreateAccount
(
@RequestParam
(
value
=
"page"
)
int
page
,
@RequestParam
(
value
=
"size"
)
int
size
,
@RequestParam
(
value
=
"strDate1"
)
String
strDate1
,
@RequestParam
(
value
=
"strDate2"
)
String
strDate2
){
public
Page
<
Account
>
searchCreateAccount
(
@RequestParam
(
value
=
"page"
)
int
page
,
@RequestParam
(
value
=
"size"
)
int
size
,
@RequestParam
(
value
=
"strDate1"
)
String
strDate1
,
@RequestParam
(
value
=
"strDate2"
)
String
strDate2
,
@RequestParam
(
"isAuthorized"
)
boolean
isAuthorized
){
Pageable
pageable
=
PageRequest
.
of
(
page
,
size
);
return
administratorService
.
searchCreateAccountBetween
(
pageable
,
strDate1
,
strDate2
);
return
administratorService
.
searchCreateAccountBetween
(
pageable
,
strDate1
,
strDate2
,
isAuthorized
);
}
//search company earnings detail by month tested
...
...
@@ -332,7 +332,7 @@ public class AdministratorController {
return
resultDto
;
}
//
获取用户企业认证的信息
//
添加推广码
@PreAuthorize
(
Securitys
.
ADMIN_EL
)
@RequestMapping
(
path
=
"/0xadministrator/promotioncode/add"
,
method
=
RequestMethod
.
PUT
)
public
ResultDto
addPromotionCode
(
Principal
principal
,
@RequestParam
(
"username"
)
String
username
,
@RequestParam
(
"promotionCode"
)
String
promotionCode
)
{
...
...
src/main/java/com/edgec/browserbackend/account/domain/AliTransfer.java
0 → 100644
View file @
34530148
package
com
.
edgec
.
browserbackend
.
account
.
domain
;
public
class
AliTransfer
{
/**
* 逻辑单号
*/
private
String
out_biz_no
;
/**
* 收款方账户类型
*/
private
String
payee_type
;
/**
* 收款方支付宝账号
*/
private
String
payee_account
;
/**
* 转账金额
*/
private
String
amount
;
/**
* 转账名称
*/
private
String
payer_show_name
;
/**
* 提现用户的真实姓名
*/
private
String
payee_real_name
;
/**
* 转账备注
*/
private
String
remark
;
public
String
getAmount
()
{
return
amount
;
}
public
void
setAmount
(
String
amount
)
{
this
.
amount
=
amount
;
}
public
String
getOut_biz_no
()
{
return
out_biz_no
;
}
public
void
setOut_biz_no
(
String
out_biz_no
)
{
this
.
out_biz_no
=
out_biz_no
;
}
public
String
getPayee_account
()
{
return
payee_account
;
}
public
void
setPayee_account
(
String
payee_account
)
{
this
.
payee_account
=
payee_account
;
}
public
String
getPayee_real_name
()
{
return
payee_real_name
;
}
public
void
setPayee_real_name
(
String
payee_real_name
)
{
this
.
payee_real_name
=
payee_real_name
;
}
public
String
getPayee_type
()
{
return
payee_type
;
}
public
void
setPayee_type
(
String
payee_type
)
{
this
.
payee_type
=
payee_type
;
}
public
String
getPayer_show_name
()
{
return
payer_show_name
;
}
public
void
setPayer_show_name
(
String
payer_show_name
)
{
this
.
payer_show_name
=
payer_show_name
;
}
public
String
getRemark
()
{
return
remark
;
}
public
void
setRemark
(
String
remark
)
{
this
.
remark
=
remark
;
}
}
src/main/java/com/edgec/browserbackend/account/domain/Promotion.java
View file @
34530148
...
...
@@ -19,6 +19,8 @@ public class Promotion {
private
double
gift
;
//所有未提现金额
private
double
allGift
;
//已提现金额
private
double
withdrawn
;
public
int
getCommission
()
{
return
commission
;
...
...
@@ -75,4 +77,12 @@ public class Promotion {
public
void
setAllGift
(
double
allGift
)
{
this
.
allGift
=
allGift
;
}
public
double
getWithdrawn
()
{
return
withdrawn
;
}
public
void
setWithdrawn
(
double
withdrawn
)
{
this
.
withdrawn
=
withdrawn
;
}
}
src/main/java/com/edgec/browserbackend/account/domain/UserPrePaidBilling.java
View file @
34530148
...
...
@@ -37,7 +37,7 @@ public class UserPrePaidBilling {
private
BillStatus
status
;
//0 -- 余额, 1 -- 支付宝, 2 -- 微信
//0 -- 余额, 1 -- 支付宝, 2 -- 微信
, 3 -- 银行转账
private
int
payMethod
;
private
boolean
isPrepaid
;
...
...
src/main/java/com/edgec/browserbackend/account/dto/BillQueryResultDto.java
View file @
34530148
...
...
@@ -6,31 +6,77 @@ import org.springframework.data.domain.Page;
import
java.util.List
;
public
class
BillQueryResultDto
{
Page
<
UserPrePaidBilling
>
userPrePaidBillingList
;
double
totalExpense
;
double
totalEarn
;
double
parentExpense
;
double
parentWithdrawn
;
double
parentBalanced
;
double
parentBankTransfer
;
public
double
getTotalEarn
()
{
return
totalEarn
;
double
childExpense
;
double
childWithdraw
;
double
childBalanced
;
double
childBankTransfer
;
public
double
getParentExpense
()
{
return
parentExpense
;
}
public
void
setParentExpense
(
double
parentExpense
)
{
this
.
parentExpense
=
parentExpense
;
}
public
double
getParentWithdrawn
()
{
return
parentWithdrawn
;
}
public
void
setParentWithdrawn
(
double
parentWithdrawn
)
{
this
.
parentWithdrawn
=
parentWithdrawn
;
}
public
double
getParentBalanced
()
{
return
parentBalanced
;
}
public
void
setParentBalanced
(
double
parentBalanced
)
{
this
.
parentBalanced
=
parentBalanced
;
}
public
double
getParentBankTransfer
()
{
return
parentBankTransfer
;
}
public
void
setParentBankTransfer
(
double
parentBankTransfer
)
{
this
.
parentBankTransfer
=
parentBankTransfer
;
}
public
double
getChildBalanced
()
{
return
childBalanced
;
}
public
void
setChildBalanced
(
double
childBalanced
)
{
this
.
childBalanced
=
childBalanced
;
}
public
double
getChildBankTransfer
()
{
return
childBankTransfer
;
}
public
void
set
TotalEarn
(
double
totalEarn
)
{
this
.
totalEarn
=
totalEarn
;
public
void
set
ChildBankTransfer
(
double
childBankTransfer
)
{
this
.
childBankTransfer
=
childBankTransfer
;
}
public
double
get
Total
Expense
()
{
return
total
Expense
;
public
double
get
Child
Expense
()
{
return
child
Expense
;
}
public
void
set
TotalExpense
(
double
total
Expense
)
{
this
.
totalExpense
=
total
Expense
;
public
void
set
ChildExpense
(
double
child
Expense
)
{
this
.
childExpense
=
child
Expense
;
}
public
Page
<
UserPrePaidBilling
>
getUserPrePaidBillingList
()
{
return
userPrePaidBillingList
;
public
double
getChildWithdraw
()
{
return
childWithdraw
;
}
public
void
set
UserPrePaidBillingList
(
Page
<
UserPrePaidBilling
>
userPrePaidBillingList
)
{
this
.
userPrePaidBillingList
=
userPrePaidBillingList
;
public
void
set
ChildWithdraw
(
double
childWithdraw
)
{
this
.
childWithdraw
=
childWithdraw
;
}
}
src/main/java/com/edgec/browserbackend/account/repository/AccountRepository.java
View file @
34530148
...
...
@@ -31,6 +31,8 @@ public interface AccountRepository extends MongoRepository<Account, String>, Acc
Page
<
Account
>
findAllBySignupDateBetweenAndParentIsNull
(
Pageable
pageable
,
Date
startDate
,
Date
endDate
);
Page
<
Account
>
findAllBySignupDateBetweenAndParentIsNullAndAuthorizedNot
(
Pageable
pageable
,
Date
startDate
,
Date
endDate
,
int
authorized
);
Page
<
Account
>
findAll
(
Pageable
pageable
);
List
<
Account
>
findByNameIn
(
List
<
String
>
names
);
...
...
src/main/java/com/edgec/browserbackend/account/repository/UserPrePaidBillingRepository.java
View file @
34530148
...
...
@@ -27,6 +27,8 @@ public interface UserPrePaidBillingRepository extends MongoRepository<UserPrePai
List
<
UserPrePaidBilling
>
findByUsernameAndPayMethodIn
(
String
username
,
List
<
Integer
>
payMethod
);
List
<
UserPrePaidBilling
>
findByUsernameAndPayMethod
(
String
username
,
int
payMethod
);
List
<
UserPrePaidBilling
>
findByUsernameAndChargeType
(
String
username
,
int
chargeType
);
List
<
UserPrePaidBilling
>
findByYearAndMonth
(
int
year
,
int
month
);
...
...
src/main/java/com/edgec/browserbackend/account/repository/UserWithdrawRepository.java
0 → 100644
View file @
34530148
package
com
.
edgec
.
browserbackend
.
account
.
repository
;
import
com.edgec.browserbackend.account.domain.UserWithdraw
;
import
org.springframework.data.mongodb.repository.MongoRepository
;
public
interface
UserWithdrawRepository
extends
MongoRepository
<
UserWithdraw
,
String
>
{
}
src/main/java/com/edgec/browserbackend/account/service/AdministratorService.java
View file @
34530148
...
...
@@ -23,7 +23,7 @@ public interface AdministratorService {
Account
getAccountByEmail
(
String
target
);
BillQueryResultDto
getUserBillingByName
(
String
name
,
int
page
,
int
size
);
BillQueryResultDto
getUserBillingByName
(
String
name
);
Account
unLockLockedAccount
(
String
name
,
Account
account
);
...
...
@@ -33,7 +33,7 @@ public interface AdministratorService {
Page
<
UserPrePaidBilling
>
searchAllUserBillingPage
(
int
page
,
int
year1
,
int
month1
,
int
year2
,
int
month2
);
Page
<
Account
>
searchCreateAccountBetween
(
Pageable
pageable
,
String
strDate1
,
String
strDate2
);
Page
<
Account
>
searchCreateAccountBetween
(
Pageable
pageable
,
String
strDate1
,
String
strDate2
,
boolean
isAuthorized
);
List
<
UserPrePaidBilling
>
getServiceFeeOwedUserInfo
();
...
...
src/main/java/com/edgec/browserbackend/account/service/PaymentService.java
View file @
34530148
...
...
@@ -22,6 +22,6 @@ public interface PaymentService {
UserPaymentDto
h5wxPayOrder
(
String
ip
,
String
username
,
int
amount
);
boolean
alipayWithdraw
(
String
username
,
String
account
,
String
realName
);
boolean
alipayWithdraw
(
String
username
,
String
account
,
String
realName
,
int
amount
);
}
src/main/java/com/edgec/browserbackend/account/service/impl/AdministratorServiceImpl.java
View file @
34530148
...
...
@@ -102,25 +102,55 @@ public class AdministratorServiceImpl implements AdministratorService {
@Override
public
BillQueryResultDto
getUserBillingByName
(
String
name
,
int
page
,
int
size
)
{
if
(
size
>
100
)
size
=
100
;
Pageable
pageable
=
PageRequest
.
of
(
page
,
size
);
Page
<
UserPrePaidBilling
>
userBillingList
=
userPrePaidBillingRepository
.
findAllByUsername
(
name
,
pageable
);
if
(
userBillingList
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
,
"Username does not exist: "
+
name
);
public
BillQueryResultDto
getUserBillingByName
(
String
name
)
{
Account
account
=
accountRepository
.
findByName
(
name
);
if
(
account
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
);
List
<
UserPrePaidBilling
>
userPrePaidBillings
=
userPrePaidBillingRepository
.
findByUsernameAndPayMethodIn
(
name
,
Arrays
.
asList
(
1
,
2
));
double
total
expense
=
0
;
double
parent
expense
=
0
;
if
(
userPrePaidBillings
!=
null
)
totalexpense
=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndChargeType
(
name
,
4
);
double
totalearn
=
0
;
parentexpense
=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
double
parentwithdrawn
=
account
.
getPromotion
().
getWithdrawn
();
UserBalance
userBalance
=
userBalanceRepository
.
findById
(
name
).
orElse
(
null
);
double
parentbalanced
=
0
;
if
(
userBalance
!=
null
)
parentbalanced
=
userBalance
.
getBalanced
();
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndPayMethod
(
name
,
3
);
double
parentbanktransfer
=
0
;
if
(
userPrePaidBillings1
!=
null
)
totalearn
=
userPrePaidBillings1
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
parentbanktransfer
=
userPrePaidBillings1
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
double
childexpense
=
0
;
double
childwithdrawn
=
0
;
double
childbalanced
=
0
;
double
childbanktransfer
=
0
;
if
(
account
.
getParent
()
==
null
)
{
List
<
Account
>
children
=
accountRepository
.
findByParent
(
account
.
getName
());
for
(
Account
child
:
children
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings_child
=
userPrePaidBillingRepository
.
findByUsernameAndPayMethodIn
(
child
.
getName
(),
Arrays
.
asList
(
1
,
2
));
if
(
userPrePaidBillings_child
!=
null
)
childexpense
+=
userPrePaidBillings_child
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
childwithdrawn
+=
child
.
getPromotion
().
getWithdrawn
();
UserBalance
userBalance_child
=
userBalanceRepository
.
findById
(
child
.
getName
()).
orElse
(
null
);
if
(
userBalance_child
!=
null
)
childbalanced
+=
userBalance_child
.
getBalanced
();
List
<
UserPrePaidBilling
>
userPrePaidBillings1_child
=
userPrePaidBillingRepository
.
findByUsernameAndPayMethod
(
name
,
3
);
if
(
userPrePaidBillings1_child
!=
null
)
childbanktransfer
+=
userPrePaidBillings1_child
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
}
}
BillQueryResultDto
billQueryResultDto
=
new
BillQueryResultDto
();
billQueryResultDto
.
setUserPrePaidBillingList
(
userBillingList
);
billQueryResultDto
.
setTotalEarn
(
totalearn
);
billQueryResultDto
.
setTotalExpense
(
totalexpense
);
billQueryResultDto
.
setChildExpense
(
childexpense
);
billQueryResultDto
.
setChildBankTransfer
(
childbanktransfer
);
billQueryResultDto
.
setChildBalanced
(
childbalanced
);
billQueryResultDto
.
setChildWithdraw
(
childwithdrawn
);
billQueryResultDto
.
setParentExpense
(
parentexpense
);
billQueryResultDto
.
setParentBalanced
(
parentbalanced
);
billQueryResultDto
.
setParentBankTransfer
(
parentbanktransfer
);
billQueryResultDto
.
setParentWithdrawn
(
parentwithdrawn
);
return
billQueryResultDto
;
}
...
...
@@ -168,14 +198,16 @@ public class AdministratorServiceImpl implements AdministratorService {
}
@Override
public
Page
<
Account
>
searchCreateAccountBetween
(
Pageable
pageable
,
String
strDate1
,
String
strDate2
)
{
public
Page
<
Account
>
searchCreateAccountBetween
(
Pageable
pageable
,
String
strDate1
,
String
strDate2
,
boolean
isAuthorized
)
{
SimpleDateFormat
formatter
=
new
SimpleDateFormat
(
"yyyy-MM-dd"
);
Page
<
Account
>
accounts
=
null
;
try
{
Date
dateTime1
=
formatter
.
parse
(
strDate1
);
Date
dateTime2
=
formatter
.
parse
(
strDate2
);
accounts
=
accountRepository
.
findAllBySignupDateBetweenAndParentIsNull
(
pageable
,
dateTime1
,
dateTime2
);
if
(
isAuthorized
)
accounts
=
accountRepository
.
findAllBySignupDateBetweenAndParentIsNullAndAuthorizedNot
(
pageable
,
dateTime1
,
dateTime2
,
0
);
else
accounts
=
accountRepository
.
findAllBySignupDateBetweenAndParentIsNull
(
pageable
,
dateTime1
,
dateTime2
);
}
catch
(
ParseException
e
){
e
.
printStackTrace
();
}
...
...
src/main/java/com/edgec/browserbackend/account/service/impl/PaymentServiceImpl.java
View file @
34530148
...
...
@@ -4,16 +4,15 @@ import com.alibaba.fastjson.JSONObject;
import
com.alipay.api.AlipayClient
;
import
com.alipay.api.DefaultAlipayClient
;
import
com.alipay.api.request.AlipayFundTransToaccountTransferRequest
;
import
com.alipay.api.request.AlipayFundTransUniTransferRequest
;
import
com.alipay.api.request.AlipayTradePagePayRequest
;
import
com.alipay.api.request.AlipayTradeQueryRequest
;
import
com.alipay.api.response.AlipayFundTransToaccountTransferResponse
;
import
com.alipay.api.response.AlipayFundTransUniTransferResponse
;
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
;
import
com.edgec.browserbackend.account.repository.*
;
import
com.edgec.browserbackend.account.service.AccountService
;
import
com.edgec.browserbackend.account.service.PaymentService
;
import
com.edgec.browserbackend.account.controller.AccountController
;
...
...
@@ -23,10 +22,12 @@ 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
;
import
com.edgec.browserbackend.browser.ErrorCode.BrowserErrorCode
;
import
com.edgec.browserbackend.browser.domain.PayBack
;
import
com.edgec.browserbackend.browser.repository.PayBackRepository
;
import
com.edgec.browserbackend.common.commons.error.ClientRequestException
;
import
com.edgec.browserbackend.wxpay.*
;
import
com.google.gson.Gson
;
import
org.apache.commons.lang3.StringUtils
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
...
...
@@ -64,6 +65,9 @@ public class PaymentServiceImpl implements PaymentService {
@Autowired
private
AccountRepository
accountRepository
;
@Autowired
private
UserWithdrawRepository
userWithdrawRepository
;
@Override
public
String
wechatPayCallback
(
String
tradno
)
{
...
...
@@ -560,13 +564,16 @@ public class PaymentServiceImpl implements PaymentService {
}
@Override
public
boolean
alipayWithdraw
(
String
username
,
String
account
,
String
realName
)
{
public
boolean
alipayWithdraw
(
String
username
,
String
account
,
String
realName
,
int
amount
)
{
Account
byName
=
accountService
.
findByName
(
username
);
if
(
byName
==
null
)
throw
new
ClientRequestException
(
AccountErrorCode
.
NAMENOTEXIST
,
"account does not exist: "
+
username
);
boolean
isVpsClient
=
true
;
if
(
amount
>
byName
.
getPromotion
().
getAllGift
())
throw
new
ClientRequestException
(
AccountErrorCode
.
NOTENOUGHBALANCE
);
UserWithdraw
internalOrder
=
new
UserWithdraw
();
internalOrder
.
setAmount
(
byName
.
getPromotion
().
getCommission
());
internalOrder
.
setWithdrawMethod
(
PaymentMethod
.
ALIPAY
);
...
...
@@ -575,45 +582,81 @@ public class PaymentServiceImpl implements PaymentService {
try
{
byName
.
getPromotion
().
setAllGift
(
byName
.
getPromotion
().
getAllGift
()
-
amount
);
byName
.
getPromotion
().
setWithdrawn
(
byName
.
getPromotion
().
getWithdrawn
()
+
amount
);
accountRepository
.
save
(
byName
);
AlipayConfig
alipayConfig
=
isVpsClient
?
new
VpsAlipayConfig
()
:
new
CloudamAlipayConfig
();
AlipayClient
alipayClient
=
new
DefaultAlipayClient
(
alipayConfig
.
getURL
(),
alipayConfig
.
getAPPID
(),
alipayConfig
.
getAPP_PRIVATE_KEY
(),
Default
AlipayClient
alipayClient
=
new
DefaultAlipayClient
(
alipayConfig
.
getURL
(),
alipayConfig
.
getAPPID
(),
alipayConfig
.
getAPP_PRIVATE_KEY
(),
"json"
,
alipayConfig
.
getCHARSET
(),
alipayConfig
.
getALIPAY_PUBLIC_KEY
(),
alipayConfig
.
getSIGN_TYPE
());
AlipayFundTransToaccountTransferRequest
alipayRequest
=
new
AlipayFundTransToaccountTransferRequest
();
// String out_biz_no = internalOrder.getTradeNo();
// String product_code = "TRANS_ACCOUNT_NO_PWD";
// String trans_amount = "" + byName.getPromotion().getCommission() + ".00";
// String subject = "订单" + out_trade_no;
// String body = "";
//
// alipayRequest.setBizContent(""
// + "{"
// + "\"out_biz_no\":\"" + out_biz_no + "\","
// + "\"product_code\":\"" + product_code + "\","
// + "\"trans_amount\":\"" + trans_amount + "\","
// + "\"subject\":\"" + subject + "\","
// + "\"body\":\"" + body + "\""
// + "}"
// );
// AlipayFundTransToaccountTransferResponse response = alipayClient.pageExecute(alipayRequest);
// if("10000".equals(response.getCode())){
// resultMap.put("success", "true");
// resultMap.put("des", "转账成功");
// }else{
// resultMap.put("success", "false");
// resultMap.put("des", response.getSubMsg());
// }
// userPaymentRepository.save(internalOrder);
//
// String form = response.getBody();
// return form;
String
out_biz_no
=
internalOrder
.
getTradeNo
();
String
trans_amount
=
""
+
amount
+
".00"
;
String
identity_type
=
"ALIPAY_LOGONID"
;
String
subject
=
"礼金提现"
+
out_biz_no
;
AliTransfer
aliTransfer
=
new
AliTransfer
();
aliTransfer
.
setOut_biz_no
(
internalOrder
.
getTradeNo
());
aliTransfer
.
setPayee_type
(
identity_type
);
aliTransfer
.
setAmount
(
trans_amount
);
aliTransfer
.
setPayer_show_name
(
"防关联浏览器"
);
aliTransfer
.
setPayee_account
(
account
);
aliTransfer
.
setPayee_real_name
(
realName
);
aliTransfer
.
setRemark
(
subject
);
String
json
=
new
Gson
().
toJson
(
aliTransfer
);
alipayRequest
.
setBizContent
(
json
);
AlipayFundTransToaccountTransferResponse
response
=
alipayClient
.
execute
(
alipayRequest
);
if
(
response
==
null
)
throw
new
ClientRequestException
(
BrowserErrorCode
.
UNKNOWN
);
if
(
response
.
isSuccess
()){
internalOrder
.
setSucceed
(
true
);
userWithdrawRepository
.
save
(
internalOrder
);
UserPrePaidBilling
bill
=
new
UserPrePaidBilling
();
if
(
byName
!=
null
&&
byName
.
getParent
()
!=
null
)
bill
.
setAdministrator
(
byName
.
getParent
());
else
bill
.
setAdministrator
(
byName
.
getName
());
bill
.
setTradeNo
(
new
SimpleDateFormat
(
"yyyyMMddHHmmss"
).
format
(
new
Date
())+
SmsUtils
.
createRandom
(
true
,
4
));
bill
.
setChargeType
(
4
);
bill
.
setAmount
(
0
);
bill
.
setUnit
(
null
);
bill
.
setPeriod
(
0
);
bill
.
setPayMethod
(
1
);
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
);
userPrePaidBillingRepository
.
save
(
bill
);
return
true
;
}
else
{
byName
.
getPromotion
().
setAllGift
(
byName
.
getPromotion
().
getAllGift
()
+
amount
);
byName
.
getPromotion
().
setWithdrawn
(
byName
.
getPromotion
().
getWithdrawn
()
-
amount
);
accountRepository
.
save
(
byName
);
internalOrder
.
setSucceed
(
false
);
userWithdrawRepository
.
save
(
internalOrder
);
log
.
error
(
response
.
getBody
());
return
false
;
}
}
catch
(
Exception
e
)
{
log
.
error
(
"Al
y
pay payment order generation fails"
,
e
);
throw
new
ClientRequestException
(
AccountErrorCode
.
ALIPAYERROR
,
"Al
y
pay payment order error"
);
log
.
error
(
"Al
i
pay payment order generation fails"
,
e
);
throw
new
ClientRequestException
(
AccountErrorCode
.
ALIPAYERROR
,
"Al
i
pay payment order error"
);
}
return
false
;
}
}
src/main/java/com/edgec/browserbackend/alipay/AlipaySubmit.java
View file @
34530148
...
...
@@ -52,7 +52,7 @@ public class AlipaySubmit {
try
{
AlipayUserInfoShareResponse
userinfoShareResponse
=
alipayClient
.
execute
(
request
,
accessToken
);
return
userinfoShareResponse
.
get
Body
();
return
userinfoShareResponse
.
get
UserId
();
}
catch
(
AlipayApiException
e
)
{
//处理异常
e
.
printStackTrace
();
...
...
src/main/java/com/edgec/browserbackend/auth/config/ResourceServerConfiguration.java
View file @
34530148
...
...
@@ -20,7 +20,7 @@ public class ResourceServerConfiguration extends ResourceServerConfigurerAdapter
http
.
authorizeRequests
()
.
antMatchers
(
"/oauth/**"
).
permitAll
()
.
antMatchers
(
"/shop/*
"
,
"/ip/*"
,
"/group/*"
,
"/0xadministrator/*"
,
"/user/*"
,
"/history/
*"
).
authenticated
()
.
antMatchers
(
"/shop/*
*"
,
"/ip/**"
,
"/group/**"
,
"/0xadministrator/**"
,
"/user/**"
,
"/history/*
*"
).
authenticated
()
.
and
()
//关闭跨站请求防护
.
csrf
().
disable
();
...
...
src/main/java/com/edgec/browserbackend/browser/task/PromotionTask.java
View file @
34530148
...
...
@@ -37,15 +37,28 @@ public class PromotionTask {
String
code
=
account
.
getPromotion
().
getCode
();
List
<
Account
>
promotes
=
accountRepository
.
findByPromotionCode
(
code
);
double
totalCommission
=
0
;
double
secondCommission
=
0
;
for
(
Account
promote
:
promotes
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
promote
.
getName
(),
YearMonth
.
now
().
minusMonths
(
1
).
getYear
(),
YearMonth
.
now
().
minusMonths
(
1
).
getMonthValue
(),
Arrays
.
asList
(
1
,
2
));
totalCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
if
(
account
.
getPromotion
().
isSale
()
&&
promote
.
getParent
()
==
null
)
{
List
<
Account
>
secondPromotes
=
accountRepository
.
findByPromotionCode
(
promote
.
getPromotion
().
getCode
());
for
(
Account
secondPromote
:
secondPromotes
)
{
List
<
UserPrePaidBilling
>
userPrePaidBillings1
=
userPrePaidBillingRepository
.
findByUsernameAndYearAndMonthAndPayMethodIn
(
promote
.
getName
(),
YearMonth
.
now
().
minusMonths
(
1
).
getYear
(),
YearMonth
.
now
().
minusMonths
(
1
).
getMonthValue
(),
Arrays
.
asList
(
1
,
2
));
secondCommission
+=
userPrePaidBillings
.
stream
().
mapToDouble
(
UserPrePaidBilling:
:
getTotal
).
sum
();
}
}
}
Promotion
promotion
=
account
.
getPromotion
();
promotion
.
setCommissionLastMonth
((
int
)
totalCommission
);
promotion
.
setGift
(
totalCommission
*
8
/
100
);
promotion
.
setGift
(
totalCommission
*
0.08
);
if
(
account
.
getPromotion
().
isSale
())
{
promotion
.
setGift
(
totalCommission
*
0.1
+
secondCommission
*
0.02
);
}
promotion
.
setAllGift
(
promotion
.
getAllGift
()
+
promotion
.
getGift
());
accountRepository
.
save
(
account
);
}
...
...
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