Commit e1686bf4 authored by 技术部-任文超's avatar 技术部-任文超

解决重置实名信息失败时反馈成功bug

parent 30e9d3f7
...@@ -1296,15 +1296,17 @@ public class InnerController implements IBaseController { ...@@ -1296,15 +1296,17 @@ public class InnerController implements IBaseController {
if (Objects.nonNull(userId) && ValidationUtil.validateChinese(name)) { if (Objects.nonNull(userId) && ValidationUtil.validateChinese(name)) {
try { try {
User user = userService.findById(userId); User user = userService.findById(userId);
int rows = userDetailService.updateIdCard(name, idNo, user.getPhoneNo()); int rows = userDetailService.updateNameAndIdCard(name, idNo, user.getPhoneNo());
log.info("重置用户实名信息,userId:{},name:{},idNo:{},result:[{}]", userId, name, idNo, rows); log.info("重置用户实名信息,userId:{},name:{},idNo:{},result:[{}]", userId, name, idNo, rows);
return JsonResult.buildSuccessResult("用户姓名已重置.", name); if(rows > 0){
return JsonResult.buildSuccessResult("用户实名信息已重置.", name.concat(",").concat(idNo).concat(",").concat(userId.toString()));
}
} catch (Exception e) { } catch (Exception e) {
log.error("用户姓名重置失败,userId[{}],name[{}],err:[{}]", userId, name, e); log.error("用户实名信息重置失败,userId[{}],name[{}],err:[{}]", userId, name, e);
} }
return JsonResult.buildErrorStateResult("用户姓名重置失败.", "Error data"); return JsonResult.buildErrorStateResult("用户实名信息重置失败.", "Error data");
} else { } else {
return JsonResult.buildErrorStateResult("用户姓名重置失败.", "Error data"); return JsonResult.buildErrorStateResult("用户实名信息重置失败.", "Error data");
} }
} }
...@@ -1356,9 +1358,17 @@ public class InnerController implements IBaseController { ...@@ -1356,9 +1358,17 @@ public class InnerController implements IBaseController {
log.info("手机号有误, phoneNo:{}", phoneNo); log.info("手机号有误, phoneNo:{}", phoneNo);
return JsonResult.buildErrorStateResult("用户手机号错误", null); return JsonResult.buildErrorStateResult("用户手机号错误", null);
} }
int affectedRows = userDetailService.updateIdCard(name, idNo, phoneNo); log.info("重置用户实名信息 phoneNo:{},name:{},idNo:{}", phoneNo, name, idNo);
log.info("更新用户的信息,name;{},idNo:{},phoneNo:{},操作的理由reason:{},受影响的行数affectedRows:{}", name, idNo, phoneNo, reason, affectedRows); try {
return JsonResult.buildSuccessResult("修改用户身份证号或姓名成功", affectedRows); int rows = userDetailService.updateNameAndIdCard(name, idNo, phoneNo);
log.info("重置用户实名信息,phoneNo:{},name:{},idNo:{},result:[{}],操作的理由reason:{}", phoneNo, name, idNo, rows, reason);
if(rows > 0){
return JsonResult.buildSuccessResult("用户实名信息已重置.", phoneNo.concat(",").concat(name).concat(",").concat(idNo));
}
} catch (Exception e) {
log.error("用户实名信息重置失败,phoneNo[{}],name[{}],err:[{}]", phoneNo, name, e);
}
return JsonResult.buildErrorStateResult("用户实名信息重置失败.", "Error data");
} }
/** /**
......
...@@ -49,13 +49,8 @@ public interface IUserDetailRepository extends JpaRepository<UserDetail, Long>, ...@@ -49,13 +49,8 @@ public interface IUserDetailRepository extends JpaRepository<UserDetail, Long>,
@Transactional @Transactional
@Modifying @Modifying
@Query(value = "update user_detail set id_no=?1,gender=?2 where phone_no=?3", nativeQuery = true) @Query(value = "update user_detail set name=?1,id_no=?2,gender=?3 where phone_no=?4", nativeQuery = true)
int updateIdNoByPhoneNo(String idNo, int gender, String phoneNo); int updateNameAndIdNoByPhoneNo(String name, String idNo, int gender, String phoneNo);
@Transactional
@Modifying
@Query(value = "update user_detail set name=?1 where phone_no=?2", nativeQuery = true)
int updateNameByPhoneNo(String name, String phoneNo);
/** /**
* 按照身份证号和手机号 - 模糊查询 * 按照身份证号和手机号 - 模糊查询
......
...@@ -30,9 +30,7 @@ public interface IUserDetailService { ...@@ -30,9 +30,7 @@ public interface IUserDetailService {
List<UserDetail> findByIdnos(List<String> idnos); List<UserDetail> findByIdnos(List<String> idnos);
Page<UserDetail> getUserDetailsPage(List<Long> userId, List<String> phoneNos, List<String> idNos, int pageNumber, int pageSize, Page<UserDetail> getUserDetailsPage(List<Long> userId, List<String> phoneNos, List<String> idNos, int pageNumber, int pageSize, String sortType);
String sortType);
/** /**
* 更新用户的身份证号 * 更新用户的身份证号
...@@ -42,7 +40,7 @@ public interface IUserDetailService { ...@@ -42,7 +40,7 @@ public interface IUserDetailService {
* @param phoneNo phoneNo * @param phoneNo phoneNo
* @return 受影响的行数 * @return 受影响的行数
*/ */
int updateIdCard(String name, String idNo, String phoneNo); int updateNameAndIdCard(String name, String idNo, String phoneNo);
List<UserDetail> findByPhones(List<String> phoneNos); List<UserDetail> findByPhones(List<String> phoneNos);
......
...@@ -196,19 +196,26 @@ public class UserDetailServiceImpl implements IUserDetailService { ...@@ -196,19 +196,26 @@ public class UserDetailServiceImpl implements IUserDetailService {
} }
@Override @Override
public int updateIdCard(String name, String idNo, String phoneNo) { public int updateNameAndIdCard(String name, String idNo, String phoneNo) {
UserDetail userDetail = userDetailRepository.findByPhoneNo(phoneNo); UserDetail userDetail = userDetailRepository.findByPhoneNo(phoneNo);
if (null != userDetail) { if (null != userDetail) {
String newName = userDetail.getName();
String newIdNo = userDetail.getIdNo();
Gender newGender = Gender.UNKNOWN;
if (ValidationUtil.validateChinese(name)) {
newName = name;
}
if (StringUtils.isNotBlank(idNo)) { if (StringUtils.isNotBlank(idNo)) {
IdCardInfo idCardInfo = idCardService.getIdCardInfo(idNo); IdCardInfo idCardInfo = idCardService.getIdCardInfo(idNo);
if (idCardInfo == null || !idCardInfo.isValid()) { if(Objects.nonNull(idCardInfo) && idCardInfo.isValid()){
newIdNo = idCardInfo.getIdNo();
newGender = idCardInfo.getGender();
}else{
log.error("用户的身份证错误,phoneNo:{},idNo:{}", phoneNo, idNo); log.error("用户的身份证错误,phoneNo:{},idNo:{}", phoneNo, idNo);
return 0;
} }
return userDetailRepository.updateIdNoByPhoneNo(idCardInfo.getIdNo(), Optional.ofNullable(idCardInfo.getGender()).orElse(Gender.UNKNOWN).ordinal(), phoneNo);
} }
if (StringUtils.isNotBlank(name) && ValidationUtil.validateChinese(name)) { if(!Objects.equals(newName, userDetail.getName()) || !Objects.equals(newIdNo, userDetail.getIdNo())){
return userDetailRepository.updateNameByPhoneNo(name, phoneNo); return userDetailRepository.updateNameAndIdNoByPhoneNo(newName, newIdNo, Optional.ofNullable(newGender).orElse(Gender.UNKNOWN).ordinal(), phoneNo);
} }
} }
return 0; return 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment