using System.ComponentModel.DataAnnotations.Schema; using YLErp.Commons; using YLErp.Helpers; namespace YLErp.DBModels { public class ClientCashICO : DBModelWithOperator,IDBModelWithCreator { /// /// 目前只有期权费和出入金会设置该字段为InValid /// [DisplayName("有效状态")] public string ValidState { get; set; } public int? TradeId { get; set; } [DisplayName("操作来源")] public string Action { get; set; } /// /// 出入金方向 /// [DisplayName("方向")] [DataChange] public string Direction { set; get; } = ""; /// /// 资金编号 /// [DisplayName("资金编号")] public string Number { set; get; } = ""; /// /// 客户信息 /// [DisplayName("客户名称")] public int? ClientId { set; get; } /// /// 客户编号 /// [DisplayName("客户编号")] public string ClientNumber { set; get; } = ""; /// /// 客户名称 /// [DisplayName("客户名称")] [DataChange] public string ClientName { set; get; } = ""; private double? _money; /// /// 出入金额 /// [DisplayName("出入金额")] [DataChange] public double? Money { set { _money = value.FormatValue(2); } get { return _money; } } /// /// 出入金时间 /// [DisplayName("发生时间")] [DataChange] public DateTime? HappenDate { set; get; } /// /// 状态 /// [DisplayName("状态")] public string State { set; get; } = ""; /// /// 开户行 /// [DisplayName("开户银行")] public string OpenBank { get; set; } /// /// 银行账号 /// [DisplayName("银行账号")] public int? OpenBankId { set; get; } /// /// 备注 /// [DisplayName("备注")] public string OpenBankComments { get; set; } /// /// 银行账号 /// [DisplayName("银行账号")] [DataChange] public string OpenBankCard { set; get; } = ""; [NotMapped] [DisplayName("金额")] public string MoneyStr { get { return Money?.ToString("###,##0.00"); } } [DisplayName("流水号")] public string SerialNumber { get; set; } /// /// 银行流水ID /// [DisplayName("银行流水ID")] public string BankFlowId { get; set; } [DisplayName("账户余额")] public double? AccountBalance { get; set; } [DisplayName("用途")] public string Uses { get; set; } /// /// 结算日 /// [DisplayName("结算日")] public DateTime? SettleDate { get; set; } /// /// 备注 /// [DisplayName("备注")] [DataChange] public string Comments { get; set; } /// /// 相关交易 /// [DisplayName("相关交易")] //[Obsolete("应该删除")] public string TradeNumber { get; set; } [NotMapped] public string TradeType { get; set; } /// /// 资金标识 /// public ClientCashFlag CashFlag { get; set; } /// /// trade_cash id /// public int TradeCashId { get; set; } /// /// 是否是组合交易 /// public int IsGroup { get; set; } /// /// 币种代码 /// [DisplayName("币种")] [DataChange] public string CurrencyCode { get; set; } /// /// 主交易编号 /// [DisplayName("主交易编号")] public string ParentTradeNumber { get; set; } /// /// 成交单号(电子盘数据库id) /// [DisplayName("成交单号")] public long Deal { get; set; } /// /// 审批进程 已拒绝-1,已确认-2 /// [DisplayName("审批进程")] public int ApprovalProcess { get; set; } /// /// 创建人ID /// [DisplayName("创建人")] public int? CreatorId { set; get; } /// /// 创建人名称 /// [DisplayName("创建人")] public string CreatorName { set; get; } /// /// 创建时间 /// [DisplayName("创建时间")] public DateTime? CreateDate { set; get; } /// /// 审批时间 /// public DateTime? ApprovalDate { get; set; } /// /// 资金类型初保账户/追保账户 /// [DisplayName("账户类型")] public string cash_type { get; set; } /// /// 转出科目 /// [DisplayName("转出科目")] [Column("transfer_out_account")] public string TransferOutAccount { get; set; } /// /// 转入科目 /// [DisplayName("转入科目")] [Column("transfer_in_account")] public string TransferInAccount { get; set; } } /// /// 出入金信息 /// [Table("ClientCashInCashOut")] public class ClientCashInCashOut : ClientCashICO { //每笔交易 应该只有一个应到账出入金 public const string 撤回 = "已撤回"; public const string 同意 = "已同意"; public const string 拒绝 = "拒绝"; public const string 未确认 = "未确认"; public const string 已确认 = "已确认"; public const string 已结算 = "已结算"; public const string 审批中 = "审批中"; public const string 修改待确认 = "修改待确认"; public static string 已到帐 = "已到帐"; public static string 应到帐 = "应到帐"; public static string 人工操作 = "人工操作"; public static string 应收 = "应收"; public static List 到账类型 = new List { 已到帐, 应到帐 }; public static List outCashCals = new List { 未确认, 同意, 已确认, 已结算 }; public static List calcCashs = new List { 未确认, 同意 }; public static List cashStateChecks = new List { "出金", "入金" }; public const string 系统操作_期权费 = "系统操作-期权费"; public const string 系统操作_行权费 = "系统操作-行权费"; public const string 系统操作_平仓费 = "系统操作-平仓费"; public const string 系统操作_票息 = "系统操作-票息"; public const string 系统操作_互换 = "系统操作-互换"; public const string 系统操作_应付预付金 = "系统操作-应付预付金"; public const string 系统操作_预付金返息 = "系统操作-预付金返息"; public const string 人工操作_其他 = "人工操作-其他"; public const string 人工操作_预付金 = "人工操作-预付金"; public const string 系统 = "系统"; /// /// all action /// public static List ACTION = new List { 系统操作_期权费, 系统操作_行权费, 系统操作_平仓费, 系统操作_票息 }; public static List OPTIONFEE_ACTION = new List { 系统操作_期权费 }; public static List PROFIT_ACTION = new List { 系统操作_行权费, 系统操作_平仓费, 系统操作_互换 }; public static List CompanyCashAction = new List { 人工操作_预付金 }; public static Dictionary CompanyCashActionKVs = new Dictionary { { "预付金",人工操作_预付金} }; /// /// 方向类型 /// [NotMapped] [DisplayName("方向类型")] public string DirectionType { get { if (Direction == "出金" || Direction == "入金" || Direction == "其他收入" || Direction == "其他支出" || Direction == "应收预付金" || Direction == "实收预付金" || Direction == "实付预付金" || Direction == "实收权利金" || Direction == "实付权利金" || Direction == "划转") { return Direction; } if (Direction == "应收") { var action = ""; if (Action == "系统操作-平仓费" || Action == "系统操作-行权费") { action = "平仓/行权"; } else if (Action == "系统操作-期权费") { action = "权利金"; } else if (Action == "系统操作-票息") { action = "票息"; } else if (Action == "系统操作-互换") { action = "互换"; } else if (Action == "系统操作-应付预付金") { action = "应付预付金"; } else if (Action == "系统操作-预付金返息") { action = "预付金返息"; } if (action != "") { return $"{ action}{(Money > 0 ? "收入" : "支出")}"; } } return ""; } } /// /// 交易员方向类型 /// [NotMapped] [DisplayName("方向类型")] public string TradeDirectionType { get { if (Direction == "其他收入") { return "其他支出"; } else if (Direction == "其他支出") { return "其他收入"; } else if (Direction == "应收") { var action = ""; if (Action == "系统操作-平仓费" || Action == "系统操作-行权费") { action = "平仓/行权"; } else if (Action == "系统操作-期权费") { action = "权利金"; } else if (Action == "系统操作-票息") { action = "票息"; } else if (Action == "系统操作-互换") { action = "互换"; } else if (Action == "系统操作-应付预付金") { action = "应付预付金"; } else if (Action == "系统操作-预付金返息") { action = "预付金返息"; } if (action != "") { return $"{ action}{(Money > 0 ? "支出" : "收入")}"; } } return ""; } } [NotMapped] public bool CanGenerateExit => PS.Config.IsExportEntryexit && Direction == "出金" && new List { 已确认, 已结算 }.Contains(State); /// /// 修改说明 /// [NotMapped] [DisplayName("说明")] public string Explain { get; set; } public ClientCashInCashOut Clone() { return (ClientCashInCashOut)MemberwiseClone(); } } /// /// 客户资金标识(小于100为入金,大于100为出金) /// public enum ClientCashFlag : byte { None = 0, /// /// 调入 /// TransferIn = 21, /// /// 调出 /// TransferOut = 121, } [NotMapped] public class ClientCashInCashOutDto : ClientCashInCashOut { } }