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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 客户存款量查询
    /// 根据证件类型证件号码查询客户存款量
    /// </summary>
    public class QueryKHCKL : 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 KHH { get; set; }

            /// <summary>
            /// 产品信息
            /// </summary>
            public string CPXX { get; set; }

            /// <summary>
            /// 产品累计额
            /// </summary>
            public string CPLJE { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 证件号码 0620
            ///  
            /// </summary>
            public string ZJHM { get; set; }

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

            /// <summary>
            /// 查询方式 0670
            /// 1.按产品查询2.按定活期查询 
            /// </summary>
            public string CXFS { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryKHCKL();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd62 = ZJHM;
                MessageData.Fd66 = ZJLX;
                MessageData.Fd67 = CXFS;
                MessageData.Fd128 = "0106";

                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
                                                {
                                                    KHH = x["客户号"],
                                                    CPXX = x["产品信息"],
                                                    CPLJE = x["产品累计额"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
