using System.Text.Json; using Tiku.Domain.Commerce; using Tiku.Domain.Tenancy; namespace Tiku.Application.Commerce; public sealed record CommerceAdminActor(Guid TenantId, Guid UserId); public sealed record CommerceAdminQuery(string? Provider = null, string? Status = null, int? Limit = null); public sealed record TenantPointQuery(string? Status = null, int? Limit = null, Guid? UserId = null, Guid? RegionId = null); public sealed record UpsertPaymentAccountCommand( string Provider, TenantPaymentMode Mode, string? DisplayName, TenantPaymentAccountStatus Status, JsonElement ConfigPublic); public sealed record TenantPaymentAccountItem( Guid Id, string Provider, string Mode, string? DisplayName, string Status, JsonElement ConfigPublic, DateTimeOffset CreatedAt, DateTimeOffset UpdatedAt); public sealed record UpsertTenantSecretCommand( string Purpose, string Provider, string SecretKey, string SecretRef, TenantSecretStatus Status, JsonElement SecretPayload, DateTimeOffset? ExpiresAt); public sealed record TenantSecretItem( Guid Id, string Purpose, string Provider, string SecretKey, string SecretRef, string Status, DateTimeOffset? RotatedAt, DateTimeOffset? ExpiresAt, DateTimeOffset UpdatedAt); public sealed record AdminOrderList(IReadOnlyCollection Items); public sealed record AdminPaymentList(IReadOnlyCollection Items); public sealed record CreateCodeBatchCommand( string Name, int TotalCount, int Days, Guid? RegionId, string? SaleType, string? Channel, int? DefaultUnitPriceCents, int? CostPriceCents, string? Remark); public sealed record CodeBatchItem( Guid Id, string Name, int TotalCount, int Days, Guid? RegionId, string? SaleType, string? Channel, int DefaultUnitPriceCents, int CostPriceCents, DateTimeOffset? IssuedAt, string? Remark, DateTimeOffset CreatedAt); public sealed record ActivationCodeItem( Guid Id, Guid? BatchId, string Code, int Days, bool IsUsed, Guid? UsedBy, DateTimeOffset? UsedAt, string? SaleType, string? SoldTo, string? Remark, DateTimeOffset CreatedAt); public sealed record ActivationCodeList(IReadOnlyCollection Items); public sealed record RedeemActivationCodeCommand(string Code, Guid UserId, Guid? RegionId); public sealed record UpsertPointTaskCommand( Guid? Id, string TaskKey, string Title, string? Description, PointActivityTaskType TaskType, PointActivityTaskStatus Status, int Points, int MaxClaimsPerUser, DateTimeOffset? StartsAt, DateTimeOffset? EndsAt, int SortOrder, JsonElement Rules, JsonElement Metadata); public sealed record UpsertPointExchangeItemCommand( Guid? Id, Guid? RegionId, string ItemKey, string Name, string? Description, PointExchangeItemType ItemType, PointExchangeItemStatus Status, int PointsCost, int? Stock, int? Days, int SortOrder, DateTimeOffset? StartsAt, DateTimeOffset? EndsAt, JsonElement FulfillmentPayload, JsonElement Metadata); public sealed record UpdatePointExchangeOrderStatusCommand(Guid OrderId, PointExchangeOrderStatus Status); public sealed record TenantPointTaskList(IReadOnlyCollection Items); public sealed record TenantPointClaimList(IReadOnlyCollection Items); public sealed record TenantPointExchangeItemList(IReadOnlyCollection Items); public sealed record TenantPointExchangeOrderList(IReadOnlyCollection Items); public sealed record UpsertCouponCommand( Guid? Id, string Code, Guid? PlanId, DiscountType DiscountType, decimal DiscountValue, DateTimeOffset? ValidFrom, DateTimeOffset? ValidTo, int? MaxUses, string? Source, string? Remark); public sealed record TenantCouponList(IReadOnlyCollection Items); public sealed record TenantCouponRedemptionList(IReadOnlyCollection Items); public sealed record TenantCouponReport(int CouponCount, int ClaimedCount, int UsedCount, int DiscountAppliedCents); public interface ICommerceAdminService { Task> GetPaymentAccountsAsync( CommerceAdminActor actor, CommerceAdminQuery query, CancellationToken cancellationToken = default); Task UpsertPaymentAccountAsync( CommerceAdminActor actor, UpsertPaymentAccountCommand command, CancellationToken cancellationToken = default); Task UpsertTenantSecretAsync( CommerceAdminActor actor, UpsertTenantSecretCommand command, CancellationToken cancellationToken = default); Task GetOrdersAsync( CommerceAdminActor actor, CommerceAdminQuery query, CancellationToken cancellationToken = default); Task GetPaymentsAsync( CommerceAdminActor actor, CommerceAdminQuery query, CancellationToken cancellationToken = default); Task CreateCodeBatchAsync( CommerceAdminActor actor, CreateCodeBatchCommand command, CancellationToken cancellationToken = default); Task GetActivationCodesAsync( CommerceAdminActor actor, CommerceAdminQuery query, CancellationToken cancellationToken = default); Task RedeemActivationCodeAsync( CommerceAdminActor actor, RedeemActivationCodeCommand command, CancellationToken cancellationToken = default); Task GetPointTasksAsync( CommerceAdminActor actor, TenantPointQuery query, CancellationToken cancellationToken = default); Task UpsertPointTaskAsync( CommerceAdminActor actor, UpsertPointTaskCommand command, CancellationToken cancellationToken = default); Task GetPointClaimsAsync( CommerceAdminActor actor, TenantPointQuery query, CancellationToken cancellationToken = default); Task GetPointExchangeItemsAsync( CommerceAdminActor actor, TenantPointQuery query, CancellationToken cancellationToken = default); Task UpsertPointExchangeItemAsync( CommerceAdminActor actor, UpsertPointExchangeItemCommand command, CancellationToken cancellationToken = default); Task GetPointExchangeOrdersAsync( CommerceAdminActor actor, TenantPointQuery query, CancellationToken cancellationToken = default); Task UpdatePointExchangeOrderStatusAsync( CommerceAdminActor actor, UpdatePointExchangeOrderStatusCommand command, CancellationToken cancellationToken = default); Task GetCouponsAsync( CommerceAdminActor actor, CommerceAdminQuery query, CancellationToken cancellationToken = default); Task UpsertCouponAsync( CommerceAdminActor actor, UpsertCouponCommand command, CancellationToken cancellationToken = default); Task GetCouponRedemptionsAsync( CommerceAdminActor actor, CommerceAdminQuery query, CancellationToken cancellationToken = default); Task GetCouponReportAsync( CommerceAdminActor actor, CommerceAdminQuery query, CancellationToken cancellationToken = default); }