using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询卡折一体信息(文件)
    /// 通过卡号或存折号查询详细信息
    /// </summary>
    public class QueryKZYTXX : TFOutput
    {
        #region Output
        /// <summary>
        /// 文件
        /// 卡号|账户序号|姓名|余额|账户状态|存折账号|账户序号|名称|余额|账户状态|
        /// </summary>
        public string WJ { get; internal set; }

        /// <summary>
        /// 文件
        /// 卡号|账户序号|姓名|余额|账户状态|存折账号|账户序号|名称|余额|账户状态|
        /// </summary>
        public List<E_WJ> WJData { get; internal set; }

        /// <summary>
        /// 文件
        /// 卡号|账户序号|姓名|余额|账户状态|存折账号|账户序号|名称|余额|账户状态|
        /// </summary>
        public class E_WJ
        {
            /// <summary>
            /// 卡号
            /// </summary>
            public string KH { get; set; }

            /// <summary>
            /// 账户序号
            /// </summary>
            public string ZHXH { get; set; }

            /// <summary>
            /// 姓名
            /// </summary>
            public string XM { get; set; }

            /// <summary>
            /// 余额
            /// </summary>
            public string YE { get; set; }

            /// <summary>
            /// 账户状态
            /// </summary>
            public string ZHZT { get; set; }

            /// <summary>
            /// 存折账号
            /// </summary>
            public string CZZH { get; set; }

            /// <summary>
            /// 账户序号
            /// </summary>
            public string ZHXH_1 { get; set; }

            /// <summary>
            /// 名称
            /// </summary>
            public string MC { get; set; }

            /// <summary>
            /// 余额
            /// </summary>
            public string YE_1 { get; set; }

            /// <summary>
            /// 账户状态
            /// </summary>
            public string ZHZT_1 { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 卡号 0300
            ///  
            /// </summary>
            public string KH { get; set; }

            /// <summary>
            /// 卡折账号 0310
            ///  
            /// </summary>
            public string KZZH { get; set; }

            /// <summary>
            /// 账户状态 0670
            /// 1正常0开户待确认3挂失结清4开户更正5临时销户*销户#计息结束6久悬 
            /// </summary>
            public string ZHZT { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryKZYTXX();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd30 = KH;
                MessageData.Fd31 = KZZH;
                MessageData.Fd128 = "0093";
                MessageData.Fd67 = ZHZT;

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.WJData = AnilyzeFileData<E_WJ>(MessageData.FileData,
                                            "卡号|账户序号|姓名|余额|账户状态|存折账号|账户序号|名称|余额|账户状态|",
                                            x =>
                                            {
                                                return new E_WJ
                                                {
                                                    KH = x["卡号"],
                                                    ZHXH = x["账户序号"],
                                                    XM = x["姓名"],
                                                    YE = x["余额"],
                                                    ZHZT = x["账户状态"],
                                                    CZZH = x["存折账号"],
                                                    ZHXH_1 = x["账户序号"],
                                                    MC = x["名称"],
                                                    YE_1 = x["余额"],
                                                    ZHZT_1 = x["账户状态"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
