diff --git a/src/CloudGaming/Api/CloudGaming.Api/Controllers/AccountController.cs b/src/CloudGaming/Api/CloudGaming.Api/Controllers/AccountController.cs index e6bba4c..a847d5a 100644 --- a/src/CloudGaming/Api/CloudGaming.Api/Controllers/AccountController.cs +++ b/src/CloudGaming/Api/CloudGaming.Api/Controllers/AccountController.cs @@ -119,4 +119,18 @@ public class AccountController : CloudGamingControllerBase await account.ExitApp(); return true; } + + /// + /// 账号注销 + /// + /// + [HttpPost] + [Message("注销成功")] + public async Task AccountLogOff() + { + AccountBLL account = new AccountBLL(ServiceProvider); + await account.AccountLogOff(); + return true; + } + } diff --git a/src/CloudGaming/Code/CloudGaming.Code/Account/AccountBLL.cs b/src/CloudGaming/Code/CloudGaming.Code/Account/AccountBLL.cs index a0b5632..4cf7e2d 100644 --- a/src/CloudGaming/Code/CloudGaming.Code/Account/AccountBLL.cs +++ b/src/CloudGaming/Code/CloudGaming.Code/Account/AccountBLL.cs @@ -719,8 +719,36 @@ namespace CloudGaming.Code.Account { await userInfo.DeleteUserInfoCache(this); } - - + } + /// + /// 账号注销 + /// + /// + public async Task AccountLogOff() + { + if (_UserId == 0) + { + return; + } + //redis + //用户信息 + var user = await Dao.DaoUser.Context.T_User.FirstOrDefaultAsync(it => it.Id == _UserId); + if (user != null) + { + user.State = 1; + } + //用户手机号登录表 + var userData = await Dao.DaoUser.Context.T_User_Phone_Account.FirstOrDefaultAsync(it => it.UserId == _UserId); + if (userData != null) + { + userData.IsLogout = true; + } + await Dao.DaoUser.Context.SaveChangesAsync(); + var userInfo = await AccountExtend.GetUserInfoOrNull(_UserId, this); + if (userInfo != null) + { + await userInfo.DeleteUserInfoCache(this); + } } } }