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.Entities;
|
||||||
using Yi.Framework.AiHub.Domain.Managers;
|
using Yi.Framework.AiHub.Domain.Managers;
|
||||||
using Yi.Framework.AiHub.Domain.Shared.Consts;
|
using Yi.Framework.AiHub.Domain.Shared.Consts;
|
||||||
|
using Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||||
using Yi.Framework.Rbac.Application.Contracts.IServices;
|
using Yi.Framework.Rbac.Application.Contracts.IServices;
|
||||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||||
|
|
||||||
@@ -64,6 +65,7 @@ namespace Yi.Framework.AiHub.Application.Services
|
|||||||
{
|
{
|
||||||
// 直接查询该用户最大的过期时间
|
// 直接查询该用户最大的过期时间
|
||||||
var maxExpireTime = await _repository._DbQueryable
|
var maxExpireTime = await _repository._DbQueryable
|
||||||
|
.Where(x => x.RechargeType == RechargeTypeEnum.Vip)
|
||||||
.Where(x => x.UserId == input.UserId && x.ExpireDateTime.HasValue)
|
.Where(x => x.UserId == input.UserId && x.ExpireDateTime.HasValue)
|
||||||
.MaxAsync(x => x.ExpireDateTime);
|
.MaxAsync(x => x.ExpireDateTime);
|
||||||
|
|
||||||
@@ -85,7 +87,8 @@ namespace Yi.Framework.AiHub.Application.Services
|
|||||||
Content = input.Content,
|
Content = input.Content,
|
||||||
ExpireDateTime = expireDateTime,
|
ExpireDateTime = expireDateTime,
|
||||||
Remark = input.Remark,
|
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 SqlSugar;
|
||||||
using Volo.Abp.Domain.Entities.Auditing;
|
using Volo.Abp.Domain.Entities.Auditing;
|
||||||
|
using Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||||
|
|
||||||
namespace Yi.Framework.AiHub.Domain.Entities;
|
namespace Yi.Framework.AiHub.Domain.Entities;
|
||||||
|
|
||||||
@@ -38,4 +39,9 @@ public class AiRechargeAggregateRoot : FullAuditedAggregateRoot<Guid>
|
|||||||
/// 联系方式
|
/// 联系方式
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public string? ContactInfo { get; set; }
|
public string? ContactInfo { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 订单类型
|
||||||
|
/// </summary>
|
||||||
|
public RechargeTypeEnum RechargeType { get; set; }
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,7 @@
|
|||||||
using Volo.Abp.Domain.Services;
|
using Volo.Abp.Domain.Services;
|
||||||
using Yi.Framework.AiHub.Domain.Entities;
|
using Yi.Framework.AiHub.Domain.Entities;
|
||||||
using Yi.Framework.AiHub.Domain.Entities.OpenApi;
|
using Yi.Framework.AiHub.Domain.Entities.OpenApi;
|
||||||
|
using Yi.Framework.AiHub.Domain.Shared.Enums;
|
||||||
using Yi.Framework.SqlSugarCore.Abstractions;
|
using Yi.Framework.SqlSugarCore.Abstractions;
|
||||||
|
|
||||||
namespace Yi.Framework.AiHub.Domain.Managers;
|
namespace Yi.Framework.AiHub.Domain.Managers;
|
||||||
@@ -28,7 +29,7 @@ public class AiRechargeManager : DomainService
|
|||||||
var currentTime = DateTime.Now;
|
var currentTime = DateTime.Now;
|
||||||
|
|
||||||
// 查找所有充值记录,按用户分组
|
// 查找所有充值记录,按用户分组
|
||||||
var allRecharges = await _rechargeRepository._DbQueryable
|
var allRecharges = await _rechargeRepository._DbQueryable.Where(x => x.RechargeType == RechargeTypeEnum.Vip)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
|
||||||
if (!allRecharges.Any())
|
if (!allRecharges.Any())
|
||||||
|
|||||||
@@ -66,7 +66,8 @@ public class PremiumPackageManager : DomainService
|
|||||||
Content = packageName,
|
Content = packageName,
|
||||||
ExpireDateTime = premiumPackage.ExpireDateTime,
|
ExpireDateTime = premiumPackage.ExpireDateTime,
|
||||||
Remark = "自助充值",
|
Remark = "自助充值",
|
||||||
ContactInfo = null
|
ContactInfo = null,
|
||||||
|
RechargeType = RechargeTypeEnum.PremiumPackage
|
||||||
};
|
};
|
||||||
|
|
||||||
// 保存充值记录到数据库
|
// 保存充值记录到数据库
|
||||||
|
|||||||
Reference in New Issue
Block a user