Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
S
shop-Mall
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
licc
shop-Mall
Commits
b93b9eca
Commit
b93b9eca
authored
Mar 04, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提现接口实现
parent
c07bae07
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
52 additions
and
7 deletions
+52
-7
RedisUtils.java
...n/src/main/java/cn/wisenergy/common/utils/RedisUtils.java
+10
-0
BankServiceImpl.java
...n/java/cn/wisenergy/service/app/impl/BankServiceImpl.java
+29
-7
BankController.java
...cn/wisenergy/web/admin/controller/app/BankController.java
+13
-0
No files found.
wisenergy-common/src/main/java/cn/wisenergy/common/utils/RedisUtils.java
View file @
b93b9eca
...
...
@@ -456,4 +456,14 @@ public class RedisUtils {
}
return
null
;
}
/**
* 根据key 获取过期时间
*
* @param key 键 不能为null
* @return 时间(秒) 返回0代表为永久有效
*/
public
long
getExpire
(
String
key
)
{
return
redisTemplate
.
getExpire
(
key
,
TimeUnit
.
SECONDS
);
}
}
\ No newline at end of file
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/BankServiceImpl.java
View file @
b93b9eca
...
...
@@ -3,11 +3,15 @@ package cn.wisenergy.service.app.impl;
import
cn.wisenergy.common.utils.*
;
import
cn.wisenergy.mapper.AccountMapper
;
import
cn.wisenergy.mapper.BankInfoMapper
;
import
cn.wisenergy.mapper.TradeRecordMapper
;
import
cn.wisenergy.mapper.UsersMapper
;
import
cn.wisenergy.model.app.AccountInfo
;
import
cn.wisenergy.model.app.BankInfo
;
import
cn.wisenergy.model.app.TradeRecord
;
import
cn.wisenergy.model.app.User
;
import
cn.wisenergy.model.dto.WithdrawBankDto
;
import
cn.wisenergy.model.enums.TradeRecordEnum
;
import
cn.wisenergy.model.enums.TradeStatusEnum
;
import
cn.wisenergy.service.app.BankService
;
import
com.baomidou.mybatisplus.extension.service.impl.ServiceImpl
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -40,6 +44,9 @@ public class BankServiceImpl extends ServiceImpl<BankInfoMapper, BankInfo> imple
@Autowired
private
AccountMapper
accountMapper
;
@Autowired
private
TradeRecordMapper
recordMapper
;
@Override
public
R
<
BankInfo
>
add
(
BankInfo
bankInfo
)
{
...
...
@@ -131,17 +138,32 @@ public class BankServiceImpl extends ServiceImpl<BankInfoMapper, BankInfo> imple
//1、判断提现金额不得超过余额
//获取账户信息
AccountInfo
accountInfo
=
accountMapper
.
getByUserId
(
dto
.
getUserId
());
if
(
null
!=
accountInfo
)
{
if
(
dto
.
getMoney
()
>
accountInfo
.
getExtractMoney
().
doubleValue
())
{
AccountInfo
accountInfo
=
accountMapper
.
getByUserId
(
dto
.
getUserId
());
if
(
null
!=
accountInfo
)
{
if
(
dto
.
getMoney
()
>
accountInfo
.
getExtractMoney
().
doubleValue
())
{
return
R
.
error
(
"提现金额不得超过余额"
);
}
}
//2、验证短信验证码
//判断缓存是否过期
assert
accountInfo
!=
null
;
String
phone
=
accountInfo
.
getUserId
();
String
code
=
dto
.
getCode
();
String
key
=
StringUtil
.
formatKeyWithPrefix
(
Constants
.
RedisKey
.
BANK_PRIFIX
,
Constants
.
RedisKey
.
SMS_PRIFIX
,
phone
,
code
+
""
);
long
time
=
redisUtils
.
getExpire
(
key
);
if
(
time
<
0
)
{
return
R
.
error
(
1
,
"验证码已过期!"
,
false
);
}
//3、添加提现交易流水记录
return
null
;
TradeRecord
tradeRecord
=
new
TradeRecord
();
tradeRecord
.
setUserId
(
accountInfo
.
getUserId
());
tradeRecord
.
setTradeType
(
TradeRecordEnum
.
WITHDRAW_DEPOSIT
.
getCode
());
tradeRecord
.
setTradeNo
(
null
);
tradeRecord
.
setStatus
(
TradeStatusEnum
.
BANK_TRANSFER_ACCOUNTS
.
getCode
());
int
count
=
recordMapper
.
add
(
tradeRecord
);
if
(
count
==
0
)
{
return
R
.
error
(
"保存交易流水失败!"
);
}
return
R
.
ok
(
0
,
true
);
}
}
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/BankController.java
View file @
b93b9eca
...
...
@@ -2,6 +2,7 @@ package cn.wisenergy.web.admin.controller.app;
import
cn.wisenergy.common.utils.R
;
import
cn.wisenergy.model.app.BankInfo
;
import
cn.wisenergy.model.dto.WithdrawBankDto
;
import
cn.wisenergy.service.app.BankService
;
import
io.swagger.annotations.Api
;
import
io.swagger.annotations.ApiImplicitParam
;
...
...
@@ -58,4 +59,16 @@ public class BankController {
public
R
<
Boolean
>
sendSmsCode
(
String
userId
)
{
return
bankService
.
bankWithdrawSendSms
(
userId
);
}
@ApiOperation
(
value
=
"钱包余额-提现"
,
notes
=
"编辑用户银行卡信息"
,
httpMethod
=
"POST"
)
@ApiImplicitParam
(
name
=
"dto"
,
value
=
"提现信息"
,
dataType
=
"WithdrawBankDto"
)
@PostMapping
(
"/userWithdrawBank"
)
public
R
<
Boolean
>
userWithdrawBank
(
@RequestBody
WithdrawBankDto
dto
)
{
log
.
info
(
"shop-mall[]BankController[]userWithdrawBank[]input.param.dto:"
+
dto
);
if
(
null
==
dto
)
{
return
R
.
error
(
"入参为空!"
);
}
return
bankService
.
userWithdrawBank
(
dto
);
}
}
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