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
d704c0c6
Commit
d704c0c6
authored
Nov 21, 2022
by
李健华
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
客服系统修改手机号及记录接口
parent
58939807
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
96 additions
and
1 deletion
+96
-1
ModifyPhoneNoController.java
...yqb/controller/modifyphoneno/ModifyPhoneNoController.java
+27
-0
IModifyPhoneNoService.java
...n/quantgroup/xyqb/service/user/IModifyPhoneNoService.java
+5
-0
ModifyPhoneNoServiceImpl.java
...roup/xyqb/service/user/impl/ModifyPhoneNoServiceImpl.java
+64
-1
No files found.
src/main/java/cn/quantgroup/xyqb/controller/modifyphoneno/ModifyPhoneNoController.java
View file @
d704c0c6
...
...
@@ -5,6 +5,7 @@ import cn.quantgroup.xyqb.controller.modifyphoneno.req.*;
import
cn.quantgroup.xyqb.controller.modifyphoneno.resp.ProgressResp
;
import
cn.quantgroup.xyqb.entity.ModifyPhoneNo
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UserModifyPhoneRecord
;
import
cn.quantgroup.xyqb.model.JsonResult
;
import
cn.quantgroup.xyqb.service.user.IModifyPhoneNoService
;
import
com.fasterxml.jackson.databind.ObjectMapper
;
...
...
@@ -30,6 +31,7 @@ public class ModifyPhoneNoController implements IBaseController {
@Resource
private
IModifyPhoneNoService
modifyPhoneNoService
;
@GetMapping
(
"/progress"
)
public
JsonResult
<
ProgressResp
>
progress
()
{
User
user
=
getCurrentUserFromRedis
();
...
...
@@ -107,10 +109,35 @@ public class ModifyPhoneNoController implements IBaseController {
/*------------------------------------------------------------------------------------------------------------*/
/**
* 客服系统修改手机号
* @param modifyPhoneRecord
* @return
*/
@PostMapping
(
"/submitModify"
)
public
JsonResult
submitModify
(
@Valid
@RequestBody
ModifyPhoneRecord
modifyPhoneRecord
)
{
modifyPhoneNoService
.
submitModify
(
modifyPhoneRecord
);
return
JsonResult
.
buildSuccessResult
();
}
/**
* 金融修改手机号
* @param modifyPhoneRecord
* @return
*/
@PostMapping
(
"/financial/submitModify"
)
public
JsonResult
financialSubmitModify
(
@Valid
@RequestBody
ModifyPhoneRecord
modifyPhoneRecord
)
{
modifyPhoneNoService
.
financialSubmitModify
(
modifyPhoneRecord
);
return
JsonResult
.
buildSuccessResult
();
}
@PostMapping
(
"/modifyPhoneNolist"
)
public
JsonResult
getModifyPhoneNolist
(
@RequestParam
(
"userId"
)
Long
userId
,
@RequestParam
(
value
=
"pageNo"
,
defaultValue
=
"1"
,
required
=
false
)
int
pageNo
,
@RequestParam
(
value
=
"pageSize"
,
defaultValue
=
"10"
,
required
=
false
)
int
pageSize
)
{
Page
<
UserModifyPhoneRecord
>
pageData
=
modifyPhoneNoService
.
query
(
userId
,
pageNo
,
pageSize
);
return
JsonResult
.
buildSuccessResult
(
"修改手机号列表"
,
pageData
);
}
}
src/main/java/cn/quantgroup/xyqb/service/user/IModifyPhoneNoService.java
View file @
d704c0c6
...
...
@@ -3,6 +3,7 @@ package cn.quantgroup.xyqb.service.user;
import
cn.quantgroup.xyqb.controller.modifyphoneno.req.*
;
import
cn.quantgroup.xyqb.controller.modifyphoneno.resp.ProgressResp
;
import
cn.quantgroup.xyqb.entity.ModifyPhoneNo
;
import
cn.quantgroup.xyqb.entity.UserModifyPhoneRecord
;
import
org.springframework.data.domain.Page
;
/**
...
...
@@ -32,4 +33,8 @@ public interface IModifyPhoneNoService {
void
audit
(
AuditReq
auditReq
);
void
submitModify
(
ModifyPhoneRecord
modifyPhoneRecord
);
void
financialSubmitModify
(
ModifyPhoneRecord
modifyPhoneRecord
);
Page
<
UserModifyPhoneRecord
>
query
(
Long
userId
,
int
pageNo
,
int
pageSize
);
}
src/main/java/cn/quantgroup/xyqb/service/user/impl/ModifyPhoneNoServiceImpl.java
View file @
d704c0c6
...
...
@@ -4,6 +4,7 @@ import cn.quantgroup.xyqb.aspect.limit.AccessLimit;
import
cn.quantgroup.xyqb.controller.modifyphoneno.req.*
;
import
cn.quantgroup.xyqb.controller.modifyphoneno.resp.ProgressResp
;
import
cn.quantgroup.xyqb.entity.ModifyPhoneNo
;
import
cn.quantgroup.xyqb.entity.User
;
import
cn.quantgroup.xyqb.entity.UserModifyPhoneRecord
;
import
cn.quantgroup.xyqb.exception.DataException
;
import
cn.quantgroup.xyqb.model.JsonResult
;
...
...
@@ -247,8 +248,18 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
try
{
if
(
lock
.
lock
())
{
if
(
modifyPhoneRecord
.
getCurPhoneNo
().
equals
(
modifyPhoneRecord
.
getPrevPhoneNo
()))
{
throw
new
DataException
(
"新
旧手机号相同
"
);
throw
new
DataException
(
"新
手机号已存在,不支持更换
"
);
}
User
user
=
userService
.
findById
(
modifyPhoneRecord
.
getUserId
());
if
(
user
==
null
)
{
throw
new
DataException
(
"用户不存在"
);
}
if
(!
modifyPhoneRecord
.
getPrevPhoneNo
().
equals
(
user
.
getPhoneNo
())
&&
!
modifyPhoneRecord
.
getPrevPhoneNo
().
equals
(
user
.
getEncryptedPhoneNo
()))
{
throw
new
DataException
(
"原手机号填写不符"
);
}
// 请求其他系统信息
HashMap
<
String
,
String
>
parameters
=
new
HashMap
<>();
HashMap
<
String
,
String
>
headers
=
new
HashMap
<>();
...
...
@@ -278,12 +289,64 @@ public class ModifyPhoneNoServiceImpl implements IModifyPhoneNoService {
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
throw
new
DataException
(
e
.
getMessage
());
}
finally
{
lock
.
unlock
();
}
}
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
public
void
financialSubmitModify
(
ModifyPhoneRecord
modifyPhoneRecord
)
{
String
lockKey
=
"modifyPhone:"
.
concat
(
modifyPhoneRecord
.
getCurPhoneNo
());
RedisLock
lock
=
new
RedisLock
(
redisTemplate
,
lockKey
);
try
{
if
(
lock
.
lock
())
{
if
(
modifyPhoneRecord
.
getCurPhoneNo
().
equals
(
modifyPhoneRecord
.
getPrevPhoneNo
()))
{
throw
new
DataException
(
"新手机号已存在,不支持更换"
);
}
User
user
=
userService
.
findById
(
modifyPhoneRecord
.
getUserId
());
if
(
user
==
null
)
{
throw
new
DataException
(
"用户不存在"
);
}
if
(!
modifyPhoneRecord
.
getPrevPhoneNo
().
equals
(
user
.
getPhoneNo
())
&&
!
modifyPhoneRecord
.
getPrevPhoneNo
().
equals
(
user
.
getEncryptedPhoneNo
()))
{
throw
new
DataException
(
"原手机号填写不符"
);
}
userService
.
submitModifyPhone
(
modifyPhoneRecord
.
getPrevPhoneNo
(),
modifyPhoneRecord
.
getCurPhoneNo
());
UserModifyPhoneRecord
record
=
new
UserModifyPhoneRecord
();
BeanUtils
.
copyProperties
(
modifyPhoneRecord
,
record
);
modifyPhoneRecordRepository
.
saveAndFlush
(
record
);
}
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
log
.
error
(
"金融来修改手机号失败--{}, 原因:---"
,
JSONObject
.
toJSONString
(
modifyPhoneRecord
),
e
);
String
failString
=
String
.
format
(
"金融来修改手机号失败--%s"
,
e
.
getMessage
());
throw
new
DataException
(
failString
);
}
finally
{
lock
.
unlock
();
}
}
@Override
public
Page
<
UserModifyPhoneRecord
>
query
(
Long
userId
,
int
pageNo
,
int
pageSize
)
{
Pageable
pageable
=
getPageable
(
pageNo
,
pageSize
);
Page
<
UserModifyPhoneRecord
>
userModifyPhoneRecord
=
modifyPhoneRecordRepository
.
findAll
((
root
,
query
,
criteriaBuilder
)
->
{
List
<
Predicate
>
predicates
=
Lists
.
newArrayList
();
predicates
.
add
(
criteriaBuilder
.
equal
(
root
.
get
(
"userId"
),
userId
));
query
.
where
(
predicates
.
toArray
(
new
Predicate
[
predicates
.
size
()]));
return
query
.
getRestriction
();
},
pageable
);
return
userModifyPhoneRecord
;
}
private
Pageable
getPageable
(
int
currentPage
,
int
pageSize
)
{
return
new
PageRequest
(
currentPage
-
1
,
pageSize
,
new
Sort
(
Sort
.
Direction
.
DESC
,
"id"
));
}
/**
* 验证用户是否允许修改手机号
* <p>
...
...
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