feat: add tenant points and coupon operations

This commit is contained in:
xiong
2026-07-26 20:08:23 +08:00
parent 7139da766a
commit 4efccf8355
5 changed files with 780 additions and 0 deletions

View File

@@ -8,6 +8,8 @@ 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,
@@ -91,6 +93,61 @@ public sealed record ActivationCodeList(IReadOnlyCollection<ActivationCodeItem>
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<PointActivityTask> Items);
public sealed record TenantPointClaimList(IReadOnlyCollection<PointActivityClaim> Items);
public sealed record TenantPointExchangeItemList(IReadOnlyCollection<PointExchangeItem> Items);
public sealed record TenantPointExchangeOrderList(IReadOnlyCollection<PointExchangeOrder> 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<Coupon> Items);
public sealed record TenantCouponRedemptionList(IReadOnlyCollection<CouponRedemption> Items);
public sealed record TenantCouponReport(int CouponCount, int ClaimedCount, int UsedCount, int DiscountAppliedCents);
public interface ICommerceAdminService
{
Task<IReadOnlyCollection<TenantPaymentAccountItem>> GetPaymentAccountsAsync(
@@ -132,4 +189,59 @@ public interface ICommerceAdminService
CommerceAdminActor actor,
RedeemActivationCodeCommand command,
CancellationToken cancellationToken = default);
Task<TenantPointTaskList> GetPointTasksAsync(
CommerceAdminActor actor,
TenantPointQuery query,
CancellationToken cancellationToken = default);
Task<PointActivityTask> UpsertPointTaskAsync(
CommerceAdminActor actor,
UpsertPointTaskCommand command,
CancellationToken cancellationToken = default);
Task<TenantPointClaimList> GetPointClaimsAsync(
CommerceAdminActor actor,
TenantPointQuery query,
CancellationToken cancellationToken = default);
Task<TenantPointExchangeItemList> GetPointExchangeItemsAsync(
CommerceAdminActor actor,
TenantPointQuery query,
CancellationToken cancellationToken = default);
Task<PointExchangeItem> UpsertPointExchangeItemAsync(
CommerceAdminActor actor,
UpsertPointExchangeItemCommand command,
CancellationToken cancellationToken = default);
Task<TenantPointExchangeOrderList> GetPointExchangeOrdersAsync(
CommerceAdminActor actor,
TenantPointQuery query,
CancellationToken cancellationToken = default);
Task<PointExchangeOrder> UpdatePointExchangeOrderStatusAsync(
CommerceAdminActor actor,
UpdatePointExchangeOrderStatusCommand command,
CancellationToken cancellationToken = default);
Task<TenantCouponList> GetCouponsAsync(
CommerceAdminActor actor,
CommerceAdminQuery query,
CancellationToken cancellationToken = default);
Task<Coupon> UpsertCouponAsync(
CommerceAdminActor actor,
UpsertCouponCommand command,
CancellationToken cancellationToken = default);
Task<TenantCouponRedemptionList> GetCouponRedemptionsAsync(
CommerceAdminActor actor,
CommerceAdminQuery query,
CancellationToken cancellationToken = default);
Task<TenantCouponReport> GetCouponReportAsync(
CommerceAdminActor actor,
CommerceAdminQuery query,
CancellationToken cancellationToken = default);
}