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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 受托支付支取额度查询
    /// 根据账号查询受托支付支取额度
    /// </summary>
    public class QueryFixedPay : TFOutput
    {
        #region Output
        /// <summary>
        /// 以文件形式返回支取额度
        /// 贷款协议号|授权支付协议|支取金额|自主支取限额|委托支付限额|支付方式|收款账号|
        /// </summary>
        public string YWJXSFHZQED { get; internal set; }

        /// <summary>
        /// 以文件形式返回支取额度
        /// 贷款协议号|授权支付协议|支取金额|自主支取限额|委托支付限额|支付方式|收款账号|
        /// </summary>
        public List<E_YWJXSFHZQED> YWJXSFHZQEDData { get; internal set; }

        /// <summary>
        /// 以文件形式返回支取额度
        /// 贷款协议号|授权支付协议|支取金额|自主支取限额|委托支付限额|支付方式|收款账号|
        /// </summary>
        public class E_YWJXSFHZQED
        {
            /// <summary>
            /// 贷款协议号
            /// </summary>
            public string DKXYH { get; set; }

            /// <summary>
            /// 授权支付协议
            /// </summary>
            public string SQZFXY { get; set; }

            /// <summary>
            /// 支取金额
            /// </summary>
            public string ZQJE { get; set; }

            /// <summary>
            /// 自主支取限额
            /// </summary>
            public string ZZZQXE { get; set; }

            /// <summary>
            /// 委托支付限额
            /// </summary>
            public string WTZFXE { get; set; }

            /// <summary>
            /// 支付方式
            /// </summary>
            public string ZFFS { get; set; }

            /// <summary>
            /// 收款账号
            /// </summary>
            public string SKZH { get; set; }

        }

        #endregion

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

            /// <summary>
            /// 扣划标志 0670
            /// 1：扣划 2非扣划 
            /// </summary>
            public string KHBZ { get; set; }

            /// <summary>
            /// 支取标志 0690
            /// 1：待支取； 2：已支取 
            /// </summary>
            public string ZQBZ { get; set; }


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

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                
                output.YWJXSFHZQEDData = AnilyzeFileData<E_YWJXSFHZQED>(MessageData.FileData,
                                            "贷款协议号|授权支付协议|支取金额|自主支取限额|委托支付限额|支付方式|收款账号|",
                                            x =>
                                            {
                                                return new E_YWJXSFHZQED
                                                {
                                                    DKXYH = x["贷款协议号"],
                                                    SQZFXY = x["授权支付协议"],
                                                    ZQJE = x["支取金额"],
                                                    ZZZQXE = x["自主支取限额"],
                                                    WTZFXE = x["委托支付限额"],
                                                    ZFFS = x["支付方式"],
                                                    SKZH = x["收款账号"]
                                                };
                                            });
                output.YWJXSFHZQED = MessageData.FileData;

                return output;
            }
        }
        #endregion
    }
}
