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

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 交易规则检查
    /// 交易规则检查,账户序号检查，根据交易代码,账号,交易金额检查是否超出限额
    /// </summary>
    public class CheckTradeRule : TFOutput
    {
        #region Output

        #endregion

        #region Input
		/// <summary>
        /// 参数清单
        /// </summary>
        public class Input : TFInput
        {
            /// <summary>
            /// 目标交易代码 0120
            /// 主交易代码 
            /// </summary>
            public string MBJYDM { get; set; }

            /// <summary>
            /// 账号 0300
            ///  
            /// </summary>
            public string ZH { get; set; }

            /// <summary>
            /// 账户序号 0340
            ///  
            /// </summary>
            public string ZHXH { get; set; }

            /// <summary>
            /// 交易金额 0420
            ///  
            /// </summary>
            public string JYJE { get; set; }

            /// <summary>
            /// 开户机构 0020
            ///  
            /// </summary>
            public string KHJG { get; set; }

            /// <summary>
            /// 渠道类型 096C
            ///  
            /// </summary>
            public string QDLX { get; set; }

            /// <summary>
            /// 商户类型 096K
            ///  
            /// </summary>
            public string SHLX { get; set; }

            /// <summary>
            /// 业务类型 096M
            ///  
            /// </summary>
            public string YWLX { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new CheckTradeRule();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "K039";
                MessageData.Fd12 = MBJYDM;
                MessageData.Fd30 = ZH;
                MessageData.Fd34 = ZHXH;
                MessageData.Fd42 = JYJE;
                MessageData.Fd2 = KHJG;
                MessageData.Fd96_C = QDLX;
                MessageData.Fd96_K = SHLX;
                MessageData.Fd96_M = YWLX;

                PageData.TradeAPIs.CallServer(MessageData);
                if (MessageData.Fd12 != "0000")
                {
                    output.IsFailed = true;
                    output.FailureCause = PageData.TradeAPIs.GetError(MessageData);
                }                

                return output;
            }
        }
        #endregion
    }
}
