QueryModel.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334
  1. using System.Collections.Generic;
  2. using System.ComponentModel.DataAnnotations;
  3. using Newtonsoft.Json;
  4. using Newtonsoft.Json.Serialization;
  5. namespace PaySharp.Alipay.Domain
  6. {
  7. [JsonObject(NamingStrategyType = typeof(SnakeCaseNamingStrategy))]
  8. public class QueryModel : IValidatableObject
  9. {
  10. /// <summary>
  11. /// 订单支付时传入的商户订单号,和支付宝交易号不能同时为空。
  12. /// TradeNo,OutTradeNo如果同时存在优先取TradeNo
  13. /// </summary>
  14. [StringLength(64, ErrorMessage = "商户订单号最大长度为64位")]
  15. public string OutTradeNo { get; set; }
  16. /// <summary>
  17. /// 支付宝交易号,和商户订单号不能同时为空
  18. /// </summary>
  19. [StringLength(64, ErrorMessage = "支付宝交易号最大长度为64位")]
  20. public string TradeNo { get; set; }
  21. public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
  22. {
  23. if (string.IsNullOrEmpty(OutTradeNo) && string.IsNullOrEmpty(TradeNo))
  24. {
  25. yield return new ValidationResult("商户订单号和支付宝交易号不能同时为空");
  26. }
  27. yield return ValidationResult.Success;
  28. }
  29. }
  30. }