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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 查询贷款产品信息
    /// 根据贷款类别加载产品列表数据
    /// </summary>
    public class QueryLoanProductInfo : TFOutput
    {
        #region Output
        /// <summary>
        /// 产品列表数据
        /// 产品号|产品名称|币种|
        /// </summary>
        public string CPLBSJ { get; internal set; }

        /// <summary>
        /// 产品列表数据
        /// 产品号|产品名称|币种|
        /// </summary>
        public List<E_CPLBSJ> CPLBSJData { get; internal set; }

        /// <summary>
        /// 产品列表数据
        /// 产品号|产品名称|币种|
        /// </summary>
        public class E_CPLBSJ
        {
            /// <summary>
            /// 产品号
            /// </summary>
            public string CPH { get; set; }

            /// <summary>
            /// 产品名称
            /// </summary>
            public string CPMC { get; set; }

            /// <summary>
            /// 币种
            /// </summary>
            public string BZ { get; set; }

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 贷款期限 103A
            /// 必输 
            /// </summary>
            public string DKQX { get; set; }

            /// <summary>
            /// 贷款类型 1145
            /// 必输 
            /// </summary>
            public string DKLX { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryLoanProductInfo();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd103_A = DKQX;
                MessageData.Fd114_5 = DKLX;
                MessageData.Fd128 = "0016";

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.CPLBSJData = AnilyzeFileData<E_CPLBSJ>(MessageData.FileData,
                                            "产品号|产品名称|币种|",
                                            x =>
                                            {
                                                return new E_CPLBSJ
                                                {
                                                    CPH = x["产品号"],
                                                    CPMC = x["产品名称"],
                                                    BZ = x["币种"]
                                                };
                                            });
                output.CPLBSJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
