feat: add coupon checkout support

This commit is contained in:
xiong
2026-07-26 20:04:24 +08:00
parent a4621df728
commit 7139da766a
6 changed files with 673 additions and 9 deletions

View File

@@ -10,7 +10,8 @@ public sealed record CreateCommerceOrderCommand(
string? PayMethod,
string? PayProvider,
Guid? RegionId,
string? CouponCode);
string? CouponCode,
Guid? CouponRedemptionId);
public sealed record CommerceOrderQuery(int? Limit = null, string? Status = null);
@@ -64,6 +65,41 @@ public sealed record CurrentEntitlementItem(
string Status,
int? DaysLeft);
public sealed record CommerceCouponQuery(int? Limit = null, string? Status = null);
public sealed record ClaimCommerceCouponCommand(string CouponCode);
public sealed record CheckCommerceCouponCommand(string? CouponCode, Guid? CouponRedemptionId, Guid PlanId, int Quantity, Guid? RegionId);
public sealed record CommerceCouponItem(
Guid Id,
Guid? CouponId,
string CouponCode,
string Status,
Guid? PlanId,
Guid? RegionId,
string? DiscountType,
decimal? DiscountValue,
int? DiscountPreviewCents,
string? DiscountPreview,
DateTimeOffset? ValidFrom,
DateTimeOffset? ValidTo,
DateTimeOffset? ClaimedAt,
DateTimeOffset? UsedAt);
public sealed record CommerceCouponList(IReadOnlyCollection<CommerceCouponItem> Items);
public sealed record CommerceCouponCheckResult(
bool Valid,
string? ReasonCode,
Guid? CouponId,
Guid? CouponRedemptionId,
string? CouponCode,
int OriginalAmountCents,
int DiscountCents,
int PayableAmountCents,
string PayablePrice);
public sealed record PaymentNotificationProcessResult(
string Provider,
string EventId,
@@ -97,6 +133,21 @@ public interface ICommerceService
CommerceActor actor,
CancellationToken cancellationToken = default);
Task<CommerceCouponItem> ClaimCouponAsync(
CommerceActor actor,
ClaimCommerceCouponCommand command,
CancellationToken cancellationToken = default);
Task<CommerceCouponList> GetCouponsAsync(
CommerceActor actor,
CommerceCouponQuery query,
CancellationToken cancellationToken = default);
Task<CommerceCouponCheckResult> CheckCouponAsync(
CommerceActor actor,
CheckCommerceCouponCommand command,
CancellationToken cancellationToken = default);
Task<PaymentNotificationProcessResult> ProcessPaymentNotificationAsync(
Guid tenantId,
string provider,