diff --git a/src/CloudGaming/Code/CloudGaming.Code/Account/AccountBLL.cs b/src/CloudGaming/Code/CloudGaming.Code/Account/AccountBLL.cs
index 1724ace..47f1212 100644
--- a/src/CloudGaming/Code/CloudGaming.Code/Account/AccountBLL.cs
+++ b/src/CloudGaming/Code/CloudGaming.Code/Account/AccountBLL.cs
@@ -529,7 +529,7 @@ namespace CloudGaming.Code.Account
UserId = _UserId,
Ip = HttpContextAccessor.HttpContext.GetClientIpAddress()
};
-
+ await this.GetConsumeMoney(UserCurrencyType.钻石).ConsumeMoneyAsync(10);
await Dao.DaoUser.Context.T_User_LimitActionLog.AddAsync(limitActionLog);
await Dao.DaoUser.Context.SaveChangesAsync();
return "奖励已经发送,钻石*10";
diff --git a/src/CloudGaming/Code/CloudGaming.Code/Account/AccountExtend.cs b/src/CloudGaming/Code/CloudGaming.Code/Account/AccountExtend.cs
index 3745fa1..5d3e4b2 100644
--- a/src/CloudGaming/Code/CloudGaming.Code/Account/AccountExtend.cs
+++ b/src/CloudGaming/Code/CloudGaming.Code/Account/AccountExtend.cs
@@ -1,5 +1,6 @@
using CloudGaming.Code.Account.Contract;
using CloudGaming.Code.Account.Login;
+using CloudGaming.Code.Account.UserCurrency;
using CloudGaming.Code.DataAccess;
using CloudGaming.DtoModel.Account.Login;
using CloudGaming.DtoModel.Account.User;
@@ -219,5 +220,20 @@ namespace CloudGaming.Code.Account
await cloudGamingBase.RedisCache.StringSetAsync(key, userInfo, TimeSpan.FromHours(1));
return userInfo;
}
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static IUserConsumeMoney GetConsumeMoney(this CloudGamingBase cloudGamingBase, UserCurrencyType userCurrencyType)
+ {
+ if (UserCurrencyType.钻石 == userCurrencyType)
+ {
+ return new DiamondConsumeMoney(cloudGamingBase);
+ }
+ return new DiamondConsumeMoney(cloudGamingBase);
+ }
}
}
diff --git a/src/CloudGaming/Code/CloudGaming.Code/Account/Contract/IUserConsumeMoney.cs b/src/CloudGaming/Code/CloudGaming.Code/Account/Contract/IUserConsumeMoney.cs
new file mode 100644
index 0000000..297fe8a
--- /dev/null
+++ b/src/CloudGaming/Code/CloudGaming.Code/Account/Contract/IUserConsumeMoney.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CloudGaming.Code.Account.Contract;
+
+///
+/// 用户货币变更
+///
+public interface IUserConsumeMoney
+{
+ ///
+ /// 扣除或者添加货币
+ ///
+ ///
+ ///
+ public Task ConsumeMoneyAsync(decimal money);
+}
diff --git a/src/CloudGaming/Code/CloudGaming.Code/Account/UserCurrency/DiamondConsumeMoney.cs b/src/CloudGaming/Code/CloudGaming.Code/Account/UserCurrency/DiamondConsumeMoney.cs
new file mode 100644
index 0000000..4c2a385
--- /dev/null
+++ b/src/CloudGaming/Code/CloudGaming.Code/Account/UserCurrency/DiamondConsumeMoney.cs
@@ -0,0 +1,21 @@
+using CloudGaming.Code.Account.Contract;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CloudGaming.Code.Account.UserCurrency
+{
+ ///
+ ///
+ ///
+ public class DiamondConsumeMoney(CloudGamingBase cloudGamingBase) : IUserConsumeMoney
+ {
+ public Task ConsumeMoneyAsync(decimal money)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/src/CloudGaming/Code/CloudGaming.Code/Account/UserCurrencyExtend.cs b/src/CloudGaming/Code/CloudGaming.Code/Account/UserCurrencyExtend.cs
new file mode 100644
index 0000000..89416f6
--- /dev/null
+++ b/src/CloudGaming/Code/CloudGaming.Code/Account/UserCurrencyExtend.cs
@@ -0,0 +1,96 @@
+using CloudGaming.Code.DataAccess;
+using CloudGaming.DtoModel.Account.User;
+
+using Microsoft.EntityFrameworkCore.Storage;
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace CloudGaming.Code.Account
+{
+ public static class UserCurrencyExtend
+ {
+ ///
+ /// 获取用户货币余额,没有货币的时候添加
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static async Task 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)
+ {
+ 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;
+ }
+
+ ///
+ /// 获取用户货币余额
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static async Task 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;
+ }
+
+ ///
+ /// 获取用户所有货币信息
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static async Task> 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;
+ }
+
+ ///
+ /// 扣除或者充值货币
+ ///
+ ///
+ /// 货币类型
+ /// 扣除金额(负数扣除,正数添加)
+ /// 数据库
+ ///
+ /// 订单号
+ ///
+ ///
+ ///
+ public static 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)
+ {
+ throw new ArgumentNullException("用户不能为空");
+ }
+ int userId = user.Id;
+ return ConsumeMoneyNoWork(userId, userCurrencyType, money, dao, orderId: orderId, title: title);
+ }
+ public static bool ConsumeMoneyNoWork(int userId, UserCurrencyType userCurrencyType, decimal money, DAO dao, T_User_Currency? _currency = null, string remarks = "", string title = "", string orderId = "")
+ {
+
+ return true;
+ }
+ }
+}