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

@@ -17,6 +17,10 @@ public sealed class TenantCommerceQueryDto
[Range(1, 200)]
public int? Limit { get; set; }
public Guid? UserId { get; set; }
public Guid? RegionId { get; set; }
}
public sealed class UpsertPaymentAccountDto
@@ -134,3 +138,162 @@ public sealed class RedeemActivationCodeDto
return new RedeemActivationCodeCommand(Code, UserId, RegionId);
}
}
public sealed class UpsertPointTaskDto
{
public Guid? Id { get; set; }
[Required]
[StringLength(100)]
public string TaskKey { get; set; } = string.Empty;
[Required]
[StringLength(200)]
public string Title { get; set; } = string.Empty;
[StringLength(1000)]
public string? Description { get; set; }
public PointActivityTaskType TaskType { get; set; } = PointActivityTaskType.Manual;
public PointActivityTaskStatus Status { get; set; } = PointActivityTaskStatus.Active;
[Range(1, int.MaxValue)]
public int Points { get; set; }
[Range(1, 1000)]
public int MaxClaimsPerUser { get; set; } = 1;
public DateTimeOffset? StartsAt { get; set; }
public DateTimeOffset? EndsAt { get; set; }
public int SortOrder { get; set; }
public JsonElement Rules { get; set; } = JsonDefaults.Object();
public JsonElement Metadata { get; set; } = JsonDefaults.Object();
public UpsertPointTaskCommand ToCommand()
{
return new UpsertPointTaskCommand(
Id,
TaskKey,
Title,
Description,
TaskType,
Status,
Points,
MaxClaimsPerUser,
StartsAt,
EndsAt,
SortOrder,
Rules,
Metadata);
}
}
public sealed class UpsertPointExchangeItemDto
{
public Guid? Id { get; set; }
public Guid? RegionId { get; set; }
[Required]
[StringLength(100)]
public string ItemKey { get; set; } = string.Empty;
[Required]
[StringLength(200)]
public string Name { get; set; } = string.Empty;
[StringLength(1000)]
public string? Description { get; set; }
public PointExchangeItemType ItemType { get; set; } = PointExchangeItemType.Entitlement;
public PointExchangeItemStatus Status { get; set; } = PointExchangeItemStatus.Active;
[Range(1, int.MaxValue)]
public int PointsCost { get; set; }
[Range(0, int.MaxValue)]
public int? Stock { get; set; }
[Range(0, 3650)]
public int? Days { get; set; }
public int SortOrder { get; set; }
public DateTimeOffset? StartsAt { get; set; }
public DateTimeOffset? EndsAt { get; set; }
public JsonElement FulfillmentPayload { get; set; } = JsonDefaults.Object();
public JsonElement Metadata { get; set; } = JsonDefaults.Object();
public UpsertPointExchangeItemCommand ToCommand()
{
return new UpsertPointExchangeItemCommand(
Id,
RegionId,
ItemKey,
Name,
Description,
ItemType,
Status,
PointsCost,
Stock,
Days,
SortOrder,
StartsAt,
EndsAt,
FulfillmentPayload,
Metadata);
}
}
public sealed class UpdatePointExchangeOrderStatusDto
{
[Required]
public Guid OrderId { get; set; }
public PointExchangeOrderStatus Status { get; set; }
public UpdatePointExchangeOrderStatusCommand ToCommand()
{
return new UpdatePointExchangeOrderStatusCommand(OrderId, Status);
}
}
public sealed class UpsertTenantCouponDto
{
public Guid? Id { get; set; }
[Required]
[StringLength(100)]
public string Code { get; set; } = string.Empty;
public Guid? PlanId { get; set; }
public DiscountType DiscountType { get; set; } = DiscountType.Fixed;
[Range(typeof(decimal), "0.01", "999999")]
public decimal DiscountValue { get; set; }
public DateTimeOffset? ValidFrom { get; set; }
public DateTimeOffset? ValidTo { get; set; }
[Range(1, int.MaxValue)]
public int? MaxUses { get; set; }
[StringLength(50)]
public string? Source { get; set; }
[StringLength(1000)]
public string? Remark { get; set; }
public UpsertCouponCommand ToCommand()
{
return new UpsertCouponCommand(
Id,
Code,
PlanId,
DiscountType,
DiscountValue,
ValidFrom,
ValidTo,
MaxUses,
Source,
Remark);
}
}