refactor: move buildable .NET source into src/, update CI/doc paths
TaxBaik CI/CD / build-and-deploy (push) Successful in 2m7s
TaxBaik CI/CD / build-and-deploy (push) Successful in 2m7s
Groups the repo root into src (buildable source), docs (already existed), and everything else (db/, scripts/, tests/, deploy/ - deployment/ops/test assets that aren't compiled, already organized as their own folders). CI now only needs src/ to build: dotnet restore/build/test/publish all point at src/TaxBaik.sln, src/TaxBaik.Web/, src/TaxBaik.Proxy/. - git mv every project (Domain, Infrastructure, Application, Application.Tests, Web, Web.Client, Proxy) and TaxBaik.sln into src/ as a unit, so relative ProjectReference/.sln paths stay valid unchanged. - .gitea/workflows/deploy.yml: 6 dotnet restore/clean/build/test/publish invocations now point at src/. db/migrations and scripts/ stay at root (deploy_gb.sh and browser-e2e.yml only touch published output and the deployed URL, not source paths - verified, no changes needed there). - scripts/validate_admin_render.sh: admin render-mode file paths now src/TaxBaik.Web.Client/... - scripts/validate_kst_timestamps.sh: dropped deploy.sh from its target list - that script was removed in the prior cleanup commit (dead, no CI workflow referenced it) but this validator still expected it to exist. - CLAUDE.md, docs/ENGINEERING_HARNESS.md, docs/ADMIN_PATTERN_CRITIQUE_WBS.md: updated project-structure diagram, dotnet run/build commands, and grep targets to the new src/ paths (also fixed a pre-existing stale path in ADMIN_PATTERN_CRITIQUE_WBS.md that still said TaxBaik.Web/Components/Admin from before that ever moved to TaxBaik.Web.Client). - Added a Repo Root harness rule + Architecture Guardrail entries: new files belong under src/docs/tests/scripts/db/deploy, not loose at root; temp work stays outside the repo (or under a gitignored .scratch/) and is never committed. Verified locally: dotnet build/test src/TaxBaik.sln (26/26 tests), and all three scripts/validate_*.sh pass against the new layout. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,87 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using TaxBaik.Domain.Entities;
|
||||
|
||||
public record AdminDashboardSummary(
|
||||
int ThisMonthInquiries,
|
||||
int NewInquiries,
|
||||
int TotalPosts,
|
||||
int PublishedPosts,
|
||||
IReadOnlyList<Inquiry> RecentInquiries);
|
||||
|
||||
public class AdminDashboardService(
|
||||
InquiryService inquiryService,
|
||||
BlogService blogService,
|
||||
IMemoryCache memoryCache)
|
||||
{
|
||||
private static readonly TimeSpan CacheDuration = TimeSpan.FromSeconds(30);
|
||||
public const string CacheKey = "admin-dashboard-summary";
|
||||
|
||||
public async Task<AdminDashboardSummary> GetSummaryAsync(CancellationToken ct = default)
|
||||
{
|
||||
if (memoryCache.TryGetValue(CacheKey, out AdminDashboardSummary? cached) && cached != null)
|
||||
return cached;
|
||||
|
||||
var recentTask = inquiryService.GetPagedAsync(1, 5, ct: ct);
|
||||
var thisMonthTask = inquiryService.CountThisMonthAsync(ct);
|
||||
var newTask = inquiryService.CountByStatusAsync("new", ct);
|
||||
var statsTask = blogService.GetStatsAsync(ct);
|
||||
|
||||
var (recentInquiries, _) = await recentTask;
|
||||
var stats = await statsTask;
|
||||
var summary = new AdminDashboardSummary(
|
||||
ThisMonthInquiries: await thisMonthTask,
|
||||
NewInquiries: await newTask,
|
||||
TotalPosts: stats.TotalPosts,
|
||||
PublishedPosts: stats.PublishedPosts,
|
||||
RecentInquiries: recentInquiries.OrderByDescending(x => x.CreatedAt).Take(5).ToList());
|
||||
|
||||
memoryCache.Set(CacheKey, summary, CacheDuration);
|
||||
return summary;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 최근 문의 조회
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<Inquiry>> GetRecentInquiriesAsync(int limit, CancellationToken ct = default)
|
||||
{
|
||||
var (inquiries, _) = await inquiryService.GetPagedAsync(1, limit, ct: ct);
|
||||
return inquiries.OrderByDescending(x => x.CreatedAt).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 월별 통계 (접수 건수, 진행 중, 완료)
|
||||
/// </summary>
|
||||
public async Task<object> GetMonthlyStatsAsync(string? month, CancellationToken ct = default)
|
||||
{
|
||||
var targetMonth = month != null && DateTime.TryParse($"{month}-01", out var dt)
|
||||
? dt
|
||||
: DateTime.Today;
|
||||
|
||||
var startDate = new DateTime(targetMonth.Year, targetMonth.Month, 1);
|
||||
var endDate = startDate.AddMonths(1).AddDays(-1);
|
||||
|
||||
// 캐시 시도 (일 단위)
|
||||
var cacheKey = $"admin-stats-{startDate:yyyy-MM}";
|
||||
if (memoryCache.TryGetValue(cacheKey, out object? cachedStats) && cachedStats != null)
|
||||
return cachedStats;
|
||||
|
||||
var total = await inquiryService.CountByDateRangeAsync(startDate, endDate, ct);
|
||||
var consulting = await inquiryService.CountByStatusAndDateAsync("consulting", startDate, endDate, ct);
|
||||
var completed = await inquiryService.CountByStatusAndDateAsync("contracted", startDate, endDate, ct);
|
||||
|
||||
var result = new
|
||||
{
|
||||
month = startDate.ToString("yyyy-MM"),
|
||||
totalInquiries = total,
|
||||
consultingCount = consulting,
|
||||
completedCount = completed,
|
||||
newCount = total - consulting - completed,
|
||||
completionRate = total > 0 ? (completed * 100.0 / total) : 0.0
|
||||
};
|
||||
|
||||
memoryCache.Set(cacheKey, result, TimeSpan.FromHours(1));
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using TaxBaik.Application.DTOs;
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class AnnouncementService(IAnnouncementRepository repository)
|
||||
{
|
||||
public Task<IEnumerable<Announcement>> GetActiveAsync(CancellationToken ct = default)
|
||||
=> repository.GetActiveAsync(ct);
|
||||
|
||||
public Task<IEnumerable<Announcement>> GetAllAsync(CancellationToken ct = default)
|
||||
=> repository.GetAllAsync(ct);
|
||||
|
||||
public Task<Announcement?> GetByIdAsync(int id, CancellationToken ct = default)
|
||||
=> repository.GetByIdAsync(id, ct);
|
||||
|
||||
public Task<int> CreateAsync(AnnouncementDto dto, CancellationToken ct = default)
|
||||
{
|
||||
var entity = MapToEntity(dto);
|
||||
return repository.CreateAsync(entity, ct);
|
||||
}
|
||||
|
||||
public Task UpdateAsync(AnnouncementDto dto, CancellationToken ct = default)
|
||||
{
|
||||
var entity = MapToEntity(dto);
|
||||
return repository.UpdateAsync(entity, ct);
|
||||
}
|
||||
|
||||
public Task DeleteAsync(int id, CancellationToken ct = default)
|
||||
=> repository.DeleteAsync(id, ct);
|
||||
|
||||
private static Announcement MapToEntity(AnnouncementDto dto) => new()
|
||||
{
|
||||
Id = dto.Id,
|
||||
Title = dto.Title.Trim(),
|
||||
Content = string.IsNullOrWhiteSpace(dto.Content) ? null : dto.Content.Trim(),
|
||||
DisplayType = dto.DisplayType,
|
||||
IsActive = dto.IsActive,
|
||||
StartsAt = dto.StartsAt,
|
||||
EndsAt = dto.EndsAt,
|
||||
SortOrder = dto.SortOrder
|
||||
};
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
using TaxBaik.Application.DTOs;
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
|
||||
public class BlogService(IBlogPostRepository repository, IMemoryCache memoryCache)
|
||||
{
|
||||
public async Task<BlogPost?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.GetByIdAsync(id, ct);
|
||||
|
||||
public async Task<BlogPost?> GetBySlugAsync(string slug, CancellationToken ct = default) =>
|
||||
await repository.GetBySlugAsync(slug, ct);
|
||||
|
||||
/// <summary>카테고리 슬러그 기준 시즌 관련 글 조회. 부족 시 최신 글로 채워 total개 반환.</summary>
|
||||
public async Task<(IEnumerable<BlogPost> Seasonal, IEnumerable<BlogPost> Latest)> GetSeasonalPostsAsync(
|
||||
string categorySlug, int seasonalCount, int totalCount, CancellationToken ct = default)
|
||||
{
|
||||
var seasonal = (await repository.GetByCategorySlugAsync(categorySlug, seasonalCount, ct)).ToList();
|
||||
var seasonalIds = seasonal.Select(p => p.Id).ToHashSet();
|
||||
|
||||
var (latestAll, _) = await repository.GetPublishedPagedAsync(1, totalCount + seasonalCount, null, ct);
|
||||
var latest = latestAll.Where(p => !seasonalIds.Contains(p.Id)).Take(totalCount - seasonal.Count).ToList();
|
||||
|
||||
return (seasonal, latest);
|
||||
}
|
||||
|
||||
public async Task<(IEnumerable<BlogPost>, int)> GetPublishedPagedAsync(
|
||||
int page, int pageSize, int? categoryId = null, CancellationToken ct = default) =>
|
||||
await repository.GetPublishedPagedAsync(NormalizePage(page), NormalizePageSize(pageSize), categoryId, ct);
|
||||
|
||||
public async Task<IEnumerable<BlogPost>> GetAllAsync(CancellationToken ct = default) =>
|
||||
await repository.GetAllForAdminAsync(ct);
|
||||
|
||||
public async Task<IEnumerable<BlogPost>> GetAllForAdminAsync(CancellationToken ct = default) =>
|
||||
await repository.GetAllForAdminAsync(ct);
|
||||
|
||||
public async Task<(IEnumerable<BlogPost>, int)> GetAdminPagedAsync(
|
||||
int page, int pageSize, CancellationToken ct = default) =>
|
||||
await repository.GetAdminPagedAsync(NormalizePage(page), NormalizePageSize(pageSize), ct);
|
||||
|
||||
public async Task<(IEnumerable<BlogPost>, int)> GetArchivedPagedAsync(
|
||||
int page, int pageSize, CancellationToken ct = default) =>
|
||||
await repository.GetArchivedPagedAsync(NormalizePage(page), NormalizePageSize(pageSize), ct);
|
||||
|
||||
public async Task<int> CreateAsync(BlogPost post, CancellationToken ct = default)
|
||||
{
|
||||
ValidatePost(post);
|
||||
post.Title = post.Title.Trim();
|
||||
post.Content = post.Content.Trim();
|
||||
post.Slug = await GenerateUniqueSlugAsync(post.Title, ct: ct);
|
||||
post.PublishedAt = post.IsPublished ? DateTime.UtcNow : null;
|
||||
var result = await repository.CreateAsync(post, ct);
|
||||
memoryCache.Remove(AdminDashboardService.CacheKey);
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<BlogPost> CreateAsync(CreateBlogPostDto dto, CancellationToken ct = default)
|
||||
{
|
||||
var post = new BlogPost
|
||||
{
|
||||
Title = dto.Title,
|
||||
Content = dto.Content,
|
||||
CategoryId = dto.CategoryId,
|
||||
Tags = dto.Tags,
|
||||
SeoTitle = dto.SeoTitle,
|
||||
SeoDescription = dto.SeoDescription,
|
||||
ThumbnailUrl = dto.ThumbnailUrl,
|
||||
IsPublished = dto.IsPublished,
|
||||
AuthorId = dto.AuthorId,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
};
|
||||
|
||||
var id = await CreateAsync(post, ct);
|
||||
post.Id = id;
|
||||
return post;
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(BlogPost post, CancellationToken ct = default)
|
||||
{
|
||||
await repository.UpdateAsync(post, ct);
|
||||
memoryCache.Remove(AdminDashboardService.CacheKey);
|
||||
}
|
||||
|
||||
public async Task<BlogPost?> UpdateAsync(int id, CreateBlogPostDto dto, CancellationToken ct = default)
|
||||
{
|
||||
var post = await repository.GetByIdAsync(id, ct);
|
||||
if (post == null)
|
||||
return null;
|
||||
|
||||
post.Title = dto.Title;
|
||||
post.Content = dto.Content;
|
||||
post.CategoryId = dto.CategoryId;
|
||||
post.Tags = dto.Tags;
|
||||
post.SeoTitle = dto.SeoTitle;
|
||||
post.SeoDescription = dto.SeoDescription;
|
||||
post.ThumbnailUrl = dto.ThumbnailUrl;
|
||||
post.IsPublished = dto.IsPublished;
|
||||
post.PublishedAt = dto.IsPublished
|
||||
? post.PublishedAt ?? DateTime.UtcNow
|
||||
: null;
|
||||
ValidatePost(post);
|
||||
|
||||
await UpdateAsync(post, ct);
|
||||
return post;
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(int id, CancellationToken ct = default)
|
||||
{
|
||||
await repository.DeleteAsync(id, ct);
|
||||
memoryCache.Remove(AdminDashboardService.CacheKey);
|
||||
}
|
||||
|
||||
public async Task ArchiveAsync(int id, CancellationToken ct = default)
|
||||
{
|
||||
await repository.ArchiveAsync(id, ct);
|
||||
memoryCache.Remove(AdminDashboardService.CacheKey);
|
||||
}
|
||||
|
||||
public async Task RestoreAsync(int id, CancellationToken ct = default)
|
||||
{
|
||||
await repository.RestoreAsync(id, ct);
|
||||
memoryCache.Remove(AdminDashboardService.CacheKey);
|
||||
}
|
||||
|
||||
public async Task IncrementViewCountAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.IncrementViewCountAsync(id, ct);
|
||||
|
||||
private static string GenerateSlug(string title)
|
||||
{
|
||||
var slug = Regex.Replace(title.ToLowerInvariant(), @"[^\w\s-]", "");
|
||||
slug = Regex.Replace(slug, @"\s+", "-");
|
||||
slug = Regex.Replace(slug, @"-+", "-").Trim('-');
|
||||
if (string.IsNullOrWhiteSpace(slug))
|
||||
slug = $"post-{DateTime.UtcNow:yyyyMMddHHmmss}";
|
||||
return slug.Length > 100 ? slug[..100] : slug;
|
||||
}
|
||||
|
||||
private async Task<string> GenerateUniqueSlugAsync(string title, int? existingPostId = null, CancellationToken ct = default)
|
||||
{
|
||||
var baseSlug = GenerateSlug(title);
|
||||
var slug = baseSlug;
|
||||
var suffix = 2;
|
||||
var allPosts = (await repository.GetAllForAdminAsync(ct)).ToList();
|
||||
|
||||
while (allPosts.Any(x => x.Id != existingPostId && string.Equals(x.Slug, slug, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
var suffixText = $"-{suffix++}";
|
||||
var maxBaseLength = Math.Max(1, 100 - suffixText.Length);
|
||||
slug = $"{baseSlug[..Math.Min(baseSlug.Length, maxBaseLength)]}{suffixText}";
|
||||
}
|
||||
|
||||
return slug;
|
||||
}
|
||||
|
||||
private static void ValidatePost(BlogPost post)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(post.Title))
|
||||
throw new ValidationException("제목을 입력하세요.");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(post.Content))
|
||||
throw new ValidationException("본문을 입력하세요.");
|
||||
|
||||
if (post.IsPublished && string.IsNullOrWhiteSpace(post.SeoTitle))
|
||||
throw new ValidationException("발행하려면 SEO 제목을 입력하세요.");
|
||||
|
||||
if (post.IsPublished && string.IsNullOrWhiteSpace(post.SeoDescription))
|
||||
throw new ValidationException("발행하려면 SEO 설명을 입력하세요.");
|
||||
}
|
||||
|
||||
private static int NormalizePage(int page) => Math.Max(1, page);
|
||||
|
||||
private static int NormalizePageSize(int pageSize) => Math.Clamp(pageSize, 1, 100);
|
||||
|
||||
public async Task<(int TotalPosts, int PublishedPosts)> GetStatsAsync(CancellationToken ct = default)
|
||||
{
|
||||
var posts = (await repository.GetAllForAdminAsync(ct)).ToList();
|
||||
return (posts.Count, posts.Count(x => x.IsPublished));
|
||||
}
|
||||
}
|
||||
@@ -1,54 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class CategoryService(ICategoryRepository repository)
|
||||
{
|
||||
public async Task<IEnumerable<Category>> GetAllAsync(CancellationToken ct = default) =>
|
||||
await repository.GetAllAsync(ct);
|
||||
|
||||
public async Task<Category?> GetBySlugAsync(string slug, CancellationToken ct = default) =>
|
||||
await repository.GetBySlugAsync(slug, ct);
|
||||
|
||||
public async Task<Category?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.GetByIdAsync(id, ct);
|
||||
|
||||
public async Task<Category> CreateAsync(string name, string? description, CancellationToken ct = default)
|
||||
{
|
||||
var slug = GenerateSlug(name);
|
||||
var category = new Category
|
||||
{
|
||||
Name = name.Trim(),
|
||||
Slug = slug,
|
||||
SortOrder = 0
|
||||
};
|
||||
|
||||
var id = await repository.CreateAsync(category, ct);
|
||||
return new Category { Id = id, Name = category.Name, Slug = category.Slug, SortOrder = category.SortOrder };
|
||||
}
|
||||
|
||||
public async Task<Category?> UpdateAsync(int id, string name, string? description, CancellationToken ct = default)
|
||||
{
|
||||
var category = await repository.GetByIdAsync(id, ct);
|
||||
if (category == null)
|
||||
return null;
|
||||
|
||||
category.Name = name.Trim();
|
||||
category.Slug = GenerateSlug(name);
|
||||
await repository.UpdateAsync(category, ct);
|
||||
return category;
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.DeleteAsync(id, ct);
|
||||
|
||||
private static string GenerateSlug(string name)
|
||||
{
|
||||
var slug = Regex.Replace(name.ToLowerInvariant(), @"[^\w\s-]", "");
|
||||
slug = Regex.Replace(slug, @"\s+", "-");
|
||||
slug = Regex.Replace(slug, @"-+", "-").Trim('-');
|
||||
return slug.Length > 100 ? slug[..100] : slug;
|
||||
}
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using TaxBaik.Application.DTOs;
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class ClientService(IClientRepository repository)
|
||||
{
|
||||
public async Task<(IEnumerable<Client> Items, int Total)> GetPagedAsync(
|
||||
int page, int pageSize, string? status = null, string? search = null, CancellationToken ct = default) =>
|
||||
await repository.GetPagedAsync(Math.Max(1, page), Math.Clamp(pageSize, 1, 100), status, search, ct);
|
||||
|
||||
public async Task<Client?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.GetByIdAsync(id, ct);
|
||||
|
||||
public async Task<Client?> GetByEmailAsync(string email, CancellationToken ct = default) =>
|
||||
await repository.GetByEmailAsync(email, ct);
|
||||
|
||||
public async Task<Client?> GetByPhoneAsync(string phone, CancellationToken ct = default) =>
|
||||
await repository.GetByPhoneAsync(phone, ct);
|
||||
|
||||
public async Task<int> CountCreatedAtRangeAsync(DateTime startDateUtc, DateTime endDateUtc, CancellationToken ct = default) =>
|
||||
await repository.CountByCreatedAtRangeAsync(startDateUtc, endDateUtc, ct);
|
||||
|
||||
public async Task<int> CreateAsync(CreateClientDto dto, CancellationToken ct = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(dto.Name))
|
||||
throw new ValidationException("고객명을 입력하세요.");
|
||||
|
||||
var client = new Client
|
||||
{
|
||||
Name = dto.Name.Trim(),
|
||||
CompanyName = dto.CompanyName?.Trim(),
|
||||
Phone = dto.Phone?.Trim(),
|
||||
Email = dto.Email?.Trim(),
|
||||
ServiceType = dto.ServiceType,
|
||||
TaxType = dto.TaxType,
|
||||
Status = dto.Status,
|
||||
Source = dto.Source,
|
||||
Memo = dto.Memo?.Trim()
|
||||
};
|
||||
|
||||
return await repository.CreateAsync(client, ct);
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(int id, CreateClientDto dto, CancellationToken ct = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(dto.Name))
|
||||
throw new ValidationException("고객명을 입력하세요.");
|
||||
|
||||
var client = await repository.GetByIdAsync(id, ct)
|
||||
?? throw new KeyNotFoundException($"고객 ID {id}를 찾을 수 없습니다.");
|
||||
|
||||
client.Name = dto.Name.Trim();
|
||||
client.CompanyName = dto.CompanyName?.Trim();
|
||||
client.Phone = dto.Phone?.Trim();
|
||||
client.Email = dto.Email?.Trim();
|
||||
client.ServiceType = dto.ServiceType;
|
||||
client.TaxType = dto.TaxType;
|
||||
client.Status = dto.Status;
|
||||
client.Source = dto.Source;
|
||||
client.Memo = dto.Memo?.Trim();
|
||||
|
||||
await repository.UpdateAsync(client, ct);
|
||||
}
|
||||
|
||||
public async Task<int> CreateFromInquiryAsync(string name, string? phone, string? serviceType, CancellationToken ct = default)
|
||||
{
|
||||
var client = new Client
|
||||
{
|
||||
Name = name.Trim(),
|
||||
Phone = phone?.Trim(),
|
||||
ServiceType = serviceType,
|
||||
Status = "active",
|
||||
Source = "홈페이지문의"
|
||||
};
|
||||
return await repository.CreateAsync(client, ct);
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.DeleteAsync(id, ct);
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
public class CommonCodeService(ICommonCodeRepository commonCodeRepository)
|
||||
{
|
||||
private const int MaxCodeGroupLength = 80;
|
||||
private const int MaxCodeValueLength = 120;
|
||||
private const int MaxCodeNameLength = 200;
|
||||
|
||||
public async Task<IEnumerable<string>> GetAllGroupsAsync(CancellationToken ct = default)
|
||||
{
|
||||
return await commonCodeRepository.GetAllGroupsAsync(ct);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<CommonCode>> GetByGroupAsync(string codeGroup, CancellationToken ct = default)
|
||||
{
|
||||
return await commonCodeRepository.GetByGroupAsync(codeGroup, ct);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<CommonCode>> GetAllActiveAsync(CancellationToken ct = default)
|
||||
{
|
||||
return await commonCodeRepository.GetAllActiveAsync(ct);
|
||||
}
|
||||
|
||||
public async Task<CommonCode?> GetAsync(string codeGroup, string codeValue, CancellationToken ct = default)
|
||||
{
|
||||
return await commonCodeRepository.GetAsync(codeGroup, codeValue, ct);
|
||||
}
|
||||
|
||||
public async Task UpsertAsync(CommonCode code, CancellationToken ct = default)
|
||||
{
|
||||
Normalize(code);
|
||||
await commonCodeRepository.UpsertAsync(code, ct);
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(string codeGroup, string codeValue, CancellationToken ct = default)
|
||||
{
|
||||
await commonCodeRepository.DeleteAsync(NormalizeToken(codeGroup, nameof(codeGroup), MaxCodeGroupLength), NormalizeToken(codeValue, nameof(codeValue), MaxCodeValueLength), ct);
|
||||
}
|
||||
|
||||
private static void Normalize(CommonCode code)
|
||||
{
|
||||
code.CodeGroup = NormalizeToken(code.CodeGroup, nameof(code.CodeGroup), MaxCodeGroupLength, disallowWhitespace: true);
|
||||
code.CodeValue = NormalizeToken(code.CodeValue, nameof(code.CodeValue), MaxCodeValueLength, disallowWhitespace: true);
|
||||
code.CodeName = NormalizeToken(code.CodeName, nameof(code.CodeName), MaxCodeNameLength);
|
||||
}
|
||||
|
||||
private static string NormalizeToken(string value, string fieldName, int maxLength, bool disallowWhitespace = false)
|
||||
{
|
||||
var normalized = (value ?? string.Empty).Trim();
|
||||
if (string.IsNullOrWhiteSpace(normalized))
|
||||
throw new ValidationException($"{fieldName}은(는) 필수입니다.");
|
||||
|
||||
if (normalized.Length > maxLength)
|
||||
throw new ValidationException($"{fieldName}은(는) 최대 {maxLength}자까지 입력할 수 있습니다.");
|
||||
|
||||
if (disallowWhitespace && normalized.Any(char.IsWhiteSpace))
|
||||
throw new ValidationException($"{fieldName}에는 공백을 사용할 수 없습니다.");
|
||||
|
||||
return normalized;
|
||||
}
|
||||
}
|
||||
@@ -1,95 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class CompanyService(ICompanyRepository repository)
|
||||
{
|
||||
public async Task<int> CreateAsync(string companyCode, string companyName, string? contactPerson = null,
|
||||
string? phone = null, string? email = null, string? memo = null, CancellationToken ct = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(companyCode))
|
||||
throw new ValidationException("회사 코드를 입력하세요.");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(companyName))
|
||||
throw new ValidationException("회사명을 입력하세요.");
|
||||
|
||||
var existing = await repository.GetByCodeAsync(companyCode.Trim(), ct);
|
||||
if (existing != null)
|
||||
throw new ValidationException("이미 존재하는 회사 코드입니다.");
|
||||
|
||||
var company = new Company
|
||||
{
|
||||
CompanyCode = companyCode.Trim(),
|
||||
CompanyName = companyName.Trim(),
|
||||
ContactPerson = string.IsNullOrWhiteSpace(contactPerson) ? null : contactPerson.Trim(),
|
||||
Phone = string.IsNullOrWhiteSpace(phone) ? null : phone.Trim(),
|
||||
Email = string.IsNullOrWhiteSpace(email) ? null : email.Trim(),
|
||||
Memo = string.IsNullOrWhiteSpace(memo) ? null : memo.Trim(),
|
||||
IsActive = true,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UpdatedAt = DateTime.UtcNow
|
||||
};
|
||||
|
||||
return await repository.CreateAsync(company, ct);
|
||||
}
|
||||
|
||||
public async Task<Company?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.GetByIdAsync(id, ct);
|
||||
|
||||
public async Task<Company?> GetByCodeAsync(string code, CancellationToken ct = default) =>
|
||||
await repository.GetByCodeAsync(code, ct);
|
||||
|
||||
public async Task<IEnumerable<Company>> GetAllActiveAsync(CancellationToken ct = default) =>
|
||||
await repository.GetAllActiveAsync(ct);
|
||||
|
||||
public async Task<(IEnumerable<Company>, int)> GetPagedAsync(int page, int pageSize, CancellationToken ct = default)
|
||||
{
|
||||
var (items, total) = await repository.GetPagedAsync(NormalizePage(page), NormalizePageSize(pageSize), ct);
|
||||
return (items, total);
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(int id, string companyCode, string companyName, string? contactPerson = null,
|
||||
string? phone = null, string? email = null, string? memo = null, bool isActive = true, CancellationToken ct = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(companyCode))
|
||||
throw new ValidationException("회사 코드를 입력하세요.");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(companyName))
|
||||
throw new ValidationException("회사명을 입력하세요.");
|
||||
|
||||
var company = await repository.GetByIdAsync(id, ct);
|
||||
if (company == null)
|
||||
throw new ValidationException("회사를 찾을 수 없습니다.");
|
||||
|
||||
var existing = await repository.GetByCodeAsync(companyCode.Trim(), ct);
|
||||
if (existing != null && existing.Id != id)
|
||||
throw new ValidationException("이미 존재하는 회사 코드입니다.");
|
||||
|
||||
company.CompanyCode = companyCode.Trim();
|
||||
company.CompanyName = companyName.Trim();
|
||||
company.ContactPerson = string.IsNullOrWhiteSpace(contactPerson) ? null : contactPerson.Trim();
|
||||
company.Phone = string.IsNullOrWhiteSpace(phone) ? null : phone.Trim();
|
||||
company.Email = string.IsNullOrWhiteSpace(email) ? null : email.Trim();
|
||||
company.Memo = string.IsNullOrWhiteSpace(memo) ? null : memo.Trim();
|
||||
company.IsActive = isActive;
|
||||
company.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
await repository.UpdateAsync(company, ct);
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(int id, CancellationToken ct = default)
|
||||
{
|
||||
var company = await repository.GetByIdAsync(id, ct);
|
||||
if (company == null)
|
||||
throw new ValidationException("회사를 찾을 수 없습니다.");
|
||||
|
||||
if (company.CompanyCode == "DEFAULT")
|
||||
throw new ValidationException("기본 회사는 삭제할 수 없습니다.");
|
||||
|
||||
await repository.DeleteAsync(id, ct);
|
||||
}
|
||||
|
||||
private static int NormalizePage(int page) => Math.Max(1, page);
|
||||
private static int NormalizePageSize(int pageSize) => Math.Clamp(pageSize, 1, 100);
|
||||
}
|
||||
@@ -1,25 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class ConsultationService(IConsultationRepository repository)
|
||||
{
|
||||
public static readonly string[] Results =
|
||||
["상담 중", "계약 완료", "보류", "거절", "완료"];
|
||||
|
||||
public async Task<IEnumerable<Consultation>> GetByClientIdAsync(int clientId, CancellationToken ct = default) =>
|
||||
await repository.GetByClientIdAsync(clientId, ct);
|
||||
|
||||
public async Task<int> CreateAsync(Consultation consultation, CancellationToken ct = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(consultation.Summary))
|
||||
throw new ValidationException("상담 내용을 입력하세요.");
|
||||
if (consultation.ClientId <= 0)
|
||||
throw new ValidationException("고객을 선택하세요.");
|
||||
return await repository.CreateAsync(consultation, ct);
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.DeleteAsync(id, ct);
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class ConsultingActivityService(IConsultingActivityRepository repository)
|
||||
{
|
||||
public async Task<int> CreateAsync(int clientId, string activityType, DateTime activityDate,
|
||||
string description, int? consultantId = null, DateTime? nextFollowupDate = null, CancellationToken ct = default)
|
||||
{
|
||||
if (clientId <= 0)
|
||||
throw new ValidationException("유효한 고객을 선택하세요.");
|
||||
if (string.IsNullOrWhiteSpace(activityType))
|
||||
throw new ValidationException("활동 유형을 입력하세요.");
|
||||
if (string.IsNullOrWhiteSpace(description))
|
||||
throw new ValidationException("활동 내용을 입력하세요.");
|
||||
|
||||
var activity = new ConsultingActivity
|
||||
{
|
||||
ClientId = clientId,
|
||||
ActivityType = activityType.Trim(),
|
||||
ActivityDate = activityDate,
|
||||
Description = description.Trim(),
|
||||
AssignedConsultantId = consultantId,
|
||||
NextFollowupDate = nextFollowupDate,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UpdatedAt = DateTime.UtcNow
|
||||
};
|
||||
|
||||
return await repository.CreateAsync(activity, ct);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<ConsultingActivity>> GetByClientIdAsync(int clientId, CancellationToken ct = default) =>
|
||||
await repository.GetByClientIdAsync(clientId, ct);
|
||||
|
||||
public async Task<IEnumerable<ConsultingActivity>> GetAllAsync(CancellationToken ct = default) =>
|
||||
await repository.GetAllAsync(ct);
|
||||
|
||||
public async Task<IEnumerable<ConsultingActivity>> GetPendingFollowupsAsync(CancellationToken ct = default) =>
|
||||
await repository.GetPendingFollowupsAsync(ct);
|
||||
|
||||
public async Task<IEnumerable<ConsultingActivity>> GetConsultantActivityAsync(int consultantId, DateTime fromDate, CancellationToken ct = default) =>
|
||||
await repository.GetByConsultantAsync(consultantId, fromDate, ct);
|
||||
|
||||
public async Task UpdateAsync(int id, string? outcome, DateTime? nextFollowupDate, CancellationToken ct = default)
|
||||
{
|
||||
var activity = new ConsultingActivity { Id = id, Outcome = outcome, NextFollowupDate = nextFollowupDate, UpdatedAt = DateTime.UtcNow };
|
||||
await repository.UpdateAsync(activity, ct);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class ContractService(IContractRepository repository)
|
||||
{
|
||||
public async Task<int> CreateAsync(int clientId, string contractNumber, string serviceType,
|
||||
DateTime startDate, decimal? monthlyFee = null, decimal? totalAmount = null, CancellationToken ct = default)
|
||||
{
|
||||
if (clientId <= 0)
|
||||
throw new ValidationException("유효한 고객을 선택하세요.");
|
||||
if (string.IsNullOrWhiteSpace(contractNumber))
|
||||
throw new ValidationException("계약 번호를 입력하세요.");
|
||||
if (string.IsNullOrWhiteSpace(serviceType))
|
||||
throw new ValidationException("서비스 유형을 입력하세요.");
|
||||
|
||||
var contract = new Contract
|
||||
{
|
||||
ClientId = clientId,
|
||||
ContractNumber = contractNumber.Trim(),
|
||||
ServiceType = serviceType.Trim(),
|
||||
ContractDate = DateTime.Today,
|
||||
StartDate = startDate,
|
||||
MonthlyFee = monthlyFee,
|
||||
TotalAmount = totalAmount,
|
||||
Status = "active",
|
||||
PaymentStatus = "pending",
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UpdatedAt = DateTime.UtcNow
|
||||
};
|
||||
|
||||
return await repository.CreateAsync(contract, ct);
|
||||
}
|
||||
|
||||
public async Task<Contract?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.GetByIdAsync(id, ct);
|
||||
|
||||
public async Task<IEnumerable<Contract>> GetAllAsync(CancellationToken ct = default) =>
|
||||
await repository.GetAllAsync(ct);
|
||||
|
||||
public async Task<IEnumerable<Contract>> GetByClientIdAsync(int clientId, CancellationToken ct = default) =>
|
||||
await repository.GetByClientIdAsync(clientId, ct);
|
||||
|
||||
public async Task<IEnumerable<Contract>> GetActiveContractsAsync(CancellationToken ct = default) =>
|
||||
await repository.GetActiveContractsAsync(ct);
|
||||
|
||||
public async Task<IEnumerable<Contract>> GetExpiringContractsAsync(int daysAhead = 30, CancellationToken ct = default) =>
|
||||
await repository.GetExpiringContractsAsync(daysAhead, ct);
|
||||
|
||||
public async Task<decimal> GetMonthlyRecurringRevenueAsync(CancellationToken ct = default) =>
|
||||
await repository.GetMonthlyRecurringRevenueAsync(ct);
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class FaqService(IFaqRepository repository)
|
||||
{
|
||||
public static readonly string[] Categories =
|
||||
["기장세금신고", "부동산", "증여상속", "기타"];
|
||||
|
||||
public async Task<IEnumerable<Faq>> GetActiveAsync(CancellationToken ct = default) =>
|
||||
await repository.GetActiveAsync(ct);
|
||||
|
||||
public async Task<IEnumerable<Faq>> GetAllAsync(CancellationToken ct = default) =>
|
||||
await repository.GetAllAsync(ct);
|
||||
|
||||
public async Task<Faq?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.GetByIdAsync(id, ct);
|
||||
|
||||
public async Task<int> CreateAsync(Faq faq, CancellationToken ct = default)
|
||||
{
|
||||
Validate(faq);
|
||||
return await repository.CreateAsync(faq, ct);
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(Faq faq, CancellationToken ct = default)
|
||||
{
|
||||
Validate(faq);
|
||||
await repository.UpdateAsync(faq, ct);
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.DeleteAsync(id, ct);
|
||||
|
||||
private static void Validate(Faq faq)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(faq.Question))
|
||||
throw new ValidationException("질문을 입력하세요.");
|
||||
if (string.IsNullOrWhiteSpace(faq.Answer))
|
||||
throw new ValidationException("답변을 입력하세요.");
|
||||
}
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
public interface IInquiryNotificationService
|
||||
{
|
||||
Task NotifyCreatedAsync(int inquiryId, string name, string phone, string serviceType, string message, string? ipAddress, DateTime createdAtUtc, CancellationToken ct = default);
|
||||
Task NotifyStatusChangedAsync(int inquiryId, string name, string phone, string serviceType, string previousStatus, string newStatus, string? changedBy = null, CancellationToken ct = default);
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using System.Text.RegularExpressions;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using TaxBaik.Application.DTOs;
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Enums;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class InquiryService(
|
||||
IInquiryRepository repository,
|
||||
IInquiryNotificationService notificationService,
|
||||
IMemoryCache memoryCache)
|
||||
{
|
||||
private static readonly Regex PhoneRegex = new(@"^01[0-9]-\d{3,4}-\d{4}$");
|
||||
|
||||
public async Task<int> SubmitAsync(
|
||||
string name, string phone, string serviceType, string message,
|
||||
string? email = null, string? ipAddress = null, bool suppressNotification = false, CancellationToken ct = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
throw new ValidationException("이름을 입력하세요.");
|
||||
|
||||
if (!PhoneRegex.IsMatch(phone))
|
||||
throw new ValidationException("올바른 전화번호를 입력하세요. (예: 010-1234-5678)");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(message))
|
||||
throw new ValidationException("문의 내용을 입력하세요.");
|
||||
|
||||
var inquiry = new Inquiry
|
||||
{
|
||||
Name = name.Trim(),
|
||||
Phone = phone.Trim(),
|
||||
Email = string.IsNullOrWhiteSpace(email) ? null : email.Trim(),
|
||||
ServiceType = serviceType ?? "기타",
|
||||
Message = message.Trim(),
|
||||
IpAddress = ipAddress,
|
||||
Status = InquiryStatusMapper.ToStorageValue(InquiryStatus.New),
|
||||
CreatedAt = DateTime.UtcNow
|
||||
};
|
||||
|
||||
var inquiryId = await repository.CreateAsync(inquiry, ct);
|
||||
if (!suppressNotification)
|
||||
{
|
||||
await notificationService.NotifyCreatedAsync(inquiryId, inquiry.Name, inquiry.Phone, inquiry.ServiceType, inquiry.Message, inquiry.IpAddress, inquiry.CreatedAt, ct);
|
||||
}
|
||||
memoryCache.Remove(AdminDashboardService.CacheKey);
|
||||
return inquiryId;
|
||||
}
|
||||
|
||||
public async Task<Inquiry?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.GetByIdAsync(id, ct);
|
||||
|
||||
public async Task<(IEnumerable<Inquiry>, int)> GetPagedAsync(
|
||||
int page, int pageSize, string? status = null, CancellationToken ct = default) =>
|
||||
await repository.GetPagedAsync(NormalizePage(page), NormalizePageSize(pageSize), NormalizeOptionalStatus(status), ct);
|
||||
|
||||
public Task<int> CountAsync(CancellationToken ct = default)
|
||||
=> repository.CountAsync(ct);
|
||||
|
||||
public Task<int> CountThisMonthAsync(CancellationToken ct = default)
|
||||
=> repository.CountThisMonthAsync(ct);
|
||||
|
||||
public Task<int> CountByStatusAsync(string status, CancellationToken ct = default)
|
||||
=> repository.CountByStatusAsync(status, ct);
|
||||
|
||||
public Task<int> CountByDateRangeAsync(DateTime startDate, DateTime endDate, CancellationToken ct = default)
|
||||
=> repository.CountByDateRangeAsync(startDate, endDate, ct);
|
||||
|
||||
public Task<int> CountByStatusAndDateAsync(string status, DateTime startDate, DateTime endDate, CancellationToken ct = default)
|
||||
=> repository.CountByStatusAndDateAsync(status, startDate, endDate, ct);
|
||||
|
||||
public async Task UpdateAdminMemoAsync(int id, string? adminMemo, CancellationToken ct = default) =>
|
||||
await repository.UpdateAdminMemoAsync(id, adminMemo, ct);
|
||||
|
||||
public async Task<Inquiry?> UpdateAsync(int id, UpdateInquiryDto dto, CancellationToken ct = default)
|
||||
{
|
||||
var inquiry = await repository.GetByIdAsync(id, ct);
|
||||
if (inquiry == null)
|
||||
return null;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(dto.Name))
|
||||
throw new ValidationException("이름을 입력하세요.");
|
||||
|
||||
if (!PhoneRegex.IsMatch(dto.Phone))
|
||||
throw new ValidationException("올바른 전화번호를 입력하세요. (예: 010-1234-5678)");
|
||||
|
||||
if (string.IsNullOrWhiteSpace(dto.Message))
|
||||
throw new ValidationException("문의 내용을 입력하세요.");
|
||||
|
||||
if (!InquiryStatusMapper.TryParse(dto.Status, out var parsedStatus))
|
||||
throw new ValidationException("지원하지 않는 문의 상태입니다.");
|
||||
|
||||
inquiry.Name = dto.Name.Trim();
|
||||
inquiry.Phone = dto.Phone.Trim();
|
||||
inquiry.Email = string.IsNullOrWhiteSpace(dto.Email) ? null : dto.Email.Trim();
|
||||
inquiry.ServiceType = string.IsNullOrWhiteSpace(dto.ServiceType) ? "기타" : dto.ServiceType.Trim();
|
||||
inquiry.Message = dto.Message.Trim();
|
||||
inquiry.Status = InquiryStatusMapper.ToStorageValue(parsedStatus);
|
||||
inquiry.AdminMemo = dto.AdminMemo;
|
||||
|
||||
await repository.UpdateAsync(inquiry, ct);
|
||||
memoryCache.Remove(AdminDashboardService.CacheKey);
|
||||
return inquiry;
|
||||
}
|
||||
|
||||
public async Task LinkClientAsync(int inquiryId, int clientId, CancellationToken ct = default) =>
|
||||
await repository.LinkClientAsync(inquiryId, clientId, ct);
|
||||
|
||||
public async Task UpdateStatusAsync(int id, string status, string? changedBy = null, CancellationToken ct = default)
|
||||
{
|
||||
if (!InquiryStatusMapper.TryParse(status, out var parsed))
|
||||
throw new ValidationException("지원하지 않는 문의 상태입니다.");
|
||||
|
||||
var inquiry = await repository.GetByIdAsync(id, ct);
|
||||
if (inquiry == null)
|
||||
return;
|
||||
|
||||
var previousStatus = inquiry.Status;
|
||||
var newStatus = InquiryStatusMapper.ToStorageValue(parsed);
|
||||
|
||||
await repository.UpdateStatusAsync(id, newStatus, ct);
|
||||
await notificationService.NotifyStatusChangedAsync(id, inquiry.Name, inquiry.Phone, inquiry.ServiceType, previousStatus, newStatus, changedBy, ct);
|
||||
memoryCache.Remove(AdminDashboardService.CacheKey);
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(int id, CancellationToken ct = default)
|
||||
{
|
||||
await repository.DeleteAsync(id, ct);
|
||||
memoryCache.Remove(AdminDashboardService.CacheKey);
|
||||
}
|
||||
|
||||
private static int NormalizePage(int page) => Math.Max(1, page);
|
||||
|
||||
private static int NormalizePageSize(int pageSize) => Math.Clamp(pageSize, 1, 100);
|
||||
|
||||
private static string? NormalizeOptionalStatus(string? status)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(status))
|
||||
return null;
|
||||
|
||||
if (!InquiryStatusMapper.TryParse(status, out var parsed))
|
||||
throw new ValidationException("지원하지 않는 문의 상태입니다.");
|
||||
|
||||
return InquiryStatusMapper.ToStorageValue(parsed);
|
||||
}
|
||||
}
|
||||
|
||||
public class ValidationException : Exception
|
||||
{
|
||||
public ValidationException(string message) : base(message) { }
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using TaxBaik.Domain.Enums;
|
||||
|
||||
public static class InquiryStatusMapper
|
||||
{
|
||||
public static readonly Dictionary<string, string> Labels = new()
|
||||
{
|
||||
["new"] = "신규",
|
||||
["consulting"] = "상담중",
|
||||
["contracted"] = "계약완료",
|
||||
["rejected"] = "거절",
|
||||
["closed"] = "종결",
|
||||
};
|
||||
|
||||
public static string ToStorageValue(InquiryStatus status) => status switch
|
||||
{
|
||||
InquiryStatus.New => "new",
|
||||
InquiryStatus.Consulting => "consulting",
|
||||
InquiryStatus.Contracted => "contracted",
|
||||
InquiryStatus.Rejected => "rejected",
|
||||
InquiryStatus.Closed => "closed",
|
||||
_ => throw new ArgumentOutOfRangeException(nameof(status), status, null)
|
||||
};
|
||||
|
||||
public static bool TryParse(string? value, out InquiryStatus status)
|
||||
{
|
||||
var key = value?.Trim().ToLowerInvariant();
|
||||
status = key switch
|
||||
{
|
||||
"new" => InquiryStatus.New,
|
||||
"consulting" => InquiryStatus.Consulting,
|
||||
"contracted" => InquiryStatus.Contracted,
|
||||
"rejected" => InquiryStatus.Rejected,
|
||||
"closed" => InquiryStatus.Closed,
|
||||
_ => default
|
||||
};
|
||||
return key is "new" or "consulting" or "contracted" or "rejected" or "closed";
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
public sealed class NoopInquiryNotificationService : IInquiryNotificationService
|
||||
{
|
||||
public Task NotifyCreatedAsync(int inquiryId, string name, string phone, string serviceType, string message, string? ipAddress, DateTime createdAtUtc, CancellationToken ct = default)
|
||||
=> Task.CompletedTask;
|
||||
|
||||
public Task NotifyStatusChangedAsync(int inquiryId, string name, string phone, string serviceType, string previousStatus, string newStatus, string? changedBy = null, CancellationToken ct = default)
|
||||
=> Task.CompletedTask;
|
||||
}
|
||||
@@ -1,59 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class PortalUserService(IPortalUserRepository repository)
|
||||
{
|
||||
public async Task<PortalUser?> GetByEmailAsync(string email, CancellationToken ct = default) =>
|
||||
await repository.GetByEmailAsync(email.Trim(), ct);
|
||||
|
||||
public async Task<PortalUser?> GetByProviderAsync(string provider, string providerId, CancellationToken ct = default) =>
|
||||
await repository.GetByProviderAsync(provider.Trim(), providerId.Trim(), ct);
|
||||
|
||||
public async Task<int> RegisterLocalAsync(string name, string email, string phone, string? passwordHash, int? clientId = null, CancellationToken ct = default) =>
|
||||
await RegisterAsync(name, email, phone, "local", null, passwordHash, clientId, ct);
|
||||
|
||||
public async Task<int> RegisterOAuthAsync(string name, string email, string? phone, string provider, string providerId, int? clientId = null, CancellationToken ct = default) =>
|
||||
await RegisterAsync(name, email, phone, provider, providerId, null, clientId, ct);
|
||||
|
||||
public async Task LinkOAuthAsync(PortalUser user, string provider, string providerId, string? displayName = null, string? email = null, CancellationToken ct = default)
|
||||
{
|
||||
user.Name = string.IsNullOrWhiteSpace(displayName) ? user.Name : displayName.Trim();
|
||||
user.Email = string.IsNullOrWhiteSpace(email) ? user.Email : email.Trim();
|
||||
if (string.IsNullOrWhiteSpace(user.PasswordHash))
|
||||
{
|
||||
user.Provider = provider.Trim();
|
||||
user.ProviderId = providerId.Trim();
|
||||
}
|
||||
await repository.UpdateAsync(user, ct);
|
||||
}
|
||||
|
||||
public async Task AttachClientAsync(PortalUser user, int clientId, CancellationToken ct = default)
|
||||
{
|
||||
user.ClientId = clientId;
|
||||
await repository.UpdateAsync(user, ct);
|
||||
}
|
||||
|
||||
private async Task<int> RegisterAsync(string name, string email, string? phone, string provider, string? providerId, string? passwordHash, int? clientId, CancellationToken ct)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
throw new ValidationException("이름을 입력하세요.");
|
||||
if (string.IsNullOrWhiteSpace(email))
|
||||
throw new ValidationException("이메일을 입력하세요.");
|
||||
|
||||
var user = new PortalUser
|
||||
{
|
||||
ClientId = clientId,
|
||||
Name = name.Trim(),
|
||||
Email = email.Trim(),
|
||||
Phone = string.IsNullOrWhiteSpace(phone) ? null : phone.Trim(),
|
||||
Provider = provider,
|
||||
ProviderId = providerId,
|
||||
PasswordHash = passwordHash,
|
||||
CreatedAt = DateTime.UtcNow
|
||||
};
|
||||
|
||||
return await repository.CreateAsync(user, ct);
|
||||
}
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class RevenueTrackingService(IRevenueTrackingRepository repository)
|
||||
{
|
||||
public async Task<int> CreateAsync(int clientId, string invoiceNumber, DateTime invoiceDate,
|
||||
decimal amount, string? serviceType = null, DateTime? dueDate = null, CancellationToken ct = default)
|
||||
{
|
||||
if (clientId <= 0)
|
||||
throw new ValidationException("유효한 고객을 선택하세요.");
|
||||
if (string.IsNullOrWhiteSpace(invoiceNumber))
|
||||
throw new ValidationException("인보이스 번호를 입력하세요.");
|
||||
if (amount <= 0)
|
||||
throw new ValidationException("금액은 0보다 커야 합니다.");
|
||||
|
||||
var revenue = new RevenueTracking
|
||||
{
|
||||
ClientId = clientId,
|
||||
InvoiceNumber = invoiceNumber.Trim(),
|
||||
InvoiceDate = invoiceDate,
|
||||
Amount = amount,
|
||||
ServiceType = string.IsNullOrWhiteSpace(serviceType) ? null : serviceType.Trim(),
|
||||
DueDate = dueDate,
|
||||
PaymentStatus = "pending",
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UpdatedAt = DateTime.UtcNow
|
||||
};
|
||||
|
||||
return await repository.CreateAsync(revenue, ct);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<RevenueTracking>> GetByClientIdAsync(int clientId, CancellationToken ct = default) =>
|
||||
await repository.GetByClientIdAsync(clientId, ct);
|
||||
|
||||
public async Task<IEnumerable<RevenueTracking>> GetAllAsync(CancellationToken ct = default) =>
|
||||
await repository.GetAllAsync(ct);
|
||||
|
||||
public async Task<IEnumerable<RevenueTracking>> GetPendingPaymentsAsync(CancellationToken ct = default) =>
|
||||
await repository.GetPendingPaymentsAsync(ct);
|
||||
|
||||
public async Task<IEnumerable<RevenueTracking>> GetMonthlyRevenueAsync(DateTime month, CancellationToken ct = default)
|
||||
{
|
||||
var startDate = new DateTime(month.Year, month.Month, 1);
|
||||
var endDate = startDate.AddMonths(1).AddDays(-1);
|
||||
return await repository.GetByDateRangeAsync(startDate, endDate, ct);
|
||||
}
|
||||
|
||||
public async Task MarkPaidAsync(int id, DateTime paymentDate, CancellationToken ct = default) =>
|
||||
await repository.MarkPaidAsync(id, paymentDate, ct);
|
||||
|
||||
public async Task<decimal> GetTotalRevenueAsync(DateTime startDate, DateTime endDate, CancellationToken ct = default) =>
|
||||
await repository.GetTotalRevenueAsync(startDate, endDate, ct);
|
||||
}
|
||||
@@ -1,40 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using TaxBaik.Application.Seasonal;
|
||||
|
||||
public class SeasonalMarketingService
|
||||
{
|
||||
public CurrentSeasonDto? GetCurrentSeason()
|
||||
{
|
||||
var today = DateTime.Today;
|
||||
|
||||
foreach (var season in TaxSeasonCalendar.Seasons)
|
||||
{
|
||||
var start = new DateTime(today.Year, season.StartMonth, season.StartDay);
|
||||
var end = new DateTime(today.Year, season.EndMonth, season.EndDay);
|
||||
|
||||
if (today >= start && today <= end)
|
||||
{
|
||||
var effectiveEnd = BusinessDayCalculator.GetEffectiveBusinessDate(DateOnly.FromDateTime(end)).ToDateTime(TimeOnly.MinValue);
|
||||
var days = BusinessDayCalculator.GetBusinessDayDiff(DateOnly.FromDateTime(end), DateOnly.FromDateTime(today));
|
||||
return new CurrentSeasonDto
|
||||
{
|
||||
Key = season.Key,
|
||||
Name = season.Name,
|
||||
HeroHeadline = season.HeroHeadline,
|
||||
HeroSubtext = season.HeroSubtext,
|
||||
UrgencyBadge = season.UrgencyBadge.Replace("{n}", days.ToString()),
|
||||
FocusService = season.FocusService,
|
||||
RelatedCategorySlug = season.RelatedCategorySlug,
|
||||
CtaText = season.CtaText,
|
||||
DaysUntilDeadline = days,
|
||||
Deadline = effectiveEnd
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public IReadOnlyList<TaxSeason> GetFullCalendar() => TaxSeasonCalendar.Seasons;
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
public class SiteSettingService(ISiteSettingRepository repository)
|
||||
{
|
||||
public Task<IReadOnlyDictionary<string, string>> GetAllAsync(CancellationToken ct = default)
|
||||
=> repository.GetAllAsync(ct);
|
||||
|
||||
public Task SaveAsync(string phone, string email, string kakaoUrl, string instagramUrl, CancellationToken ct = default)
|
||||
{
|
||||
var settings = new[]
|
||||
{
|
||||
new SiteSetting { Key = "PhoneNumber", Value = phone.Trim(), UpdatedAt = DateTime.UtcNow },
|
||||
new SiteSetting { Key = "EmailAddress", Value = email.Trim(), UpdatedAt = DateTime.UtcNow },
|
||||
new SiteSetting { Key = "KakaoChannelUrl", Value = kakaoUrl.Trim(), UpdatedAt = DateTime.UtcNow },
|
||||
new SiteSetting { Key = "InstagramUrl", Value = instagramUrl.Trim(), UpdatedAt = DateTime.UtcNow },
|
||||
};
|
||||
|
||||
return repository.UpsertAsync(settings, ct);
|
||||
}
|
||||
}
|
||||
@@ -1,53 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class TaxFilingScheduleService(ITaxFilingScheduleRepository repository)
|
||||
{
|
||||
public async Task<int> CreateAsync(int clientId, string filingType, DateTime dueDate, int filingYear,
|
||||
int? assignedToId = null, CancellationToken ct = default)
|
||||
{
|
||||
if (clientId <= 0)
|
||||
throw new ValidationException("유효한 고객을 선택하세요.");
|
||||
if (string.IsNullOrWhiteSpace(filingType))
|
||||
throw new ValidationException("신고 유형을 입력하세요.");
|
||||
if (dueDate < DateTime.Today)
|
||||
throw new ValidationException("마감일은 오늘 이후여야 합니다.");
|
||||
|
||||
var schedule = new TaxFilingSchedule
|
||||
{
|
||||
ClientId = clientId,
|
||||
FilingType = filingType.Trim(),
|
||||
DueDate = dueDate,
|
||||
FilingYear = filingYear,
|
||||
Status = "pending",
|
||||
AssignedToId = assignedToId,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UpdatedAt = DateTime.UtcNow
|
||||
};
|
||||
|
||||
return await repository.CreateAsync(schedule, ct);
|
||||
}
|
||||
|
||||
public async Task<TaxFilingSchedule?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.GetByIdAsync(id, ct);
|
||||
|
||||
public async Task<IEnumerable<TaxFilingSchedule>> GetAllAsync(CancellationToken ct = default) =>
|
||||
await repository.GetAllAsync(ct);
|
||||
|
||||
public async Task<IEnumerable<TaxFilingSchedule>> GetByClientIdAsync(int clientId, CancellationToken ct = default) =>
|
||||
await repository.GetByClientIdAsync(clientId, ct);
|
||||
|
||||
public async Task<IEnumerable<TaxFilingSchedule>> GetUpcomingDuesAsync(int daysAhead = 30, CancellationToken ct = default) =>
|
||||
await repository.GetUpcomingDuesAsync(daysAhead, ct);
|
||||
|
||||
public async Task MarkCompletedAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.MarkCompletedAsync(id, ct);
|
||||
|
||||
public async Task<int> GetPendingCountAsync(CancellationToken ct = default)
|
||||
{
|
||||
var pending = await repository.GetByStatusAsync("pending", ct);
|
||||
return pending.Count();
|
||||
}
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class TaxFilingService(ITaxFilingRepository repository)
|
||||
{
|
||||
public static readonly string[] Statuses =
|
||||
["pending", "filed", "overdue"];
|
||||
|
||||
public static readonly Dictionary<string, string> StatusLabels = new()
|
||||
{
|
||||
["pending"] = "신고 예정",
|
||||
["filed"] = "신고 완료",
|
||||
["overdue"] = "기한 초과",
|
||||
};
|
||||
|
||||
public async Task<IEnumerable<TaxFiling>> GetByClientIdAsync(int clientId, CancellationToken ct = default) =>
|
||||
await repository.GetByClientIdAsync(clientId, ct);
|
||||
|
||||
public async Task<IEnumerable<TaxFiling>> GetUpcomingAsync(int daysAhead = 30, CancellationToken ct = default) =>
|
||||
await repository.GetUpcomingAsync(daysAhead, ct);
|
||||
|
||||
public async Task<TaxFiling?> GetByIdAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.GetByIdAsync(id, ct);
|
||||
|
||||
public async Task<int> CreateAsync(TaxFiling filing, CancellationToken ct = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filing.FilingType))
|
||||
throw new ValidationException("신고 유형을 선택하세요.");
|
||||
if (filing.ClientId <= 0)
|
||||
throw new ValidationException("고객을 선택하세요.");
|
||||
if (filing.DueDate == default)
|
||||
throw new ValidationException("신고 기한을 입력하세요.");
|
||||
return await repository.CreateAsync(filing, ct);
|
||||
}
|
||||
|
||||
public async Task UpdateAsync(TaxFiling filing, CancellationToken ct = default)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(filing.FilingType))
|
||||
throw new ValidationException("신고 유형을 선택하세요.");
|
||||
await repository.UpdateAsync(filing, ct);
|
||||
}
|
||||
|
||||
public async Task DeleteAsync(int id, CancellationToken ct = default) =>
|
||||
await repository.DeleteAsync(id, ct);
|
||||
}
|
||||
@@ -1,64 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
using TaxBaik.Domain.Entities;
|
||||
using TaxBaik.Domain.Interfaces;
|
||||
|
||||
public class TaxProfileService(ITaxProfileRepository repository)
|
||||
{
|
||||
public async Task<int> CreateAsync(int clientId, string? businessType, string? businessRegistration = null,
|
||||
string? accountingMethod = null, DateTime? establishmentDate = null, CancellationToken ct = default)
|
||||
{
|
||||
if (clientId <= 0)
|
||||
throw new ValidationException("유효한 고객을 선택하세요.");
|
||||
if (string.IsNullOrWhiteSpace(businessType))
|
||||
throw new ValidationException("사업 유형을 입력하세요.");
|
||||
|
||||
var profile = new TaxProfile
|
||||
{
|
||||
ClientId = clientId,
|
||||
BusinessType = businessType.Trim(),
|
||||
BusinessRegistration = string.IsNullOrWhiteSpace(businessRegistration) ? null : businessRegistration.Trim(),
|
||||
EstablishmentDate = establishmentDate,
|
||||
AccountingMethod = string.IsNullOrWhiteSpace(accountingMethod) ? null : accountingMethod.Trim(),
|
||||
TaxRiskLevel = "normal",
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
UpdatedAt = DateTime.UtcNow
|
||||
};
|
||||
|
||||
return await repository.CreateAsync(profile, ct);
|
||||
}
|
||||
|
||||
public async Task<TaxProfile?> GetByClientIdAsync(int clientId, CancellationToken ct = default) =>
|
||||
await repository.GetByClientIdAsync(clientId, ct);
|
||||
|
||||
public async Task<IEnumerable<TaxProfile>> GetAllAsync(CancellationToken ct = default) =>
|
||||
await repository.GetAllAsync(ct);
|
||||
|
||||
public async Task UpdateAsync(int profileId, string? businessType, string? accountingMethod,
|
||||
DateTime? nextFilingDueDate, string taxRiskLevel = "normal", CancellationToken ct = default)
|
||||
{
|
||||
var profile = await repository.GetByIdAsync(profileId, ct);
|
||||
if (profile == null)
|
||||
throw new ValidationException("세무 프로필을 찾을 수 없습니다.");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(businessType))
|
||||
profile.BusinessType = businessType.Trim();
|
||||
if (!string.IsNullOrWhiteSpace(accountingMethod))
|
||||
profile.AccountingMethod = accountingMethod.Trim();
|
||||
profile.NextFilingDueDate = nextFilingDueDate;
|
||||
profile.TaxRiskLevel = taxRiskLevel;
|
||||
profile.UpdatedAt = DateTime.UtcNow;
|
||||
|
||||
await repository.UpdateAsync(profile, ct);
|
||||
}
|
||||
|
||||
public async Task<IEnumerable<TaxProfile>> GetHighRiskProfilesAsync(CancellationToken ct = default) =>
|
||||
await repository.GetByRiskLevelAsync("high", ct);
|
||||
|
||||
public async Task<IEnumerable<TaxProfile>> GetUpcomingFilingDuesAsync(int daysAhead = 30, CancellationToken ct = default)
|
||||
{
|
||||
var startDate = DateTime.Today;
|
||||
var endDate = startDate.AddDays(daysAhead);
|
||||
return await repository.GetUpcomingFilingDuesAsync(startDate, endDate, ct);
|
||||
}
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
namespace TaxBaik.Application.Services;
|
||||
|
||||
public record TelegramDailyReport(
|
||||
DateOnly Date,
|
||||
int NewInquiries,
|
||||
int PendingInquiries,
|
||||
int NewClients,
|
||||
int PendingTaxFilings,
|
||||
int PendingPayments);
|
||||
|
||||
public record TelegramWeeklyReport(
|
||||
DateOnly WeekStart,
|
||||
DateOnly WeekEnd,
|
||||
int NewInquiries,
|
||||
int NewClients,
|
||||
int UpcomingTaxFilings,
|
||||
decimal RevenueThisWeek);
|
||||
|
||||
public class TelegramReportService(
|
||||
InquiryService inquiryService,
|
||||
ClientService clientService,
|
||||
TaxFilingScheduleService taxFilingScheduleService,
|
||||
RevenueTrackingService revenueTrackingService)
|
||||
{
|
||||
public async Task<TelegramDailyReport> BuildDailyReportAsync(DateOnly date, CancellationToken ct = default)
|
||||
{
|
||||
var start = date.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc);
|
||||
var end = date.ToDateTime(TimeOnly.MaxValue, DateTimeKind.Utc);
|
||||
|
||||
return new TelegramDailyReport(
|
||||
Date: date,
|
||||
NewInquiries: await inquiryService.CountByDateRangeAsync(start, end, ct),
|
||||
PendingInquiries: await inquiryService.CountByStatusAsync("new", ct),
|
||||
NewClients: await clientService.CountCreatedAtRangeAsync(start, end, ct),
|
||||
PendingTaxFilings: await taxFilingScheduleService.GetPendingCountAsync(ct),
|
||||
PendingPayments: (await revenueTrackingService.GetPendingPaymentsAsync(ct)).Count());
|
||||
}
|
||||
|
||||
public async Task<TelegramWeeklyReport> BuildWeeklyReportAsync(DateOnly weekStart, CancellationToken ct = default)
|
||||
{
|
||||
var weekEnd = weekStart.AddDays(6);
|
||||
var start = weekStart.ToDateTime(TimeOnly.MinValue, DateTimeKind.Utc);
|
||||
var end = weekEnd.ToDateTime(TimeOnly.MaxValue, DateTimeKind.Utc);
|
||||
var upcomingEnd = weekEnd.AddDays(7).ToDateTime(TimeOnly.MaxValue, DateTimeKind.Utc);
|
||||
|
||||
var revenue = await revenueTrackingService.GetTotalRevenueAsync(start, end, ct);
|
||||
|
||||
return new TelegramWeeklyReport(
|
||||
WeekStart: weekStart,
|
||||
WeekEnd: weekEnd,
|
||||
NewInquiries: await inquiryService.CountByDateRangeAsync(start, end, ct),
|
||||
NewClients: await clientService.CountCreatedAtRangeAsync(start, end, ct),
|
||||
UpcomingTaxFilings: (await taxFilingScheduleService.GetUpcomingDuesAsync(14, ct))
|
||||
.Count(x => x.DueDate >= start && x.DueDate <= upcomingEnd),
|
||||
RevenueThisWeek: revenue);
|
||||
}
|
||||
|
||||
public static string FormatDailyMessage(TelegramDailyReport report) =>
|
||||
$"<b>📊 일간 리포트</b>\n\n" +
|
||||
$"기준일: <code>{report.Date:yyyy-MM-dd}</code>\n" +
|
||||
$"신규 문의: <code>{report.NewInquiries}</code>\n" +
|
||||
$"처리 대기 문의: <code>{report.PendingInquiries}</code>\n" +
|
||||
$"신규 고객: <code>{report.NewClients}</code>\n" +
|
||||
$"신고 대기: <code>{report.PendingTaxFilings}</code>\n" +
|
||||
$"미수 청구: <code>{report.PendingPayments}</code>";
|
||||
|
||||
public static string FormatWeeklyMessage(TelegramWeeklyReport report) =>
|
||||
$"<b>📈 주간 리포트</b>\n\n" +
|
||||
$"기간: <code>{report.WeekStart:yyyy-MM-dd}</code> ~ <code>{report.WeekEnd:yyyy-MM-dd}</code>\n" +
|
||||
$"신규 문의: <code>{report.NewInquiries}</code>\n" +
|
||||
$"신규 고객: <code>{report.NewClients}</code>\n" +
|
||||
$"다가오는 신고: <code>{report.UpcomingTaxFilings}</code>\n" +
|
||||
$"주간 매출: <code>₩{report.RevenueThisWeek:N0}</code>";
|
||||
}
|
||||
Reference in New Issue
Block a user