修改扩展
This commit is contained in:
parent
4086acade3
commit
2feb295a6a
|
|
@ -13,7 +13,7 @@ namespace CloudGaming.Code.Monitor
|
|||
/// <summary>
|
||||
/// 游戏控制器
|
||||
/// </summary>
|
||||
[QuartzTrigger("GameMonitorProcessor", "* 05 4 * * ?")]
|
||||
[QuartzTrigger("GameMonitorProcessor", "* 5 4 * * ?")]
|
||||
public class GameMonitorProcessor : AppJobBase
|
||||
{
|
||||
public GameMonitorProcessor(IServiceScopeFactory scopeFactory) : base(scopeFactory)
|
||||
|
|
@ -71,11 +71,17 @@ namespace CloudGaming.Code.Monitor
|
|||
statisticsUser.UpdatedAt = DateTime.Now;
|
||||
}
|
||||
|
||||
foreach (var item in gamePlayCount)
|
||||
var list = dao.DaoExt.Context.T_App_Channel.ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
UpdateStatistics(item.Key, item.Value, gamePlaySeconds.GetValueOrDefault(item.Key, 0), gamePlayLog.GetValueOrDefault(item.Key, 0));
|
||||
}
|
||||
var key = item.ChannelId;
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
key = "27001";
|
||||
}
|
||||
UpdateStatistics(key, gamePlayCount.GetValueOrDefault(key, 0), gamePlaySeconds.GetValueOrDefault(key, 0), gamePlayLog.GetValueOrDefault(key, 0));
|
||||
|
||||
}
|
||||
await dao.DaoExt.Context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using CloudGaming.Code.DataAccess;
|
||||
using CloudGaming.DtoModel.Other;
|
||||
|
||||
using HuanMeng.DotNetCore.QuartzExtend;
|
||||
|
|
@ -39,6 +40,18 @@ public class OrderMonitorProcessor : AppJobBase
|
|||
.Where(it => it.LoginDay == day)
|
||||
.ToDictionaryAsync(it => it.Channel ?? "");
|
||||
|
||||
var list = dao.DaoExt.Context.T_App_Channel.ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var key = item.ChannelId;
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
key = "27001";
|
||||
}
|
||||
UpdateStatistics(key, intendedOrder.GetValueOrDefault(key, 0), paidOrders.GetValueOrDefault(key, 0), paidOrdersPrice.GetValueOrDefault(key, 0));
|
||||
|
||||
}
|
||||
await dao.DaoExt.Context.SaveChangesAsync();
|
||||
// 更新或创建统计记录
|
||||
void UpdateStatistics(string channel, int intendedOrderCount, int paidOrders, decimal rechargeAmount)
|
||||
{
|
||||
|
|
@ -63,12 +76,7 @@ public class OrderMonitorProcessor : AppJobBase
|
|||
statisticsUser.PaidOrders = paidOrders;
|
||||
statisticsUser.UpdatedAt = DateTime.Now;
|
||||
}
|
||||
foreach (var item in intendedOrder)
|
||||
{
|
||||
UpdateStatistics(item.Key, item.Value, paidOrders.GetValueOrDefault(item.Key, 0), paidOrdersPrice.GetValueOrDefault(item.Key, 0));
|
||||
}
|
||||
|
||||
await dao.DaoExt.Context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -89,19 +97,32 @@ public class OrderHourMonitorProcessor : AppJobBase
|
|||
int dayHour = int.Parse(now.ToString("yyyyMMddHH"));
|
||||
var nowDay = DateOnly.FromDateTime(now);
|
||||
//意向订单次数
|
||||
var intendedOrder = await dao.DaoUser.Context.T_User_IntentOrder.Where(it => it.CreatedDay == day && it.CreatedAt >= newDayHour && it.CreatedAt <= oldDayHour).GroupBy(it => it.Channel).ToDictionaryAsync(it => it.Key ?? "", it => it.Count());
|
||||
var intendedOrder = await dao.DaoUser.Context.T_User_IntentOrder.Where(it => it.CreatedDay == day && it.CreatedAt >= newDayHour && it.CreatedAt < oldDayHour).GroupBy(it => it.Channel).ToDictionaryAsync(it => it.Key ?? "", it => it.Count());
|
||||
|
||||
//支付订单次数
|
||||
var paidOrders = await dao.DaoUser.Context.T_User_Order.Where(it => it.PaymentDay == nowDay && it.CreatedAt >= newDayHour && it.CreatedAt <= oldDayHour).GroupBy(it => it.Channel).ToDictionaryAsync(it => it.Key ?? "", it => it.Count());
|
||||
var paidOrders = await dao.DaoUser.Context.T_User_Order.Where(it => it.PaymentDay == nowDay && it.CreatedAt >= newDayHour && it.CreatedAt < oldDayHour).GroupBy(it => it.Channel).ToDictionaryAsync(it => it.Key ?? "", it => it.Count());
|
||||
|
||||
//支付金额
|
||||
var paidOrdersPrice = await dao.DaoUser.Context.T_User_Order.Where(it => it.PaymentDay == nowDay && it.CreatedAt >= newDayHour && it.CreatedAt <= oldDayHour).GroupBy(it => it.Channel).ToDictionaryAsync(it => it.Key ?? "", it => it.Sum(it => it.TotalPrice));
|
||||
var paidOrdersPrice = await dao.DaoUser.Context.T_User_Order.Where(it => it.PaymentDay == nowDay && it.CreatedAt >= newDayHour && it.CreatedAt < oldDayHour).GroupBy(it => it.Channel).ToDictionaryAsync(it => it.Key ?? "", it => it.Sum(it => it.TotalPrice));
|
||||
//数据源
|
||||
var orderStatistics = await dao.DaoExt.Context.T_Statistics_OrderHour
|
||||
.Where(it => it.LoginHour == dayHour)
|
||||
.ToDictionaryAsync(it => it.Channel ?? "");
|
||||
var list = dao.DaoExt.Context.T_App_Channel.ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var key = item.ChannelId;
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
key = "27001";
|
||||
}
|
||||
UpdateStatistics(key, intendedOrder.GetValueOrDefault(key, 0), paidOrders.GetValueOrDefault(key, 0), paidOrdersPrice.GetValueOrDefault(key, 0));
|
||||
}
|
||||
|
||||
|
||||
await dao.DaoExt.Context.SaveChangesAsync();
|
||||
|
||||
|
||||
// 更新或创建统计记录
|
||||
void UpdateStatistics(string channel, int intendedOrderCount, int paidOrders, decimal rechargeAmount)
|
||||
{
|
||||
if (!orderStatistics.TryGetValue(channel, out var statisticsUser))
|
||||
|
|
@ -127,17 +148,6 @@ public class OrderHourMonitorProcessor : AppJobBase
|
|||
statisticsUser.PaidOrders = paidOrders;
|
||||
statisticsUser.UpdatedAt = DateTime.Now;
|
||||
}
|
||||
var list = dao.DaoExt.Context.T_App_Channel.ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
var key = item.ChannelId;
|
||||
UpdateStatistics(key, intendedOrder.GetValueOrDefault(key, 0), paidOrders.GetValueOrDefault(key, 0), paidOrdersPrice.GetValueOrDefault(key, 0));
|
||||
}
|
||||
foreach (var item in intendedOrder)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
await dao.DaoExt.Context.SaveChangesAsync();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace CloudGaming.Code.Monitor;
|
|||
/// <summary>
|
||||
/// 用户定时类
|
||||
/// </summary>
|
||||
[QuartzTrigger("UserMonitorProcessor", "* 15 4 * * ?")]
|
||||
[QuartzTrigger("UserMonitorProcessor", "* 25 4 * * ?")]
|
||||
public class UserMonitorProcessor : AppJobBase
|
||||
{
|
||||
public UserMonitorProcessor(IServiceScopeFactory scopeFactory) : base(scopeFactory)
|
||||
|
|
@ -72,12 +72,17 @@ public class UserMonitorProcessor : AppJobBase
|
|||
statisticsUser.ActiveCount = activeCount;
|
||||
statisticsUser.UpdatedAt = DateTime.Now;
|
||||
}
|
||||
|
||||
foreach (var item in todayLoggedInUsers)
|
||||
var list = dao.DaoExt.Context.T_App_Channel.ToList();
|
||||
foreach (var item in list)
|
||||
{
|
||||
UpdateStatistics(item.Key, item.Value, todayRegisteredUsers.GetValueOrDefault(item.Key, 0), todayActionUsers.GetValueOrDefault(item.Key, 0));
|
||||
}
|
||||
var key = item.ChannelId;
|
||||
if (string.IsNullOrEmpty(key))
|
||||
{
|
||||
key = "27001";
|
||||
}
|
||||
UpdateStatistics(key, todayLoggedInUsers.GetValueOrDefault(key, 0), todayRegisteredUsers.GetValueOrDefault(key, 0), todayActionUsers.GetValueOrDefault(key, 0));
|
||||
|
||||
}
|
||||
await dao.DaoExt.Context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user