Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
D
data-server
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
data-server
Commits
697d26af
Commit
697d26af
authored
Mar 04, 2021
by
licc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
钱包接口,提现发送短信验证码
parent
aab12fb4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
98 additions
and
761 deletions
+98
-761
pom.xml
wisenergy-common/pom.xml
+6
-0
Constants.java
...on/src/main/java/cn/wisenergy/common/utils/Constants.java
+18
-3
MathUtils.java
...on/src/main/java/cn/wisenergy/common/utils/MathUtils.java
+44
-0
BankServiceImpl.java
...n/java/cn/wisenergy/service/app/impl/BankServiceImpl.java
+21
-2
RedisService.java
...rc/main/java/cn/wisenergy/service/cache/RedisService.java
+0
-666
BankController.java
...cn/wisenergy/web/admin/controller/app/BankController.java
+7
-2
SmsController.java
.../cn/wisenergy/web/admin/controller/app/SmsController.java
+2
-1
Constants.java
...b-admin/src/main/java/cn/wisenergy/web/sms/Constants.java
+0
-87
No files found.
wisenergy-common/pom.xml
View file @
697d26af
...
...
@@ -146,6 +146,12 @@
<version>
RELEASE
</version>
<scope>
compile
</scope>
</dependency>
<!-- 阿里短信依赖-->
<dependency>
<groupId>
com.aliyun
</groupId>
<artifactId>
aliyun-java-sdk-core
</artifactId>
<version>
4.4.0
</version>
</dependency>
</dependencies>
<!-- MAVEN构建 -->
...
...
wisenergy-common/src/main/java/cn/wisenergy/common/utils/Constants.java
View file @
697d26af
...
...
@@ -41,21 +41,35 @@ public class Constants {
//一秒
public
final
static
Integer
SECOND_INT
=
1
;
//一分钟
public
final
static
Integer
MINUTE_INT
=
SECOND_INT
*
6
0
;
public
final
static
Integer
MINUTE_INT
=
SECOND_INT
*
18
0
;
//半小时
public
final
static
Integer
HALF_HOUR_INT
=
MINUTE_INT
*
30
;
}
//正则的一些常量
public
static
class
RegConstant
{
//手机号正则
public
static
String
PHONE_REGSTR
=
"^
[1]
[0-9]{10}$"
;
public
static
String
PHONE_REGSTR
=
"^
1
[0-9]{10}$"
;
//密码正则
public
static
String
PASSWORD_REGSTR
=
"^([A-Z]|[a-z]|[0-9]|[_]){6,10}$"
;
}
//SMS相关常量
public
static
class
Sms
{
public
static
class
TemplateCode
{
public
static
String
LOGIN_OR_REGISTER
=
"SMS_197895260"
;
//对存入redis的tokn用户进行标注
public
static
String
LOGIN_BZ_REGISTER
=
"xts"
;
//身份验证验证码
public
static
String
LOGIN_SF_REGISTER
=
"SMS_212170059"
;
//登录确认验证码
public
static
String
LOGIN_DL_REGISTER
=
"SMS_212170058"
;
//登录异常验证码
public
static
String
LOGIN_DLYC_REGISTER
=
"SMS_212170057"
;
//用户注册验证码
public
static
String
LOGIN_ZC_REGISTER
=
"SMS_212170056"
;
//修改密码验证码
public
static
String
LOGIN_XGMM_REGISTER
=
"SMS_212170055"
;
// 信息变更验证码
public
static
String
LOGIN_XXBG_REGISTER
=
"SMS_212170054"
;
}
public
static
class
CodeType
{
...
...
@@ -69,5 +83,6 @@ public class Constants {
public
static
String
PROJECT_PRIFIX
=
"xts"
;
public
static
String
SMS_PRIFIX
=
"sms"
;
public
static
String
TOKEN_PRIFIX
=
"token"
;
public
static
String
BANK_PRIFIX
=
"bank"
;
}
}
wisenergy-common/src/main/java/cn/wisenergy/common/utils/MathUtils.java
0 → 100644
View file @
697d26af
package
cn
.
wisenergy
.
common
.
utils
;
import
java.math.BigDecimal
;
/**
* @Description 数字相关工具类
* @Date 2019-08-22 17:08
* @Author est team
* Version 1.0
**/
public
class
MathUtils
{
/**
* 返回一个4位随机数
* @return
*/
public
static
String
random
(){
int
random
=
(
int
)
((
Math
.
random
()
*
9
+
1
)
*
1000
);
return
random
+
""
;
}
/**
* 格式化BigDecimal,返回保留相应的小数
* @param decimal
* @param num
* @return
*/
public
static
BigDecimal
formatDecimal
(
BigDecimal
decimal
,
int
num
){
BigDecimal
result
=
decimal
.
setScale
(
num
,
BigDecimal
.
ROUND_HALF_UP
);
return
result
;
}
/**
* 格式化BigDecimal,默认保留两位小数
* @param decimal
* @return
*/
public
static
BigDecimal
formatDecimal
(
BigDecimal
decimal
){
BigDecimal
result
=
formatDecimal
(
decimal
,
Constants
.
Common
.
DECIMAL_DIGITS
);
return
result
;
}
}
wisenergy-service/src/main/java/cn/wisenergy/service/app/impl/BankServiceImpl.java
View file @
697d26af
package
cn
.
wisenergy
.
service
.
app
.
impl
;
import
cn.wisenergy.common.utils.
R
;
import
cn.wisenergy.common.utils.
*
;
import
cn.wisenergy.mapper.BankInfoMapper
;
import
cn.wisenergy.mapper.UsersMapper
;
import
cn.wisenergy.model.app.BankInfo
;
...
...
@@ -28,6 +28,11 @@ public class BankServiceImpl extends ServiceImpl<BankInfoMapper, BankInfo> imple
@Autowired
private
UsersMapper
usersMapper
;
@Autowired
private
SmsUtils
smsUtils
;
@Autowired
private
RedisUtils
redisUtils
;
@Override
...
...
@@ -93,7 +98,21 @@ public class BankServiceImpl extends ServiceImpl<BankInfoMapper, BankInfo> imple
}
//2、调用发送短信验证码接口
return
null
;
String
templateCode
=
""
;
String
code
=
MathUtils
.
random
();
boolean
bool
=
smsUtils
.
sendMessage
(
user
.
getUserId
(),
templateCode
,
code
);
if
(!
bool
)
{
return
R
.
error
(
"验证码发送失败,请重发!"
);
}
//缓存code到redis
String
phone
=
user
.
getUserId
();
String
key
=
StringUtil
.
formatKeyWithPrefix
(
Constants
.
RedisKey
.
BANK_PRIFIX
,
Constants
.
RedisKey
.
SMS_PRIFIX
,
phone
,
code
+
""
);
boolean
cache
=
redisUtils
.
set
(
key
,
code
,
Constants
.
Duration
.
MINUTE_INT
);
if
(!
cache
)
{
return
R
.
error
(
"缓存验证码失败!"
);
}
return
R
.
ok
(
0
,
true
);
}
@Override
...
...
wisenergy-service/src/main/java/cn/wisenergy/service/cache/RedisService.java
deleted
100644 → 0
View file @
aab12fb4
This diff is collapsed.
Click to expand it.
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/BankController.java
View file @
697d26af
...
...
@@ -48,9 +48,14 @@ public class BankController {
@ApiOperation
(
value
=
"获取银行卡信息"
,
notes
=
"获取银行卡信息"
,
httpMethod
=
"GET"
)
@ApiImplicitParam
(
name
=
"userId"
,
value
=
"用户id"
,
dataType
=
"String"
)
@GetMapping
(
"/getByUserId"
)
public
R
<
BankInfo
>
getByUserId
(
String
userId
){
public
R
<
BankInfo
>
getByUserId
(
String
userId
)
{
return
bankService
.
getByUserId
(
userId
);
}
@ApiOperation
(
value
=
"提现发送短信验证码"
,
notes
=
"提现发送短信验证码"
,
httpMethod
=
"GET"
)
@ApiImplicitParam
(
name
=
"userId"
,
value
=
"用户id"
,
dataType
=
"String"
)
@GetMapping
(
"/sendSmsCode"
)
public
R
<
Boolean
>
sendSmsCode
(
String
userId
)
{
return
bankService
.
bankWithdrawSendSms
(
userId
);
}
}
wisenergy-web-admin/src/main/java/cn/wisenergy/web/admin/controller/app/SmsController.java
View file @
697d26af
package
cn
.
wisenergy
.
web
.
admin
.
controller
.
app
;
import
cn.wisenergy.common.utils.Constants
;
import
cn.wisenergy.common.utils.RedisUtils
;
import
cn.wisenergy.common.utils.SmsUtils
;
import
cn.wisenergy.common.utils.StringUtil
;
...
...
@@ -39,7 +40,7 @@ public class SmsController {
if
(!
phone
.
matches
(
Constants
.
RegConstant
.
PHONE_REGSTR
)){
throw
new
BaseException
(
ResultEnum
.
PHONE_ERROR
);
}
if
(
codeType
!=
Constants
.
Sms
.
CodeType
.
LOGIN_OR_REGISTER
&&
codeType
!=
Constants
.
Sms
.
CodeType
.
PASS_UPDATE
&&
codeType
!=
Constants
.
Sms
.
CodeType
.
ORDER_NOTICE
){
if
(
!
codeType
.
equals
(
Constants
.
Sms
.
CodeType
.
LOGIN_OR_REGISTER
)
&&
!
codeType
.
equals
(
Constants
.
Sms
.
CodeType
.
PASS_UPDATE
)
&&
!
codeType
.
equals
(
Constants
.
Sms
.
CodeType
.
ORDER_NOTICE
)
){
throw
new
BaseException
(
ResultEnum
.
CODETYPE_ERROR
);
}
String
key
=
StringUtil
.
formatKeyWithPrefix
(
Constants
.
RedisKey
.
PROJECT_PRIFIX
,
Constants
.
RedisKey
.
SMS_PRIFIX
,
phone
,
codeType
+
""
);
...
...
wisenergy-web-admin/src/main/java/cn/wisenergy/web/sms/Constants.java
deleted
100644 → 0
View file @
aab12fb4
package
cn
.
wisenergy
.
web
.
sms
;
/***
* 系统中保存的一些常量
*/
/**
* Created by m1991 on 2021/2/28 22:50
*/
public
class
Constants
{
//通用常量
public
static
class
Common
{
//否
public
final
static
Integer
NOT
=
0
;
//是
public
final
static
Integer
YES
=
1
;
//女
public
final
static
Integer
SEX_WOMEN
=
0
;
//男
public
final
static
Integer
SEX_MAN
=
1
;
//数据精度
public
final
static
Integer
DECIMAL_DIGITS
=
2
;
}
//访问来源
public
static
class
SourceType
{
//访问来源-APP
public
final
static
Integer
APP
=
0
;
//访问来源-PC
public
final
static
Integer
PC
=
1
;
}
//连接符
public
static
class
Connnector
{
//逗号
public
final
static
String
COMMA_
=
","
;
//下划线
public
final
static
String
UNDERLINE
=
"_"
;
//冒号
public
final
static
String
COLON
=
":"
;
}
//时长
public
static
class
Duration
{
//一秒
public
final
static
Integer
SECOND_INT
=
1
;
//一分钟
public
final
static
Integer
MINUTE_INT
=
SECOND_INT
*
60
;
//半小时
public
final
static
Integer
HALF_HOUR_INT
=
MINUTE_INT
*
30
;
}
//正则的一些常量
public
static
class
RegConstant
{
//手机号正则
public
static
String
PHONE_REGSTR
=
"^1[0-9]{10}$"
;
//密码正则
public
static
String
PASSWORD_REGSTR
=
"^([A-Z]|[a-z]|[0-9]|[_]){6,10}$"
;
}
//SMS相关常量
public
static
class
Sms
{
public
static
class
TemplateCode
{
//对存入redis的tokn用户进行标注
public
static
String
LOGIN_BZ_REGISTER
=
"xts"
;
//身份验证验证码
public
static
String
LOGIN_SF_REGISTER
=
"SMS_212170059"
;
//登录确认验证码
public
static
String
LOGIN_DL_REGISTER
=
"SMS_212170058"
;
//登录异常验证码
public
static
String
LOGIN_DLYC_REGISTER
=
"SMS_212170057"
;
//用户注册验证码
public
static
String
LOGIN_ZC_REGISTER
=
"SMS_212170056"
;
//修改密码验证码
public
static
String
LOGIN_XGMM_REGISTER
=
"SMS_212170055"
;
// 信息变更验证码
public
static
String
LOGIN_XXBG_REGISTER
=
"SMS_212170054"
;
}
public
static
class
CodeType
{
public
static
Integer
LOGIN_OR_REGISTER
=
0
;
public
static
Integer
PASS_UPDATE
=
1
;
public
static
Integer
ORDER_NOTICE
=
2
;
}
}
//RedisKey相关的常量
public
static
class
RedisKey
{
public
static
String
PROJECT_PRIFIX
=
"xts"
;
public
static
String
SMS_PRIFIX
=
"sms"
;
public
static
String
TOKEN_PRIFIX
=
"token"
;
}
}
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