fix: 门店资质日期字段改为date
This commit is contained in:
@@ -130,19 +130,19 @@ public sealed class GetStoreAuditDetailQueryHandler(
|
||||
}
|
||||
|
||||
// 2. (空行后) 映射资质 DTO
|
||||
var now = DateTime.UtcNow.Date;
|
||||
var today = DateOnly.FromDateTime(DateTime.UtcNow);
|
||||
while (await reader.ReadAsync(cancellationToken))
|
||||
{
|
||||
DateTime? expiresAt = reader.IsDBNull(reader.GetOrdinal("ExpiresAt"))
|
||||
DateOnly? expiresAt = reader.IsDBNull(reader.GetOrdinal("ExpiresAt"))
|
||||
? null
|
||||
: reader.GetDateTime(reader.GetOrdinal("ExpiresAt"));
|
||||
: DateOnly.FromDateTime(reader.GetDateTime(reader.GetOrdinal("ExpiresAt")));
|
||||
int? daysUntilExpiry = expiresAt.HasValue
|
||||
? (int)Math.Ceiling((expiresAt.Value.Date - now).TotalDays)
|
||||
? expiresAt.Value.DayNumber - today.DayNumber
|
||||
: null;
|
||||
var isExpired = expiresAt.HasValue && expiresAt.Value < DateTime.UtcNow;
|
||||
var isExpired = expiresAt.HasValue && expiresAt.Value < today;
|
||||
var isExpiringSoon = expiresAt.HasValue
|
||||
&& expiresAt.Value >= DateTime.UtcNow
|
||||
&& expiresAt.Value <= DateTime.UtcNow.AddDays(30);
|
||||
&& expiresAt.Value >= today
|
||||
&& expiresAt.Value <= today.AddDays(30);
|
||||
|
||||
// 2.1 (空行后) 写入列表
|
||||
items.Add(new StoreQualificationDto
|
||||
@@ -156,7 +156,7 @@ public sealed class GetStoreAuditDetailQueryHandler(
|
||||
: reader.GetString(reader.GetOrdinal("DocumentNumber")),
|
||||
IssuedAt = reader.IsDBNull(reader.GetOrdinal("IssuedAt"))
|
||||
? null
|
||||
: reader.GetDateTime(reader.GetOrdinal("IssuedAt")),
|
||||
: DateOnly.FromDateTime(reader.GetDateTime(reader.GetOrdinal("IssuedAt"))),
|
||||
ExpiresAt = expiresAt,
|
||||
IsExpired = isExpired,
|
||||
IsExpiringSoon = isExpiringSoon,
|
||||
|
||||
@@ -32,12 +32,12 @@ public sealed record CreateStoreQualificationCommand : IRequest<StoreQualificati
|
||||
/// <summary>
|
||||
/// 签发日期。
|
||||
/// </summary>
|
||||
public DateTime? IssuedAt { get; init; }
|
||||
public DateOnly? IssuedAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 到期日期。
|
||||
/// </summary>
|
||||
public DateTime? ExpiresAt { get; init; }
|
||||
public DateOnly? ExpiresAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序值。
|
||||
|
||||
@@ -31,12 +31,12 @@ public sealed record UpdateStoreQualificationCommand : IRequest<StoreQualificati
|
||||
/// <summary>
|
||||
/// 签发日期。
|
||||
/// </summary>
|
||||
public DateTime? IssuedAt { get; init; }
|
||||
public DateOnly? IssuedAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 到期日期。
|
||||
/// </summary>
|
||||
public DateTime? ExpiresAt { get; init; }
|
||||
public DateOnly? ExpiresAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 排序值。
|
||||
|
||||
@@ -50,7 +50,7 @@ public sealed record StoreQualificationAlertDto
|
||||
/// <summary>
|
||||
/// 过期时间。
|
||||
/// </summary>
|
||||
public DateTime? ExpiresAt { get; init; }
|
||||
public DateOnly? ExpiresAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 距离过期天数。
|
||||
|
||||
@@ -39,12 +39,12 @@ public sealed class StoreQualificationDto
|
||||
/// <summary>
|
||||
/// 签发日期。
|
||||
/// </summary>
|
||||
public DateTime? IssuedAt { get; init; }
|
||||
public DateOnly? IssuedAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 到期日期。
|
||||
/// </summary>
|
||||
public DateTime? ExpiresAt { get; init; }
|
||||
public DateOnly? ExpiresAt { get; init; }
|
||||
|
||||
/// <summary>
|
||||
/// 是否已过期。
|
||||
|
||||
@@ -30,7 +30,7 @@ public sealed class ListExpiringStoreQualificationsQueryHandler(
|
||||
daysThreshold = 365;
|
||||
}
|
||||
var offset = (page - 1) * pageSize;
|
||||
var now = DateTime.UtcNow;
|
||||
var now = DateOnly.FromDateTime(DateTime.UtcNow);
|
||||
var expiringBefore = now.AddDays(daysThreshold);
|
||||
|
||||
// 2. (空行后) 执行查询
|
||||
@@ -92,12 +92,12 @@ public sealed class ListExpiringStoreQualificationsQueryHandler(
|
||||
List<StoreQualificationAlertDto> items = [];
|
||||
while (await reader.ReadAsync(token))
|
||||
{
|
||||
DateTime? expiresAt = reader.IsDBNull(expiresAtOrdinal)
|
||||
DateOnly? expiresAt = reader.IsDBNull(expiresAtOrdinal)
|
||||
? null
|
||||
: reader.GetDateTime(expiresAtOrdinal);
|
||||
: DateOnly.FromDateTime(reader.GetDateTime(expiresAtOrdinal));
|
||||
var isExpired = expiresAt.HasValue && expiresAt.Value < now;
|
||||
int? daysUntilExpiry = expiresAt.HasValue
|
||||
? (int)Math.Ceiling((expiresAt.Value.Date - now.Date).TotalDays)
|
||||
? expiresAt.Value.DayNumber - now.DayNumber
|
||||
: null;
|
||||
|
||||
items.Add(new StoreQualificationAlertDto
|
||||
@@ -146,8 +146,8 @@ public sealed class ListExpiringStoreQualificationsQueryHandler(
|
||||
|
||||
private static async Task<StoreQualificationAlertSummaryDto> ExecuteSummaryAsync(
|
||||
IDbConnection connection,
|
||||
DateTime now,
|
||||
DateTime expiringBefore,
|
||||
DateOnly now,
|
||||
DateOnly expiringBefore,
|
||||
long? tenantId,
|
||||
CancellationToken cancellationToken)
|
||||
{
|
||||
|
||||
@@ -78,8 +78,9 @@ public static class StoreMapping
|
||||
/// <returns>DTO。</returns>
|
||||
public static StoreQualificationDto ToDto(StoreQualification qualification)
|
||||
{
|
||||
var today = DateOnly.FromDateTime(DateTime.UtcNow);
|
||||
int? daysUntilExpiry = qualification.ExpiresAt.HasValue
|
||||
? (int)Math.Ceiling((qualification.ExpiresAt.Value.Date - DateTime.UtcNow.Date).TotalDays)
|
||||
? qualification.ExpiresAt.Value.DayNumber - today.DayNumber
|
||||
: null;
|
||||
|
||||
return new StoreQualificationDto
|
||||
|
||||
@@ -21,7 +21,7 @@ public sealed class CreateStoreQualificationCommandValidator : AbstractValidator
|
||||
RuleFor(x => x.DocumentNumber).MaximumLength(100);
|
||||
|
||||
RuleFor(x => x.ExpiresAt)
|
||||
.Must(date => date.HasValue && date.Value.Date > DateTime.UtcNow.Date)
|
||||
.Must(date => date.HasValue && date.Value > DateOnly.FromDateTime(DateTime.UtcNow))
|
||||
.When(x => IsLicenseType(x.QualificationType))
|
||||
.WithMessage("证照有效期必须晚于今天");
|
||||
|
||||
@@ -32,7 +32,7 @@ public sealed class CreateStoreQualificationCommandValidator : AbstractValidator
|
||||
.WithMessage("证照编号不能为空");
|
||||
|
||||
RuleFor(x => x.ExpiresAt)
|
||||
.Must(date => !date.HasValue || date.Value.Date > DateTime.UtcNow.Date)
|
||||
.Must(date => !date.HasValue || date.Value > DateOnly.FromDateTime(DateTime.UtcNow))
|
||||
.When(x => !IsLicenseType(x.QualificationType))
|
||||
.WithMessage("证照有效期必须晚于今天");
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ public sealed class UpdateStoreQualificationCommandValidator : AbstractValidator
|
||||
RuleFor(x => x.DocumentNumber).MaximumLength(100).When(x => !string.IsNullOrWhiteSpace(x.DocumentNumber));
|
||||
RuleFor(x => x.SortOrder).GreaterThanOrEqualTo(0).When(x => x.SortOrder.HasValue);
|
||||
RuleFor(x => x.ExpiresAt)
|
||||
.Must(date => !date.HasValue || date.Value.Date > DateTime.UtcNow.Date)
|
||||
.Must(date => !date.HasValue || date.Value > DateOnly.FromDateTime(DateTime.UtcNow))
|
||||
.When(x => x.ExpiresAt.HasValue)
|
||||
.WithMessage("证照有效期必须晚于今天");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user