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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询转开对公定期账户
    /// 查询指定账号转开的定期账户列表
    /// </summary>
    public class QueryEnterprisePeriodicalAccount : 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 ZHXH { get; set; }

            /// <summary>
            /// 开户日期
            /// </summary>
            public string KHRQ { get; set; }

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

            /// <summary>
            /// 账户余额
            /// </summary>
            public string ZHYE { get; set; }

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

        }

        #endregion

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


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryEnterprisePeriodicalAccount();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd38 = ZH;
                MessageData.Fd128 = "0068";

                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
                                                {
                                                    ZHXH = x["账户序号"],
                                                    KHRQ = x["开户日期"],
                                                    CPMC = x["产品名称"],
                                                    ZHYE = x["账户余额"],
                                                    ZHZT = x["账户状态"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
