Files
zszq-trs/Framework/YLErp.Core/DBModels/ClientCashInCashOut.cs
T

437 lines
14 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.ComponentModel.DataAnnotations.Schema;
using YLErp.Commons;
using YLErp.Helpers;
namespace YLErp.DBModels
{
public class ClientCashICO : DBModelWithOperator,IDBModelWithCreator
{
/// <summary>
/// 目前只有期权费和出入金会设置该字段为InValid
/// </summary>
[DisplayName("有效状态")]
public string ValidState { get; set; }
public int? TradeId { get; set; }
[DisplayName("操作来源")]
public string Action { get; set; }
/// <summary>
/// 出入金方向
/// </summary>
[DisplayName("方向")]
[DataChange]
public string Direction { set; get; } = "";
/// <summary>
/// 资金编号
/// </summary>
[DisplayName("资金编号")]
public string Number { set; get; } = "";
/// <summary>
/// 客户信息
/// </summary>
[DisplayName("客户名称")]
public int? ClientId { set; get; }
/// <summary>
/// 客户编号
/// </summary>
[DisplayName("客户编号")]
public string ClientNumber { set; get; } = "";
/// <summary>
/// 客户名称
/// </summary>
[DisplayName("客户名称")]
[DataChange]
public string ClientName { set; get; } = "";
private double? _money;
/// <summary>
/// 出入金额
/// </summary>
[DisplayName("出入金额")]
[DataChange]
public double? Money
{
set { _money = value.FormatValue(2); }
get { return _money; }
}
/// <summary>
/// 出入金时间
/// </summary>
[DisplayName("发生时间")]
[DataChange]
public DateTime? HappenDate { set; get; }
/// <summary>
/// 状态
/// </summary>
[DisplayName("状态")]
public string State { set; get; } = "";
/// <summary>
/// 开户行
/// </summary>
[DisplayName("开户银行")]
public string OpenBank { get; set; }
/// <summary>
/// 银行账号
/// </summary>
[DisplayName("银行账号")]
public int? OpenBankId { set; get; }
/// <summary>
/// 备注
/// </summary>
[DisplayName("备注")]
public string OpenBankComments { get; set; }
/// <summary>
/// 银行账号
/// </summary>
[DisplayName("银行账号")]
[DataChange]
public string OpenBankCard { set; get; } = "";
[NotMapped]
[DisplayName("金额")]
public string MoneyStr
{
get { return Money?.ToString("###,##0.00"); }
}
[DisplayName("流水号")]
public string SerialNumber { get; set; }
/// <summary>
/// 银行流水ID
/// </summary>
[DisplayName("银行流水ID")]
public string BankFlowId { get; set; }
[DisplayName("账户余额")]
public double? AccountBalance { get; set; }
[DisplayName("用途")]
public string Uses { get; set; }
/// <summary>
/// 结算日
/// </summary>
[DisplayName("结算日")]
public DateTime? SettleDate { get; set; }
/// <summary>
/// 备注
/// </summary>
[DisplayName("备注")]
[DataChange]
public string Comments { get; set; }
/// <summary>
/// 相关交易
/// </summary>
[DisplayName("相关交易")]
//[Obsolete("应该删除")]
public string TradeNumber { get; set; }
[NotMapped]
public string TradeType { get; set; }
/// <summary>
/// 资金标识
/// </summary>
public ClientCashFlag CashFlag { get; set; }
/// <summary>
/// trade_cash id
/// </summary>
public int TradeCashId { get; set; }
/// <summary>
/// 是否是组合交易
/// </summary>
public int IsGroup { get; set; }
/// <summary>
/// 币种代码
/// </summary>
[DisplayName("币种")]
[DataChange]
public string CurrencyCode { get; set; }
/// <summary>
/// 主交易编号
/// </summary>
[DisplayName("主交易编号")]
public string ParentTradeNumber { get; set; }
/// <summary>
/// 成交单号(电子盘数据库id)
/// </summary>
[DisplayName("成交单号")]
public long Deal { get; set; }
/// <summary>
/// 审批进程 已拒绝-1,已确认-2
/// </summary>
[DisplayName("审批进程")]
public int ApprovalProcess { get; set; }
/// <summary>
/// 创建人ID
/// </summary>
[DisplayName("创建人")]
public int? CreatorId { set; get; }
/// <summary>
/// 创建人名称
/// </summary>
[DisplayName("创建人")]
public string CreatorName { set; get; }
/// <summary>
/// 创建时间
/// </summary>
[DisplayName("创建时间")]
public DateTime? CreateDate { set; get; }
/// <summary>
/// 审批时间
/// </summary>
public DateTime? ApprovalDate { get; set; }
/// <summary>
/// 资金类型初保账户/追保账户
/// </summary>
[DisplayName("账户类型")]
public string cash_type { get; set; }
/// <summary>
/// 转出科目
/// </summary>
[DisplayName("转出科目")]
[Column("transfer_out_account")]
public string TransferOutAccount { get; set; }
/// <summary>
/// 转入科目
/// </summary>
[DisplayName("转入科目")]
[Column("transfer_in_account")]
public string TransferInAccount { get; set; }
}
/// <summary>
/// 出入金信息
/// </summary>
[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<string> 到账类型 = new List<string> { 已到帐, 应到帐 };
public static List<string> outCashCals = new List<string> { 未确认, 同意, 已确认, 已结算 };
public static List<string> calcCashs = new List<string> { 未确认, 同意 };
public static List<string> cashStateChecks = new List<string> { "出金", "入金" };
public const string 系统操作_期权费 = "系统操作-期权费";
public const string 系统操作_行权费 = "系统操作-行权费";
public const string 系统操作_平仓费 = "系统操作-平仓费";
public const string 系统操作_票息 = "系统操作-票息";
public const string 系统操作_互换 = "系统操作-互换";
public const string 系统操作_应付预付金 = "系统操作-应付预付金";
public const string 系统操作_预付金返息 = "系统操作-预付金返息";
/// <summary>
/// 阶段四 §4.1 合约维度(MarginWatchRule==0EOD 结算产生的追加保证金资金记录:
/// 交易级单条累计值(TradeId+Action+Deal=0 幂等 upsert),负数=客户应付追加;写入见 SwapAdditionalMarginService。
/// </summary>
public const string 系统操作_追加保证金 = "系统操作-追加保证金";
public const string 人工操作_其他 = "人工操作-其他";
public const string 人工操作_预付金 = "人工操作-预付金";
public const string 系统 = "系统";
/// <summary>
/// all action
/// </summary>
public static List<string> ACTION = new List<string> { 系统操作_期权费, 系统操作_行权费, 系统操作_平仓费, 系统操作_票息 };
public static List<string> OPTIONFEE_ACTION = new List<string> { 系统操作_期权费 };
public static List<string> PROFIT_ACTION = new List<string> { 系统操作_行权费, 系统操作_平仓费, 系统操作_互换 };
public static List<string> CompanyCashAction = new List<string> { 人工操作_预付金 };
public static Dictionary<string, string> CompanyCashActionKVs = new Dictionary<string, string>
{
{ "预付金",人工操作_预付金}
};
/// <summary>
/// 方向类型
/// </summary>
[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 = "预付金返息";
}
else if (Action == "系统操作-追加保证金")
{
action = "追加保证金";
}
if (action != "")
{
return $"{ action}{(Money > 0 ? "收入" : "支出")}";
}
}
return "";
}
}
/// <summary>
/// 交易员方向类型
/// </summary>
[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 = "预付金返息";
}
else if (Action == "系统操作-追加保证金")
{
action = "追加保证金";
}
if (action != "")
{
return $"{ action}{(Money > 0 ? "支出" : "收入")}";
}
}
return "";
}
}
[NotMapped]
public bool CanGenerateExit => PS.Config.IsExportEntryexit && Direction == "出金" && new List<string> { 已确认, 已结算 }.Contains(State);
/// <summary>
/// 修改说明
/// </summary>
[NotMapped]
[DisplayName("说明")]
public string Explain { get; set; }
public ClientCashInCashOut Clone()
{
return (ClientCashInCashOut)MemberwiseClone();
}
}
/// <summary>
/// 客户资金标识(小于100为入金,大于100为出金)
/// </summary>
public enum ClientCashFlag : byte
{
None = 0,
/// <summary>
/// 调入
/// </summary>
TransferIn = 21,
/// <summary>
/// 调出
/// </summary>
TransferOut = 121,
}
[NotMapped]
public class ClientCashInCashOutDto : ClientCashInCashOut
{
}
}