feat: 租户审核领单与强制接管
This commit is contained in:
@@ -24,6 +24,14 @@ public sealed class ReviewTenantCommandHandler(
|
||||
var tenant = await tenantRepository.FindByIdAsync(request.TenantId, cancellationToken)
|
||||
?? throw new BusinessException(ErrorCodes.NotFound, "租户不存在");
|
||||
|
||||
var reviewClaim = await tenantRepository.FindActiveReviewClaimAsync(request.TenantId, cancellationToken)
|
||||
?? throw new BusinessException(ErrorCodes.Conflict, "请先领取审核");
|
||||
|
||||
if (reviewClaim.ClaimedBy != currentUserAccessor.UserId)
|
||||
{
|
||||
throw new BusinessException(ErrorCodes.Conflict, $"该审核已被 {reviewClaim.ClaimedByName} 领取");
|
||||
}
|
||||
|
||||
var verification = await tenantRepository.GetVerificationProfileAsync(request.TenantId, cancellationToken)
|
||||
?? throw new BusinessException(ErrorCodes.BadRequest, "请先提交实名认证资料");
|
||||
|
||||
@@ -83,7 +91,22 @@ public sealed class ReviewTenantCommandHandler(
|
||||
CurrentStatus = tenant.Status
|
||||
}, cancellationToken);
|
||||
|
||||
// 7. 保存并返回 DTO
|
||||
// 7. (空行后) 审核完成自动释放领取
|
||||
reviewClaim.ReleasedAt = DateTime.UtcNow;
|
||||
await tenantRepository.UpdateReviewClaimAsync(reviewClaim, cancellationToken);
|
||||
await tenantRepository.AddAuditLogAsync(new Domain.Tenants.Entities.TenantAuditLog
|
||||
{
|
||||
TenantId = tenant.Id,
|
||||
Action = TenantAuditAction.ReviewClaimReleased,
|
||||
Title = "审核完成释放",
|
||||
Description = $"释放人:{actorName}",
|
||||
OperatorId = currentUserAccessor.UserId == 0 ? null : currentUserAccessor.UserId,
|
||||
OperatorName = actorName,
|
||||
PreviousStatus = tenant.Status,
|
||||
CurrentStatus = tenant.Status
|
||||
}, cancellationToken);
|
||||
|
||||
// 8. 保存并返回 DTO
|
||||
await tenantRepository.SaveChangesAsync(cancellationToken);
|
||||
|
||||
return TenantMapping.ToDto(tenant, subscription, verification);
|
||||
|
||||
Reference in New Issue
Block a user