217 lines
4.6 KiB
C#
217 lines
4.6 KiB
C#
using System.ComponentModel.DataAnnotations;
|
|
using Tiku.Application.Commerce;
|
|
|
|
namespace Tiku.Api.Contracts;
|
|
|
|
/// <summary>
|
|
/// 创建交易订单请求 DTO。
|
|
/// </summary>
|
|
public sealed class CreateCommerceOrderDto
|
|
{
|
|
/// <summary>
|
|
/// 套餐 ID。
|
|
/// </summary>
|
|
[Required]
|
|
public Guid PlanId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 数量。
|
|
/// </summary>
|
|
[Range(1, 99)]
|
|
public int Quantity { get; set; } = 1;
|
|
|
|
/// <summary>
|
|
/// 支付方式。
|
|
/// </summary>
|
|
[StringLength(50)]
|
|
public string? PayMethod { get; set; }
|
|
|
|
/// <summary>
|
|
/// 支付渠道。
|
|
/// </summary>
|
|
[StringLength(50)]
|
|
public string? PayProvider { get; set; }
|
|
|
|
/// <summary>
|
|
/// 地区 ID。
|
|
/// </summary>
|
|
public Guid? RegionId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 优惠券码。
|
|
/// </summary>
|
|
[StringLength(100)]
|
|
public string? CouponCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 优惠券领取记录 ID。
|
|
/// </summary>
|
|
public Guid? CouponRedemptionId { get; set; }
|
|
|
|
public CreateCommerceOrderCommand ToCommand()
|
|
{
|
|
return new CreateCommerceOrderCommand(
|
|
PlanId,
|
|
Quantity,
|
|
PayMethod,
|
|
PayProvider,
|
|
RegionId,
|
|
CouponCode,
|
|
CouponRedemptionId);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 交易订单查询参数。
|
|
/// </summary>
|
|
public sealed class CommerceOrderQueryDto
|
|
{
|
|
/// <summary>
|
|
/// 返回数量上限。
|
|
/// </summary>
|
|
[Range(1, 100)]
|
|
public int? Limit { get; set; }
|
|
|
|
/// <summary>
|
|
/// 状态。
|
|
/// </summary>
|
|
[StringLength(32)]
|
|
public string? Status { get; set; }
|
|
}
|
|
|
|
/// <summary>
|
|
/// 创建交易支付请求 DTO。
|
|
/// </summary>
|
|
public sealed class CreateCommercePaymentDto
|
|
{
|
|
/// <summary>
|
|
/// 订单号。
|
|
/// </summary>
|
|
[Required]
|
|
[StringLength(100)]
|
|
public string OrderNo { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 服务提供方。
|
|
/// </summary>
|
|
[Required]
|
|
[StringLength(50)]
|
|
public string Provider { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 方式。
|
|
/// </summary>
|
|
[Required]
|
|
[StringLength(50)]
|
|
public string Method { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// 微信或支付渠道 openid。
|
|
/// </summary>
|
|
[StringLength(255)]
|
|
public string? OpenId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 支付完成返回地址。
|
|
/// </summary>
|
|
[StringLength(2048)]
|
|
public string? ReturnUrl { get; set; }
|
|
|
|
/// <summary>
|
|
/// 支付取消返回地址。
|
|
/// </summary>
|
|
[StringLength(2048)]
|
|
public string? QuitUrl { get; set; }
|
|
|
|
public CreateCommercePaymentCommand ToCommand()
|
|
{
|
|
return new CreateCommercePaymentCommand(
|
|
OrderNo,
|
|
Provider,
|
|
Method,
|
|
OpenId,
|
|
ReturnUrl,
|
|
QuitUrl);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 交易优惠券查询参数。
|
|
/// </summary>
|
|
public sealed class CommerceCouponQueryDto
|
|
{
|
|
/// <summary>
|
|
/// 返回数量上限。
|
|
/// </summary>
|
|
[Range(1, 100)]
|
|
public int? Limit { get; set; }
|
|
|
|
/// <summary>
|
|
/// 状态。
|
|
/// </summary>
|
|
[StringLength(32)]
|
|
public string? Status { get; set; }
|
|
|
|
public CommerceCouponQuery ToQuery()
|
|
{
|
|
return new CommerceCouponQuery(Limit, Status);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 领取交易优惠券请求 DTO。
|
|
/// </summary>
|
|
public sealed class ClaimCommerceCouponDto
|
|
{
|
|
/// <summary>
|
|
/// 优惠券码。
|
|
/// </summary>
|
|
[Required]
|
|
[StringLength(100)]
|
|
public string CouponCode { get; set; } = string.Empty;
|
|
|
|
public ClaimCommerceCouponCommand ToCommand()
|
|
{
|
|
return new ClaimCommerceCouponCommand(CouponCode);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 校验交易优惠券请求 DTO。
|
|
/// </summary>
|
|
public sealed class CheckCommerceCouponDto
|
|
{
|
|
/// <summary>
|
|
/// 优惠券码。
|
|
/// </summary>
|
|
[StringLength(100)]
|
|
public string? CouponCode { get; set; }
|
|
|
|
/// <summary>
|
|
/// 优惠券领取记录 ID。
|
|
/// </summary>
|
|
public Guid? CouponRedemptionId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 套餐 ID。
|
|
/// </summary>
|
|
[Required]
|
|
public Guid PlanId { get; set; }
|
|
|
|
/// <summary>
|
|
/// 数量。
|
|
/// </summary>
|
|
[Range(1, 99)]
|
|
public int Quantity { get; set; } = 1;
|
|
|
|
/// <summary>
|
|
/// 地区 ID。
|
|
/// </summary>
|
|
public Guid? RegionId { get; set; }
|
|
|
|
public CheckCommerceCouponCommand ToCommand()
|
|
{
|
|
return new CheckCommerceCouponCommand(CouponCode, CouponRedemptionId, PlanId, Quantity, RegionId);
|
|
}
|
|
}
|