|
@@ -14,8 +14,8 @@ import shop.alien.entity.store.LifeUser;
|
|
|
import shop.alien.entity.store.dto.LifeFansFollowOutcome;
|
|
import shop.alien.entity.store.dto.LifeFansFollowOutcome;
|
|
|
import shop.alien.entity.store.vo.LifeUserVo;
|
|
import shop.alien.entity.store.vo.LifeUserVo;
|
|
|
import shop.alien.mapper.LifeUserMapper;
|
|
import shop.alien.mapper.LifeUserMapper;
|
|
|
-import shop.alien.store.config.BaseRedisService;
|
|
|
|
|
import shop.alien.store.service.LifeUserService;
|
|
import shop.alien.store.service.LifeUserService;
|
|
|
|
|
+import shop.alien.store.util.ali.AliSms;
|
|
|
import shop.alien.util.common.FileUpload;
|
|
import shop.alien.util.common.FileUpload;
|
|
|
import shop.alien.util.common.RandomCreateUtil;
|
|
import shop.alien.util.common.RandomCreateUtil;
|
|
|
|
|
|
|
@@ -41,7 +41,7 @@ public class LifeUserController {
|
|
|
|
|
|
|
|
private final LifeUserMapper lifeUserMapper;
|
|
private final LifeUserMapper lifeUserMapper;
|
|
|
|
|
|
|
|
- private final BaseRedisService baseRedisService;
|
|
|
|
|
|
|
+ private final AliSms aliSms;
|
|
|
|
|
|
|
|
@ApiOperation("查询用户信息")
|
|
@ApiOperation("查询用户信息")
|
|
|
@ApiOperationSupport(order = 2)
|
|
@ApiOperationSupport(order = 2)
|
|
@@ -168,16 +168,37 @@ public class LifeUserController {
|
|
|
@ApiOperation("用户端注销用户")
|
|
@ApiOperation("用户端注销用户")
|
|
|
@PostMapping("/liftCancelAccount")
|
|
@PostMapping("/liftCancelAccount")
|
|
|
public R<Boolean> liftCancelAccount(@RequestBody LifeUserVo user) {
|
|
public R<Boolean> liftCancelAccount(@RequestBody LifeUserVo user) {
|
|
|
- log.info("StoreUserController.liftCancelAccount?LifeUserVo={}", user.toString());
|
|
|
|
|
- // 2025-11-04 验证码-用户端注销账号
|
|
|
|
|
- String cacheCode = baseRedisService.getString("verification_user_cancel_account_" + user.getUserPhone());
|
|
|
|
|
- if (null == cacheCode) {
|
|
|
|
|
- return R.fail("验证码过期或未发送");
|
|
|
|
|
|
|
+ log.info("LifeUserController.liftCancelAccount?LifeUserVo={}", user);
|
|
|
|
|
+ if (user.getId() == null) {
|
|
|
|
|
+ return R.fail("用户id不能为空");
|
|
|
}
|
|
}
|
|
|
- if (!cacheCode.trim().equals(user.getVerificationCode().trim())) {
|
|
|
|
|
- return R.fail("验证码错误");
|
|
|
|
|
|
|
+ LifeUser lifeUser = lifeUserMapper.selectById(user.getId());
|
|
|
|
|
+ if (lifeUser == null) {
|
|
|
|
|
+ return R.fail("用户不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (lifeUser.getLogoutFlag() != null && lifeUser.getLogoutFlag() == 1) {
|
|
|
|
|
+ return R.fail("账号已在注销中");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!StringUtils.hasText(lifeUser.getUserPhone())) {
|
|
|
|
|
+ return R.fail("用户手机号不存在");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!StringUtils.hasText(user.getVerificationCode())) {
|
|
|
|
|
+ return R.fail("验证码不能为空");
|
|
|
|
|
+ }
|
|
|
|
|
+ int code;
|
|
|
|
|
+ try {
|
|
|
|
|
+ code = Integer.parseInt(user.getVerificationCode().trim());
|
|
|
|
|
+ } catch (NumberFormatException e) {
|
|
|
|
|
+ return R.fail("验证码格式错误");
|
|
|
|
|
+ }
|
|
|
|
|
+ if (!aliSms.checkSmsCode(lifeUser.getUserPhone(), 0, 5, code)) {
|
|
|
|
|
+ return R.fail("验证码错误或已过期");
|
|
|
|
|
+ }
|
|
|
|
|
+ try {
|
|
|
|
|
+ service.liftCancelAccount(user);
|
|
|
|
|
+ } catch (IllegalArgumentException e) {
|
|
|
|
|
+ return R.fail(e.getMessage());
|
|
|
}
|
|
}
|
|
|
- service.liftCancelAccount(user);
|
|
|
|
|
return R.success("注销成功");
|
|
return R.success("注销成功");
|
|
|
}
|
|
}
|
|
|
|
|
|