添加会员啦
This commit is contained in:
parent
99fafeac96
commit
37a3882929
|
|
@ -10,7 +10,7 @@
|
|||
"secret": "95BB717C61D1ECB0E9FB82C932CC77FF",
|
||||
"nodes": "http://124.220.55.158:94", //多个节点使用逗号分隔
|
||||
"url": "http://124.220.55.158:94",
|
||||
"env": "PROD",
|
||||
"env": "DEV",
|
||||
"UserName": "admin",
|
||||
"Password": "dbt@com@1234"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -14,416 +14,414 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudGaming.Code.Account
|
||||
namespace CloudGaming.Code.Account;
|
||||
|
||||
public static class UserCurrencyExtend
|
||||
{
|
||||
public static class UserCurrencyExtend
|
||||
/// <summary>
|
||||
/// 获取用户货币余额,没有货币的时候添加
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <param name="dao"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<decimal> GetUserCurrencyMoney(this T_User user, UserCurrencyType userCurrencyType, DAO dao)
|
||||
{
|
||||
/// <summary>
|
||||
/// 获取用户货币余额,没有货币的时候添加
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <param name="dao"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<decimal> GetUserCurrencyMoney(this T_User user, UserCurrencyType userCurrencyType, DAO dao)
|
||||
var userCurrency = await dao.DaoUser.Context.T_User_Currency.FirstOrDefaultAsync(it => it.UserId == user.Id && it.CurrencyType == (int)userCurrencyType);
|
||||
if (userCurrency == null)
|
||||
{
|
||||
var userCurrency = await dao.DaoUser.Context.T_User_Currency.FirstOrDefaultAsync(it => it.UserId == user.Id && it.CurrencyType == (int)userCurrencyType);
|
||||
if (userCurrency == null)
|
||||
userCurrency = new T_User_Currency()
|
||||
{
|
||||
userCurrency = new T_User_Currency()
|
||||
{
|
||||
CurrencyMoney = 0,
|
||||
CreateAt = DateTime.Now,
|
||||
CurrencyName = userCurrencyType.ToString(),
|
||||
CurrencyType = (int)userCurrencyType,
|
||||
UpdateAt = DateTime.Now,
|
||||
UserId = user.Id,
|
||||
};
|
||||
await dao.DaoUser.Context.AddAsync(userCurrency);
|
||||
await dao.DaoUser.Context.SaveChangesAsync();
|
||||
}
|
||||
return userCurrency?.CurrencyMoney ?? 0;
|
||||
CurrencyMoney = 0,
|
||||
CreateAt = DateTime.Now,
|
||||
CurrencyName = userCurrencyType.ToString(),
|
||||
CurrencyType = (int)userCurrencyType,
|
||||
UpdateAt = DateTime.Now,
|
||||
UserId = user.Id,
|
||||
};
|
||||
await dao.DaoUser.Context.AddAsync(userCurrency);
|
||||
await dao.DaoUser.Context.SaveChangesAsync();
|
||||
}
|
||||
return userCurrency?.CurrencyMoney ?? 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户货币余额
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <param name="dao"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<T_User_Currency> GetUserCurrency(this T_User user, UserCurrencyType userCurrencyType, DAO dao)
|
||||
{
|
||||
var userCurrency = await dao.DaoUser.Context.T_User_Currency.FirstOrDefaultAsync(it => it.UserId == user.Id && it.CurrencyType == (int)userCurrencyType);
|
||||
return userCurrency;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取用户货币余额
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <param name="dao"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<T_User_Currency> GetUserCurrency(this T_User user, UserCurrencyType userCurrencyType, DAO dao)
|
||||
{
|
||||
var userCurrency = await dao.DaoUser.Context.T_User_Currency.FirstOrDefaultAsync(it => it.UserId == user.Id && it.CurrencyType == (int)userCurrencyType);
|
||||
return userCurrency;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户所有货币信息
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <param name="dao"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<List<T_User_Currency>> GetUserCurrencys(this T_User user, DAO dao)
|
||||
{
|
||||
var userCurrency = await dao.DaoUser.Context.T_User_Currency.Where(it => it.UserId == user.Id).ToListAsync();
|
||||
return userCurrency;
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取用户所有货币信息
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="dao"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<List<T_User_Currency>> GetUserCurrencys(this T_User user, DAO dao)
|
||||
{
|
||||
var userCurrency = await dao.DaoUser.Context.T_User_Currency.Where(it => it.UserId == user.Id).ToListAsync();
|
||||
return userCurrency;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扣除或者充值货币
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="userCurrencyType">货币类型</param>
|
||||
/// <param name="money">扣除金额(负数扣除,正数添加)</param>
|
||||
/// <param name="dao">数据库</param>
|
||||
/// <param name="_currency"></param>
|
||||
/// <param name="orderId">订单号</param>
|
||||
/// <param name="title"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public static async Task<bool> ConsumeMoneyNoWork(this T_User user, UserCurrencyType userCurrencyType, decimal money, DAO dao, T_User_Currency? _currency = null, string orderId = "", string title = "")
|
||||
/// <summary>
|
||||
/// 扣除或者充值货币
|
||||
/// </summary>
|
||||
/// <param name="user"></param>
|
||||
/// <param name="userCurrencyType">货币类型</param>
|
||||
/// <param name="money">扣除金额(负数扣除,正数添加)</param>
|
||||
/// <param name="dao">数据库</param>
|
||||
/// <param name="_currency"></param>
|
||||
/// <param name="orderId">订单号</param>
|
||||
/// <param name="title"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public static async Task<bool> ConsumeMoneyNoWork(this T_User user, UserCurrencyType userCurrencyType, decimal money, DAO dao, T_User_Currency? _currency = null, string orderId = "", string title = "")
|
||||
{
|
||||
if (user == null || user.Id == 0)
|
||||
{
|
||||
if (user == null || user.Id == 0)
|
||||
{
|
||||
throw new ArgumentNullException("用户不能为空");
|
||||
}
|
||||
int userId = user.Id;
|
||||
return await UserConsumeDiamondMoneyAsync(dao, userId, userCurrencyType, money, title, orderId, _currency);
|
||||
throw new ArgumentNullException("用户不能为空");
|
||||
}
|
||||
int userId = user.Id;
|
||||
return await UserConsumeDiamondMoneyAsync(dao, userId, userCurrencyType, money, title, orderId, _currency);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 扣除当前用户钻石
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <returns></returns>
|
||||
public static IUserConsumeMoney GetCurrentUserConsumeMoney(this CloudGamingBase cloudGamingBase, UserCurrencyType userCurrencyType, T_User_Currency currency = null)
|
||||
/// <summary>
|
||||
/// 扣除当前用户钻石
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <returns></returns>
|
||||
public static IUserConsumeMoney GetCurrentUserConsumeMoney(this CloudGamingBase cloudGamingBase, UserCurrencyType userCurrencyType, T_User_Currency currency = null)
|
||||
{
|
||||
return GetCurrentUserConsumeMoney(cloudGamingBase.Dao, cloudGamingBase._UserId, userCurrencyType, currency);
|
||||
}
|
||||
/// <summary>
|
||||
/// 扣除当前用户钻石
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <returns></returns>
|
||||
public static IUserConsumeMoney GetCurrentUserConsumeMoney(DAO dao, int userId, UserCurrencyType userCurrencyType, T_User_Currency currency = null)
|
||||
{
|
||||
if (UserCurrencyType.钻石 == userCurrencyType)
|
||||
{
|
||||
return GetCurrentUserConsumeMoney(cloudGamingBase.Dao, cloudGamingBase._UserId, userCurrencyType, currency);
|
||||
}
|
||||
/// <summary>
|
||||
/// 扣除当前用户钻石
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <returns></returns>
|
||||
public static IUserConsumeMoney GetCurrentUserConsumeMoney(DAO dao, int userId, UserCurrencyType userCurrencyType, T_User_Currency currency = null)
|
||||
{
|
||||
if (UserCurrencyType.钻石 == userCurrencyType)
|
||||
{
|
||||
return new DiamondConsumeMoney(dao, userId, userCurrencyType, currency);
|
||||
}
|
||||
else if (userCurrencyType == UserCurrencyType.会员卡 || userCurrencyType == UserCurrencyType.会员季卡 || userCurrencyType == UserCurrencyType.会员月卡 || userCurrencyType == UserCurrencyType.会员年卡)
|
||||
{
|
||||
return new PlayCardConsumeMoney(dao, userId, userCurrencyType, currency);
|
||||
}
|
||||
return new DiamondConsumeMoney(dao, userId, userCurrencyType, currency);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扣除当前用户钻石
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <returns></returns>
|
||||
public static IUserConsumeMoney CurrentUserConsumeMoney(this UserInfoCache userInfo, CloudGamingBase cloudGamingBase, UserCurrencyType userCurrencyType, T_User_Currency currency = null)
|
||||
else if (userCurrencyType == UserCurrencyType.会员卡 || userCurrencyType == UserCurrencyType.会员季卡 || userCurrencyType == UserCurrencyType.会员月卡 || userCurrencyType == UserCurrencyType.会员年卡)
|
||||
{
|
||||
return GetCurrentUserConsumeMoney(cloudGamingBase.Dao, userInfo.UserId, userCurrencyType, currency);
|
||||
|
||||
return new PlayCardConsumeMoney(dao, userId, userCurrencyType, currency);
|
||||
}
|
||||
return new DiamondConsumeMoney(dao, userId, userCurrencyType, currency);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扣除当前用户钻石
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="money"></param>
|
||||
/// <param name="userDoamondAction"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> UserConsumeDiamondMoneyAsync(this CloudGamingBase cloudGamingBase, decimal money, Action<T_User_DiamondList>? userDoamondAction = null)
|
||||
/// <summary>
|
||||
/// 扣除当前用户钻石
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <returns></returns>
|
||||
public static IUserConsumeMoney CurrentUserConsumeMoney(this UserInfoCache userInfo, CloudGamingBase cloudGamingBase, UserCurrencyType userCurrencyType, T_User_Currency currency = null)
|
||||
{
|
||||
return GetCurrentUserConsumeMoney(cloudGamingBase.Dao, userInfo.UserId, userCurrencyType, currency);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 扣除当前用户钻石
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="money"></param>
|
||||
/// <param name="userDoamondAction"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> UserConsumeDiamondMoneyAsync(this CloudGamingBase cloudGamingBase, decimal money, Action<T_User_DiamondList>? userDoamondAction = null)
|
||||
{
|
||||
T_User_Currency currency = new T_User_Currency();
|
||||
try
|
||||
{
|
||||
T_User_Currency currency = new T_User_Currency();
|
||||
try
|
||||
var isSuccess = await UserConsumeDiamondMoneyAsync(cloudGamingBase.Dao, cloudGamingBase.UserInfo.UserId, money, userDoamondAction, currency);//
|
||||
if (!isSuccess)
|
||||
{
|
||||
var isSuccess = await UserConsumeDiamondMoneyAsync(cloudGamingBase.Dao, cloudGamingBase.UserInfo.UserId, money, userDoamondAction, currency);//
|
||||
if (!isSuccess)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
cloudGamingBase.UserInfo.Diamond = (int)currency.CurrencyMoney;
|
||||
await cloudGamingBase.SaveUserInfoCacheChangesAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
cloudGamingBase.UserInfo.Diamond = (int)currency.CurrencyMoney;
|
||||
await cloudGamingBase.SaveUserInfoCacheChangesAsync();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 扣除或者添加当前用户钻石
|
||||
/// </summary>
|
||||
/// <param name="dao"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="money">负数扣除,正数添加</param>
|
||||
/// <param name="userDoamondAction"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> UserConsumeDiamondMoneyAsync(DAO dao, int userId, decimal money, Action<T_User_DiamondList>? userDoamondAction = null, T_User_Currency userCurrency = null)
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
var userConsumeMoney = new DiamondConsumeMoney(dao, userId, UserCurrencyType.钻石, userCurrency);
|
||||
try
|
||||
{
|
||||
var isSuccess = await userConsumeMoney.ConsumeMoneyAsync(money);
|
||||
if (!isSuccess)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
UserCurrencyConsumeType consumeType = money >= 0 ? UserCurrencyConsumeType.收入 : UserCurrencyConsumeType.消耗;
|
||||
T_User_DiamondList userDiamondList = new T_User_DiamondList()
|
||||
{
|
||||
CreateAt = DateTime.Now,
|
||||
Consume = money,
|
||||
ConsumeType = (int)consumeType,
|
||||
CurrencyType = (int)UserCurrencyType.钻石,
|
||||
OrderCode = "",
|
||||
Title = "",
|
||||
UpdateAt = DateTime.Now,
|
||||
UserId = userId,
|
||||
};
|
||||
if (userDoamondAction != null)
|
||||
{
|
||||
userDoamondAction(userDiamondList);
|
||||
}
|
||||
await dao.DaoUser.Context.AddAsync(userDiamondList);
|
||||
await dao.DaoUser.Context.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 扣除或者添加当前用户钻石
|
||||
/// </summary>
|
||||
/// <param name="dao"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="money">负数扣除,正数添加</param>
|
||||
/// <param name="userDoamondAction"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> UserConsumeDiamondMoneyAsync(DAO dao, int userId, decimal money, Action<T_User_DiamondList>? userDoamondAction = null, T_User_Currency userCurrency = null)
|
||||
{
|
||||
|
||||
var userConsumeMoney = new DiamondConsumeMoney(dao, userId, UserCurrencyType.钻石, userCurrency);
|
||||
try
|
||||
{
|
||||
var isSuccess = await userConsumeMoney.ConsumeMoneyAsync(money);
|
||||
if (!isSuccess)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
UserCurrencyConsumeType consumeType = money >= 0 ? UserCurrencyConsumeType.收入 : UserCurrencyConsumeType.消耗;
|
||||
T_User_DiamondList userDiamondList = new T_User_DiamondList()
|
||||
{
|
||||
CreateAt = DateTime.Now,
|
||||
Consume = money,
|
||||
ConsumeType = (int)consumeType,
|
||||
CurrencyType = (int)UserCurrencyType.钻石,
|
||||
OrderCode = "",
|
||||
Title = "",
|
||||
UpdateAt = DateTime.Now,
|
||||
UserId = userId,
|
||||
};
|
||||
if (userDoamondAction != null)
|
||||
{
|
||||
userDoamondAction(userDiamondList);
|
||||
}
|
||||
await dao.DaoUser.Context.AddAsync(userDiamondList);
|
||||
await dao.DaoUser.Context.SaveChangesAsync();
|
||||
}
|
||||
/// <summary>
|
||||
/// 畅玩卡
|
||||
/// </summary>
|
||||
/// <param name="dao"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="money"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <param name="userDoamondAction"></param>
|
||||
/// <param name="userCurrency"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> UserConsumePlayGameMoneyAsync(DAO dao, int userId, decimal money, UserCurrencyType userCurrencyType, Action<T_User_DiamondList>? userDoamondAction = null, T_User_Currency userCurrency = null)
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
var userConsumeMoney = GetCurrentUserConsumeMoney(dao, userId, userCurrencyType, userCurrency);
|
||||
try
|
||||
{
|
||||
var isSuccess = await userConsumeMoney.ConsumeMoneyAsync(money);
|
||||
if (!isSuccess)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
UserCurrencyConsumeType consumeType = money >= 0 ? UserCurrencyConsumeType.收入 : UserCurrencyConsumeType.消耗;
|
||||
T_User_DiamondList userDiamondList = new T_User_DiamondList()
|
||||
{
|
||||
CreateAt = DateTime.Now,
|
||||
Consume = money,
|
||||
ConsumeType = (int)consumeType,
|
||||
CurrencyType = (int)userCurrencyType,
|
||||
OrderCode = "",
|
||||
Title = "",
|
||||
UpdateAt = DateTime.Now,
|
||||
UserId = userId,
|
||||
};
|
||||
if (userDoamondAction != null)
|
||||
{
|
||||
userDoamondAction(userDiamondList);
|
||||
}
|
||||
await dao.DaoUser.Context.AddAsync(userDiamondList);
|
||||
await dao.DaoUser.Context.SaveChangesAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
/// <summary>
|
||||
/// 畅玩卡
|
||||
/// </summary>
|
||||
/// <param name="dao"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="money"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <param name="userDoamondAction"></param>
|
||||
/// <param name="userCurrency"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> UserConsumePlayGameMoneyAsync(DAO dao, int userId, decimal money, UserCurrencyType userCurrencyType, Action<T_User_DiamondList>? userDoamondAction = null, T_User_Currency userCurrency = null)
|
||||
{
|
||||
|
||||
var userConsumeMoney = GetCurrentUserConsumeMoney(dao, userId, userCurrencyType, userCurrency);
|
||||
try
|
||||
{
|
||||
var isSuccess = await userConsumeMoney.ConsumeMoneyAsync(money);
|
||||
if (!isSuccess)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
UserCurrencyConsumeType consumeType = money >= 0 ? UserCurrencyConsumeType.收入 : UserCurrencyConsumeType.消耗;
|
||||
T_User_DiamondList userDiamondList = new T_User_DiamondList()
|
||||
{
|
||||
CreateAt = DateTime.Now,
|
||||
Consume = money,
|
||||
ConsumeType = (int)consumeType,
|
||||
CurrencyType = (int)userCurrencyType,
|
||||
OrderCode = "",
|
||||
Title = "",
|
||||
UpdateAt = DateTime.Now,
|
||||
UserId = userId,
|
||||
};
|
||||
if (userDoamondAction != null)
|
||||
{
|
||||
userDoamondAction(userDiamondList);
|
||||
}
|
||||
await dao.DaoUser.Context.AddAsync(userDiamondList);
|
||||
await dao.DaoUser.Context.SaveChangesAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="money">金额</param>
|
||||
/// <param name="title">资产支出标题</param>
|
||||
/// <param name="orderId">订单号</param>
|
||||
/// <returns></returns>
|
||||
|
||||
public static async Task<bool> UserConsumeDiamondMoneyAsync(this CloudGamingBase cloudGamingBase, UserCurrencyType userCurrencyType, decimal money, string title = "", string orderId = "")
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (userCurrencyType == UserCurrencyType.钻石)
|
||||
{
|
||||
return await UserConsumeDiamondMoneyAsync(cloudGamingBase, money, it => { it.Title = title; it.OrderCode = orderId; });
|
||||
}
|
||||
else if (userCurrencyType == UserCurrencyType.会员卡 || userCurrencyType == UserCurrencyType.会员季卡 || userCurrencyType == UserCurrencyType.会员月卡 || userCurrencyType == UserCurrencyType.会员年卡)
|
||||
{
|
||||
var cu = new T_User_Currency();
|
||||
var isSuccess = await UserConsumePlayGameMoneyAsync(cloudGamingBase.Dao, cloudGamingBase._UserId, money, userCurrencyType, it => { it.Title = title; it.OrderCode = orderId; }, cu);
|
||||
if (isSuccess)
|
||||
{
|
||||
|
||||
cloudGamingBase.UserInfo.UserVipInfo = new UserInfoPlayGameCard(cu);
|
||||
}
|
||||
return isSuccess;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="money">金额</param>
|
||||
/// <param name="title">资产支出标题</param>
|
||||
/// <param name="orderId">订单号</param>
|
||||
/// <returns></returns>
|
||||
|
||||
public static async Task<bool> UserConsumeDiamondMoneyAsync(this CloudGamingBase cloudGamingBase, UserCurrencyType userCurrencyType, decimal money, string title = "", string orderId = "")
|
||||
{
|
||||
if (userCurrencyType == UserCurrencyType.钻石)
|
||||
{
|
||||
return await UserConsumeDiamondMoneyAsync(cloudGamingBase, money, it => { it.Title = title; it.OrderCode = orderId; });
|
||||
}
|
||||
/// <summary>
|
||||
/// 充值或者消耗用户货币
|
||||
/// </summary>
|
||||
/// <param name="dao"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <param name="money"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="orderId"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
public static async Task<bool> UserConsumeDiamondMoneyAsync(DAO dao, int userId, UserCurrencyType userCurrencyType, decimal money, string title = "", string orderId = "", T_User_Currency currency = null)
|
||||
else if (userCurrencyType == UserCurrencyType.会员卡 || userCurrencyType == UserCurrencyType.会员季卡 || userCurrencyType == UserCurrencyType.会员月卡 || userCurrencyType == UserCurrencyType.会员年卡)
|
||||
{
|
||||
if (userCurrencyType == UserCurrencyType.钻石)
|
||||
{
|
||||
return await UserConsumeDiamondMoneyAsync(dao, userId, money, it => { it.Title = title; it.OrderCode = orderId; }, currency);
|
||||
}
|
||||
else if (userCurrencyType == UserCurrencyType.会员卡 || userCurrencyType == UserCurrencyType.会员季卡 || userCurrencyType == UserCurrencyType.会员月卡 || userCurrencyType == UserCurrencyType.会员年卡)
|
||||
{
|
||||
return await UserConsumePlayGameMoneyAsync(dao, userId, money, userCurrencyType, it => { it.Title = title; it.OrderCode = orderId; }, currency);
|
||||
}
|
||||
return await UserConsumeDiamondMoneyAsync(dao, userId, money, it => { it.Title = title; it.OrderCode = orderId; }, currency);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户玩游戏消耗钻石
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="money">金额</param>
|
||||
/// <param name="currencyLogId">资产记录日志id</param>
|
||||
/// <param name="gameName">游戏名称</param>
|
||||
/// <param name="diamondListId">资产收入支出记录id</param>
|
||||
/// <param name="gameXiaoHao">游戏每分钟消耗多少钻石</param>
|
||||
/// <returns></returns>
|
||||
public static async Task<(bool, int, int)> UserPlayGameDiamondConsumeMoney(this CloudGamingBase cloudGamingBase, decimal money, string gameName, int currencyLogId, int diamondListId, string gameXiaoHao)
|
||||
{
|
||||
bool issuccess = false;
|
||||
int _currencyLogId = currencyLogId;
|
||||
try
|
||||
{
|
||||
var currency = new T_User_Currency();
|
||||
GameDiamondConsumeMoney gameDiamondConsumeMoney = new GameDiamondConsumeMoney(cloudGamingBase.Dao, cloudGamingBase._UserId, UserCurrencyType.钻石, currency);
|
||||
(issuccess, _currencyLogId) = await gameDiamondConsumeMoney.ConsumeMoneyAsync(money, currencyLogId);
|
||||
if (issuccess)
|
||||
{
|
||||
cloudGamingBase.UserInfo.Diamond = (int)currency.CurrencyMoney;
|
||||
//await cloudGamingBase.SaveUserInfoCacheChangesAsync();
|
||||
UserCurrencyConsumeType consumeType = money >= 0 ? UserCurrencyConsumeType.收入 : UserCurrencyConsumeType.消耗;
|
||||
T_User_DiamondList userDiamondList = null;
|
||||
if (diamondListId > 0)
|
||||
{
|
||||
userDiamondList = await cloudGamingBase.Dao.DaoUser.Context.T_User_DiamondList.FirstOrDefaultAsync(it => it.Id == diamondListId);
|
||||
}
|
||||
if (userDiamondList == null)
|
||||
{
|
||||
userDiamondList = new T_User_DiamondList()
|
||||
{
|
||||
CreateAt = DateTime.Now,
|
||||
Consume = 0,
|
||||
ConsumeType = (int)consumeType,
|
||||
CurrencyType = (int)UserCurrencyType.钻石,
|
||||
OrderCode = "",
|
||||
Title = $"游玩《{gameName}》",
|
||||
UpdateAt = DateTime.Now,
|
||||
UserId = cloudGamingBase.UserInfo.UserId,
|
||||
Extend = gameXiaoHao,
|
||||
};
|
||||
await cloudGamingBase.Dao.DaoUser.Context.AddAsync(userDiamondList);
|
||||
|
||||
}
|
||||
userDiamondList.Consume += Math.Abs(money);
|
||||
userDiamondList.UpdateAt = DateTime.Now;
|
||||
await cloudGamingBase.Dao.DaoUser.Context.SaveChangesAsync();
|
||||
diamondListId = userDiamondList.Id;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
return (false, _currencyLogId, diamondListId); ;
|
||||
}
|
||||
return (issuccess, _currencyLogId, diamondListId);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 扣除当前用户钻石
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> UserConsumeMoneyAsync(this CloudGamingBase cloudGamingBase, int userId, decimal money)
|
||||
{
|
||||
bool isSuccess = await UserConsumeDiamondMoneyAsync(userId, money, cloudGamingBase);
|
||||
var cu = new T_User_Currency();
|
||||
var isSuccess = await UserConsumePlayGameMoneyAsync(cloudGamingBase.Dao, cloudGamingBase._UserId, money, userCurrencyType, it => { it.Title = title; it.OrderCode = orderId; }, cu);
|
||||
if (isSuccess)
|
||||
{
|
||||
|
||||
cloudGamingBase.UserInfo.UserVipInfo = new UserInfoPlayGameCard(cu);
|
||||
await cloudGamingBase.SaveUserInfoCacheChangesAsync();
|
||||
}
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
return await UserConsumeDiamondMoneyAsync(cloudGamingBase, money, it => { it.Title = title; it.OrderCode = orderId; });
|
||||
}
|
||||
/// <summary>
|
||||
/// 充值或者消耗用户货币
|
||||
/// </summary>
|
||||
/// <param name="dao"></param>
|
||||
/// <param name="userId"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <param name="money"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="orderId"></param>
|
||||
/// <returns></returns>
|
||||
|
||||
/// <summary>
|
||||
/// 扣除当前用户钻石
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> UserConsumeDiamondMoneyAsync(int userId, decimal money, CloudGamingBase cloudGamingBase)
|
||||
public static async Task<bool> UserConsumeDiamondMoneyAsync(DAO dao, int userId, UserCurrencyType userCurrencyType, decimal money, string title = "", string orderId = "", T_User_Currency currency = null)
|
||||
{
|
||||
if (userCurrencyType == UserCurrencyType.钻石)
|
||||
{
|
||||
T_User_Currency currency = new T_User_Currency();
|
||||
var userConsumeMoney = new DiamondConsumeMoney(cloudGamingBase.Dao, userId, UserCurrencyType.钻石, currency);
|
||||
try
|
||||
{
|
||||
var isSuccess = await userConsumeMoney.ConsumeMoneyAsync(money);
|
||||
|
||||
if (!isSuccess)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//清除缓存
|
||||
string key = AccountExtend.GetUserInfoRedisKey(userId);
|
||||
var userInfo = await cloudGamingBase.RedisCache.StringGetAsync<UserInfoCache>(key);
|
||||
if (userInfo != null)
|
||||
{
|
||||
userInfo.Diamond = (int)currency.CurrencyMoney;
|
||||
await cloudGamingBase.RedisCache.StringSetAsync(key, userInfo, TimeSpan.FromMinutes(30));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return await UserConsumeDiamondMoneyAsync(dao, userId, money, it => { it.Title = title; it.OrderCode = orderId; }, currency);
|
||||
}
|
||||
else if (userCurrencyType == UserCurrencyType.会员卡 || userCurrencyType == UserCurrencyType.会员季卡 || userCurrencyType == UserCurrencyType.会员月卡 || userCurrencyType == UserCurrencyType.会员年卡)
|
||||
{
|
||||
return await UserConsumePlayGameMoneyAsync(dao, userId, money, userCurrencyType, it => { it.Title = title; it.OrderCode = orderId; }, currency);
|
||||
}
|
||||
return await UserConsumeDiamondMoneyAsync(dao, userId, money, it => { it.Title = title; it.OrderCode = orderId; }, currency);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 用户玩游戏消耗钻石
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="money">金额</param>
|
||||
/// <param name="currencyLogId">资产记录日志id</param>
|
||||
/// <param name="gameName">游戏名称</param>
|
||||
/// <param name="diamondListId">资产收入支出记录id</param>
|
||||
/// <param name="gameXiaoHao">游戏每分钟消耗多少钻石</param>
|
||||
/// <returns></returns>
|
||||
public static async Task<(bool, int, int)> UserPlayGameDiamondConsumeMoney(this CloudGamingBase cloudGamingBase, decimal money, string gameName, int currencyLogId, int diamondListId, string gameXiaoHao)
|
||||
{
|
||||
bool issuccess = false;
|
||||
int _currencyLogId = currencyLogId;
|
||||
try
|
||||
{
|
||||
var currency = new T_User_Currency();
|
||||
GameDiamondConsumeMoney gameDiamondConsumeMoney = new GameDiamondConsumeMoney(cloudGamingBase.Dao, cloudGamingBase._UserId, UserCurrencyType.钻石, currency);
|
||||
(issuccess, _currencyLogId) = await gameDiamondConsumeMoney.ConsumeMoneyAsync(money, currencyLogId);
|
||||
if (issuccess)
|
||||
{
|
||||
cloudGamingBase.UserInfo.Diamond = (int)currency.CurrencyMoney;
|
||||
//await cloudGamingBase.SaveUserInfoCacheChangesAsync();
|
||||
UserCurrencyConsumeType consumeType = money > 0 ? UserCurrencyConsumeType.收入 : UserCurrencyConsumeType.消耗;
|
||||
T_User_DiamondList userDiamondList = null;
|
||||
if (diamondListId > 0)
|
||||
{
|
||||
userDiamondList = await cloudGamingBase.Dao.DaoUser.Context.T_User_DiamondList.FirstOrDefaultAsync(it => it.Id == diamondListId);
|
||||
}
|
||||
if (userDiamondList == null)
|
||||
{
|
||||
userDiamondList = new T_User_DiamondList()
|
||||
{
|
||||
CreateAt = DateTime.Now,
|
||||
Consume = 0,
|
||||
ConsumeType = (int)consumeType,
|
||||
CurrencyType = (int)UserCurrencyType.钻石,
|
||||
OrderCode = "",
|
||||
Title = $"游玩《{gameName}》",
|
||||
UpdateAt = DateTime.Now,
|
||||
UserId = cloudGamingBase.UserInfo.UserId,
|
||||
Extend = gameXiaoHao,
|
||||
};
|
||||
await cloudGamingBase.Dao.DaoUser.Context.AddAsync(userDiamondList);
|
||||
}
|
||||
userDiamondList.Consume += Math.Abs(money);
|
||||
userDiamondList.UpdateAt = DateTime.Now;
|
||||
await cloudGamingBase.Dao.DaoUser.Context.SaveChangesAsync();
|
||||
diamondListId = userDiamondList.Id;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
return (false, _currencyLogId, diamondListId); ;
|
||||
}
|
||||
return (issuccess, _currencyLogId, diamondListId);
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 扣除当前用户钻石
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> UserConsumeMoneyAsync(this CloudGamingBase cloudGamingBase, int userId, decimal money)
|
||||
{
|
||||
bool isSuccess = await UserConsumeDiamondMoneyAsync(userId, money, cloudGamingBase);
|
||||
if (isSuccess)
|
||||
{
|
||||
await cloudGamingBase.SaveUserInfoCacheChangesAsync();
|
||||
}
|
||||
return isSuccess;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 扣除当前用户钻石
|
||||
/// </summary>
|
||||
/// <param name="cloudGamingBase"></param>
|
||||
/// <param name="userCurrencyType"></param>
|
||||
/// <returns></returns>
|
||||
public static async Task<bool> UserConsumeDiamondMoneyAsync(int userId, decimal money, CloudGamingBase cloudGamingBase)
|
||||
{
|
||||
T_User_Currency currency = new T_User_Currency();
|
||||
var userConsumeMoney = new DiamondConsumeMoney(cloudGamingBase.Dao, userId, UserCurrencyType.钻石, currency);
|
||||
try
|
||||
{
|
||||
var isSuccess = await userConsumeMoney.ConsumeMoneyAsync(money);
|
||||
|
||||
if (!isSuccess)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//清除缓存
|
||||
string key = AccountExtend.GetUserInfoRedisKey(userId);
|
||||
var userInfo = await cloudGamingBase.RedisCache.StringGetAsync<UserInfoCache>(key);
|
||||
if (userInfo != null)
|
||||
{
|
||||
userInfo.Diamond = (int)currency.CurrencyMoney;
|
||||
await cloudGamingBase.RedisCache.StringSetAsync(key, userInfo, TimeSpan.FromMinutes(30));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ namespace CloudGaming.Code.AppExtend
|
|||
{
|
||||
if (!(httpRequest?.Headers?.TryGetValue("Channel", out var _channel) ?? false))
|
||||
{
|
||||
_channel = "ps_001";
|
||||
_channel = "cs_001";
|
||||
}
|
||||
channel = _channel;
|
||||
if (string.IsNullOrEmpty(channel))
|
||||
|
|
|
|||
|
|
@ -165,15 +165,23 @@ public class PlayGameBLL : CloudGamingBase
|
|||
gameInfoCache?.PlayGameStart(gameResponse?.Data?.ScId ?? 0, userGameList.Id, playGameSettings.DisplayGrade, jyResponseData);
|
||||
gameInfoCache.Ip = HttpContextAccessor.HttpContext.GetClientIpAddress();
|
||||
gameInfoCache.Channel = AppRequestInfo.Channel;
|
||||
var diamondNumHour = gameInfo.ConsumeDiamondNumHour / 60.0;
|
||||
if (diamondNumHour > 0)
|
||||
//var diamondNumHour = gameInfo.ConsumeDiamondNumHour / 60.0;
|
||||
var (diamondNumHour, playGamePayStatus) = GetUserGameNum(UserInfo, gameInfo);
|
||||
|
||||
if (diamondNumHour >= 0)
|
||||
{
|
||||
var startDiamond = (int)diamondNumHour < 1 ? 1 : (int)diamondNumHour;
|
||||
await BalanceDeductionFee(userInfo, gameInfoCache, diamondNumHour, 0, startDiamond);
|
||||
string c = $"启动游戏扣除钻石*{startDiamond},游戏每分钟消耗*{diamondNumHour}";
|
||||
if (playGamePayStatus != PlayGamePayStatus.钻石)
|
||||
{
|
||||
c = $"启动游戏,{playGamePayStatus}-不扣除费用。";
|
||||
}
|
||||
|
||||
await BalanceDeductionFee(userInfo, gameInfoCache, diamondNumHour, 0, startDiamond, playGamePayStatus);
|
||||
gameInfoCache.GameUserOperation.Add(new PlayGameUserOperation()
|
||||
{
|
||||
ActionId = (int)PlayGameStatus.开始游戏扣费,
|
||||
Content = $"启动游戏扣除钻石*{startDiamond},游戏每分钟消耗*{diamondNumHour}",
|
||||
Content = c,
|
||||
OperationDateTime = DateTime.Now,
|
||||
});
|
||||
}
|
||||
|
|
@ -200,6 +208,38 @@ public class PlayGameBLL : CloudGamingBase
|
|||
return response;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取用户游戏扣款金额
|
||||
/// </summary>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="gameInfo"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public (double, PlayGamePayStatus) GetUserGameNum(UserInfo userInfo, GameInfo gameInfo)
|
||||
{
|
||||
if (gameInfo == null)
|
||||
{
|
||||
throw new ArgumentNullException("游戏不能为空");
|
||||
}
|
||||
if (userInfo == null)
|
||||
{
|
||||
throw new ArgumentNullException("用户不能为空");
|
||||
}
|
||||
var diamondNumHour = gameInfo.ConsumeDiamondNumHour / 60.0;
|
||||
PlayGamePayStatus msg = PlayGamePayStatus.免费游戏;
|
||||
if (diamondNumHour > 0)
|
||||
{
|
||||
msg = PlayGamePayStatus.钻石;
|
||||
if (userInfo.UserVipInfo != null && userInfo.UserVipInfo != null && userInfo.UserVipInfo.ExpireDateTime > DateTime.Now)
|
||||
{
|
||||
diamondNumHour = 0;
|
||||
msg = PlayGamePayStatus.会员免费;
|
||||
}
|
||||
}
|
||||
return (diamondNumHour, msg);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 游戏心跳
|
||||
/// </summary>
|
||||
|
|
@ -236,8 +276,9 @@ public class PlayGameBLL : CloudGamingBase
|
|||
//LastChargingAt
|
||||
if (gameInfo.ConsumeDiamondNumHour > 0)
|
||||
{
|
||||
var (diamondNumHour, playGamePayStatus) = GetUserGameNum(UserInfo, gameInfo);
|
||||
//每分钟扣费
|
||||
var diamondNumHour = gameInfo.ConsumeDiamondNumHour / 60.0;
|
||||
//var diamondNumHour = gameInfo.ConsumeDiamondNumHour / 60.0;
|
||||
playGameHeartbeatResponse.GameConsumeDiamond = diamondNumHour.ToString("0.##");
|
||||
var chargingAt = DateTime.Now;
|
||||
var minutes = (int)chargingAt.Subtract(gameInfoCache.LastChargingAt ?? DateTime.Now).TotalMinutes;
|
||||
|
|
@ -260,35 +301,43 @@ public class PlayGameBLL : CloudGamingBase
|
|||
//判断扣费时间
|
||||
if (minutes >= 1)
|
||||
{
|
||||
var gameDiamondNumHour = (int)(diamondNumHour * minutes);
|
||||
//当前游玩的扣费金额,如果扣费金额不足1钻石,则等待下一次扣费
|
||||
if (gameDiamondNumHour >= 1)
|
||||
if (playGamePayStatus == PlayGamePayStatus.钻石)
|
||||
{
|
||||
//如果游玩余额大于用户可扣款的余额
|
||||
if (gameDiamondNumHour >= userInfo.Diamond)
|
||||
var gameDiamondNumHour = (int)(diamondNumHour * minutes);
|
||||
//当前游玩的扣费金额,如果扣费金额不足1钻石,则等待下一次扣费
|
||||
if (gameDiamondNumHour >= 1)
|
||||
{
|
||||
//去数据库中在验证一下
|
||||
//(int)userCurrency.GetUserCurrency(UserCurrencyType.钻石);
|
||||
var currency = await Dao.DaoUser.Context.T_User_Currency.Where(it => it.UserId == userInfo.UserId && it.CurrencyType == (int)UserCurrencyType.钻石).FirstOrDefaultAsync();
|
||||
if (currency == null)
|
||||
//如果游玩余额大于用户可扣款的余额
|
||||
if (gameDiamondNumHour >= userInfo.Diamond)
|
||||
{
|
||||
throw MessageBox.ErrorShow("用户数据错误");
|
||||
}
|
||||
if ((int)(currency.CurrencyMoney) != userInfo.Diamond)
|
||||
{
|
||||
userInfo.Diamond = (int)currency.CurrencyMoney;
|
||||
}
|
||||
if (gameDiamondNumHour > userInfo.Diamond)
|
||||
{
|
||||
//用户余额不足
|
||||
gameDiamondNumHour = userInfo.Diamond;
|
||||
playGameHeartbeatResponse.UserPlayGameTime = 0;
|
||||
}
|
||||
//去数据库中在验证一下
|
||||
//(int)userCurrency.GetUserCurrency(UserCurrencyType.钻石);
|
||||
var currency = await Dao.DaoUser.Context.T_User_Currency.Where(it => it.UserId == userInfo.UserId && it.CurrencyType == (int)UserCurrencyType.钻石).FirstOrDefaultAsync();
|
||||
if (currency == null)
|
||||
{
|
||||
throw MessageBox.ErrorShow("用户数据错误");
|
||||
}
|
||||
if ((int)(currency.CurrencyMoney) != userInfo.Diamond)
|
||||
{
|
||||
userInfo.Diamond = (int)currency.CurrencyMoney;
|
||||
}
|
||||
if (gameDiamondNumHour > userInfo.Diamond)
|
||||
{
|
||||
//用户余额不足
|
||||
gameDiamondNumHour = userInfo.Diamond;
|
||||
playGameHeartbeatResponse.UserPlayGameTime = 0;
|
||||
}
|
||||
|
||||
}
|
||||
await BalanceDeductionFee(userInfo, gameInfoCache, diamondNumHour, minutes, gameDiamondNumHour, playGamePayStatus);
|
||||
}
|
||||
await BalanceDeductionFee(userInfo, gameInfoCache, diamondNumHour, minutes, gameDiamondNumHour);
|
||||
}
|
||||
else
|
||||
{
|
||||
await BalanceDeductionFee(userInfo, gameInfoCache, diamondNumHour, minutes, 60, playGamePayStatus);
|
||||
}
|
||||
}
|
||||
|
||||
//用户剩余游玩时间
|
||||
if (userInfo.Diamond > 0)
|
||||
{
|
||||
|
|
@ -302,7 +351,7 @@ public class PlayGameBLL : CloudGamingBase
|
|||
|
||||
//重置一下用户钻石
|
||||
playGameHeartbeatResponse.Diamond = userInfo.Diamond;
|
||||
gameInfoCache.PlayGameHeartbeat($";累计扣除钻石*{gameInfoCache.SpendingDiamonds};用户剩余钻石*{userInfo.Diamond};当前游戏每分钟消耗钻石*{diamondNumHour.ToString("0.##")};上一次扣费时间:{gameInfoCache.LastChargingAt?.ToString("yyyy-MM-dd HH:mm:ss")}");
|
||||
gameInfoCache.PlayGameHeartbeat($";游戏消耗-{playGamePayStatus},累计扣除钻石*{gameInfoCache.SpendingDiamonds};用户剩余钻石*{userInfo.Diamond};当前游戏每分钟消耗钻石*{diamondNumHour.ToString("0.##")};上一次扣费时间:{gameInfoCache.LastChargingAt?.ToString("yyyy-MM-dd HH:mm:ss")}");
|
||||
await gameInfoCache.SaveChangesAsync(this);
|
||||
}
|
||||
else
|
||||
|
|
@ -316,26 +365,88 @@ public class PlayGameBLL : CloudGamingBase
|
|||
|
||||
}
|
||||
|
||||
private async Task BalanceDeductionFee(UserInfoCache userInfo, PlayGameUserInfo gameInfoCache, double diamondNumHour, int minutes, decimal gameDiamondNumHour)
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="userInfo"></param>
|
||||
/// <param name="gameInfoCache"></param>
|
||||
/// <param name="diamondNumHour"></param>
|
||||
/// <param name="minutes"></param>
|
||||
/// <param name="gameDiamondNumHour"></param>
|
||||
/// <returns></returns>
|
||||
private async Task BalanceDeductionFee(UserInfoCache userInfo, PlayGameUserInfo gameInfoCache, double diamondNumHour, int minutes, decimal gameDiamondNumHour, PlayGamePayStatus playGamePayStatus)
|
||||
{
|
||||
var (issuccess, currlogId, diamId) = await this.UserPlayGameDiamondConsumeMoney(-gameDiamondNumHour, gameInfoCache.GameName, gameInfoCache.CurrencyLogId, gameInfoCache.DiamondListId, $"{diamondNumHour}/分钟");
|
||||
if (!issuccess)
|
||||
int currlogId = 0;
|
||||
int diamId = 0;
|
||||
//扣费状态被改变,说明和上一次的扣费不一样,需要重置一下资产记录
|
||||
if (gameInfoCache.PlayGamePayStatus == null || gameInfoCache.PlayGamePayStatus != playGamePayStatus)
|
||||
{
|
||||
var Content = $"扣除费用{gameDiamondNumHour},用户剩余金额{userInfo.Diamond};";
|
||||
if (minutes == 0)
|
||||
{
|
||||
Content = $"启动扣除费用{gameDiamondNumHour},用户剩余金额{userInfo.Diamond};";
|
||||
}
|
||||
gameInfoCache.GameUserOperation.Add(new PlayGameUserOperation()
|
||||
{
|
||||
ActionId = (int)PlayGameStatus.用户扣款错误,
|
||||
Content = Content
|
||||
});
|
||||
await gameInfoCache.SaveChangesAsync(this);
|
||||
throw MessageBox.ErrorShow("扣款出现错误");
|
||||
gameInfoCache.DiamondListId = 0;
|
||||
gameInfoCache.CurrencyLogId = 0;
|
||||
}
|
||||
gameInfoCache.PlayGamePayStatus = playGamePayStatus;
|
||||
if (playGamePayStatus == PlayGamePayStatus.钻石)
|
||||
{
|
||||
var (issuccess, currlogId1, diamId1) = await this.UserPlayGameDiamondConsumeMoney(-gameDiamondNumHour, gameInfoCache.GameName, gameInfoCache.CurrencyLogId, gameInfoCache.DiamondListId, $"{diamondNumHour}/分钟");
|
||||
if (!issuccess)
|
||||
{
|
||||
var Content = $"扣除费用{gameDiamondNumHour},用户剩余金额{userInfo.Diamond};";
|
||||
if (minutes == 0)
|
||||
{
|
||||
Content = $"启动扣除费用{gameDiamondNumHour},用户剩余金额{userInfo.Diamond};";
|
||||
}
|
||||
gameInfoCache.GameUserOperation.Add(new PlayGameUserOperation()
|
||||
{
|
||||
ActionId = (int)PlayGameStatus.用户扣款错误,
|
||||
Content = Content
|
||||
});
|
||||
await gameInfoCache.SaveChangesAsync(this);
|
||||
throw MessageBox.ErrorShow("扣款出现错误");
|
||||
}
|
||||
currlogId = currlogId1;
|
||||
diamId = diamId1;
|
||||
gameInfoCache.SpendingDiamonds += gameDiamondNumHour;
|
||||
userInfo.UserPlayGameTime += minutes;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
T_User_DiamondList userDiamondList = null;
|
||||
int diamondListId = gameInfoCache.DiamondListId;
|
||||
if (diamondListId > 0)
|
||||
{
|
||||
userDiamondList = await Dao.DaoUser.Context.T_User_DiamondList.FirstOrDefaultAsync(it => it.Id == diamondListId);
|
||||
}
|
||||
if (userDiamondList == null)
|
||||
{
|
||||
userDiamondList = new T_User_DiamondList()
|
||||
{
|
||||
CreateAt = DateTime.Now,
|
||||
Consume = 0,
|
||||
ConsumeType = (int)UserCurrencyConsumeType.消耗,
|
||||
CurrencyType = (int)UserCurrencyType.钻石,
|
||||
OrderCode = "",
|
||||
Title = $"游玩《{gameInfoCache.GameName}》 * {playGamePayStatus}",
|
||||
UpdateAt = DateTime.Now,
|
||||
UserId = UserInfo.UserId,
|
||||
Extend = $"{playGamePayStatus}",
|
||||
};
|
||||
await Dao.DaoUser.Context.AddAsync(userDiamondList);
|
||||
}
|
||||
userDiamondList.Consume += 0;
|
||||
userDiamondList.UpdateAt = DateTime.Now;
|
||||
await Dao.DaoUser.Context.SaveChangesAsync();
|
||||
gameInfoCache.SpendingDiamonds += 0;
|
||||
userInfo.UserPlayGameTime += minutes;
|
||||
if (gameInfoCache.PlayGamePayStatus == PlayGamePayStatus.会员免费)
|
||||
{
|
||||
gameInfoCache.VipCardPlayTime += minutes;
|
||||
}
|
||||
else if (gameInfoCache.PlayGamePayStatus == PlayGamePayStatus.免费游戏)
|
||||
{
|
||||
gameInfoCache.FreePlayTime += minutes;
|
||||
}
|
||||
}
|
||||
gameInfoCache.SpendingDiamonds += gameDiamondNumHour;
|
||||
userInfo.UserPlayGameTime += minutes;
|
||||
await this.SaveUserInfoCacheChangesAsync();
|
||||
gameInfoCache.CurrencyLogId = currlogId;
|
||||
gameInfoCache.DiamondListId = diamId;
|
||||
|
|
@ -585,7 +696,7 @@ public class PlayGameBLL : CloudGamingBase
|
|||
/// <summary>
|
||||
/// 重连会话
|
||||
/// </summary>
|
||||
/// <param name="reconPlayGameRequest"></param>
|
||||
/// <param name="gameRequest"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<BaseResponse<string>> ReconPlayGame(GameRequest gameRequest)
|
||||
{
|
||||
|
|
@ -643,7 +754,7 @@ public class PlayGameBLL : CloudGamingBase
|
|||
{
|
||||
throw MessageBox.ErrorShow("未找到游戏信息");
|
||||
}
|
||||
JYRequestCommonParameter playGameCommonSetting = new JYRequestCommonParameter(sn,userId)
|
||||
JYRequestCommonParameter playGameCommonSetting = new JYRequestCommonParameter(sn, userId)
|
||||
{
|
||||
ScId = gameInfoCache.ScId,
|
||||
Ip = this.HttpContextAccessor.HttpContext.GetClientIpAddress()
|
||||
|
|
@ -652,7 +763,7 @@ public class PlayGameBLL : CloudGamingBase
|
|||
|
||||
return new BaseResponse<dynamic>(ResponseCode.Success, "", dic.Data);
|
||||
}
|
||||
|
||||
|
||||
public async Task<GameSettingDto> GameSetting(string gameId)
|
||||
{
|
||||
if (_UserId == 0)
|
||||
|
|
|
|||
|
|
@ -667,6 +667,14 @@ namespace CloudGaming.Code.Game
|
|||
await dao.DaoPhone.Context.T_User_PlayGameTime.AddAsync(playGameTime);
|
||||
}
|
||||
playGameTime.PlayTime += playTime;
|
||||
if (playGameUserInfo.FreePlayTime > 0)
|
||||
{
|
||||
playGameTime.FreePlayTime = playGameUserInfo.FreePlayTime / 60;
|
||||
}
|
||||
if (playGameUserInfo.VipCardPlayTime > 0)
|
||||
{
|
||||
playGameTime.NightCardPlayTime = playGameUserInfo.VipCardPlayTime / 60;
|
||||
}
|
||||
playGameTime.UpdateTime = DateTime.Now;
|
||||
playGameTime.DiamondPlayTime += playTime;
|
||||
await dao.DaoPhone.Context.SaveChangesAsync();
|
||||
|
|
|
|||
|
|
@ -99,69 +99,69 @@ using (var package = new ExcelPackage(new FileInfo(filePath)))
|
|||
}
|
||||
Console.WriteLine("验证成功,开始导入数据...");
|
||||
//Console.ReadKey();
|
||||
List<string> tags = new List<string>();
|
||||
Console.WriteLine("开始验证标签...");
|
||||
tempGames.ForEach(it => tags.AddRange(it.GameTag));
|
||||
tags = tags.Distinct().ToList();
|
||||
var gameTags = gameDao.T_Game_Tags.ToList();
|
||||
var notTags = tags.Where(it => !gameTags.Any(item => item.TagName == it)).ToList();
|
||||
if (notTags != null && notTags.Count > 0)
|
||||
{
|
||||
var orderId = (gameTags.Max(it => (int?)it.OrderId) ?? 0) + 1;
|
||||
var tagId = (gameTags.Max(it => (int?)it.TagId) ?? 0) + 1;
|
||||
notTags.ForEach(t =>
|
||||
{
|
||||
//不在数据库中
|
||||
T_Game_Tags t_Game_Tags = new T_Game_Tags()
|
||||
{
|
||||
CreatTime = DateTime.Now,
|
||||
Desc = "",
|
||||
IsOnline = true,
|
||||
OrderId = orderId,
|
||||
TagId = tagId,
|
||||
TagName = t,
|
||||
UpdateTime = DateTime.Now,
|
||||
};
|
||||
gameDao.Add(t_Game_Tags);
|
||||
tagId++;
|
||||
orderId++;
|
||||
Console.WriteLine($"添加标签{t}==>tagId:{tagId}==>orderId:{orderId}");
|
||||
});
|
||||
gameDao.SaveChanges();
|
||||
gameTags = gameDao.T_Game_Tags.ToList();
|
||||
}
|
||||
Console.WriteLine("开始验证类型...");
|
||||
var gameTypes = gameDao.T_Game_Types.ToList();
|
||||
List<string> types = new List<string>();
|
||||
tempGames.ForEach(it => types.AddRange(it.GameType));
|
||||
types = types.Distinct().ToList();
|
||||
//List<string> tags = new List<string>();
|
||||
//Console.WriteLine("开始验证标签...");
|
||||
//tempGames.ForEach(it => tags.AddRange(it.GameTag));
|
||||
//tags = tags.Distinct().ToList();
|
||||
//var gameTags = gameDao.T_Game_Tags.ToList();
|
||||
//var notTags = tags.Where(it => !gameTags.Any(item => item.TagName == it)).ToList();
|
||||
//if (notTags != null && notTags.Count > 0)
|
||||
//{
|
||||
// var orderId = (gameTags.Max(it => (int?)it.OrderId) ?? 0) + 1;
|
||||
// var tagId = (gameTags.Max(it => (int?)it.TagId) ?? 0) + 1;
|
||||
// notTags.ForEach(t =>
|
||||
// {
|
||||
// //不在数据库中
|
||||
// T_Game_Tags t_Game_Tags = new T_Game_Tags()
|
||||
// {
|
||||
// CreatTime = DateTime.Now,
|
||||
// Desc = "",
|
||||
// IsOnline = true,
|
||||
// OrderId = orderId,
|
||||
// TagId = tagId,
|
||||
// TagName = t,
|
||||
// UpdateTime = DateTime.Now,
|
||||
// };
|
||||
// gameDao.Add(t_Game_Tags);
|
||||
// tagId++;
|
||||
// orderId++;
|
||||
// Console.WriteLine($"添加标签{t}==>tagId:{tagId}==>orderId:{orderId}");
|
||||
// });
|
||||
// gameDao.SaveChanges();
|
||||
// gameTags = gameDao.T_Game_Tags.ToList();
|
||||
//}
|
||||
//Console.WriteLine("开始验证类型...");
|
||||
//var gameTypes = gameDao.T_Game_Types.ToList();
|
||||
//List<string> types = new List<string>();
|
||||
//tempGames.ForEach(it => types.AddRange(it.GameType));
|
||||
//types = types.Distinct().ToList();
|
||||
|
||||
var notTypes = types.Where(it => !gameTypes.Any(item => item.TypeName == it)).ToList();
|
||||
if (notTypes != null && notTypes.Count > 0)
|
||||
{
|
||||
var orderId = (gameTypes.Max(it => (int?)it.OrderId) ?? 0) + 1;
|
||||
var TypeId = (gameTypes.Max(it => (int?)it.TypeId) ?? 0) + 1;
|
||||
notTypes.ForEach(t =>
|
||||
{
|
||||
//不在数据库中
|
||||
T_Game_Types t_Game_Tags = new T_Game_Types()
|
||||
{
|
||||
CreatTime = DateTime.Now,
|
||||
IsOnline = true,
|
||||
OrderId = orderId,
|
||||
TypeId = TypeId,
|
||||
TypeName = t,
|
||||
UpdateTime = DateTime.Now,
|
||||
TypeDetails = ""
|
||||
};
|
||||
gameDao.Add(t_Game_Tags);
|
||||
TypeId++;
|
||||
orderId++;
|
||||
Console.WriteLine($"添加类型{t}==>tagId:{TypeId}==>orderId:{orderId}");
|
||||
});
|
||||
gameDao.SaveChanges();
|
||||
gameTypes = gameDao.T_Game_Types.ToList();
|
||||
}
|
||||
//var notTypes = types.Where(it => !gameTypes.Any(item => item.TypeName == it)).ToList();
|
||||
//if (notTypes != null && notTypes.Count > 0)
|
||||
//{
|
||||
// var orderId = (gameTypes.Max(it => (int?)it.OrderId) ?? 0) + 1;
|
||||
// var TypeId = (gameTypes.Max(it => (int?)it.TypeId) ?? 0) + 1;
|
||||
// notTypes.ForEach(t =>
|
||||
// {
|
||||
// //不在数据库中
|
||||
// T_Game_Types t_Game_Tags = new T_Game_Types()
|
||||
// {
|
||||
// CreatTime = DateTime.Now,
|
||||
// IsOnline = true,
|
||||
// OrderId = orderId,
|
||||
// TypeId = TypeId,
|
||||
// TypeName = t,
|
||||
// UpdateTime = DateTime.Now,
|
||||
// TypeDetails = ""
|
||||
// };
|
||||
// gameDao.Add(t_Game_Tags);
|
||||
// TypeId++;
|
||||
// orderId++;
|
||||
// Console.WriteLine($"添加类型{t}==>tagId:{TypeId}==>orderId:{orderId}");
|
||||
// });
|
||||
// gameDao.SaveChanges();
|
||||
// gameTypes = gameDao.T_Game_Types.ToList();
|
||||
//}
|
||||
|
||||
var gameChildList = gameDao.T_Game_ChildList.ToList();
|
||||
|
||||
|
|
@ -202,66 +202,68 @@ tempGames.ForEach((Action<tempGame>)(game =>
|
|||
gameDao.Add(gamel);
|
||||
gameList.Add(gamel);
|
||||
}
|
||||
gamel.GameIntroduce = game.GameIntroduce;
|
||||
gamel.GameCloudId = game.GameCloudId;
|
||||
gamel.GameName = game.GameName;
|
||||
//添加游戏标签
|
||||
//if(gameTypes)
|
||||
var tempTypes = gameChildList.Where(it => it.GameId == game.GameId && it.ChildType == 1).ToList();
|
||||
//先删除当前游戏所有的类型
|
||||
if (tempTypes != null && tempTypes.Count > 0)
|
||||
{
|
||||
gameDao.RemoveRange(tempTypes);
|
||||
}
|
||||
if (game.GameType != null && game.GameType.Length > 0)
|
||||
{
|
||||
int index = 0;
|
||||
foreach (var gameTypeName in game.GameType)
|
||||
{
|
||||
var g = gameTypes.FirstOrDefault(it => it.TypeName == gameTypeName);
|
||||
if (g != null)
|
||||
{
|
||||
T_Game_ChildList cg = new T_Game_ChildList()
|
||||
{
|
||||
ChildId = g.TypeId,
|
||||
ChildType = 1,
|
||||
GameId = game.GameId,
|
||||
OrderId = index,
|
||||
Desc = ""
|
||||
};
|
||||
gameDao.Add(cg);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//游戏标签管理
|
||||
var tempTags = gameChildList.Where(it => it.GameId == game.GameId && it.ChildType == 2).ToList();
|
||||
//先删除当前游戏所有的标签
|
||||
if (tempTags != null && tempTags.Count > 0)
|
||||
{
|
||||
gameDao.RemoveRange(tempTags);
|
||||
}
|
||||
if (game.GameTag != null && game.GameTag.Length > 0)
|
||||
{
|
||||
int index = 0;
|
||||
foreach (var gameTagName in game.GameTag)
|
||||
{
|
||||
var g = gameTags.FirstOrDefault(it => it.TagName == gameTagName);
|
||||
if (g != null)
|
||||
{
|
||||
T_Game_ChildList cg = new T_Game_ChildList()
|
||||
{
|
||||
ChildId = g.TagId,
|
||||
ChildType = 2,
|
||||
GameId = game.GameId,
|
||||
OrderId = index,
|
||||
Desc = ""
|
||||
};
|
||||
gameDao.Add(cg);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//gamel.GameIntroduce = game.GameIntroduce;
|
||||
//gamel.GameCloudId = game.GameCloudId;
|
||||
//gamel.GameName = game.GameName;
|
||||
////添加游戏标签
|
||||
////if(gameTypes)
|
||||
//var tempTypes = gameChildList.Where(it => it.GameId == game.GameId && it.ChildType == 1).ToList();
|
||||
////先删除当前游戏所有的类型
|
||||
//if (tempTypes != null && tempTypes.Count > 0)
|
||||
//{
|
||||
// gameDao.RemoveRange(tempTypes);
|
||||
//}
|
||||
//if (game.GameType != null && game.GameType.Length > 0)
|
||||
//{
|
||||
// int index = 0;
|
||||
// foreach (var gameTypeName in game.GameType)
|
||||
// {
|
||||
// var g = gameTypes.FirstOrDefault(it => it.TypeName == gameTypeName);
|
||||
// if (g != null)
|
||||
// {
|
||||
// T_Game_ChildList cg = new T_Game_ChildList()
|
||||
// {
|
||||
// ChildId = g.TypeId,
|
||||
// ChildType = 1,
|
||||
// GameId = game.GameId,
|
||||
// OrderId = index,
|
||||
// Desc = ""
|
||||
// };
|
||||
// gameDao.Add(cg);
|
||||
// index++;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
////游戏标签管理
|
||||
//var tempTags = gameChildList.Where(it => it.GameId == game.GameId && it.ChildType == 2).ToList();
|
||||
////先删除当前游戏所有的标签
|
||||
//if (tempTags != null && tempTags.Count > 0)
|
||||
//{
|
||||
// gameDao.RemoveRange(tempTags);
|
||||
//}
|
||||
//if (game.GameTag != null && game.GameTag.Length > 0)
|
||||
//{
|
||||
// int index = 0;
|
||||
// foreach (var gameTagName in game.GameTag)
|
||||
// {
|
||||
// var g = gameTags.FirstOrDefault(it => it.TagName == gameTagName);
|
||||
// if (g != null)
|
||||
// {
|
||||
// T_Game_ChildList cg = new T_Game_ChildList()
|
||||
// {
|
||||
// ChildId = g.TagId,
|
||||
// ChildType = 2,
|
||||
// GameId = game.GameId,
|
||||
// OrderId = index,
|
||||
// Desc = ""
|
||||
// };
|
||||
// gameDao.Add(cg);
|
||||
// index++;
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
//添加游戏类型
|
||||
//gameDao.SaveChanges();
|
||||
//添加配置表
|
||||
|
|
@ -271,7 +273,7 @@ tempGames.ForEach((Action<tempGame>)(game =>
|
|||
{
|
||||
gameCbt1 = new T_GameCBT()
|
||||
{
|
||||
GameId = game.GameId,
|
||||
GameId = gamel.GameId,
|
||||
IsOnline = true,
|
||||
Score = game.Score,
|
||||
OrderId = gameCbtOrderId,
|
||||
|
|
@ -282,9 +284,9 @@ tempGames.ForEach((Action<tempGame>)(game =>
|
|||
IsLimitToVip = false,
|
||||
GameLoadTime = game.GameLoadTime,
|
||||
Title2 = game.Title2,
|
||||
GameName = game.GameName,
|
||||
GameName = gamel.GameName,
|
||||
ImageId_Banner = 0,
|
||||
ConsumeDiamondNumHour = game.ConsumeDiamondNumHour,
|
||||
ConsumeDiamondNumHour = 60,
|
||||
ConsumeDiamondNumHourVip = 0,
|
||||
GameGroup = 0,
|
||||
VipTypeLimit = 0,
|
||||
|
|
|
|||
|
|
@ -46,7 +46,7 @@ namespace CloudGaming.Test
|
|||
},
|
||||
};
|
||||
|
||||
var dic = epgCategoryDto.ToDictionaryOrList();
|
||||
var dic = epgCategoryDto.ToDictionaryOrList(true);
|
||||
return dic;
|
||||
|
||||
}
|
||||
|
|
@ -85,7 +85,7 @@ namespace CloudGaming.Test
|
|||
});
|
||||
}
|
||||
|
||||
var dic = epgCategoryDtos.ToDictionaryOrList();
|
||||
var dic = epgCategoryDtos.ToDictionaryOrList(true);
|
||||
return dic;
|
||||
|
||||
}
|
||||
|
|
@ -111,368 +111,10 @@ namespace CloudGaming.Test
|
|||
}
|
||||
},
|
||||
};
|
||||
var dic = ObjectExtensions1.ToDictionaryOrList(epgCategoryDto);
|
||||
return dic;
|
||||
//var dic = ObjectExtensions.ToDictionaryOrList(epgCategoryDto);
|
||||
return null ;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//[Benchmark]
|
||||
public object ListToDictionaryOrListExtend1()
|
||||
{
|
||||
List<EpgCategoryDto> epgCategoryDtos = new List<EpgCategoryDto>();
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
epgCategoryDtos.Add(new EpgCategoryDto()
|
||||
{
|
||||
CategoryName = "Banner" + i,
|
||||
CategoryType = "Banner" + i,
|
||||
IsQuickStartPopUp = true,
|
||||
ShowNum_Index = 10 + i,
|
||||
EpgList = new List<EpgInfo>()
|
||||
{
|
||||
new EpgInfo(){
|
||||
CornerIcon=i,
|
||||
EpgId=i,
|
||||
IdName="IO"+i,
|
||||
ResType=4,
|
||||
Title="title"+i
|
||||
},
|
||||
new EpgInfo(){
|
||||
CornerIcon=i+2,
|
||||
EpgId=i+2,
|
||||
IdName="IO"+i+2,
|
||||
ResType=4+2,
|
||||
Title="title"+i+2
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var dic = ObjectExtensions1.ToDictionaryOrList(epgCategoryDtos);
|
||||
return dic;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//[Benchmark]
|
||||
public object ObjectToDictionaryOrListExtend3()
|
||||
{
|
||||
EpgCategoryDto epgCategoryDto = new EpgCategoryDto()
|
||||
{
|
||||
CategoryName = "Banner",
|
||||
CategoryType = "Banner",
|
||||
IsQuickStartPopUp = true,
|
||||
ShowNum_Index = 10,
|
||||
EpgList = new List<EpgInfo>()
|
||||
{
|
||||
new EpgInfo(){
|
||||
CornerIcon=10,
|
||||
EpgId=10,
|
||||
IdName="IO",
|
||||
ResType=4,
|
||||
Title="title"
|
||||
}
|
||||
},
|
||||
};
|
||||
var dic = ObjectExtensions3.ToDictionaryOrList(epgCategoryDto);
|
||||
return dic;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//[Benchmark]
|
||||
public object ListToDictionaryOrListExtend3()
|
||||
{
|
||||
List<EpgCategoryDto> epgCategoryDtos = new List<EpgCategoryDto>();
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
epgCategoryDtos.Add(new EpgCategoryDto()
|
||||
{
|
||||
CategoryName = "Banner" + i,
|
||||
CategoryType = "Banner" + i,
|
||||
IsQuickStartPopUp = true,
|
||||
ShowNum_Index = 10 + i,
|
||||
EpgList = new List<EpgInfo>()
|
||||
{
|
||||
new EpgInfo(){
|
||||
CornerIcon=i,
|
||||
EpgId=i,
|
||||
IdName="IO"+i,
|
||||
ResType=4,
|
||||
Title="title"+i
|
||||
},
|
||||
new EpgInfo(){
|
||||
CornerIcon=i+2,
|
||||
EpgId=i+2,
|
||||
IdName="IO"+i+2,
|
||||
ResType=4+2,
|
||||
Title="title"+i+2
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var dic = ObjectExtensions3.ToDictionaryOrList(epgCategoryDtos);
|
||||
return dic;
|
||||
|
||||
}
|
||||
|
||||
// [Benchmark]
|
||||
public object ObjectToDictionaryOrListExtend4()
|
||||
{
|
||||
EpgCategoryDto epgCategoryDto = new EpgCategoryDto()
|
||||
{
|
||||
CategoryName = "Banner",
|
||||
CategoryType = "Banner",
|
||||
IsQuickStartPopUp = true,
|
||||
ShowNum_Index = 10,
|
||||
EpgList = new List<EpgInfo>()
|
||||
{
|
||||
new EpgInfo(){
|
||||
CornerIcon=10,
|
||||
EpgId=10,
|
||||
IdName="IO",
|
||||
ResType=4,
|
||||
Title="title"
|
||||
}
|
||||
},
|
||||
};
|
||||
var dic = ObjectExtensions5.ToDictionaryOrList(epgCategoryDto);
|
||||
return dic;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//[Benchmark]
|
||||
public object ListToDictionaryOrListExtend4()
|
||||
{
|
||||
List<EpgCategoryDto> epgCategoryDtos = new List<EpgCategoryDto>();
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
epgCategoryDtos.Add(new EpgCategoryDto()
|
||||
{
|
||||
CategoryName = "Banner" + i,
|
||||
CategoryType = "Banner" + i,
|
||||
IsQuickStartPopUp = true,
|
||||
ShowNum_Index = 10 + i,
|
||||
EpgList = new List<EpgInfo>()
|
||||
{
|
||||
new EpgInfo(){
|
||||
CornerIcon=i,
|
||||
EpgId=i,
|
||||
IdName="IO"+i,
|
||||
ResType=4,
|
||||
Title="title"+i
|
||||
},
|
||||
new EpgInfo(){
|
||||
CornerIcon=i+2,
|
||||
EpgId=i+2,
|
||||
IdName="IO"+i+2,
|
||||
ResType=4+2,
|
||||
Title="title"+i+2
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var dic = ObjectExtensions5.ToDictionaryOrList(epgCategoryDtos);
|
||||
return dic;
|
||||
|
||||
}
|
||||
|
||||
//[Benchmark]
|
||||
public object ObjectToDictionaryOrListExtend6()
|
||||
{
|
||||
EpgCategoryDto epgCategoryDto = new EpgCategoryDto()
|
||||
{
|
||||
CategoryName = "Banner",
|
||||
CategoryType = "Banner",
|
||||
IsQuickStartPopUp = true,
|
||||
ShowNum_Index = 10,
|
||||
EpgList = new List<EpgInfo>()
|
||||
{
|
||||
new EpgInfo(){
|
||||
CornerIcon=10,
|
||||
EpgId=10,
|
||||
IdName="IO",
|
||||
ResType=4,
|
||||
Title="title"
|
||||
}
|
||||
},
|
||||
};
|
||||
var dic = ObjectExtensions6.ToDictionaryOrList(epgCategoryDto);
|
||||
return dic;
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
//[Benchmark]
|
||||
public object ListToDictionaryOrListExtend6()
|
||||
{
|
||||
List<EpgCategoryDto> epgCategoryDtos = new List<EpgCategoryDto>();
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
epgCategoryDtos.Add(new EpgCategoryDto()
|
||||
{
|
||||
CategoryName = "Banner" + i,
|
||||
CategoryType = "Banner" + i,
|
||||
IsQuickStartPopUp = true,
|
||||
ShowNum_Index = 10 + i,
|
||||
EpgList = new List<EpgInfo>()
|
||||
{
|
||||
new EpgInfo(){
|
||||
CornerIcon=i,
|
||||
EpgId=i,
|
||||
IdName="IO"+i,
|
||||
ResType=4,
|
||||
Title="title"+i
|
||||
},
|
||||
new EpgInfo(){
|
||||
CornerIcon=i+2,
|
||||
EpgId=i+2,
|
||||
IdName="IO"+i+2,
|
||||
ResType=4+2,
|
||||
Title="title"+i+2
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var dic = ObjectExtensions6.ToDictionaryOrList(epgCategoryDtos);
|
||||
return dic;
|
||||
}
|
||||
|
||||
|
||||
//[Benchmark]
|
||||
public object ObjectToDictionaryOrListExtend7()
|
||||
{
|
||||
EpgCategoryDto epgCategoryDto = new EpgCategoryDto()
|
||||
{
|
||||
CategoryName = "Banner",
|
||||
CategoryType = "Banner",
|
||||
IsQuickStartPopUp = true,
|
||||
ShowNum_Index = 10,
|
||||
EpgList = new List<EpgInfo>()
|
||||
{
|
||||
new EpgInfo(){
|
||||
CornerIcon=10,
|
||||
EpgId=10,
|
||||
IdName="IO",
|
||||
ResType=4,
|
||||
Title="title"
|
||||
}
|
||||
},
|
||||
};
|
||||
var dic = ObjectExtensions6.ToDictionaryOrList(epgCategoryDto);
|
||||
return dic;
|
||||
|
||||
}
|
||||
|
||||
|
||||
//[Benchmark]
|
||||
public object ListToDictionaryOrListExtend7()
|
||||
{
|
||||
List<EpgCategoryDto> epgCategoryDtos = new List<EpgCategoryDto>();
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
epgCategoryDtos.Add(new EpgCategoryDto()
|
||||
{
|
||||
CategoryName = "Banner" + i,
|
||||
CategoryType = "Banner" + i,
|
||||
IsQuickStartPopUp = true,
|
||||
ShowNum_Index = 10 + i,
|
||||
EpgList = new List<EpgInfo>()
|
||||
{
|
||||
new EpgInfo(){
|
||||
CornerIcon=i,
|
||||
EpgId=i,
|
||||
IdName="IO"+i,
|
||||
ResType=4,
|
||||
Title="title"+i
|
||||
},
|
||||
new EpgInfo(){
|
||||
CornerIcon=i+2,
|
||||
EpgId=i+2,
|
||||
IdName="IO"+i+2,
|
||||
ResType=4+2,
|
||||
Title="title"+i+2
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var dic = ObjectExtensions7.ToDictionaryOrList(epgCategoryDtos);
|
||||
return dic;
|
||||
}
|
||||
|
||||
//[Benchmark]
|
||||
public object ObjectToDictionaryOrListExtend8()
|
||||
{
|
||||
EpgCategoryDto epgCategoryDto = new EpgCategoryDto()
|
||||
{
|
||||
CategoryName = "Banner",
|
||||
CategoryType = "Banner",
|
||||
IsQuickStartPopUp = true,
|
||||
ShowNum_Index = 10,
|
||||
EpgList = new List<EpgInfo>()
|
||||
{
|
||||
new EpgInfo(){
|
||||
CornerIcon=10,
|
||||
EpgId=10,
|
||||
IdName="IO",
|
||||
ResType=4,
|
||||
Title="title"
|
||||
}
|
||||
},
|
||||
};
|
||||
var dic = ObjectExtensions.ToDictionaryOrList(epgCategoryDto);
|
||||
return dic;
|
||||
|
||||
}
|
||||
|
||||
|
||||
// [Benchmark]
|
||||
public object ListToDictionaryOrListExtend8()
|
||||
{
|
||||
List<EpgCategoryDto> epgCategoryDtos = new List<EpgCategoryDto>();
|
||||
for (int i = 0; i < 20; i++)
|
||||
{
|
||||
epgCategoryDtos.Add(new EpgCategoryDto()
|
||||
{
|
||||
CategoryName = "Banner" + i,
|
||||
CategoryType = "Banner" + i,
|
||||
IsQuickStartPopUp = true,
|
||||
ShowNum_Index = 10 + i,
|
||||
EpgList = new List<EpgInfo>()
|
||||
{
|
||||
new EpgInfo(){
|
||||
CornerIcon=i,
|
||||
EpgId=i,
|
||||
IdName="IO"+i,
|
||||
ResType=4,
|
||||
Title="title"+i
|
||||
},
|
||||
new EpgInfo(){
|
||||
CornerIcon=i+2,
|
||||
EpgId=i+2,
|
||||
IdName="IO"+i+2,
|
||||
ResType=4+2,
|
||||
Title="title"+i+2
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
var dic = ObjectExtensions.ToDictionaryOrList(epgCategoryDtos);
|
||||
return dic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace CloudGaming.DtoModel.PlayGame;
|
||||
|
||||
/// <summary>
|
||||
/// 玩游戏状态
|
||||
/// </summary>
|
||||
public enum PlayGamePayStatus
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
免费游戏 = 0,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
钻石 = 1,
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
会员免费 = 2
|
||||
}
|
||||
|
|
@ -157,6 +157,19 @@ public class PlayGameUserInfo
|
|||
/// </summary>
|
||||
public string Channel { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 当前游戏付费状态
|
||||
/// </summary>
|
||||
public PlayGamePayStatus? PlayGamePayStatus { get; set; }
|
||||
/// <summary>
|
||||
/// 会员游玩时间
|
||||
/// </summary>
|
||||
public int VipCardPlayTime { get; set; }
|
||||
/// <summary>
|
||||
/// 免费游玩时间
|
||||
/// </summary>
|
||||
public int FreePlayTime { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 转化成数据库实体类
|
||||
/// </summary>
|
||||
|
|
@ -196,7 +209,7 @@ public class PlayGameUserInfo
|
|||
GameStatus = (int)GameStatus,
|
||||
GameUserOperationJson = GameUserOperation == null ? "" : JsonConvert.SerializeObject(GameUserOperation, settings),
|
||||
Channel = Channel,
|
||||
CreateDay = int.Parse(CreateDateTime.ToString("yyyyMMdd"))
|
||||
CreateDay = int.Parse(CreateDateTime.ToString("yyyyMMdd")),
|
||||
};
|
||||
return log;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user