feat: 为充值记录新增订单类型字段并区分VIP与套餐逻辑
This commit is contained in:
@@ -8,6 +8,7 @@ using Yi.Framework.AiHub.Application.Contracts.IServices;
|
||||
using Yi.Framework.AiHub.Domain.Entities;
|
||||
using Yi.Framework.AiHub.Domain.Managers;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Consts;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
using Yi.Framework.Rbac.Application.Contracts.IServices;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
@@ -64,6 +65,7 @@ namespace Yi.Framework.AiHub.Application.Services
|
||||
{
|
||||
// 直接查询该用户最大的过期时间
|
||||
var maxExpireTime = await _repository._DbQueryable
|
||||
.Where(x => x.RechargeType == RechargeTypeEnum.Vip)
|
||||
.Where(x => x.UserId == input.UserId && x.ExpireDateTime.HasValue)
|
||||
.MaxAsync(x => x.ExpireDateTime);
|
||||
|
||||
@@ -85,7 +87,8 @@ namespace Yi.Framework.AiHub.Application.Services
|
||||
Content = input.Content,
|
||||
ExpireDateTime = expireDateTime,
|
||||
Remark = input.Remark,
|
||||
ContactInfo = input.ContactInfo
|
||||
ContactInfo = input.ContactInfo,
|
||||
RechargeType = RechargeTypeEnum.Vip
|
||||
};
|
||||
|
||||
// 保存充值记录到数据库
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
|
||||
public enum RechargeTypeEnum
|
||||
{
|
||||
Vip = 10,
|
||||
PremiumPackage = 20
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using SqlSugar;
|
||||
using Volo.Abp.Domain.Entities.Auditing;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
|
||||
namespace Yi.Framework.AiHub.Domain.Entities;
|
||||
|
||||
@@ -13,7 +14,7 @@ public class AiRechargeAggregateRoot : FullAuditedAggregateRoot<Guid>
|
||||
/// 充值金额
|
||||
/// </summary>
|
||||
public decimal RechargeAmount { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 用户
|
||||
/// </summary>
|
||||
@@ -33,9 +34,14 @@ public class AiRechargeAggregateRoot : FullAuditedAggregateRoot<Guid>
|
||||
/// 到期时间
|
||||
/// </summary>
|
||||
public DateTime? ExpireDateTime { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 联系方式
|
||||
/// </summary>
|
||||
public string? ContactInfo { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 订单类型
|
||||
/// </summary>
|
||||
public RechargeTypeEnum RechargeType { get; set; }
|
||||
}
|
||||
@@ -2,6 +2,7 @@
|
||||
using Volo.Abp.Domain.Services;
|
||||
using Yi.Framework.AiHub.Domain.Entities;
|
||||
using Yi.Framework.AiHub.Domain.Entities.OpenApi;
|
||||
using Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||
|
||||
namespace Yi.Framework.AiHub.Domain.Managers;
|
||||
@@ -28,7 +29,7 @@ public class AiRechargeManager : DomainService
|
||||
var currentTime = DateTime.Now;
|
||||
|
||||
// 查找所有充值记录,按用户分组
|
||||
var allRecharges = await _rechargeRepository._DbQueryable
|
||||
var allRecharges = await _rechargeRepository._DbQueryable.Where(x => x.RechargeType == RechargeTypeEnum.Vip)
|
||||
.ToListAsync();
|
||||
|
||||
if (!allRecharges.Any())
|
||||
@@ -48,7 +49,7 @@ public class AiRechargeManager : DomainService
|
||||
|
||||
// 找到用户最大的过期时间
|
||||
var maxExpireTime = group.Max(x => x.ExpireDateTime);
|
||||
|
||||
|
||||
// 如果最大过期时间小于当前时间,说明用户已过期(比较日期,满足用户最后一天)
|
||||
return maxExpireTime.HasValue && maxExpireTime.Value.Date < currentTime.Date;
|
||||
})
|
||||
|
||||
@@ -66,7 +66,8 @@ public class PremiumPackageManager : DomainService
|
||||
Content = packageName,
|
||||
ExpireDateTime = premiumPackage.ExpireDateTime,
|
||||
Remark = "自助充值",
|
||||
ContactInfo = null
|
||||
ContactInfo = null,
|
||||
RechargeType = RechargeTypeEnum.PremiumPackage
|
||||
};
|
||||
|
||||
// 保存充值记录到数据库
|
||||
|
||||
Reference in New Issue
Block a user