商家注销功能
This commit is contained in:
parent
b8406deda7
commit
f1204cf2d0
@ -10,6 +10,7 @@ import cn.hutool.core.util.StrUtil;
|
||||
import com.suisung.mall.account.service.*;
|
||||
import com.suisung.mall.common.api.CommonResult;
|
||||
import com.suisung.mall.common.api.ResultCode;
|
||||
import com.suisung.mall.common.api.StateCode;
|
||||
import com.suisung.mall.common.constant.CommonConstant;
|
||||
import com.suisung.mall.common.domain.UserDto;
|
||||
import com.suisung.mall.common.exception.ApiException;
|
||||
@ -21,6 +22,7 @@ import com.suisung.mall.common.modules.distribution.ShopDistributionUserCommissi
|
||||
import com.suisung.mall.common.modules.pay.PayUserResource;
|
||||
import com.suisung.mall.common.service.impl.BaseControllerImpl;
|
||||
import com.suisung.mall.common.utils.CheckUtil;
|
||||
import com.suisung.mall.common.utils.ContextUtil;
|
||||
import com.suisung.mall.common.utils.I18nUtil;
|
||||
import com.suisung.mall.common.utils.phone.PhoneNumberUtils;
|
||||
import io.swagger.annotations.Api;
|
||||
@ -310,5 +312,22 @@ public class UserController extends BaseControllerImpl {
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
@ApiOperation(value = "注销账号")
|
||||
@RequestMapping(value = "/cancleAccount", method = RequestMethod.POST)
|
||||
public CommonResult cancleAccount(@RequestParam(name = "cancelReason") String cancelReason) {
|
||||
UserDto user = ContextUtil.getCurrentUser();
|
||||
if (user == null) {
|
||||
throw new ApiException(I18nUtil._("用户信息异常!"));
|
||||
}
|
||||
AccountUserBase userBase = new AccountUserBase();
|
||||
userBase.setUser_id(user.getId());
|
||||
userBase.setCancel_reason(cancelReason);
|
||||
userBase.setUser_state(StateCode.USER_STATE_CANCLE);//账号注销
|
||||
if (!accountUserBaseService.edit(userBase)) {
|
||||
throw new ApiException(I18nUtil._("注销失败!"));
|
||||
}
|
||||
return CommonResult.success();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -113,4 +113,8 @@ public class SecurityUser implements UserDetails {
|
||||
return this.user_state != null && this.user_state != 0;
|
||||
}
|
||||
|
||||
public boolean isCancle() {
|
||||
return this.user_state != null && this.user_state ==3;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -57,6 +57,8 @@ public class UserServiceImpl implements UserDetailsService {
|
||||
throw new AccountExpiredException(MessageConstant.ACCOUNT_EXPIRED);
|
||||
} else if (!securityUser.isCredentialsNonExpired()) {
|
||||
throw new CredentialsExpiredException(MessageConstant.CREDENTIALS_EXPIRED);
|
||||
} if (securityUser.isCancle()) {
|
||||
throw new DisabledException(MessageConstant.ACCOUNT_CANCLE);
|
||||
}
|
||||
return securityUser;
|
||||
}
|
||||
|
||||
@ -38,6 +38,7 @@ public class StateCode {
|
||||
public static final int USER_STATE_LOCKING = 0; //用户状态:锁定
|
||||
public static final int USER_STATE_NOTACTIVE = 1; //用户状态:未激活
|
||||
public static final int USER_STATE_ACTIVATION = 2; //用户状态:已激活
|
||||
public static final int USER_STATE_CANCLE = 3; //用户状态:注销
|
||||
|
||||
public static final int PRODUCT_STATE_ILLEGAL = 1000; //违规下架禁售
|
||||
public static final int PRODUCT_STATE_NORMAL = 1001; //正常
|
||||
|
||||
@ -45,7 +45,7 @@ public class AccountUserBase implements Serializable {
|
||||
@ApiModelProperty(value = " 用户昵称")
|
||||
private String user_nickname;
|
||||
|
||||
@ApiModelProperty(value = "状态(ENUM):0-锁定;1-未激活;2-已激活;")
|
||||
@ApiModelProperty(value = "状态(ENUM):0-锁定;1-未激活;2-已激活;3-已注销;")
|
||||
private Integer user_state;
|
||||
|
||||
@ApiModelProperty(value = "Cookie加密Key:修改密码更改 登录修改涉及多端,影响用户中心")
|
||||
@ -92,5 +92,6 @@ public class AccountUserBase implements Serializable {
|
||||
@ApiModelProperty(value = "更新时间")
|
||||
private Date updated_at;
|
||||
|
||||
|
||||
@ApiModelProperty(value = "注销理由")
|
||||
private String cancel_reason;
|
||||
}
|
||||
|
||||
1
sql/shop/dev/20250916_ddl.sql
Normal file
1
sql/shop/dev/20250916_ddl.sql
Normal file
@ -0,0 +1 @@
|
||||
alter table account_user_base add column cancel_reason text default NULL comment '注销理由';
|
||||
Loading…
Reference in New Issue
Block a user