using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace VA.Modules.JDingMember.Interface.MemberConsume.ClassLibrary
{
    public class InterfaceUtils
    {
        public static　bool InterfacePasswordCheck(string encryptedPwd, out string errorMsg)
        {
            errorMsg = null;

            string originalStr = VA.Utils.SecurityHelper.Decrypt(encryptedPwd, Utils.CryptProvider.DES);
            string[] tempArray = originalStr.Split('|');

            string interfacePwd = tempArray[0];
            string shopCode = tempArray[1];
            string dateStr = tempArray[2];

            DateTime clientDate = DateTime.Parse(dateStr);
            DateTime dtNow = DateTime.Now;
            TimeSpan ts = dtNow - clientDate;

            if (ts.TotalHours > 1)
            {
                errorMsg = "时间戳无效！";
                return false;
            }

            if (interfacePwd != "123456")
            {
                errorMsg = "接口调用密码无效！";
                return false;
            }

            return true;
        }
    }
}