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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询按揭欠款表
    /// 根据贷款账号返回按揭贷款欠款信息
    /// </summary>
    public class QueryLoanArrearList : TFOutput
    {
        #region Output
        /// <summary>
        /// 欠款信息列表
        /// 后台返回文件，内容包括：欠款期次|欠本金|欠利息|欠罚息|还本金|还利息|还罚息|还款日期|本期本金|本期利息|
        /// </summary>
        public string QKXXLB { get; internal set; }

        /// <summary>
        /// 欠款信息列表
        /// 后台返回文件，内容包括：欠款期次|欠本金|欠利息|欠罚息|还本金|还利息|还罚息|还款日期|本期本金|本期利息|
        /// </summary>
        public List<E_QKXXLB> QKXXLBData { get; internal set; }

        /// <summary>
        /// 欠款信息列表
        /// 后台返回文件，内容包括：欠款期次|欠本金|欠利息|欠罚息|还本金|还利息|还罚息|还款日期|本期本金|本期利息|
        /// </summary>
        public class E_QKXXLB
        {
            /// <summary>
            /// 欠款期次
            /// </summary>
            public string QKQC { get; set; }

            /// <summary>
            /// 欠本金
            /// </summary>
            public string QBJ { get; set; }

            /// <summary>
            /// 欠利息
            /// </summary>
            public string QLX { get; set; }

            /// <summary>
            /// 欠罚息
            /// </summary>
            public string QFX { get; set; }

            /// <summary>
            /// 还本金
            /// </summary>
            public string HBJ { get; set; }

            /// <summary>
            /// 还利息
            /// </summary>
            public string HLX { get; set; }

            /// <summary>
            /// 还罚息
            /// </summary>
            public string HFX { get; set; }

            /// <summary>
            /// 还款日期
            /// </summary>
            public string HKRQ { get; set; }

            /// <summary>
            /// 本期本金
            /// </summary>
            public string BQBJ { get; set; }

            /// <summary>
            /// 本期利息
            /// </summary>
            public string BQLX { 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 QueryLoanArrearList();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd30 = DKZH;
                MessageData.Fd128 = "0030";

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.QKXXLBData = AnilyzeFileData<E_QKXXLB>(MessageData.FileData,
                                            "欠款期次|欠本金|欠利息|欠罚息|还本金|还利息|还罚息|还款日期|本期本金|本期利息|",
                                            x =>
                                            {
                                                return new E_QKXXLB
                                                {
                                                    QKQC = x["欠款期次"],
                                                    QBJ = x["欠本金"],
                                                    QLX = x["欠利息"],
                                                    QFX = x["欠罚息"],
                                                    HBJ = x["还本金"],
                                                    HLX = x["还利息"],
                                                    HFX = x["还罚息"],
                                                    HKRQ = x["还款日期"],
                                                    BQBJ = x["本期本金"],
                                                    BQLX = x["本期利息"]
                                                };
                                            });
                output.QKXXLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
