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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询贷款信息
    /// 根据贷款账号返回相关信息
    /// </summary>
    public class QueryLoanInfo : TFOutput
    {
        #region Output
        /// <summary>
        /// 贷款信息列表
        /// 后台返回文件，内容包括：还款账号|账户序号|还款类型|
        /// </summary>
        public string DKXXLB { get; internal set; }

        /// <summary>
        /// 贷款信息列表
        /// 后台返回文件，内容包括：还款账号|账户序号|还款类型|
        /// </summary>
        public List<E_DKXXLB> DKXXLBData { get; internal set; }

        /// <summary>
        /// 贷款信息列表
        /// 后台返回文件，内容包括：还款账号|账户序号|还款类型|
        /// </summary>
        public class E_DKXXLB
        {
            /// <summary>
            /// 还款账号
            /// </summary>
            public string HKZH { get; set; }

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

            /// <summary>
            /// 还款类型
            /// </summary>
            public string HKLX { get; set; }

        }

        #endregion

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


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

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.DKXXLBData = AnilyzeFileData<E_DKXXLB>(MessageData.FileData,
                                            "还款账号|账户序号|还款类型|",
                                            x =>
                                            {
                                                return new E_DKXXLB
                                                {
                                                    HKZH = x["还款账号"],
                                                    ZHXH = x["账户序号"],
                                                    HKLX = x["还款类型"]
                                                };
                                            });
                output.DKXXLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
