/// <summary>
 /// 绑定用户账户信息
 /// </summary>
 /// <param name="uInfo"></param>
 /// <param name="dt"></param>
 /// <returns></returns>
 private UserAccountInfo BindUserAccountInfo(UserAccountInfo uInfo, DataTable dt)
 {
     uInfo.AttributeHeadID = dt.Rows[0]["AttributeHeadID"].ToInt32();
     uInfo.CustomerID = dt.Rows[0]["CustomerID"].ToInt32();
     uInfo.ProtocolCustomerID = dt.Rows[0]["ProtocolCustomerID"].ToInt32();
     uInfo.Accounttpe = dt.Rows[0]["Accounttpe"].ToInt32();
     return uInfo;
 }
        /// <summary>
        /// 根据账户名称获取账户信息
        /// </summary>
        /// <param name="appAccount"></param>
        /// <param name="sqlHelper"></param>
        /// <returns></returns>
        public UserAccountInfo GetCustomerInfoByAppAccount(string appAccount, SQLHelper sqlHelper)
        {
            UserAccountInfo uInfo = new UserAccountInfo();
            DataTable dt = null;

            if (appAccount == null || appAccount.Trim().Length == 0)
            {
                return uInfo;
            }

            const string procName = "dbo.Usp_PCustomer_V2_GetCustomerInfo";
            SqlParameter[] spars = new SqlParameter[] {
                new SqlParameter("@appaccount",appAccount)};

            try
            {
                dt = sqlHelper.ExecuteDataTable(CommandType.StoredProcedure, procName, "", spars);
                if (dt != null && dt.Rows.Count > 0)
                {
                    uInfo = BindUserAccountInfo(uInfo, dt);
                }
            }
            catch (Exception ex)
            {

            }
            return uInfo;
        }
        public UserAccountInfo UserAccountchange(UserAccountInfo info)
        {
            UserAccountInfo Result = new UserAccountInfo();
            if (info.Accounttpe == 2)
            {
                Result.CustomerID = info.ProtocolCustomerID;
                Result.Accounttpe = 2;
                Result.AttributeHeadID = info.AttributeHeadID;
                Result.ProtocolCustomerID = info.ProtocolCustomerID;

            }
            if (info.Accounttpe == 1)
            {
                Result.CustomerID = info.CustomerID;
                Result.Accounttpe = 1;
                Result.AttributeHeadID = info.AttributeHeadID;
                Result.ProtocolCustomerID = info.ProtocolCustomerID;

            }
            //if (info.Accounttpe == 3)
            //{
            //    Result.Accounttpe = 3;
            //    Result.CustomerID = info.AttributeHeadID;
            //    Result.ProtocolCustomerID = info.ProtocolCustomerID;
            //    Result.AttributeHeadID = info.AttributeHeadID;

            //}
            return Result;
        }
        /// <summary>
        /// 根据accessToken获取账户信息
        /// </summary>
        /// <param name="accessToken"></param>
        /// <param name="sqlHelper"></param>
        /// <returns></returns>
        public UserAccountInfo GetCustomerInfoByAccessToken(string accessToken, SQLHelper sqlHelper)
        {
            UserAccountInfo uInfo = new UserAccountInfo();
            string appAcount = "";

            if (ValidateAccessToken(accessToken, sqlHelper, ref appAcount))
            {
                uInfo = GetCustomerInfoByAppAccount(appAcount, sqlHelper);
                uInfo = UserAccountchange(uInfo);
            }
            else
            {
                throw new Exception("验证失败-错误的令牌。");

            }

            return uInfo;
        }