using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using TellerSystem.ServiceProxy.Ext.ServiceHelper;

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询子账户信息
    /// 通过账号查询子账户信息列表
    /// </summary>
    public class QueryChildAccountList : TFOutput
    {
        #region Output
        /// <summary>
        /// 子账户信息
        /// 账户序号|账户名称|开户日期|产品名称|账户余额|账户状态|冻结状态|止付状态|账户名称
        /// </summary>
        public string ZZHXX { get; internal set; }

        /// <summary>
        /// 子账户信息
        /// 账户序号|账户名称|开户日期|产品名称|账户余额|账户状态|冻结状态|止付状态|
        /// </summary>
        public List<E_ZZHXX> ZZHXXData { get; internal set; }

        /// <summary>
        /// 子账户信息
        /// 账户序号|开户日期|产品名称|账户余额|账户状态|冻结状态|止付状态|
        /// </summary>
        public class E_ZZHXX
        {
            /// <summary>
            /// 账户序号
            /// </summary>
            public string ZHXH { get; set; }

            /// <summary>
            /// 账户名称
            /// </summary>
            public string ZHMC { 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; }

            /// <summary>
            /// 冻结状态
            /// </summary>
            public string DJZT { get; set; }

            /// <summary>
            /// 止付状态
            /// </summary>
            public string ZFZT { get; set; }

        }

        #endregion

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

            /// <summary>
            /// 账号类型 0670
            /// 1:只查询活期  2:只查询定期 空值返回所有活期、定期子账户 
            /// </summary>
            public string ZHLX { get; set; }

            /// <summary>
            /// 续存标志 0680
            /// Y:可以  N:不可以 空值:不可以 
            /// </summary>
            public string XCBZ { get; set; }

            /// <summary>
            /// 账户状态标志 0690
            /// 1:不返回已销户账户  空值:返回所有账户 
            /// </summary>
            public string ZHZTBZ { get; set; }

            /// <summary>
            /// 附卡查定期
            ///空值不可以查
            /// </summary>
            public string FKCDQ { get; set; }

            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryChildAccountList();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd38 = ZH;
                MessageData.Fd128 = "0014";
                MessageData.Fd67 = ZHLX;
                MessageData.Fd68 = XCBZ;
                MessageData.Fd69 = ZHZTBZ;
                MessageData.Fd70 = FKCDQ;   

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.ZZHXXData = AnilyzeFileData<E_ZZHXX>(MessageData.FileData,
                                            "账户序号|账户名称|开户日期|产品名称|账户余额|账户状态|冻结状态|止付状态|",
                                            x =>
                                            {
                                                return new E_ZZHXX
                                                {
                                                    ZHXH = x["账户序号"],
                                                    ZHMC = x["账户名称"],
                                                    KHRQ = x["开户日期"],
                                                    CPMC = x["产品名称"],
                                                    ZHYE = x["账户余额"],
                                                    ZHZT = x["账户状态"],
                                                    DJZT = x["冻结状态"],
                                                    ZFZT = x["止付状态"]
                                                };
                                            });
                output.ZZHXX = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
