using FreeSql.DatabaseModel;using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using Newtonsoft.Json;
using FreeSql.DataAnnotations;

namespace FuelServer.Core.Entity
{

	/// <summary>
	/// 订单表
	/// </summary>
	[JsonObject(MemberSerialization.OptIn), Table(DisableSyncStructure = true)]
	public partial class transactions {

		/// <summary>
		/// 订单唯一标识符
		/// </summary>
		[JsonProperty, Column(IsPrimary = true, IsIdentity = true)]
		public long Id { get; set; }

		/// <summary>
		/// 油站唯一标识符
		/// </summary>
		[JsonProperty]
		public Guid Buid { get; set; }

		/// <summary>
		/// 用户ID
		/// </summary>
		[JsonProperty]
		public long MiniProgramID { get; set; }

		/// <summary>
		/// 枪号
		/// </summary>
		[JsonProperty]
		public long NozzleId { get; set; }

		/// <summary>
		/// 油品ID
		/// </summary>
		[JsonProperty]
		public long ProductId { get; set; }

		/// <summary>
		/// 实际支付金额
		/// </summary>
		[JsonProperty]
		public decimal? ActualPaymentAmount { get; set; }

		/// <summary>
		/// 授权时间
		/// </summary>
		[JsonProperty, Column(DbType = "timestamp", InsertValueSql = "0000-00-00 00:00:00")]
		public DateTime? AuthorizationTime { get; set; }

		[JsonProperty, Column(StringLength = 100)]
		public string CreateBy { get; set; }

		[JsonProperty, Column(DbType = "timestamp", InsertValueSql = "0000-00-00 00:00:00")]
		public DateTime CreateTime { get; set; }

		/// <summary>
		/// 挂枪时间
		/// </summary>
		[JsonProperty, Column(DbType = "timestamp", InsertValueSql = "CURRENT_TIMESTAMP")]
		public DateTime? FuelItemTransactionEndTime { get; set; }

		/// <summary>
		/// 是否删除
		/// </summary>
		[JsonProperty, Column(DbType = "tinyint(1)")]
		public sbyte? IsDeleted { get; set; } = 0;

		/// <summary>
		/// 订单状态
		/// </summary>
		[JsonProperty]
		public transactionsORDERSTATUS OrderStatus { get; set; }

		/// <summary>
		/// 订单类型
		/// </summary>
		[JsonProperty]
		public transactionsORDERTYPE OrderType { get; set; }

		/// <summary>
		/// 原金额
		/// </summary>
		[JsonProperty]
		public decimal? OriginalAmount { get; set; }

		/// <summary>
		/// 支付方式
		/// </summary>
		[JsonProperty]
		public long PaymentMethod { get; set; }

		/// <summary>
		/// 油品名称
		/// </summary>
		[JsonProperty, Column(StringLength = 100, IsNullable = false)]
		public string ProductName { get; set; }

		/// <summary>
		/// 原升数
		/// </summary>
		[JsonProperty]
		public decimal Qty { get; set; }
        /// <summary>
        /// 实际加油升数
        /// </summary>
        [JsonProperty]
        public decimal? OriginalQty { get; set; }

        /// <summary>
        /// 退款金额
        /// </summary>
        [JsonProperty]
		public decimal? RefundAmount { get; set; }

		/// <summary>
		/// 订单流水号
		/// </summary>
		[JsonProperty, Column(StringLength = 50, IsNullable = false)]
		public string TransactionNumber { get; set; }

		/// <summary>
		/// 交易时间
		/// </summary>
		[JsonProperty, Column(DbType = "timestamp", InsertValueSql = "0000-00-00 00:00:00")]
		public DateTime TransactionTime { get; set; }

        /// <summary>
        /// 加密字符串，用于验证金额是否篡改
        /// </summary>
        [JsonProperty, Column(StringLength = 255, IsNullable = false)]
        public string secret { get; set; }
        /// <summary>
        /// 支付返回结果
        /// </summary>
        [JsonProperty, Column(StringLength = 500, IsNullable = false)]
        public string RawResult { get; set; }
        /// <summary>
        /// 错误信息
        /// </summary>
        [JsonProperty, Column(StringLength = 500, IsNullable = false)]
        public string ErrorDetail { get; set; }
        /// <summary>
        /// 支付结果代码
        /// </summary>
        [JsonProperty, Column(StringLength = 20, IsNullable = false)]
        public string ResultCode { get; set; }
		/// <summary>
		/// 是否授权
		/// </summary>
		public AuthorizationStatus authorizationStatus { get; set; }
    }
    public enum AuthorizationStatus
    {
        /// <summary>
        /// 未授权
        /// </summary>
        Unauthorized,

        /// <summary>
        /// 授权
        /// </summary>
        Authorized
    }
    public enum transactionsORDERSTATUS
    {
        /// <summary>
        /// 订单未支付。
        /// </summary>
        Unpaid,

        /// <summary>
        /// 订单已支付。
        /// </summary>
        Paid,

        /// <summary>
        /// 订单正在支付中。
        /// </summary>
        //Paying,

        /// <summary>
        /// 订单全额退款。
        /// </summary>
        FullyRefunded,

        /// <summary>
        /// 订单部分退款。
        /// </summary>
        PartiallyRefunded,

        /// <summary>
        /// 订单通过卡支付。
        /// </summary>
        CardPayment
    }

    /// <summary>
    /// 表示交易订单的类型。
    /// </summary>
    public enum transactionsORDERTYPE
    {
        /// <summary>
        /// 预支付订单。
        /// </summary>
        Prepayment,

        /// <summary>
        /// 后支付订单。
        /// </summary>
        Postpayment
    }
}
