添加退出
This commit is contained in:
parent
ba0c98253c
commit
79a4e26f4e
|
|
@ -107,4 +107,16 @@ public class AccountController : CloudGamingControllerBase
|
||||||
AccountBLL account = new AccountBLL(ServiceProvider);
|
AccountBLL account = new AccountBLL(ServiceProvider);
|
||||||
return await account.UpdateUserNickName(accountNickNameRequest.NickName);
|
return await account.UpdateUserNickName(accountNickNameRequest.NickName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 退出app
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
[HttpGet]
|
||||||
|
public async Task<bool> ExitApp()
|
||||||
|
{
|
||||||
|
AccountBLL account = new AccountBLL(ServiceProvider);
|
||||||
|
await account.ExitApp();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -78,10 +78,10 @@ public class PlayGameController : CloudGamingControllerBase
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Authorize]
|
[Authorize]
|
||||||
public async Task<BaseResponse<bool>> ExitPlayGame([FromBody] GameRequest gameRequest)
|
public async Task<BaseResponse<bool>> ExitPlayGame([FromBody] ExitPlayGameRequest gameRequest)
|
||||||
{
|
{
|
||||||
PlayGameBLL playGameBLL = new PlayGameBLL(ServiceProvider, JYApi);
|
PlayGameBLL playGameBLL = new PlayGameBLL(ServiceProvider, JYApi);
|
||||||
return await playGameBLL.ExitPlayGame(gameRequest.GameId);
|
return await playGameBLL.ExitPlayGame(gameRequest);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -702,5 +702,25 @@ namespace CloudGaming.Code.Account
|
||||||
return new BaseResponse<bool>(ResponseCode.Success, "", true);
|
return new BaseResponse<bool>(ResponseCode.Success, "", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 退出App
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task ExitApp()
|
||||||
|
{
|
||||||
|
if (_UserId == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//redis
|
||||||
|
var userInfo = await AccountExtend.GetUserInfoOrNull(_UserId, this);
|
||||||
|
if (userInfo != null)
|
||||||
|
{
|
||||||
|
await userInfo.DeleteUserInfoCache(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ using HuanMeng.DotNetCore.Redis;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
|
using SKIT.FlurlHttpClient.Wechat.TenpayV3.Models;
|
||||||
|
|
||||||
using StackExchange.Redis;
|
using StackExchange.Redis;
|
||||||
|
|
||||||
using Swashbuckle.AspNetCore.SwaggerGen;
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
||||||
|
|
@ -110,6 +112,41 @@ namespace CloudGaming.Code.Account
|
||||||
return userInfoCache;
|
return userInfoCache;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取用户信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <param name="cloudGamingBase"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<UserInfoCache?> GetUserInfoOrNull(int userId, CloudGamingBase cloudGamingBase)
|
||||||
|
{
|
||||||
|
if (userId == 0)
|
||||||
|
{
|
||||||
|
return new UserInfoCache();
|
||||||
|
}
|
||||||
|
string key = GetUserInfoRedisKey(userId);
|
||||||
|
var userInfo = await cloudGamingBase.RedisCache.StringGetAsync<UserInfoCache>(key);
|
||||||
|
return userInfo;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除用户缓存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="cloudGamingBase"></param>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static async Task<bool> DeleteUserInfoCache(this UserInfoCache userInfoCache, CloudGamingBase cloudGamingBase)
|
||||||
|
{
|
||||||
|
if (userInfoCache == null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
string key = GetUserInfoRedisKey(userInfoCache.UserId);
|
||||||
|
return await cloudGamingBase.RedisCache.KeyDeleteAsync(key);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 刷新用户钻石,和是否支付缓存
|
/// 刷新用户钻石,和是否支付缓存
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -306,14 +306,14 @@ public class PlayGameBLL : CloudGamingBase
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="gameId"></param>
|
/// <param name="gameId"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public async Task<BaseResponse<bool>> ExitPlayGame(string gameId)
|
public async Task<BaseResponse<bool>> ExitPlayGame(ExitPlayGameRequest gameRequest)
|
||||||
{
|
{
|
||||||
// 检查用户是否已登录
|
// 检查用户是否已登录
|
||||||
if (_UserId == 0)
|
if (_UserId == 0)
|
||||||
{
|
{
|
||||||
throw MessageBox.ErrorShow("请先登录");
|
throw MessageBox.ErrorShow("请先登录");
|
||||||
}
|
}
|
||||||
|
var gameId = gameRequest.GameId;
|
||||||
// 检查游戏是否存在
|
// 检查游戏是否存在
|
||||||
var gameCache = Cache.GameEntityCache;
|
var gameCache = Cache.GameEntityCache;
|
||||||
var gameInfo = gameCache[gameId];
|
var gameInfo = gameCache[gameId];
|
||||||
|
|
@ -335,7 +335,7 @@ public class PlayGameBLL : CloudGamingBase
|
||||||
Sn = gameInfoCache.Sn
|
Sn = gameInfoCache.Sn
|
||||||
};
|
};
|
||||||
var obj = await JYApi.StopGame(playGameQueue);
|
var obj = await JYApi.StopGame(playGameQueue);
|
||||||
gameInfoCache.ExitPlayGame(obj);
|
gameInfoCache.ExitPlayGame(obj, gameRequest);
|
||||||
await gameInfoCache.SaveChangesAsync(this);
|
await gameInfoCache.SaveChangesAsync(this);
|
||||||
}
|
}
|
||||||
return new BaseResponse<bool>(ResponseCode.Success, "", true);
|
return new BaseResponse<bool>(ResponseCode.Success, "", true);
|
||||||
|
|
|
||||||
|
|
@ -124,7 +124,7 @@ namespace CloudGaming.Code.Game
|
||||||
/// <param name="modenName"></param>
|
/// <param name="modenName"></param>
|
||||||
/// <param name="cpu"></param>
|
/// <param name="cpu"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public static bool ExitPlayGame(this PlayGameUserInfo playGameUserInfo, IJYApiRespnse jYApiRespnse)
|
public static bool ExitPlayGame(this PlayGameUserInfo playGameUserInfo, IJYApiRespnse jYApiRespnse, ExitPlayGameRequest gameRequest)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (playGameUserInfo.GameStatus != PlayGameStatus.用户主动结束游戏)
|
if (playGameUserInfo.GameStatus != PlayGameStatus.用户主动结束游戏)
|
||||||
|
|
@ -134,8 +134,18 @@ namespace CloudGaming.Code.Game
|
||||||
{
|
{
|
||||||
OperationDateTime = DateTime.Now,
|
OperationDateTime = DateTime.Now,
|
||||||
Content = "用户主动结束游戏",
|
Content = "用户主动结束游戏",
|
||||||
ActionId = (int)PlayGameStatus.用户主动结束游戏
|
ActionId = (int)PlayGameStatus.用户主动结束游戏,
|
||||||
});
|
});
|
||||||
|
if (!string.IsNullOrEmpty(gameRequest.PlayGameDetails))
|
||||||
|
{
|
||||||
|
playGameUserInfo.GameUserOperation.Add(new PlayGameUserOperation()
|
||||||
|
{
|
||||||
|
OperationDateTime = DateTime.Now,
|
||||||
|
Content = "用户玩游戏情况",
|
||||||
|
ActionId = (int)PlayGameStatus.游戏状态,
|
||||||
|
RequestContent = gameRequest.PlayGameDetails ?? ""
|
||||||
|
});
|
||||||
|
}
|
||||||
playGameUserInfo.LastDateTime = DateTime.Now;
|
playGameUserInfo.LastDateTime = DateTime.Now;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
|
|
@ -25,4 +25,30 @@ public class MonitorBLL : CloudGamingBase
|
||||||
{
|
{
|
||||||
return AppConfig.GetAppMonitorInfo().ToAppBasicStatistics();
|
return AppConfig.GetAppMonitorInfo().ToAppBasicStatistics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取近一月活跃人数统计
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task GetActiveUserCount()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取近一月登录人数统计
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task GetLoginUserCount()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取近一月注册人数统计
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public async Task GetRegisteredUserCount()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,21 @@
|
||||||
|
using CloudGaming.DtoModel.Game;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace CloudGaming.DtoModel.PlayGame
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 退出游戏
|
||||||
|
/// </summary>
|
||||||
|
public class ExitPlayGameRequest : GameRequest
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 游玩详情,网络,帧率
|
||||||
|
/// </summary>
|
||||||
|
public string PlayGameDetails { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -137,7 +137,11 @@ public enum PlayGameStatus
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 切换视频等级
|
/// 切换视频等级
|
||||||
/// </summary>
|
/// </summary>
|
||||||
切换视频等级 = 51
|
切换视频等级 = 51,
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
游戏状态 = 52,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user