|
@@ -76,20 +76,43 @@ public class FsUserInfoServiceImpl extends ServiceImpl<FsUserInfoMapper, FsUserI
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional
|
|
|
- public int updateFsUserInfo(FsUserInfo fsUserInfo) {
|
|
|
- // 若手机号有修改 需校验手机号是否已存在 且不修改fs_user表的手机号
|
|
|
- if(StringUtils.isNotEmpty(fsUserInfo.getPhone())){
|
|
|
- FsUserInfo user = baseMapper.selectFsUserInfoById(fsUserInfo.getUserId());
|
|
|
- if(user== null){
|
|
|
- throw new ServiceException("用户已注销或不存在");
|
|
|
+ public void updateFsUserInfo(FsUserInfo fsUserInfo) {
|
|
|
+ // 微信小程序的用户 没有登录fs_user表
|
|
|
+ FsUser userQuery = fsUserService.selectFsUserById(fsUserInfo.getUserId());
|
|
|
+ if(userQuery==null){
|
|
|
+ throw new ServiceException("用户已注销或不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ FsUserInfo userInfo = baseMapper.selectFsUserInfoByIdOnle(fsUserInfo.getUserId());
|
|
|
+ if(userInfo==null){
|
|
|
+ if(StringUtils.isEmpty(fsUserInfo.getPhone())){
|
|
|
+ throw new ServiceException("手机号不能为空");
|
|
|
}
|
|
|
|
|
|
- if(!user.getPhone().equals(fsUserInfo.getPhone())){// 若要修改手机号需要验证新的手机号是否存在
|
|
|
- FsUserInfo userInfo = baseMapper.selectFsUserInfoByPhone(fsUserInfo.getPhone());
|
|
|
- if(userInfo!=null){
|
|
|
- throw new ServiceException("该手机号已存在");
|
|
|
+ // 查询手机号
|
|
|
+ FsUserInfo queryByPhone = baseMapper.selectFsUserInfoByPhone(fsUserInfo.getPhone());
|
|
|
+ if(queryByPhone!=null){
|
|
|
+ throw new ServiceException("该手机号用户已存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ // 需登记FsUserInfo 信息
|
|
|
+ if (baseMapper.insertFsUserInfo(fsUserInfo)<=0){
|
|
|
+ throw new ServiceException("用户信息登记失败");
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ // 若手机号有修改 需校验手机号是否已存在 且不修改fs_user表的手机号
|
|
|
+ if(StringUtils.isNotEmpty(fsUserInfo.getPhone())){
|
|
|
+ if(!userInfo.getPhone().equals(fsUserInfo.getPhone())){// 若要修改手机号需要验证新的手机号是否存在
|
|
|
+ FsUserInfo queryByPhone = baseMapper.selectFsUserInfoByPhone(fsUserInfo.getPhone());
|
|
|
+ if(queryByPhone!=null){
|
|
|
+ throw new ServiceException("该手机号用户已存在");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ fsUserInfo.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ if(baseMapper.updateFsUserInfo(fsUserInfo)<=0){
|
|
|
+ throw new ServiceException("用户信息修改失败");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
// 更新用户信息 不修改手机号
|
|
@@ -104,9 +127,6 @@ public class FsUserInfoServiceImpl extends ServiceImpl<FsUserInfoMapper, FsUserI
|
|
|
throw new ServiceException("用户信息修改失败");
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- fsUserInfo.setUpdateTime(DateUtils.getNowDate());
|
|
|
- return baseMapper.updateFsUserInfo(fsUserInfo);
|
|
|
}
|
|
|
|
|
|
/**
|