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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 机构信用代码证查询(文件)
    /// 通过账号或机构信用代码证查询账户信息
    /// </summary>
    public class QueryJGXYDMZ : 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 ZH { get; set; }

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

            /// <summary>
            /// 客户名称
            /// </summary>
            public string KHMC { get; set; }

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

            /// <summary>
            /// 凭证类型
            /// </summary>
            public string PZLX { get; set; }

            /// <summary>
            /// 凭证号
            /// </summary>
            public string PZH { get; set; }

            /// <summary>
            /// 证件类型
            /// </summary>
            public string ZJLX { get; set; }

            /// <summary>
            /// 证件号
            /// </summary>
            public string ZJH { get; set; }

        }

        #endregion

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

            /// <summary>
            /// 机构信用代码证号码 0620
            ///  
            /// </summary>
            public string DMZH { get; set; }

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

            /// <summary>
            /// 开户机构 0910
            ///  
            /// </summary>
            public string KHJG { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryJGXYDMZ();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd30 = ZH;
                MessageData.Fd62 = DMZH;
                MessageData.Fd67 = ZHZT;
                MessageData.Fd91 = KHJG;
                MessageData.Fd128 = "0094";

                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
                                                {
                                                    ZH = x["账号"],
                                                    ZHXH = x["账户序号"],
                                                    KHMC = x["客户名称"],
                                                    ZHZT = x["账户状态"],
                                                    PZLX = x["凭证类型"],
                                                    PZH = x["凭证号"],
                                                    ZJLX = x["证件类型"],
                                                    ZJH = x["证件号"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
