using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using TellerSystem.ServiceProxy.Ext.ServiceHelper;

namespace TellerSystem.Contract.Function
{
    /// <summary>
    /// 密码验证
    /// 对传入的柜员密码或是凭证密码单或是账号密码进行验证
    /// </summary>
    public class PasswordAuthentication : TFOutput
    {
        #region Output
        /// <summary>
        /// 凭证密码验证方式 0670
        /// 0.密码单1.支付密码器
        /// </summary>
        public string PZMMYZFS { get; internal set; }


        #endregion

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

            /// <summary>
            /// 出票日期 0440
            /// (null) 
            /// </summary>
            public string CPRQ { get; set; }

            /// <summary>
            /// 凭证号码 0580
            /// (null) 
            /// </summary>
            public string PZHM { get; set; }

            /// <summary>
            /// 验证标志 0670
            /// 0.账户密码1.柜员密码2.凭证密码3.支付密码器4.凭证密码方式选择 
            /// </summary>
            public string YZBZ { get; set; }

            /// <summary>
            /// 密码 0800
            /// (null) 
            /// </summary>
            public string MM { get; set; }

            /// <summary>
            /// 凭证类型 0890
            /// (null) 
            /// </summary>
            public string PZLX { get; set; }

            /// <summary>
            /// 柜员号 0920
            /// (null) 
            /// </summary>
            public string GYH { get; set; }

            /// <summary>
            /// 票面金额 0400
            ///  
            /// </summary>
            public string PMJE { get; set; }

            /// <summary>
            /// 证件号码 0620
            ///  
            /// </summary>
            public string ZJHM { get; set; }

            /// <summary>
            /// 证件类型 0680
            ///  
            /// </summary>
            public string ZJLX { get; set; }


            /// <summary>                 
            /// 定义业务逻辑              
            /// </summary>                
            /// <returns></returns>  
            public override TFOutput Raise()
            {
                //拉取数据                                  
                var output = new PasswordAuthentication();
                PageData.TradeAPIs.InitFd(MessageData);
                PageData.TradeAPIs.CommSend(MessageData);
				MessageData.Fd126_5 = MainCode;
                MessageData.Fd16 = "K021";
                MessageData.Fd30 = ZH;
                MessageData.Fd44 = CPRQ;
                MessageData.Fd58 = PZHM;
                MessageData.Fd67 = YZBZ;
                //国密改造
                if (TradeManagerHandle.TT_SYSCONFIG_GetConfigValueByConfigID("EncrypteGM") == "true")
                {
                    MessageData.Fd122_I = MM;
                }
                else
                {
                    MessageData.Fd80 = MM;
                }
                MessageData.Fd89 = PZLX;
                MessageData.Fd92 = GYH;
                MessageData.Fd40 = PMJE;
                MessageData.Fd62 = ZJHM;
                MessageData.Fd68 = ZJLX;

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

                return output;
            }
        }
        #endregion
    }
}
