Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
X
xyqb-user2
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
head_group
xyqb-user2
Commits
98485f4c
Commit
98485f4c
authored
Nov 05, 2019
by
杨锐
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
code review。
parent
5a775628
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
39 deletions
+50
-39
RestTemplateConfig.java
...va/cn/quantgroup/xyqb/config/http/RestTemplateConfig.java
+6
-0
AuditReq.java
...uantgroup/xyqb/controller/modifyphoneno/req/AuditReq.java
+3
-4
ModifyPhoneNoQueryReq.java
...b/controller/modifyphoneno/req/ModifyPhoneNoQueryReq.java
+6
-7
ModifyPhoneNoServiceImpl.java
...roup/xyqb/service/user/impl/ModifyPhoneNoServiceImpl.java
+33
-26
UserServiceImpl.java
...cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
+2
-2
No files found.
src/main/java/cn/quantgroup/xyqb/config/http/RestTemplateConfig.java
View file @
98485f4c
package
cn
.
quantgroup
.
xyqb
.
config
.
http
;
import
cn.quantgroup.xyqb.service.http.IHttpService
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
import
org.springframework.http.client.SimpleClientHttpRequestFactory
;
...
...
@@ -12,7 +13,12 @@ import org.springframework.web.client.RestTemplate;
* Time: 上午11:37
*
* @author: yangrui
*
* @deprecated Use
* {@link IHttpService}}
* instead. 统一.
*/
@Deprecated
@Configuration
public
class
RestTemplateConfig
{
...
...
src/main/java/cn/quantgroup/xyqb/controller/modifyphoneno/req/AuditReq.java
View file @
98485f4c
package
cn
.
quantgroup
.
xyqb
.
controller
.
modifyphoneno
.
req
;
import
cn.quantgroup.user.enums.ModifyPhoneNoApplyStatusEnum
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.hibernate.validator.constraints.Range
;
import
javax.validation.constraints.NotNull
;
...
...
@@ -16,10 +16,9 @@ import javax.validation.constraints.NotNull;
public
class
AuditReq
{
@NotNull
(
message
=
"id不能为空"
)
private
Long
id
;
@ApiModelProperty
(
"申请状态
0处理中; 1修改完成; 2
不允许修改;"
)
@ApiModelProperty
(
"申请状态
INIT处理中; DONE修改完成; NO_ALLOW
不允许修改;"
)
@NotNull
(
message
=
"申请状态不能为空"
)
@Range
(
min
=
0
,
max
=
2
,
message
=
"申请状态不合法。"
)
private
Integer
applyStatus
;
private
ModifyPhoneNoApplyStatusEnum
applyStatus
;
@ApiModelProperty
(
"申请状态补充原因"
)
private
String
applyStatusReason
;
}
src/main/java/cn/quantgroup/xyqb/controller/modifyphoneno/req/ModifyPhoneNoQueryReq.java
View file @
98485f4c
package
cn
.
quantgroup
.
xyqb
.
controller
.
modifyphoneno
.
req
;
import
cn.quantgroup.user.enums.ModifyPhoneNoApplyStatusEnum
;
import
cn.quantgroup.user.enums.ModifyPhoneNoProcessingStatusEnum
;
import
cn.quantgroup.xyqb.controller.req.Page
;
import
io.swagger.annotations.ApiModelProperty
;
import
lombok.Data
;
import
org.hibernate.validator.constraints.Range
;
/**
* Date: 2019/11/5
...
...
@@ -35,14 +36,12 @@ public class ModifyPhoneNoQueryReq extends Page {
/**
* 申请状态 0处理中; 1修改完成; 2不允许修改;
*/
@ApiModelProperty
(
"申请状态 0处理中; 1修改完成; 2不允许修改;"
)
@Range
(
min
=
0
,
max
=
2
,
message
=
"申请状态不合法。"
)
private
Integer
applyStatus
;
@ApiModelProperty
(
"申请状态 INIT 处理中; DONE 修改完成; NO_ALLOW 不允许修改;"
)
private
ModifyPhoneNoApplyStatusEnum
applyStatus
;
/**
* 处理状态 0待人工处理 1待用户反馈结果 2已反馈
*/
@ApiModelProperty
(
"处理状态 0待人工处理; 1待用户反馈结果; 2已反馈"
)
@Range
(
min
=
0
,
max
=
2
,
message
=
"处理状态不合法。"
)
private
Integer
processingStatus
;
@ApiModelProperty
(
"处理状态 INIT 待人工处理; WAIT_4_USER_FEEDBACK 待用户反馈结果; DONE 已反馈;"
)
private
ModifyPhoneNoProcessingStatusEnum
processingStatus
;
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/ModifyPhoneNoServiceImpl.java
View file @
98485f4c
...
...
@@ -11,10 +11,12 @@ import cn.quantgroup.xyqb.entity.ModifyPhoneNo;
import
cn.quantgroup.xyqb.exception.DataException
;
import
cn.quantgroup.xyqb.repository.IModifyPhoneNoRepository
;
import
cn.quantgroup.xyqb.repository.IUserDetailRepository
;
import
cn.quantgroup.xyqb.service.http.IHttpService
;
import
cn.quantgroup.xyqb.service.sms.ISmsService
;
import
cn.quantgroup.xyqb.service.user.IModifyPhoneNoService
;
import
cn.quantgroup.xyqb.service.user.IUserService
;
import
cn.quantgroup.xyqb.util.DateUtilsV1
;
import
com.alibaba.fastjson.JSONObject
;
import
com.google.common.collect.Lists
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
...
...
@@ -26,7 +28,6 @@ import org.springframework.data.domain.Sort;
import
org.springframework.data.jpa.domain.Specification
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.web.client.RestTemplate
;
import
javax.annotation.Resource
;
import
javax.persistence.criteria.*
;
...
...
@@ -49,7 +50,7 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
@Resource
private
ISmsService
smsService
;
@Resource
private
RestTemplate
restTemplat
e
;
private
IHttpService
httpServic
e
;
@Resource
private
IUserService
userService
;
...
...
@@ -58,18 +59,18 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
/**
* @param
id
user.id
* @param
userId
user.id
* @param step1Req
* @return
*/
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
Long
saveStep1
(
Long
i
d
,
Step1Req
step1Req
)
{
public
Long
saveStep1
(
Long
userI
d
,
Step1Req
step1Req
)
{
// TODO: 2019/11/4 并发访问
allowModify
(
i
d
,
step1Req
.
getName
(),
step1Req
.
getIdCard
(),
step1Req
.
getPrevPhoneNo
(),
step1Req
.
getCurPhoneNo
(),
allowModify
(
userI
d
,
step1Req
.
getName
(),
step1Req
.
getIdCard
(),
step1Req
.
getPrevPhoneNo
(),
step1Req
.
getCurPhoneNo
(),
step1Req
.
getSmsCode
());
ModifyPhoneNo
modifyPhoneNo
=
Step1Req
.
adapt
(
step1Req
);
modifyPhoneNo
.
setUserId
(
i
d
);
modifyPhoneNo
.
setUserId
(
userI
d
);
modifyPhoneNoRepository
.
saveAndFlush
(
modifyPhoneNo
);
return
modifyPhoneNo
.
getId
();
}
...
...
@@ -91,14 +92,14 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
/**
* 查询用户手机号修改进度
*
* @param
i
d user.id
* @param
userI
d user.id
* @return 进度 0初始化(用户未填写过申请单或提交过的申请单均已处理完成且反馈);
* 1已填写基本信息,未上传身份证图片;
* 2已填写基本信息,且已上传身份证图片
*/
@Override
public
Integer
progress
(
Long
i
d
)
{
ModifyPhoneNo
modifyPhoneNo
=
modifyPhoneNoRepository
.
findFirstByUserIdAndApplyStatus
(
i
d
,
ModifyPhoneNoApplyStatusEnum
.
INIT
.
getType
());
public
Integer
progress
(
Long
userI
d
)
{
ModifyPhoneNo
modifyPhoneNo
=
modifyPhoneNoRepository
.
findFirstByUserIdAndApplyStatus
(
userI
d
,
ModifyPhoneNoApplyStatusEnum
.
INIT
.
getType
());
if
(
modifyPhoneNo
==
null
)
{
return
0
;
}
...
...
@@ -131,10 +132,10 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
list
.
add
(
criteriaBuilder
.
lessThanOrEqualTo
(
root
.
get
(
"createAt"
),
DateUtilsV1
.
strToDate
(
modifyPhoneNoQueryReq
.
getEndAt
(),
DateUtilsV1
.
YMD_FORMAT
)));
}
if
(
modifyPhoneNoQueryReq
.
getApplyStatus
()
!=
null
)
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"applyStatus"
),
modifyPhoneNoQueryReq
.
getApplyStatus
()));
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"applyStatus"
),
modifyPhoneNoQueryReq
.
getApplyStatus
()
.
getType
()
));
}
if
(
modifyPhoneNoQueryReq
.
getProcessingStatus
()
!=
null
)
{
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"processingStatus"
),
modifyPhoneNoQueryReq
.
getProcessingStatus
()));
list
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"processingStatus"
),
modifyPhoneNoQueryReq
.
getProcessingStatus
()
.
getType
()
));
}
Predicate
[]
arr
=
new
Predicate
[
list
.
size
()];
return
criteriaBuilder
.
and
(
list
.
toArray
(
arr
));
...
...
@@ -164,11 +165,11 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
if
(
modifyPhoneNo
==
null
)
{
throw
new
DataException
(
"数据不存在。"
);
}
if
(
ModifyPhoneNoApplyStatusEnum
.
NO_ALLOW
.
getType
()
==
auditReq
.
getApplyStatus
())
{
if
(
ModifyPhoneNoApplyStatusEnum
.
NO_ALLOW
==
auditReq
.
getApplyStatus
())
{
modifyPhoneNo
.
setApplyStatus
(
ModifyPhoneNoApplyStatusEnum
.
NO_ALLOW
.
getType
());
modifyPhoneNo
.
setApplyStatusReason
(
auditReq
.
getApplyStatusReason
());
}
if
(
ModifyPhoneNoApplyStatusEnum
.
DONE
.
getType
()
==
auditReq
.
getApplyStatus
())
{
if
(
ModifyPhoneNoApplyStatusEnum
.
DONE
==
auditReq
.
getApplyStatus
())
{
allowModifyHttp
(
modifyPhoneNo
.
getUserId
());
userService
.
modifyPhoneNo
(
modifyPhoneNo
.
getPrevPhoneNo
(),
modifyPhoneNo
.
getCurPhoneNo
());
modifyPhoneNo
.
setApplyStatus
(
ModifyPhoneNoApplyStatusEnum
.
DONE
.
getType
());
...
...
@@ -184,7 +185,7 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
* 用户有还款中的订单,不允许修改。
* </p>
*
* @param
id
user.id
* @param
userId
user.id
* @param name 注册人真实姓名
* @param idCard 注册人身份证件号
* @param prevPhoneNo 当前手机号码
...
...
@@ -192,28 +193,34 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
* @param smsCode 新手机号码短信验证码
* @return
*/
public
void
allowModify
(
Long
i
d
,
String
name
,
String
idCard
,
String
prevPhoneNo
,
String
curPhoneNo
,
String
smsCode
)
{
if
(
modifyPhoneNoRepository
.
findFirstByUserIdAndApplyStatus
(
i
d
,
ModifyPhoneNoProcessingStatusEnum
.
INIT
.
getType
())
!=
null
)
{
public
void
allowModify
(
Long
userI
d
,
String
name
,
String
idCard
,
String
prevPhoneNo
,
String
curPhoneNo
,
String
smsCode
)
{
if
(
modifyPhoneNoRepository
.
findFirstByUserIdAndApplyStatus
(
userI
d
,
ModifyPhoneNoProcessingStatusEnum
.
INIT
.
getType
())
!=
null
)
{
throw
new
DataException
(
"已存在处理中的申请单,不支持再次更换。"
);
}
if
(
userDetailRepository
.
findByUserIdAndPhoneNoAndNameAndIdNo
(
i
d
,
prevPhoneNo
,
name
,
idCard
)
==
null
)
{
throw
new
DataException
(
"
姓名、身份证、电话号不符
。"
);
if
(
userDetailRepository
.
findByUserIdAndPhoneNoAndNameAndIdNo
(
userI
d
,
prevPhoneNo
,
name
,
idCard
)
==
null
)
{
throw
new
DataException
(
"
信息填写有误,请重新填写
。"
);
}
if
(
userDetailRepository
.
findOneByPhoneNo
(
curPhoneNo
)
!=
null
)
{
throw
new
DataException
(
"
新手机号已存在,不支持更换
。"
);
throw
new
DataException
(
"
信息填写有误,请重新填写
。"
);
}
if
(!
smsService
.
verifyPhoneAndCode
(
curPhoneNo
,
smsCode
))
{
throw
new
DataException
(
"验证码不正确。"
);
}
allowModifyHttp
(
i
d
);
allowModifyHttp
(
userI
d
);
}
public
void
allowModifyHttp
(
Long
id
)
{
log
.
info
(
"allowModify userId = 【{}】"
,
id
);
UserLoanStatusResp
userLoanStatusResp
=
restTemplate
.
getForObject
(
apiHttps
+
"?userId="
+
id
,
UserLoanStatusResp
.
class
);
log
.
info
(
"allowModify userLoanStatusResp = 【{}】"
,
userLoanStatusResp
);
if
(!
userLoanStatusResp
.
isSuccess
()
||
!
userLoanStatusResp
.
isData
())
{
throw
new
DataException
(
"用户存在订单,不支持修改。"
);
/**
* @param userId user.id
*/
public
void
allowModifyHttp
(
Long
userId
)
{
log
.
info
(
"allowModify userId = 【{}】"
,
userId
);
String
res
=
httpService
.
get
(
apiHttps
+
"?userId="
+
userId
);
log
.
info
(
"allowModify res = 【{}】"
,
res
);
if
(
StringUtils
.
isNotBlank
(
res
))
{
UserLoanStatusResp
userLoanStatusResp
=
JSONObject
.
parseObject
(
res
,
UserLoanStatusResp
.
class
);
if
(!
userLoanStatusResp
.
isSuccess
()
||
!
userLoanStatusResp
.
isData
())
{
throw
new
DataException
(
"用户存在订单,不支持修改。"
);
}
}
}
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/UserServiceImpl.java
View file @
98485f4c
...
...
@@ -215,12 +215,12 @@ public class UserServiceImpl implements IUserService {
User
newPhoneUser
=
userRepository
.
findByPhoneNo
(
newPhoneNo
);
if
(
Objects
.
nonNull
(
newPhoneUser
))
{
//新手机号已存在
throw
new
DataException
(
"
新手机号已存在
。"
);
throw
new
DataException
(
"
信息填写有误,请重新填写
。"
);
}
User
oldPhoneUser
=
userRepository
.
findByPhoneNo
(
oldPhoneNo
);
if
(
Objects
.
isNull
(
oldPhoneUser
))
{
//这不是扯了.旧手机号不存在.
throw
new
DataException
(
"
旧手机号不存在
。"
);
throw
new
DataException
(
"
信息填写有误,请重新填写
。"
);
}
//2. 执行修改
//2.1 修改 user 表
...
...
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