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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询还款账号信息表
    /// 根据贷款账号返回还款账号信息
    /// </summary>
    public class QueryRevertLoanAccount : TFOutput
    {
        #region Output
        /// <summary>
        /// 还款信息列表
        /// 后台返回文件，内容包括：还款账号|户名|账户序号|状态|签约日期|解约日期|
        /// </summary>
        public string HKXXLB { get; internal set; }

        /// <summary>
        /// 还款信息列表
        /// 后台返回文件，内容包括：还款账号|户名|账户序号|状态|签约日期|解约日期|
        /// </summary>
        public List<E_HKXXLB> HKXXLBData { get; internal set; }

        /// <summary>
        /// 还款信息列表
        /// 后台返回文件，内容包括：还款账号|户名|账户序号|状态|签约日期|解约日期|
        /// </summary>
        public class E_HKXXLB
        {
            /// <summary>
            /// 还款账号
            /// </summary>
            public string HKZH { get; set; }

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

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

            /// <summary>
            /// 状态
            /// </summary>
            public string ZT { get; set; }

            /// <summary>
            /// 签约日期
            /// </summary>
            public string QYRQ { get; set; }

            /// <summary>
            /// 解约日期
            /// </summary>
            public string JYRQ { get; set; }

        }

        #endregion

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

            /// <summary>
            /// 查询类型 0670
            /// 1-还本账号 2-还息账号 
            /// </summary>
            public string CXLX { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryRevertLoanAccount();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd30 = DKZH;
                MessageData.Fd128 = "0031";
                MessageData.Fd67 = CXLX;

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.HKXXLBData = AnilyzeFileData<E_HKXXLB>(MessageData.FileData,
                                            "还款账号|户名|账户序号|状态|签约日期|解约日期|",
                                            x =>
                                            {
                                                return new E_HKXXLB
                                                {
                                                    HKZH = x["还款账号"],
                                                    HM = x["户名"],
                                                    ZHXH = x["账户序号"],
                                                    ZT = x["状态"],
                                                    QYRQ = x["签约日期"],
                                                    JYRQ = x["解约日期"]
                                                };
                                            });
                output.HKXXLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
