提交代码
This commit is contained in:
parent
32f10aac42
commit
ffe68945d6
|
|
@ -123,7 +123,7 @@ namespace HuanMeng.MiaoYu.Code.Cache.Special
|
|||
|
||||
var imgUrl = product.ProductImg;
|
||||
var price = product.Price;
|
||||
if (product.IsFirstCharge && userOrderBy.ContainsKey(product.ProductId))
|
||||
if (product.IsFirstCharge && !userOrderBy.ContainsKey(product.ProductId))
|
||||
{
|
||||
imgUrl = product.FirstChargeImg;
|
||||
|
||||
|
|
|
|||
|
|
@ -45,17 +45,40 @@ namespace HuanMeng.MiaoYu.Code.Mall
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// 商城
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<BaseResponse<ShopInfoDto>> GetShopInfoListAsync()
|
||||
{
|
||||
ShopInfoDto myAccountInfoDto = new ShopInfoDto();
|
||||
UserInfoBLL user = new UserInfoBLL(Dao, _UserId);
|
||||
Dictionary<string, int> orderDictionary = new Dictionary<string, int>();
|
||||
if (_UserId > 0)
|
||||
{
|
||||
orderDictionary = Dao.daoDbMiaoYu.context.T_Order
|
||||
.Where(it => it.UserId == _UserId)
|
||||
.GroupBy(it => it.OrderId)
|
||||
.ToDictionary(it => it.Key, it => it.Count());
|
||||
}
|
||||
ProductEntityCache productEntityCache = new ProductEntityCache(this);
|
||||
var list = productEntityCache.GetMallItemDto(null);
|
||||
var list = productEntityCache.GetMallItemDto(orderDictionary);
|
||||
myAccountInfoDto.Mall = list;
|
||||
var cardList = await Dao.daoDbMiaoYu.context.T_User_MemoryCard.Where(it => it.UserId == _UserId && it.CharacterId == 0).ToListAsync();
|
||||
myAccountInfoDto.Purchased = new List<PurchasedItemDto>();
|
||||
cardList?.ForEach(it =>
|
||||
{
|
||||
PurchasedItemDto purchasedItemDto = new PurchasedItemDto()
|
||||
{
|
||||
ProductId = it.PopId,
|
||||
BuyingTime = it.CreateTime,
|
||||
ImgUrl = it.Image,
|
||||
ProductName = it.Name,
|
||||
PropName = it.Name,
|
||||
PriceType = 0,
|
||||
PropType = (int)ProductType.记忆卡
|
||||
};
|
||||
myAccountInfoDto.Purchased.Add(purchasedItemDto);
|
||||
});
|
||||
return new BaseResponse<ShopInfoDto>(ResonseCode.Success, "", myAccountInfoDto);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,18 @@
|
|||
using HuanMeng.MiaoYu.Code.AppExtend;
|
||||
using HuanMeng.MiaoYu.Code.Cache.Special;
|
||||
using HuanMeng.MiaoYu.Code.DataAccess;
|
||||
using HuanMeng.MiaoYu.Code.Payment;
|
||||
using HuanMeng.MiaoYu.Code.Users;
|
||||
using HuanMeng.MiaoYu.Model.DbSqlServer.Db_MiaoYu;
|
||||
using HuanMeng.MiaoYu.Model.Dto.Order;
|
||||
using HuanMeng.MiaoYu.Model.EnumModel.User;
|
||||
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using StackExchange.Redis;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
@ -104,6 +110,75 @@ namespace HuanMeng.MiaoYu.Code.Order
|
|||
}
|
||||
return new BaseResponse<bool>(ResonseCode.Success, tips, true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 购买产品
|
||||
/// </summary>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="buyCount"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public async Task<BaseResponse<bool>> BuyProduct(string productId, int buyCount = 1)
|
||||
{
|
||||
if (buyCount < 1)
|
||||
{
|
||||
buyCount = 1;
|
||||
}
|
||||
var product = await Dao.daoDbMiaoYu.context.T_Products.Where(it => it.ProductId == productId && it.ProductType == 1).FirstOrDefaultAsync();
|
||||
if (product == null)
|
||||
{
|
||||
|
||||
throw new Exception("未找到产品");
|
||||
}
|
||||
var image = product.ProductImgId.GetImageUrl(this);
|
||||
var user = await Dao.daoDbMiaoYu.context.T_User.FirstOrDefaultAsync(it => it.Id == _UserId);
|
||||
if (user == null)
|
||||
{
|
||||
throw new Exception("用户不存在");
|
||||
}
|
||||
var baseKey = $"pay:lock:{_UserId}:{productId}";
|
||||
|
||||
if (!RedisCache.StringSetLock(baseKey, "", 10))
|
||||
{
|
||||
throw new Exception("正在购买中");
|
||||
}
|
||||
using (IDbContextTransaction transaction = Dao.daoDbMiaoYu.context.Database.BeginTransaction())
|
||||
{
|
||||
try
|
||||
{
|
||||
var price = (((int)product.Price) * buyCount);
|
||||
user.ConsumeMoneyNoWork(UserCurrencyType.语珠, -price, Dao, title: $"购买{product.ProductName}消耗{price}{UserCurrencyType.语珠}");
|
||||
for (int i = 0; i < buyCount; i++)
|
||||
{
|
||||
|
||||
var productReward = await Dao.daoDbMiaoYu.context.T_Products_Reward.Where(it => it.ProductId == product.ProductId).ToListAsync();
|
||||
|
||||
if (productReward != null && productReward.Count > 0)
|
||||
{
|
||||
List<string> tips = new List<string>();
|
||||
foreach (var reward in productReward)
|
||||
{
|
||||
var money = reward.Money;
|
||||
var currency = (UserCurrencyType)reward.CurrencyType;
|
||||
var userCurrency = new T_User_Currency();
|
||||
user.ConsumeMoneyNoWork(currency, money, Dao, userCurrency, productId: productId, imageUrl: image);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
await transaction.CommitAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
await transaction.RollbackAsync();
|
||||
RedisCache.KeyDelete(baseKey);
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
RedisCache.KeyDelete(baseKey);
|
||||
return new BaseResponse<bool>(ResonseCode.Success, $"购买成功,获得{product.ProductName}*{buyCount}", true) { };
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -6,11 +6,15 @@ using HuanMeng.MiaoYu.Code.Users.UserAccount.PhoneAccount;
|
|||
using HuanMeng.MiaoYu.Model.Dto;
|
||||
using HuanMeng.MiaoYu.Model.Dto.Account;
|
||||
using HuanMeng.MiaoYu.Model.Dto.Character;
|
||||
using HuanMeng.MiaoYu.Model.Dto.Shop;
|
||||
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
@ -154,6 +158,85 @@ namespace HuanMeng.MiaoYu.Code.Users
|
|||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 交易记录
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<BaseResponse<List<TransactionDto>>> GetTransactionRecords()
|
||||
{
|
||||
if (_UserId == 0)
|
||||
{
|
||||
return new BaseResponse<List<TransactionDto>>(ResonseCode.Success, "", new List<TransactionDto>());
|
||||
}
|
||||
var logs = await Dao.daoDbMiaoYu.context.T_User_Currency_Log.Where(it => it.UserId == _UserId && !(it.CurrencyType == (int)UserCurrencyType.聊天次数 && it.ConsumeType == 0)).OrderByDescending(it => it.Id).Take(50).ToListAsync();
|
||||
List<TransactionDto> list = new List<TransactionDto>();
|
||||
foreach (var item in logs)
|
||||
{
|
||||
TransactionDto transactionDto = new TransactionDto();
|
||||
transactionDto.TransactionType = 0;
|
||||
transactionDto.TransactionTime = item.CreateTime;
|
||||
transactionDto.CurrencyType = item.CurrencyType;
|
||||
transactionDto.TransactionContent = item.Title;
|
||||
transactionDto.TransactionAmount = item.Consume;
|
||||
list.Add(transactionDto);
|
||||
}
|
||||
//var obj = JsonConvert.DeserializeObject<List<TransactionDto>>("[{\"TransactionContent\":\"购买记忆提升道具卡\",\"TransactionTime\":\"2024-07-18 12:58:52.963\",\"TransactionAmount\":\"-10\",\"TransactionType\":0,\"CurrencyType\":0},{\"TransactionContent\":\"充值语珠\",\"TransactionTime\":\"2024-07-17 12:58:52.963\",\"TransactionAmount\":\"+100\",\"TransactionType\":0,\"CurrencyType\":0},{\"TransactionContent\":\"充值语珠\",\"TransactionTime\":\"2024-07-16 12:58:52.963\",\"TransactionAmount\":\"+200\",\"TransactionType\":0,\"CurrencyType\":0}]");
|
||||
return new BaseResponse<List<TransactionDto>>(ResonseCode.Success, "", list);
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取未使用的记忆卡列表
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<BaseResponse<List<PropInfoDto>>> GetMemoryCardInfo()
|
||||
{
|
||||
var list = await Dao.daoDbMiaoYu.context.T_User_MemoryCard.Where(it => it.UserId == _UserId && it.CharacterId == 0).ToListAsync();
|
||||
List<PropInfoDto> p = new List<PropInfoDto>();
|
||||
foreach (var item in list)
|
||||
{
|
||||
PropInfoDto propInfoDto = new PropInfoDto()
|
||||
{
|
||||
PropId = item.Id,
|
||||
ImgUrl = item.Image,
|
||||
PropName = item.Name,
|
||||
};
|
||||
p.Add(propInfoDto);
|
||||
}
|
||||
|
||||
return new BaseResponse<List<PropInfoDto>>(ResonseCode.Success, "", p);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用记忆卡
|
||||
/// </summary>
|
||||
/// <param name="memoryCardRequest"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public async Task<BaseResponse<bool>> UseMemoryCard(MemoryCardRequest memoryCardRequest)
|
||||
{
|
||||
if (memoryCardRequest.PropId == 0)
|
||||
{
|
||||
throw new Exception("道具id不对");
|
||||
}
|
||||
var memory = await Dao.daoDbMiaoYu.context.T_User_MemoryCard.Where(it => it.UserId == _UserId && it.Id == memoryCardRequest.PropId).FirstOrDefaultAsync();
|
||||
if (memory == null)
|
||||
{
|
||||
throw new Exception("道具不存在");
|
||||
}
|
||||
if (memory.CharacterId != 0)
|
||||
{
|
||||
throw new Exception("记忆卡已经被使用");
|
||||
}
|
||||
var key = $"Memory:lock:{_UserId}:{memoryCardRequest.CharacterId}:{memoryCardRequest.PropId}";
|
||||
if (!RedisCache.StringSetLock(key, "", 10))
|
||||
{
|
||||
throw new Exception("记忆卡重复使用");
|
||||
}
|
||||
memory.CharacterId = memoryCardRequest.CharacterId;
|
||||
memory.Remark = $"记忆卡使用时间{DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")}";
|
||||
await Dao.daoDbMiaoYu.context.SaveChangesAsync();
|
||||
RedisCache.KeyDelete(key);
|
||||
return new BaseResponse<bool>(ResonseCode.Success, "使用成功", true);
|
||||
}
|
||||
/// <summary>
|
||||
/// 账号注销
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@ using System.Linq;
|
|||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Code.Users
|
||||
|
|
@ -109,14 +110,14 @@ namespace HuanMeng.MiaoYu.Code.Users
|
|||
/// <param name="title"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="ArgumentNullException"></exception>
|
||||
public static bool ConsumeMoneyNoWork(this T_User user, UserCurrencyType userCurrencyType, decimal money, DAO dao, T_User_Currency? _currency = null, string orderId = "", string title = "")
|
||||
public static bool ConsumeMoneyNoWork(this T_User user, UserCurrencyType userCurrencyType, decimal money, DAO dao, T_User_Currency? _currency = null, string orderId = "", string title = "", string productId = "", string imageUrl = "")
|
||||
{
|
||||
if (user == null || user.Id == 0)
|
||||
{
|
||||
throw new ArgumentNullException("用户不能为空");
|
||||
}
|
||||
int userId = user.Id;
|
||||
return ConsumeMoneyNoWork(userId, userCurrencyType, money, dao, _currency, orderId: orderId, title: title);
|
||||
return ConsumeMoneyNoWork(userId, userCurrencyType, money, dao, _currency, orderId: orderId, title: title, productId: productId, imageUrl: imageUrl);
|
||||
}
|
||||
/// <summary>
|
||||
/// 扣除或者充值货币
|
||||
|
|
@ -162,6 +163,32 @@ namespace HuanMeng.MiaoYu.Code.Users
|
|||
|
||||
}
|
||||
|
||||
public static UserCurrencyType[] MUserCurrencyType = new UserCurrencyType[] {
|
||||
UserCurrencyType.高级记忆卡,
|
||||
UserCurrencyType.中级记忆卡,
|
||||
UserCurrencyType.初级记忆卡
|
||||
};
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="userCurrency"></param>
|
||||
/// <returns></returns>
|
||||
public static UserMemoryCardType GetUserMemoryCardType(this UserCurrencyType userCurrency)
|
||||
{
|
||||
if (UserCurrencyType.高级记忆卡 == userCurrency)
|
||||
{
|
||||
return UserMemoryCardType.高级记忆卡;
|
||||
}
|
||||
if (UserCurrencyType.中级记忆卡 == userCurrency)
|
||||
{
|
||||
return UserMemoryCardType.中级记忆卡;
|
||||
}
|
||||
if (UserCurrencyType.初级记忆卡 == userCurrency)
|
||||
{
|
||||
return UserMemoryCardType.初级记忆卡;
|
||||
}
|
||||
return UserMemoryCardType.记忆卡;
|
||||
}
|
||||
/// <summary>
|
||||
/// 扣除或者充值货币,没有事务
|
||||
/// </summary>>
|
||||
|
|
@ -169,10 +196,39 @@ namespace HuanMeng.MiaoYu.Code.Users
|
|||
/// <param name="userCurrencyType">货币类型</param>
|
||||
/// <param name="money">扣除金额(负数扣除,正数添加)</param>
|
||||
/// <param name="dao">数据库</param>
|
||||
/// <param name="_currency"></param>
|
||||
/// <param name="remarks"></param>
|
||||
/// <param name="title"></param>
|
||||
/// <param name="orderId"></param>
|
||||
/// <param name="productId"></param>
|
||||
/// <param name="imageUrl"></param>
|
||||
/// <returns></returns>
|
||||
/// <exception cref="Exception"></exception>
|
||||
public static bool ConsumeMoneyNoWork(int userId, UserCurrencyType userCurrencyType, decimal money, DAO dao, T_User_Currency? _currency = null, string remarks = "", string title = "", string orderId = "")
|
||||
public static bool ConsumeMoneyNoWork(int userId, UserCurrencyType userCurrencyType, decimal money, DAO dao, T_User_Currency? _currency = null, string remarks = "", string title = "", string orderId = "", string productId = "", string imageUrl = "")
|
||||
{
|
||||
//记忆卡特殊处理
|
||||
if (MUserCurrencyType.Contains(userCurrencyType) && money > 0)
|
||||
{
|
||||
var memoryCardType = userCurrencyType.GetUserMemoryCardType();
|
||||
T_User_MemoryCard t_User_MemoryCard = new T_User_MemoryCard()
|
||||
{
|
||||
RemainingCount = (int)money,
|
||||
CharacterId = 0,
|
||||
MemoryCardToken = memoryCardType.GetUserMemoryCardTypeToken(),
|
||||
CreateTime = DateTime.Now,
|
||||
MemoryCardType = (int)memoryCardType,
|
||||
UseCount = 0,
|
||||
Name = userCurrencyType.ToString(),
|
||||
PopId = productId,
|
||||
Remark = remarks,
|
||||
TenantId = dao.daoDbMiaoYu.context.TenantInfo.TenantId,
|
||||
UpdateTime = DateTime.Now,
|
||||
UserId = userId,
|
||||
Image = imageUrl
|
||||
};
|
||||
dao.daoDbMiaoYu.context.T_User_MemoryCard.Add(t_User_MemoryCard);
|
||||
money = 1;
|
||||
}
|
||||
var userCurrency = dao.daoDbMiaoYu.context.T_User_Currency.FirstOrDefault(it => it.UserId == userId && it.CurrencyType == (int)userCurrencyType);
|
||||
if (userCurrency == null)
|
||||
{
|
||||
|
|
@ -189,17 +245,19 @@ namespace HuanMeng.MiaoYu.Code.Users
|
|||
dao.daoDbMiaoYu.context.Add(userCurrency);
|
||||
dao.daoDbMiaoYu.context.SaveChanges();
|
||||
}
|
||||
|
||||
userCurrency.CurrencyMoney += money;
|
||||
if (userCurrency.CurrencyMoney < 0)
|
||||
{
|
||||
//余额不足
|
||||
throw new Exception("余额不足");
|
||||
}
|
||||
|
||||
T_User_Currency_Log? log = null;
|
||||
UserCurrencyConsumeType userCurrencyConsumeType = UserCurrencyConsumeType.消耗;
|
||||
if (money >= 0)
|
||||
{
|
||||
userCurrencyConsumeType = UserCurrencyConsumeType.充值;
|
||||
userCurrencyConsumeType = UserCurrencyConsumeType.购买;
|
||||
}
|
||||
|
||||
if (userCurrencyType == UserCurrencyType.聊天次数 && userCurrencyConsumeType == UserCurrencyConsumeType.消耗)
|
||||
|
|
@ -361,7 +419,7 @@ namespace HuanMeng.MiaoYu.Code.Users
|
|||
UserCurrencyConsumeType userCurrencyConsumeType = UserCurrencyConsumeType.消耗;
|
||||
if (money >= 0)
|
||||
{
|
||||
userCurrencyConsumeType = UserCurrencyConsumeType.充值;
|
||||
userCurrencyConsumeType = UserCurrencyConsumeType.购买;
|
||||
}
|
||||
|
||||
if (userCurrencyType == UserCurrencyType.聊天次数 && userCurrencyConsumeType == UserCurrencyConsumeType.消耗)
|
||||
|
|
|
|||
|
|
@ -98,7 +98,7 @@ namespace HuanMeng.MiaoYu.Code.Users
|
|||
/// <summary>
|
||||
/// 记忆卡
|
||||
/// </summary>
|
||||
public Dictionary<int, Dictionary<UserMemoryCardType, T_User_MemoryCard>>? UserMemoryCard { get; set; }
|
||||
public Dictionary<int, Dictionary<UserMemoryCardType, List<T_User_MemoryCard>>>? UserMemoryCard { get; set; }
|
||||
/// <summary>
|
||||
/// 获取记忆卡
|
||||
/// </summary>
|
||||
|
|
@ -113,10 +113,10 @@ namespace HuanMeng.MiaoYu.Code.Users
|
|||
if (UserMemoryCard == null)
|
||||
{
|
||||
string key = $"{dao.daoDbMiaoYu.context.TenantInfo.TenantId}:User:{userId}:MemoryCard";
|
||||
UserMemoryCard = MemoryCacheHelper.GetCache<Dictionary<int, Dictionary<UserMemoryCardType, T_User_MemoryCard>>>(key);
|
||||
UserMemoryCard = MemoryCacheHelper.GetCache<Dictionary<int, Dictionary<UserMemoryCardType, List<T_User_MemoryCard>>>>(key);
|
||||
if (UserMemoryCard == null)
|
||||
{
|
||||
UserMemoryCard = new Dictionary<int, Dictionary<UserMemoryCardType, T_User_MemoryCard>>();
|
||||
UserMemoryCard = new Dictionary<int, Dictionary<UserMemoryCardType, List<T_User_MemoryCard>>>();
|
||||
//获取当前用户所有的记忆卡
|
||||
var _currencuys = dao.daoDbMiaoYu.context.T_User_MemoryCard.AsNoTracking().Where(it => it.UserId == userId && it.RemainingCount > 0).ToList();
|
||||
if (_currencuys != null)
|
||||
|
|
@ -124,10 +124,16 @@ namespace HuanMeng.MiaoYu.Code.Users
|
|||
var characterIds = _currencuys.Select(it => it.CharacterId).Distinct().ToList();
|
||||
foreach (var _characterId in characterIds)
|
||||
{
|
||||
var _temp = new Dictionary<UserMemoryCardType, T_User_MemoryCard>();
|
||||
var _temp = new Dictionary<UserMemoryCardType, List<T_User_MemoryCard>>();
|
||||
|
||||
foreach (var item in _currencuys)
|
||||
{
|
||||
_temp.Add((UserMemoryCardType)item.MemoryCardType, item);
|
||||
var k = (UserMemoryCardType)item.MemoryCardType;
|
||||
if (_temp.ContainsKey(k))
|
||||
{
|
||||
_temp.Add((UserMemoryCardType)item.MemoryCardType, new List<T_User_MemoryCard>());
|
||||
}
|
||||
_temp[k].Add(item);
|
||||
}
|
||||
UserMemoryCard.Add(_characterId, _temp);
|
||||
}
|
||||
|
|
@ -135,36 +141,36 @@ namespace HuanMeng.MiaoYu.Code.Users
|
|||
MemoryCacheHelper.SetCache(key, UserMemoryCard, 60 * 5);
|
||||
}
|
||||
}
|
||||
T_User_MemoryCard? _memoryCard = null;
|
||||
List<T_User_MemoryCard>? _memoryCards = null;
|
||||
if (UserMemoryCard.TryGetValue(characterId, out var _m))
|
||||
{
|
||||
if (userMemoryCardType == UserMemoryCardType.记忆卡)
|
||||
{
|
||||
|
||||
if (_m.TryGetValue(UserMemoryCardType.高级记忆卡, out _memoryCard))
|
||||
if (_m.TryGetValue(UserMemoryCardType.高级记忆卡, out _memoryCards))
|
||||
{
|
||||
return _memoryCard;
|
||||
return _memoryCards[0];
|
||||
}
|
||||
|
||||
if (_m.TryGetValue(UserMemoryCardType.中级记忆卡, out _memoryCard))
|
||||
if (_m.TryGetValue(UserMemoryCardType.中级记忆卡, out _memoryCards))
|
||||
{
|
||||
return _memoryCard;
|
||||
return _memoryCards[0];
|
||||
}
|
||||
|
||||
if (_m.TryGetValue(UserMemoryCardType.初级记忆卡, out _memoryCard))
|
||||
if (_m.TryGetValue(UserMemoryCardType.初级记忆卡, out _memoryCards))
|
||||
{
|
||||
return _memoryCard;
|
||||
return _memoryCards[0];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_m.TryGetValue(userMemoryCardType, out _memoryCard))
|
||||
if (_m.TryGetValue(userMemoryCardType, out _memoryCards))
|
||||
{
|
||||
return _memoryCard;
|
||||
return _memoryCards[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
return _memoryCard;
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1221,6 +1221,7 @@ public partial class MiaoYuContext : MultiTenantDbContext//DbContext
|
|||
entity.Property(e => e.CreateTime)
|
||||
.HasComment("创建时间")
|
||||
.HasColumnType("datetime");
|
||||
entity.Property(e => e.Image).HasMaxLength(200);
|
||||
entity.Property(e => e.MemoryCardToken).HasComment("记忆卡提升的token");
|
||||
entity.Property(e => e.MemoryCardType).HasComment("记忆卡类型,0初级,1中级,2高级");
|
||||
entity.Property(e => e.Name)
|
||||
|
|
|
|||
|
|
@ -65,4 +65,6 @@ public partial class T_User_MemoryCard: MultiTenantEntity
|
|||
/// 计费产品Id
|
||||
/// </summary>
|
||||
public virtual string PopId { get; set; } = null!;
|
||||
|
||||
public virtual string? Image { get; set; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace HuanMeng.MiaoYu.Model.Dto.Order
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public class BuyProductRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 产品编号
|
||||
/// </summary>
|
||||
public string ProductId { get; set; }
|
||||
/// <summary>
|
||||
/// 购买数量
|
||||
/// </summary>
|
||||
public int? BuyCount { get; set; } = 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -105,4 +105,19 @@ namespace HuanMeng.MiaoYu.Model.Dto.Shop
|
|||
/// </summary>
|
||||
public string ImgUrl { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用记忆卡
|
||||
/// </summary>
|
||||
public class MemoryCardRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 记忆卡Id
|
||||
/// </summary>
|
||||
public int PropId { get; set; }
|
||||
/// <summary>
|
||||
/// 角色Id
|
||||
/// </summary>
|
||||
public int CharacterId { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,17 @@ namespace HuanMeng.MiaoYu.Model.EnumModel.User
|
|||
/// </summary>
|
||||
记忆卡 = 3,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 初级记忆卡
|
||||
/// </summary>
|
||||
初级记忆卡 = 301,
|
||||
/// <summary>
|
||||
/// 中级记忆卡
|
||||
/// </summary>
|
||||
中级记忆卡 = 302,
|
||||
/// <summary>
|
||||
/// 高级记忆卡
|
||||
/// </summary>
|
||||
高级记忆卡 = 303
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,6 @@ namespace HuanMeng.MiaoYu.Model.EnumModel
|
|||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
充值 = 1
|
||||
购买 = 1
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,10 +84,9 @@ namespace HuanMeng.MiaoYu.WebApi.Controllers
|
|||
[HttpGet]
|
||||
public async Task<BaseResponse<MyAccountInfoDto>> GetMyAccount()
|
||||
{
|
||||
ProductBLL productBLL= new ProductBLL(ServiceProvider);
|
||||
ProductBLL productBLL = new ProductBLL(ServiceProvider);
|
||||
return await productBLL.GetMyAccountInfoList();
|
||||
//var obj = JsonConvert.DeserializeObject<MyAccountInfoDto>("{\"Currency\":1,\"CurrencyRechargeList\":[{\"Id\":0,\"CurrencyCount\":100,\"Price\":10,\"Discount\":\" 0%\",\"CurrencyType\":0,\"ImgUrl\":\"\"},{\"Id\":1,\"CurrencyCount\":200,\"Price\":20,\"Discount\":\" -10%\",\"CurrencyType\":0,\"ImgUrl\":\"\"}]}");
|
||||
//return new BaseResponse<MyAccountInfoDto>(ResonseCode.Success, "", obj);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -97,10 +96,12 @@ namespace HuanMeng.MiaoYu.WebApi.Controllers
|
|||
[HttpGet]
|
||||
public async Task<BaseResponse<List<TransactionDto>>> GetTransactionRecords()
|
||||
{
|
||||
var obj = JsonConvert.DeserializeObject<List<TransactionDto>>("[{\"TransactionContent\":\"购买记忆提升道具卡\",\"TransactionTime\":\"2024-07-18 12:58:52.963\",\"TransactionAmount\":\"-10\",\"TransactionType\":0,\"CurrencyType\":0},{\"TransactionContent\":\"充值语珠\",\"TransactionTime\":\"2024-07-17 12:58:52.963\",\"TransactionAmount\":\"+100\",\"TransactionType\":0,\"CurrencyType\":0},{\"TransactionContent\":\"充值语珠\",\"TransactionTime\":\"2024-07-16 12:58:52.963\",\"TransactionAmount\":\"+200\",\"TransactionType\":0,\"CurrencyType\":0}]");
|
||||
return new BaseResponse<List<TransactionDto>>(ResonseCode.Success, "", obj);
|
||||
UserBLL userBLL = new UserBLL(ServiceProvider);
|
||||
return await userBLL.GetTransactionRecords();
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 商城 - 获取商城商品 Mall
|
||||
/// </summary>
|
||||
|
|
@ -111,8 +112,6 @@ namespace HuanMeng.MiaoYu.WebApi.Controllers
|
|||
{
|
||||
ProductBLL productBLL = new ProductBLL(ServiceProvider);
|
||||
return await productBLL.GetShopInfoListAsync();
|
||||
//var obj = JsonConvert.DeserializeObject<ShopInfoDto>("{\"Mall\":[{\"PropId\":1,\"PropName\":\"记忆卡1\",\"PropCount\":100,\"PropType\":0,\"Price\":10,\"PriceType\":0,\"ImgUrl\":\"https://cos.shhuanmeng.com/image/20240718110512.png\"},{\"PropId\":2,\"PropName\":\"记忆卡2\",\"PropCount\":100,\"PropType\":0,\"Price\":20,\"PriceType\":0,\"ImgUrl\":\"https://cos.shhuanmeng.com/image/20240718110518.png\"}],\"Purchased\":[{\"PropId\":2,\"PropName\":\"记忆卡2\",\"PropCount\":100,\"PropType\":0,\"Price\":20,\"PriceType\":0,\"ImgUrl\":\"https://cos.shhuanmeng.com/image/20240718110518.png\",\"BuyingTime\":\"2024-07-09 03:33:09.563\"}]}");
|
||||
//return new BaseResponse<ShopInfoDto>(ResonseCode.Success, "", obj);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ using HuanMeng.DotNetCore.Base;
|
|||
using HuanMeng.MiaoYu.Code.Cache;
|
||||
using HuanMeng.MiaoYu.Code.Character;
|
||||
using HuanMeng.MiaoYu.Code.Chat;
|
||||
using HuanMeng.MiaoYu.Code.Users;
|
||||
using HuanMeng.MiaoYu.Model.Dto.Character;
|
||||
using HuanMeng.MiaoYu.Model.Dto.Chat;
|
||||
using HuanMeng.MiaoYu.Model.Dto.Shop;
|
||||
|
|
@ -139,11 +140,22 @@ namespace HuanMeng.MiaoYu.WebApi.Controllers
|
|||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
[AllowAnonymous]
|
||||
public async Task<BaseResponse<List<PropInfoDto>>> GetMemoryCardInfo()
|
||||
{
|
||||
var obj = JsonConvert.DeserializeObject<List<PropInfoDto>>("[{\"PropId\":\"1\",\"PropName\":\"记忆卡1\",\"ImgUrl\":\"\"},{\"PropId\":\"2\",\"PropName\":\"记忆卡2\",\"ImgUrl\":\"\"}]");
|
||||
return new BaseResponse<List<PropInfoDto>>(ResonseCode.Success, "", obj);
|
||||
UserBLL userBLL = new UserBLL(ServiceProvider);
|
||||
return await userBLL.GetMemoryCardInfo();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 使用道具卡
|
||||
/// </summary>
|
||||
/// <param name="memoryCardRequest"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<BaseResponse<bool>> UseMemoryCard([FromBody] MemoryCardRequest memoryCardRequest)
|
||||
{
|
||||
UserBLL userBLL = new UserBLL(ServiceProvider);
|
||||
return await userBLL.UseMemoryCard(memoryCardRequest);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,5 +45,17 @@ namespace HuanMeng.MiaoYu.WebApi.Controllers
|
|||
OrderBLL orderBLL = new OrderBLL(ServiceProvider);
|
||||
return await orderBLL.GetOrderRewardsInfo(orderId);
|
||||
}
|
||||
/// <summary>
|
||||
/// 购买商城物品
|
||||
/// </summary>
|
||||
/// <param name="buyProductRequest"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<BaseResponse<bool>> BuyProduct([FromBody] BuyProductRequest buyProductRequest)
|
||||
{
|
||||
OrderBLL orderBLL = new OrderBLL(ServiceProvider);
|
||||
return await orderBLL.BuyProduct(buyProductRequest.ProductId, buyProductRequest.BuyCount ?? 1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user