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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询主子卡信息(文件)
    /// 通过主卡号或子卡号查询单位IC详细信息
    /// </summary>
    public class QueryZZKXX : 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 ZKZH { 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 ZKZH_1 { 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 ZKZH { get; set; }

            /// <summary>
            /// 子卡账号 0310
            ///  
            /// </summary>
            public string CKZH { 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 QueryZZKXX();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd30 = ZKZH;
                MessageData.Fd31 = CKZH;
                MessageData.Fd128 = "0092";
                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
                                                {
                                                    ZKZH = x["主卡账号"],
                                                    ZHXH = x["账户序号"],
                                                    XM = x["姓名"],
                                                    YE = x["余额"],
                                                    ZHZT = x["账户状态"],
                                                    ZKZH_1 = x["子卡账号"],
                                                    ZHXH_1 = x["账户序号"],
                                                    MC = x["名称"],
                                                    YE_1 = x["余额"],
                                                    ZHZT_1 = x["账户状态"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
