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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 根据协议号查询委托协议登记簿
    /// 根据协议号查询委托协议登记簿
    /// </summary>
    public class QueryWTXYDJB : TFOutput
    {
        #region Output
        /// <summary>
        /// 文件
        /// 委托编号|交易机构|委托贷款人户名|委托金额|已委托金额|本金柜员账号|贷款账号|贷款序号|委托贷款标志|手续费率|分成比例|状态|
        /// </summary>
        public string WJ { get; internal set; }

        /// <summary>
        /// 文件
        /// 委托编号|交易机构|委托贷款人户名|委托金额|已委托金额|本金柜员账号|贷款账号|贷款序号|委托贷款标志|手续费率|分成比例|状态|
        /// </summary>
        public List<E_WJ> WJData { get; internal set; }

        /// <summary>
        /// 文件
        /// 委托编号|交易机构|委托贷款人户名|委托金额|已委托金额|本金柜员账号|贷款账号|贷款序号|委托贷款标志|手续费率|分成比例|状态|
        /// </summary>
        public class E_WJ
        {
            /// <summary>
            /// 委托编号
            /// </summary>
            public string WTBH { get; set; }

            /// <summary>
            /// 交易机构
            /// </summary>
            public string JYJG { get; set; }

            /// <summary>
            /// 委托贷款人户名
            /// </summary>
            public string WTDKRHM { get; set; }

            /// <summary>
            /// 委托金额
            /// </summary>
            public string WTJE { get; set; }

            /// <summary>
            /// 已委托金额
            /// </summary>
            public string YWTJE { get; set; }

            /// <summary>
            /// 本金柜员账号
            /// </summary>
            public string BJGYZH { get; set; }

            /// <summary>
            /// 贷款账号
            /// </summary>
            public string DKZH { get; set; }

            /// <summary>
            /// 贷款序号
            /// </summary>
            public string DKXH { get; set; }

            /// <summary>
            /// 委托贷款标志
            /// </summary>
            public string WTDKBZ { get; set; }

            /// <summary>
            /// 手续费率
            /// </summary>
            public string SXFL { get; set; }

            /// <summary>
            /// 分成比例
            /// </summary>
            public string FCBL { get; set; }

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

        }

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 委托贷款人户名 0250
            ///  
            /// </summary>
            public string WTDKRHM { get; set; }

            /// <summary>
            /// 委托账号 0300
            ///  
            /// </summary>
            public string WTZH { get; set; }

            /// <summary>
            /// 委托编号 0810
            ///  
            /// </summary>
            public string WTBH { get; set; }

            /// <summary>
            /// 状态 0670
            /// 1:正常 ; *:取消 
            /// </summary>
            public string ZT { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new QueryWTXYDJB();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "CXCL";
                MessageData.Fd25 = WTDKRHM;
                MessageData.Fd30 = WTZH;
                MessageData.Fd81 = WTBH;
                MessageData.Fd128 = "0087";
                MessageData.Fd67 = ZT;

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.WJData = AnilyzeFileData<E_WJ>(MessageData.FileData,
                                            "委托编号|交易机构|委托贷款人户名|委托金额|已委托金额|本金柜员账号|贷款账号|贷款序号|委托贷款标志|手续费率|分成比例|状态|",
                                            x =>
                                            {
                                                return new E_WJ
                                                {
                                                    WTBH = x["委托编号"],
                                                    JYJG = x["交易机构"],
                                                    WTDKRHM = x["委托贷款人户名"],
                                                    WTJE = x["委托金额"],
                                                    YWTJE = x["已委托金额"],
                                                    BJGYZH = x["本金柜员账号"],
                                                    DKZH = x["贷款账号"],
                                                    DKXH = x["贷款序号"],
                                                    WTDKBZ = x["委托贷款标志"],
                                                    SXFL = x["手续费率"],
                                                    FCBL = x["分成比例"],
                                                    ZT = x["状态"]
                                                };
                                            });
                output.WJ = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
