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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 利率查询(前台首页)
    /// 查询存贷款产品对应的利率值
    /// </summary>
    public class QueryRateList : TFOutput
    {
        #region Output
        /// <summary>
        /// 利率列表
        /// 产品名称|利率值|利率单位|
        /// </summary>
        public string LLLB { get; internal set; }

        /// <summary>
        /// 利率列表
        /// 产品名称|利率值|利率单位|
        /// </summary>
        public List<E_LLLB> LLLBData { get; internal set; }

        /// <summary>
        /// 利率列表
        /// 产品名称|利率值|利率单位|
        /// </summary>
        public class E_LLLB
        {
            /// <summary>
            /// 产品名称
            /// </summary>
            public string CPMC { get; set; }

            /// <summary>
            /// 利率值
            /// </summary>
            public string LLZ { get; set; }

            /// <summary>
            /// 利率单位
            /// </summary>
            public string LLDW { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 查询类型 0700
            ///  
            /// </summary>
            public string CXLX { get; set; }


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

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.LLLBData = AnilyzeFileData<E_LLLB>(MessageData.FileData,
                                            "产品名称|利率值|利率单位|",
                                            x =>
                                            {
                                                return new E_LLLB
                                                {
                                                    CPMC = x["产品名称"],
                                                    LLZ = x["利率值"],
                                                    LLDW = x["利率单位"]
                                                };
                                            });
                output.LLLB = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
