修改问题
This commit is contained in:
parent
2ce497c52f
commit
a012665a67
|
|
@ -2,6 +2,7 @@ using Alipay.EasySDK.Kernel;
|
|||
|
||||
using CloudGaming.Code.Account.Contract;
|
||||
using CloudGaming.Code.Contract;
|
||||
using CloudGaming.Code.DataAccess;
|
||||
using CloudGaming.Code.Sms;
|
||||
using CloudGaming.DtoModel.Account;
|
||||
using CloudGaming.DtoModel.Account.Login;
|
||||
|
|
@ -150,13 +151,14 @@ namespace CloudGaming.Code.Account
|
|||
var (deviceList, currentDevice) = await ManageUserDevicesAsync(user, account, jwt.AccessToken);
|
||||
// 管理设备和Redis缓存
|
||||
await ManageDeviceCacheAsync(user.Id, currentDevice.TokenMd5, deviceList);
|
||||
|
||||
var createTimeDay = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
|
||||
var createTimeHour = int.Parse(DateTime.Now.ToString("yyyyMMddHH"));
|
||||
T_User_Login_Log login_Log = new T_User_Login_Log()
|
||||
{
|
||||
Channel = this.AppRequestInfo.Channel,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateTimeDay = 0,
|
||||
CreateTimeHour = 0,
|
||||
CreateTimeDay = createTimeDay,
|
||||
CreateTimeHour = createTimeHour,
|
||||
AppVersion = this.AppRequestInfo.Version,
|
||||
Ip = ip,
|
||||
IsNew = isNew,
|
||||
|
|
@ -165,7 +167,37 @@ namespace CloudGaming.Code.Account
|
|||
UserId = user.Id,
|
||||
};
|
||||
await Dao.DaoExt.Context.AddAsync(login_Log);
|
||||
var isUserLogDay = await Dao.DaoExt.Context.T_User_LoginDay_Log.AnyAsync(it => it.UserId == user.Id && it.CreateTimeDay == createTimeDay);
|
||||
if (!isUserLogDay)
|
||||
{
|
||||
var logInDay = 0;
|
||||
if (!isNew)
|
||||
{
|
||||
var oldCreateTimeDay = int.Parse(DateTime.Now.AddDays(-1).ToString("yyyyMMdd"));
|
||||
var oldUserLog = await Dao.DaoExt.Context.T_User_LoginDay_Log.FirstOrDefaultAsync(it => it.UserId == user.Id && it.CreateTimeDay == oldCreateTimeDay);
|
||||
if (oldUserLog != null)
|
||||
{
|
||||
logInDay = oldUserLog.LogInDay++;
|
||||
}
|
||||
}
|
||||
|
||||
T_User_LoginDay_Log user_LoginDay_Log = new T_User_LoginDay_Log()
|
||||
{
|
||||
Channel = this.AppRequestInfo.Channel,
|
||||
CreateTime = DateTime.Now,
|
||||
CreateTimeDay = createTimeDay,
|
||||
CreateTimeHour = createTimeHour,
|
||||
AppVersion = this.AppRequestInfo.Version,
|
||||
Ip = ip,
|
||||
IsNew = isNew,
|
||||
LogInDay = logInDay,
|
||||
PlatformType = this.AppRequestInfo.Platform,
|
||||
UserId = user.Id,
|
||||
};
|
||||
await Dao.DaoExt.Context.AddAsync(user_LoginDay_Log);
|
||||
}
|
||||
await Dao.DaoExt.Context.SaveChangesAsync();
|
||||
|
||||
return accountLogIn;
|
||||
}
|
||||
#region 注册用户
|
||||
|
|
|
|||
|
|
@ -586,7 +586,7 @@ namespace CloudGaming.Code.Game
|
|||
|
||||
{
|
||||
//只有不等于下面这几种状态才记录游玩记录
|
||||
if (playGameUserInfo.GameStatus != PlayGameStatus.排队掉线 && playGameUserInfo.GameStatus != PlayGameStatus.取消排队 && playGameUserInfo.GameStatus != PlayGameStatus.排队掉线结束游戏 && playGameUserInfo.GameStatus != PlayGameStatus.排队掉线 && playGameUserInfo.GameStatus != PlayGameStatus.游戏启动失败 && playGameUserInfo.GameStatus != PlayGameStatus.用户钻石不足)
|
||||
if (playGameUserInfo.GameStatus != PlayGameStatus.排队掉线 && playGameUserInfo.GameStatus != PlayGameStatus.取消排队 && playGameUserInfo.GameStatus != PlayGameStatus.排队掉线结束游戏 && playGameUserInfo.GameStatus != PlayGameStatus.游戏启动失败 && playGameUserInfo.GameStatus != PlayGameStatus.用户钻石不足)
|
||||
{
|
||||
T_User_GameList userGameListLog = null;
|
||||
if (playGameUserInfo.DiamondListId > 0)
|
||||
|
|
@ -601,7 +601,7 @@ namespace CloudGaming.Code.Game
|
|||
Channel = playGameUserInfo.Channel,
|
||||
CreateTime = playGameUserInfo.PlayGameStartAt ?? playGameUserInfo.CreateDateTime,
|
||||
GameId = playGameUserInfo.GameId,
|
||||
Status = (int)PlayGameStatus.开始游戏,
|
||||
Status = (int)PlayGameStatus.游戏结束,
|
||||
UpdateTime = DateTime.Now,
|
||||
UserId = playGameUserInfo.UserId,
|
||||
SessionId = playGameUserInfo?.SessionId
|
||||
|
|
@ -610,9 +610,9 @@ namespace CloudGaming.Code.Game
|
|||
}
|
||||
userGameListLog.Status = (int)PlayGameStatus.游戏结束;
|
||||
|
||||
var t = DateTime.Now.Subtract(playGameUserInfo.PlayGameStartAt ?? playGameUserInfo.CreateDateTime);
|
||||
var playTime = (int)t.TotalSeconds / 60;
|
||||
userGameListLog.PlaySeconds = (int)t.TotalSeconds;
|
||||
|
||||
var playTime = playGameUserInfo.PlayGameTotalSeconds / 60;
|
||||
userGameListLog.PlaySeconds = playGameUserInfo.PlayGameTotalSeconds;
|
||||
userGameListLog.PlayTime = playTime;
|
||||
userGameListLog.UpdateTime = DateTime.Now;
|
||||
await dao.DaoPhone.Context.SaveChangesAsync();
|
||||
|
|
@ -653,6 +653,7 @@ namespace CloudGaming.Code.Game
|
|||
OperationDateTime = DateTime.Now,
|
||||
ActionId = (int)PlayGameStatus.游戏结束
|
||||
});
|
||||
playGameUserInfo.GameStatus = PlayGameStatus.游戏结束;
|
||||
var playGameLog = playGameUserInfo.ToGamePlayGameLog();
|
||||
if (playGameLog != null)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -59,6 +59,11 @@ public partial class CloudGamingCBTContext : DbContext
|
|||
/// </summary>
|
||||
public virtual DbSet<T_Sms_Log> T_Sms_Log { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户登录日志表,每天每个用户只有一条数据
|
||||
/// </summary>
|
||||
public virtual DbSet<T_User_LoginDay_Log> T_User_LoginDay_Log { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户登录日志表
|
||||
/// </summary>
|
||||
|
|
@ -70,7 +75,7 @@ public partial class CloudGamingCBTContext : DbContext
|
|||
public virtual DbSet<T_User_RealAuthentication_Log> T_User_RealAuthentication_Log { get; set; }
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{// => optionsBuilder.UseSqlServer("Server=192.168.195.6;Database=CloudGamingCBT;User Id=sa;Password=Dbt@com@123;TrustServerCertificate=true;");
|
||||
{// => optionsBuilder.UseSqlServer("Server=192.168.195.8;Database=CloudGamingCBT;User Id=sa;Password=Dbt@com@123;TrustServerCertificate=true;");
|
||||
}
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
|
|
@ -180,6 +185,38 @@ public partial class CloudGamingCBTContext : DbContext
|
|||
|
||||
});
|
||||
|
||||
modelBuilder.Entity<T_User_LoginDay_Log>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__T_User_L__3214EC0786EBC26A");
|
||||
|
||||
entity.ToTable(tb => tb.HasComment("用户登录日志表,每天每个用户只有一条数据"));
|
||||
|
||||
entity.HasIndex(e => new { e.UserId, e.CreateTimeDay }, "T_UserLogDay_UserId").IsDescending(false, true);
|
||||
|
||||
entity.Property(e => e.Id).HasComment("主键");
|
||||
entity.Property(e => e.AppVersion)
|
||||
.HasMaxLength(10)
|
||||
.HasComment("app版本");
|
||||
entity.Property(e => e.Channel)
|
||||
.HasMaxLength(20)
|
||||
.HasComment("渠道号");
|
||||
entity.Property(e => e.CreateTime)
|
||||
.HasComment("创建时间")
|
||||
.HasColumnType("datetime");
|
||||
entity.Property(e => e.CreateTimeDay).HasComment("登录时间,天");
|
||||
entity.Property(e => e.CreateTimeHour).HasComment("登录时间,小时");
|
||||
entity.Property(e => e.Ip)
|
||||
.HasMaxLength(50)
|
||||
.HasComment("ip地址");
|
||||
entity.Property(e => e.IsNew).HasComment("是否新用户");
|
||||
entity.Property(e => e.LogInDay).HasComment("连续登录天数");
|
||||
entity.Property(e => e.PlatformType)
|
||||
.HasMaxLength(10)
|
||||
.HasComment("登录平台");
|
||||
entity.Property(e => e.UserId).HasComment("用户Id");
|
||||
|
||||
});
|
||||
|
||||
modelBuilder.Entity<T_User_Login_Log>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id).HasName("PK__T_User_L__3214EC07C2A990A7");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using System;
|
||||
using System;
|
||||
|
||||
namespace CloudGaming.GameModel.Db.Db_Ext;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
using System;
|
||||
|
||||
namespace CloudGaming.GameModel.Db.Db_Ext;
|
||||
|
||||
/// <summary>
|
||||
/// 用户登录日志表,每天每个用户只有一条数据
|
||||
/// </summary>
|
||||
public partial class T_User_LoginDay_Log
|
||||
{
|
||||
public T_User_LoginDay_Log() { }
|
||||
|
||||
/// <summary>
|
||||
/// 主键
|
||||
/// </summary>
|
||||
public virtual int Id { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 用户Id
|
||||
/// </summary>
|
||||
public virtual int UserId { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// ip地址
|
||||
/// </summary>
|
||||
public virtual string Ip { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 是否新用户
|
||||
/// </summary>
|
||||
public virtual bool IsNew { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 登录平台
|
||||
/// </summary>
|
||||
public virtual string PlatformType { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// app版本
|
||||
/// </summary>
|
||||
public virtual string AppVersion { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 登录时间,天
|
||||
/// </summary>
|
||||
public virtual int CreateTimeDay { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 登录时间,小时
|
||||
/// </summary>
|
||||
public virtual int CreateTimeHour { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 创建时间
|
||||
/// </summary>
|
||||
public virtual DateTime CreateTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 渠道号
|
||||
/// </summary>
|
||||
public virtual string Channel { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// 连续登录天数
|
||||
/// </summary>
|
||||
public virtual int LogInDay { get; set; }
|
||||
}
|
||||
|
|
@ -9,5 +9,5 @@ dotnet ef dbcontext scaffold "Server=192.168.195.6;Database=CloudGamingGame;User
|
|||
--Ext
|
||||
dotnet ef dbcontext scaffold "Server=192.168.1.17;Database=CloudGamingCBT;User Id=sa;Password=Dbt@com@123;TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer -o Db/Db_Ext/ --use-database-names --no-pluralize --force
|
||||
内网穿透
|
||||
dotnet ef dbcontext scaffold "Server=192.168.195.6;Database=CloudGamingCBT;User Id=sa;Password=Dbt@com@123;TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer -o Db/Db_Ext/ --use-database-names --no-pluralize --force
|
||||
dotnet ef dbcontext scaffold "Server=192.168.195.8;Database=CloudGamingCBT;User Id=sa;Password=Dbt@com@123;TrustServerCertificate=true;" Microsoft.EntityFrameworkCore.SqlServer -o Db/Db_Ext/ --use-database-names --no-pluralize --force
|
||||
```
|
||||
Loading…
Reference in New Issue
Block a user