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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询客户账户信息
    /// 通过证件信息查询该客户所有账户
    /// </summary>
    public class QueryAccountInfoByCustomer : TFOutput
    {
        #region Output
        /// <summary>
        /// 账户信息
        /// 账/卡号|账号ID|户名|介质代码|介质名称|产品代码|产品名称|凭证号码|介质状态|支取方式|开户机构|启用日期|
        /// </summary>
        public string ZHXX { get; internal set; }

        /// <summary>
        /// 账户信息
        /// 账/卡号|账号ID|户名|介质代码|介质名称|产品代码|产品名称|凭证号码|介质状态|支取方式|开户机构|启用日期|
        /// </summary>
        public List<E_ZHXX> ZHXXData { get; internal set; }

        /// <summary>
        /// 账户信息
        /// 账/卡号|账号ID|户名|介质代码|介质名称|产品代码|产品名称|凭证号码|介质状态|支取方式|开户机构|启用日期|
        /// </summary>
        public class E_ZHXX
        {
            /// <summary>
            /// 账/卡号
            /// </summary>
            public string ZKH { get; set; }

            /// <summary>
            /// 账号ID
            /// </summary>
            public string ZHID { get; set; }

            /// <summary>
            /// 户名
            /// </summary>
            public string HM { get; set; }

            /// <summary>
            /// 介质代码
            /// </summary>
            public string JZDM { get; set; }

            /// <summary>
            /// 介质名称
            /// </summary>
            public string JZMC { get; set; }

            /// <summary>
            /// 产品代码
            /// </summary>
            public string CPDM { get; set; }

            /// <summary>
            /// 产品名称
            /// </summary>
            public string CPMC { get; set; }

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

            /// <summary>
            /// 介质状态
            /// </summary>
            public string JZZT { get; set; }

            /// <summary>
            /// 支取方式
            /// </summary>
            public string ZQFS { get; set; }

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

            /// <summary>
            /// 启用日期
            /// </summary>
            public string QYRQ { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 户名 0250
            ///  
            /// </summary>
            public string HM { get; set; }

            /// <summary>
            /// 证件号码 102A
            ///  
            /// </summary>
            public string ZJHM { get; set; }

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

            /// <summary>
            /// 查询标志 0670
            /// 1-不包含无单折、对公一户通（用于介质相关的交易) 
            /// </summary>
            public string CXBZ { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryAccountInfoByCustomer();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd25 = HM;
                MessageData.Fd102_A = ZJHM;
                MessageData.Fd102_G = ZJLX;
                MessageData.Fd128 = "0009";
                MessageData.Fd67 = CXBZ;

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.ZHXXData = AnilyzeFileData<E_ZHXX>(MessageData.FileData,
                                            "账/卡号|户名|介质代码|介质名称|产品代码|产品名称|凭证号码|介质状态|支取方式|开户机构|开户日期|",
                                            x =>
                                            {
                                                return new E_ZHXX
                                                {
                                                    ZKH = x["账/卡号"],
                                                    HM = x["户名"],
                                                    JZDM = x["介质代码"],
                                                    JZMC = x["介质名称"],
                                                    CPDM = x["产品代码"],
                                                    CPMC = x["产品名称"],
                                                    PZHM = x["凭证号码"],
                                                    JZZT = x["介质状态"],
                                                    ZQFS = x["支取方式"],
                                                    KHJG = x["开户机构"],
                                                    QYRQ = x["开户日期"]
                                                };
                                            });
                output.ZHXX = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
