feat: add commerce order and payment checkout
This commit is contained in:
97
Tiku.Application/Commerce/CommerceModels.cs
Normal file
97
Tiku.Application/Commerce/CommerceModels.cs
Normal file
@@ -0,0 +1,97 @@
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Tiku.Application.Commerce;
|
||||
|
||||
public sealed record CommerceActor(Guid TenantId, Guid UserId);
|
||||
|
||||
public sealed record CreateCommerceOrderCommand(
|
||||
Guid PlanId,
|
||||
int Quantity,
|
||||
string? PayMethod,
|
||||
string? PayProvider,
|
||||
Guid? RegionId,
|
||||
string? CouponCode);
|
||||
|
||||
public sealed record CommerceOrderQuery(int? Limit = null, string? Status = null);
|
||||
|
||||
public sealed record CreateCommercePaymentCommand(
|
||||
string OrderNo,
|
||||
string Provider,
|
||||
string Method,
|
||||
string? OpenId,
|
||||
string? ReturnUrl,
|
||||
string? QuitUrl);
|
||||
|
||||
public sealed record CommerceOrderItem(
|
||||
Guid Id,
|
||||
string OrderNo,
|
||||
string Status,
|
||||
Guid? PlanId,
|
||||
Guid? RegionId,
|
||||
string? ProductType,
|
||||
string? ProductName,
|
||||
int AmountCents,
|
||||
string Price,
|
||||
string? PayMethod,
|
||||
string? PayProvider,
|
||||
string? TradeNo,
|
||||
int? Days,
|
||||
DateTimeOffset? PaidAt,
|
||||
DateTimeOffset CreatedAt,
|
||||
JsonElement RawPayload);
|
||||
|
||||
public sealed record CommerceOrderList(IReadOnlyCollection<CommerceOrderItem> Items);
|
||||
|
||||
public sealed record CommercePaymentItem(
|
||||
Guid Id,
|
||||
Guid OrderId,
|
||||
string OrderNo,
|
||||
string Provider,
|
||||
string? Method,
|
||||
string Status,
|
||||
int AmountCents,
|
||||
string Price,
|
||||
string? ProviderTradeNo,
|
||||
DateTimeOffset? PaidAt,
|
||||
JsonElement ClientPayload,
|
||||
JsonElement RawPayload);
|
||||
|
||||
public sealed record CurrentEntitlementItem(
|
||||
bool IsActive,
|
||||
string EntitlementType,
|
||||
DateTimeOffset? StartsAt,
|
||||
DateTimeOffset? ExpiresAt,
|
||||
string Status,
|
||||
int? DaysLeft);
|
||||
|
||||
public interface ICommerceService
|
||||
{
|
||||
Task<CommerceOrderItem> CreateOrderAsync(
|
||||
CommerceActor actor,
|
||||
CreateCommerceOrderCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<CommerceOrderList> GetOrdersAsync(
|
||||
CommerceActor actor,
|
||||
CommerceOrderQuery query,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<CommerceOrderItem> GetOrderAsync(
|
||||
CommerceActor actor,
|
||||
string orderNo,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<CommercePaymentItem> CreatePaymentAsync(
|
||||
CommerceActor actor,
|
||||
CreateCommercePaymentCommand command,
|
||||
CancellationToken cancellationToken = default);
|
||||
|
||||
Task<CurrentEntitlementItem> GetCurrentEntitlementAsync(
|
||||
CommerceActor actor,
|
||||
CancellationToken cancellationToken = default);
|
||||
}
|
||||
|
||||
public sealed class CommerceException(string message, string code) : Exception(message)
|
||||
{
|
||||
public string Code { get; } = code;
|
||||
}
|
||||
Reference in New Issue
Block a user