using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.Serialization.Json;
using System.IO;
using Platform.Common.RunningParameters;

namespace TellerSystem.Contract.Function
{
    public class AuthConditionElement
    {
        private Dictionary<string, string> parames;

        public AuthConditionElement()
        {
            this.parames = new Dictionary<string, string>();
        }

        /// <summary>
        /// 交易代码  前端的交易码
        /// </summary>
        public string Txcode
        {
            set
            {
                this.AddElement("Txcode", value);
            }
        }

        /// <summary>
        /// 转账/现金标志
        /// 值 ：1：转账；2：现金
        /// </summary>
        public string CTSigns
        {
            set
            {
                this.AddElement("CTSigns", value.ToString());
            }
        }

        /// <summary>
        /// 借方账户类型（对公、对私、内部）
        /// 值 ：1：对公；2：对私；3：内部
        /// </summary>
        public string DeAccountType
        {
            set
            {
                this.AddElement("DeAccountType", value.ToString());
            }
        }

        /// <summary>
        /// 贷方账户类型（对公、对私、内部）
        /// 值 ：1：对公；2：对私；3：内部
        /// </summary>
        public string CrAccountType
        {
            set
            {
                this.AddElement("CrAccountType", value.ToString());
            }
        }

        /// <summary>
        /// 借方账户属性（基本户、一般户、专用户、临时户）
        /// 值 ：1：基本户；2：一般户；3：专用户；4：临时户
        /// </summary>
        public string DeAccountPro
        {
            set
            {
                this.AddElement("DeAccountPro", value.ToString());
            }
        }

        /// <summary>
        /// 贷方账户属性（基本户、一般户、专用户、临时户）
        /// 值 ：1：基本户；2：一般户；3：专用户；4：临时户
        /// </summary>
        public string CrAccountPro
        {
            set
            {
                this.AddElement("CrAccountPro", value.ToString());
            }
        }

        /// <summary>
        /// 借方是否是本行账号
        /// 值 ：true：是；false：否
        /// </summary>
        public string DeIsOwn
        {
            set
            {
                this.AddElement("DeIsOwn", value.ToString());
            }
        }

        /// <summary>
        /// 贷方是否是本行账号
        /// 值 ：true：是；false：否
        /// </summary>
        public string CrIsOwn
        {
            set
            {
                this.AddElement("CrIsOwn", value.ToString());
            }
        }


        /// <summary>
        /// 借记方和贷记方是否是同一客户
        /// 值 ：true：是；false：否
        /// </summary>
        public string DCIsSameCus
        {
            set
            {
                this.AddElement("DCIsSameCus", value.ToString());
            }
        }

        /// <summary>
        /// 单笔金额
        /// </summary>
        public string SinAmt
        {
            set
            {
                this.AddElement("SinAmt", value.ToString());
            }
        }
        /// <summary>
        /// 当日借方累计金额
        /// </summary>
        public string SumAddAmt
        {
            set
            {
                this.AddElement("SumAddAmt", value.ToString());
            }
        }


        /// <summary>
        /// 当日借方现金累计金额
        /// </summary>
        public string DeCaAddAmt
        {
            set
            {
                this.AddElement("DeCaAddAmt", value.ToString());
            }
        }
        /// <summary>
        /// 当日贷方现金累计金额
        /// </summary>
        public string CrTrAddAmt
        {
            set
            {
                this.AddElement("CrTrAddAmt", value.ToString());
            }
        }

        /// <summary>
        /// 当日借方转账累计金额
        /// </summary>
        public string DeTrAddAmt
        {
            set
            {
                this.AddElement("DeTrAddAmt", value.ToString());
            }
        }

        /// <summary>
        /// 挂失标志
        /// 值 ：true：是；false：否
        /// </summary>
        public string LossMarked
        {
            set
            {
                this.AddElement("LossMarked", value.ToString());
            }
        }

        /// <summary>
        /// 凭证种类
        /// </summary>
        public string DocumentType
        {
            set
            {
                this.AddElement("DocumentType", value.ToString());
            }
        }

        /// <summary>
        /// 扣划标志
        /// </summary>
        public string DeductMarked
        {
            set
            {
                this.AddElement("DeductMarked", value.ToString());
            }
        }

        /// <summary>
        /// 长短款标志
        /// 值 ：true：是；false：否
        /// </summary>
        public string LongOrShort
        {
            set
            {
                this.AddElement("LongOrShort", value.ToString());
            }
        }

        /// <summary>
        /// 止付类型
        /// </summary>
        public string UnPayType
        {
            set
            {
                this.AddElement("UnPayType", value.ToString());
            }
        }

        /// <summary>
        /// 是否调整积数
        /// 值 ：true：是；false：否
        /// </summary>
        public string IsChangeBase
        {
            set
            {
                this.AddElement("IsChangeBase", value.ToString());
            }
        }

        /// <summary>
        ///账户状态，一般“1”表示挂失未到期
        /// </summary>
        public string AccountState
        {
            set
            {
                this.AddElement("AccountState", value.ToString());
            }
        }
        /// <summary>
        /// 操作类型
        /// </summary>
        public string OperationType
        {
            set
            {
                this.AddElement("OperationType", value.ToString());
            }
        }
        /// <summary>
        /// 法人类型
        /// </summary>
        public string LegalPerson
        {
            set
            {
                this.AddElement("LegalPerson", value.ToString());
            }
        }



        /// <summary>
        /// 设置其他未命名要素
        /// </summary>
        /// <param name="tag"></param>
        /// <param name="value"></param>
        private void AddElement(string tag, string value)
        {
            if (parames.ContainsKey(tag))
            {
                parames[tag] = value;
            }
            else
            {
                parames.Add(tag, value);
            }
        }
        /// <summary>
        /// 获得所有要素集合
        /// </summary>
        public string JsonValue
        {
            get
            {
                return SerialazeJson();
            }
        }
        private string SerialazeJson()
        {
            DataContractJsonSerializer js = new DataContractJsonSerializer(typeof(Dictionary<string, string>));
            string result = string.Empty;
            using (MemoryStream tmp = new MemoryStream())
            {
                js.WriteObject(tmp, parames);
                result = PlatformSettings.Encoding.GetString(tmp.ToArray()); ;
            }
            return result;
        }
    }
}