Exemplo n.º 1
0
    public void SendCode()
    {
        string SPID = HttpUtility.HtmlDecode(Request.QueryString["SPID"].ToString());

        if (String.IsNullOrEmpty(SPID))
        {
            return;
        }
        String ErrorDescription = "";


        int Result = CommonBizRules.SPInterfaceGrant(SPID, "SendSMSCode", this.Context, out ErrorDescription);

        if (Result != 0)
        {
            return;
        }
        Random random     = new Random();
        string AuthenCode = random.Next(111111, 999999).ToString();
        string PhoneNum   = HttpUtility.HtmlDecode(Request.QueryString["PhoneNum"].ToString());
        string msg        = "";

        Result = PhoneBO.InsertPhoneSendMassage("", "", AuthenCode, PhoneNum, DateTime.Now, "", 1, 0, "1", out msg);
        //CommonBizRules.SendMessage(PhoneNum, "您的验证码是" + AuthenCode, SPID);
        CommonBizRules.SendMessageV3(PhoneNum, "您的验证码是" + AuthenCode, SPID);
    }
Exemplo n.º 2
0
    public int PhoneAuth()
    {
        string SPID = HttpUtility.HtmlDecode(Request.QueryString["SPID"].ToString());

        if (String.IsNullOrEmpty(SPID))
        {
            return(-1);
        }
        String ErrorDescription = "";
        int    Result           = CommonBizRules.SPInterfaceGrant(SPID, "SendSMSCode", this.Context, out ErrorDescription);

        if (Result != 0)
        {
            return(-2);
        }

        string ErrMsg   = "";
        string PhoneNum = HttpUtility.HtmlDecode(Request.QueryString["PhoneNum"].ToString());

        //int Result = PhoneBO.PhoneSel("", "", PhoneNum, SPID, out ErrMsg);
        //int Result = 0;
        Result = PhoneBO.PhoneSel("", PhoneNum, out ErrMsg);
        return(Result);
    }
Exemplo n.º 3
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="parameter"></param>
    /// <param name="strLog"></param>
    /// <returns></returns>
    protected String BesttoneCustInfoQuery(String parameter, out StringBuilder strLog)
    {
        #region 初始化变量
        int    Result           = ErrorDefinition.IError_Result_UnknowError_Code;
        String ErrorDescription = ErrorDefinition.IError_Result_UnknowError_Msg;

        strLog = new StringBuilder();
        String returnMsg = String.Empty;

        String version       = "";
        String SPID          = "";
        String fromIndex     = "";
        String rowCount      = "";
        String CustID        = "";
        String SourceSPID    = "";
        String fromDatetime  = "";
        String _fromDatetime = "";
        String toDatetime    = "";
        String _toDatetime   = "";

        Dictionary <String, String> OrderByMap = new Dictionary <String, String>();

        #endregion
        #region 解析xml请求包
        try
        {
            strLog.AppendFormat("请求参数Request:{0}\r\n", parameter);

            XmlDocument xmlDoc = new XmlDocument();
            xmlDoc.LoadXml(parameter);

            XmlNode versionNode = xmlDoc.SelectNodes("/root/callinfo/version")[0];
            version = versionNode.Attributes["value"].Value;

            XmlNode SPIDNode = xmlDoc.SelectNodes("/root/callinfo/SPID")[0];
            SPID = SPIDNode.Attributes["value"].Value;

            XmlNode fromIndexNode = xmlDoc.SelectNodes("/root/srchcond/fromIndex")[0];
            fromIndex = fromIndexNode.Attributes["value"].Value;

            XmlNode rowCountNode = xmlDoc.SelectNodes("/root/srchcond/rowCount")[0];
            String  _rowCount    = rowCountNode.Attributes["value"].Value;

            Regex r = new Regex(@"\[\d*\]$");
            if (r.IsMatch(_rowCount))
            {
                rowCount = _rowCount.Replace("[", "");
                rowCount = rowCount.Replace("]", "");
            }
            else
            {
                // 格式不对
                returnMsg = "";
                returnMsg = returnMsg + "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
                returnMsg = returnMsg + "<root>";
                returnMsg = returnMsg + "<result returnCode = \"-1001\" msg = \"rowCount格式不对!\" />";
                returnMsg = returnMsg + "</root>";
            }

            XmlNode CustIDNode = xmlDoc.SelectNodes("/root/srchcond/conds/CustID")[0];
            CustID = CustIDNode.Attributes["value"].Value;

            XmlNode BesttoneAccountNode = xmlDoc.SelectNodes("/root/srchcond/conds/SourceSPID")[0];
            SourceSPID = BesttoneAccountNode.Attributes["value"].Value;

            XmlNode fromDatetimeNode = xmlDoc.SelectNodes("/root/srchcond/conds/fromDatetime")[0];
            fromDatetime = fromDatetimeNode.Attributes["value"].Value;

            XmlNode toDatetimeNode = xmlDoc.SelectNodes("/root/srchcond/conds/toDatetime")[0];
            toDatetime = toDatetimeNode.Attributes["value"].Value;

            XmlNodeList fieldsNodeList = xmlDoc.SelectNodes("/root/srchcond/sortFields/field");

            foreach (XmlNode node in fieldsNodeList)
            {
                String key   = node.Attributes["value"].Value;
                String value = node.Attributes["desc"].Value;
                OrderByMap.Add(key, value);
            }
        }
        catch (Exception e)
        {
            // xml出错
            strLog.Append(e.ToString());
            returnMsg = "";
            returnMsg = returnMsg + "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
            returnMsg = returnMsg + "<root>";
            returnMsg = returnMsg + "<result returnCode = \"-1001\" msg = \"xml请求包格式不对!\" />";
            returnMsg = returnMsg + "</root>";
            return(returnMsg);
        }

        #endregion
        #region 校验请求数据
        try
        {
            if (String.IsNullOrEmpty(SPID))   // SPID不能为空
            {
                returnMsg = "";
                returnMsg = returnMsg + "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
                returnMsg = returnMsg + "<result returnCode = \"-1002\" msg = \"SPID不能为空!!\" />";
                return(returnMsg);
            }

            if (SPID.Length != ConstDefinition.Length_SPID)
            {
                returnMsg = "";
                returnMsg = returnMsg + "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
                returnMsg = returnMsg + "<result returnCode = \"-1003\" msg = \"SPID长度不对!\" />";
                return(returnMsg);
            }

            if (String.IsNullOrEmpty(fromIndex))   // fromIndex 如果为空默认为1
            {
                fromIndex = "1";
            }

            if (String.IsNullOrEmpty(rowCount))   // 如果rowCount请求行数为空,默认20行
            {
                rowCount = System.Configuration.ConfigurationManager.AppSettings["RechargeQueryRowCount"];
                if (String.IsNullOrEmpty(rowCount))
                {
                    rowCount = "20";
                }
            }

            if (Convert.ToInt32(rowCount) > 100) //最大只能返回100行
            {
                rowCount = "100";
            }

            if (!String.IsNullOrEmpty(fromDatetime))
            {
                if (IsDate(fromDatetime))
                {
                    _fromDatetime = Convert.ToDateTime(fromDatetime).ToString("yyyy-MM-dd");
                }
                else
                {
                    //非法日期格式
                    returnMsg = "";
                    returnMsg = returnMsg + "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
                    returnMsg = returnMsg + "<result returnCode = \"-1004\" msg = \"fromDatetime非法日期格式!\" />";
                    return(returnMsg);
                }
            }

            if (!String.IsNullOrEmpty(toDatetime))
            {
                if (IsDate(toDatetime))
                {
                    _toDatetime = Convert.ToDateTime(toDatetime).ToString("yyyy-MM-dd");
                }
                else
                {
                    //非法日期格式
                    returnMsg = "";
                    returnMsg = returnMsg + "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
                    returnMsg = returnMsg + "<result returnCode = \"-1005\" msg = \"toDatetime非法日期格式!\" />";
                    return(returnMsg);
                }
            }
        }
        catch (Exception e)
        {
            returnMsg = "";
            returnMsg = returnMsg + "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
            returnMsg = returnMsg + "<result returnCode = \"-1006\" msg ='" + e.ToString() + "'  />";
            return(returnMsg);
        }


        #endregion
        #region 权限校验

        //IP是否允许访问
        Result = CommonBizRules.CheckIPLimit(SPID, Request.UserHostAddress, this.Context, out ErrorDescription);
        if (Result != 0)
        {
            returnMsg = "";
            returnMsg = returnMsg + "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
            returnMsg = returnMsg + "<result returnCode = \"-1007\" msg ='" + Request.UserHostAddress + " :IP地址未经授权!" + "'  />";
            return(returnMsg);
        }

        //接口访问权限判断
        Result = CommonBizRules.SPInterfaceGrant(SPID, "BesttoneCustInfoQuery", this.Context, out ErrorDescription);

        if (Result != 0)
        {
            returnMsg = "";
            returnMsg = returnMsg + "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
            returnMsg = returnMsg + "<result returnCode = \"-1008\" msg ='" + ErrorDescription + "'  />";
            return(returnMsg);
        }
        #endregion

        #region dao执行Sql查询
        long          _fromIndex  = Convert.ToInt32(fromIndex);
        long          _toIndex    = _fromIndex + Convert.ToInt32(rowCount) - 1; //rowCount 请求返回的行数
        StringBuilder daologstr   = new StringBuilder();
        Int32         recordCount = 0;                                          // recordCount 实际返回的行数
        DataSet       ds          = _custInfo_dao.QueryCustInfo(SourceSPID, CustID, _fromIndex, _toIndex, _fromDatetime, _toDatetime, OrderByMap, out recordCount, out daologstr);
        strLog.Append(daologstr.ToString());
        #endregion

        #region 拼接返回xml
        //custid,provinceid,areaid,realname,custlevel,sex,username,createtime
        StringBuilder dataset = new StringBuilder();
        if (ds != null && ds.Tables[0] != null)
        {
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                dataset.Append("<Set>");
                dataset.AppendFormat("<CustID>{0}</CustID>", row["custid"].ToString());
                dataset.AppendFormat("<ProvinceID>{0}</ProvinceID>", row["provinceid"].ToString());
                dataset.AppendFormat("<AreaID>{0}</AreaID>", row["areaid"].ToString());
                dataset.AppendFormat("<RealName>{0}</RealName>", row["realname"].ToString());
                dataset.AppendFormat("<CustLevel>{0}</CustLevel>", row["custlevel"].ToString());
                dataset.AppendFormat("<Sex>{0}</Sex>", row["sex"].ToString());
                dataset.AppendFormat("<UserName>{0}</UserName>", row["cardno"].ToString());
                dataset.AppendFormat("<CreateTime>{0}</CreateTime>", row["createtime"].ToString());
                dataset.Append("</Set>");
            }
        }

        #endregion
        #region 成功返回xml
        returnMsg = "";
        returnMsg = returnMsg + "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>";
        returnMsg = returnMsg + "<result returnCode = \"00\" msg = \"成功\" recordCount='" + Convert.ToString(recordCount) + "' from='" + Convert.ToString(_fromIndex) + "' to='" + Convert.ToString(_toIndex) + "'>";
        returnMsg = returnMsg + dataset.ToString();
        returnMsg = returnMsg + "</result>";
        #endregion

        return(returnMsg);
    }
Exemplo n.º 4
0
    public String GetAuthenCode(String SPID, String CustID, String wt)
    {
        StringBuilder ResponseMsg = new StringBuilder();

        #region
        if (CommonUtility.IsEmpty(SPID))
        {
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "995");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "SPID不能为空!");
                ResponseMsg.Append("}");
            }
            else
            {
                ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                ResponseMsg.Append("<PayPlatRequestParameter>");
                ResponseMsg.Append("<PARAMETERS>");
                ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "995");
                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "SPID不能为空!");
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }

        if (CommonUtility.IsEmpty(CustID))
        {
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "995");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "CustID不能为空!");
                ResponseMsg.Append("}");
            }
            else
            {
                ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                ResponseMsg.Append("<PayPlatRequestParameter>");
                ResponseMsg.Append("<PARAMETERS>");
                ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "995");
                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "CustID不能为空!");
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }



        String             Phone   = String.Empty;
        BesttoneAccount    account = null;
        BesttoneAccountDAO dao     = new BesttoneAccountDAO();
        account = dao.QueryByCustID(CustID);
        if (account != null)
        {
            Phone = account.BestPayAccount;
        }
        else
        {
            //未开户
            // 返回错误信息
            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "997");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "该CustID尚未开户!");
                ResponseMsg.Append("}");
            }
            else
            {
                ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                ResponseMsg.Append("<PayPlatRequestParameter>");
                ResponseMsg.Append("<PARAMETERS>");
                ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "997");
                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "该CustID尚未开户!");
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }

        #endregion


        try
        {
            //String CustID = PhoneBO.IsAuthenPhone(Phone, SPID, out ErrMsg);

            Result = CommonBizRules.SPInterfaceGrant(SPID, "GetAuthenCode", this.Context, out ErrMsg);
            if (Result != 0)
            {
                ResponseMsg.Length = 0;
                if ("json".Equals(wt))
                {
                    ResponseMsg.Append("{");
                    ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "991");
                    ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "调用下行短信接口权限未开通!");
                    ResponseMsg.Append("}");
                }
                else
                {
                    ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                    ResponseMsg.Append("<PayPlatRequestParameter>");
                    ResponseMsg.Append("<PARAMETERS>");
                    ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "991");
                    ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "调用下行短信接口权限未开通!");
                    ResponseMsg.Append("</PARAMETERS>");
                    ResponseMsg.Append("</PayPlatRequestParameter>");
                }
                return(ResponseMsg.ToString());
            }

            Random random     = new Random();
            String AuthenCode = random.Next(111111, 999999).ToString();

            DateTime DealTime = DateTime.Now;
            int      k        = PhoneBO.PhoneSelV2("", Phone, out ErrMsg); // 检查发送验证码次数
            if (k == 0)
            {
                CommonBizRules.SendMessageV3(Phone, "您正在通过翼购客户端找回支付密码,验证码为:" + AuthenCode + ",有效期2分钟。", SPID);
                Result = PhoneBO.InsertPhoneSendMassage(CustID, "您正在通过翼购客户端找回支付密码,验证码为:" + AuthenCode + ",有效期2分钟。", AuthenCode, Phone, DateTime.Now, "客户端找回支付密码", 1, 0, "1", out ErrMsg);
            }
            else
            {
                ResponseMsg.Length = 0;
                if ("json".Equals(wt))
                {
                    ResponseMsg.Append("{");
                    ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "992");
                    ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "该手机号码已经被注册过了!");
                    ResponseMsg.Append("}");
                }
                else
                {
                    ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                    ResponseMsg.Append("<PayPlatRequestParameter>");
                    ResponseMsg.Append("<PARAMETERS>");
                    ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "992");
                    ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "该手机号码已经被注册过了!");
                    ResponseMsg.Append("</PARAMETERS>");
                    ResponseMsg.Append("</PayPlatRequestParameter>");
                }
                return(ResponseMsg.ToString());
            }


            ResponseMsg.Length = 0;
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "0");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "您的验证码是:" + AuthenCode);
                ResponseMsg.Append("}");
            }
            else
            {
                ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                ResponseMsg.Append("<PayPlatRequestParameter>");
                ResponseMsg.Append("<PARAMETERS>");
                ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "0");
                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "您的验证码是:" + AuthenCode);
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }
        catch (Exception exp)
        {
            if ("json".Equals(wt))
            {
                ResponseMsg.Append("{");
                ResponseMsg.AppendFormat("\"errcode\":\"{0}\",", "-25367");
                ResponseMsg.AppendFormat("\"errmsg\":\"{0}\"", "异常:" + exp.ToString());
                ResponseMsg.Append("}");
            }
            else
            {
                ResponseMsg.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
                ResponseMsg.Append("<PayPlatRequestParameter>");
                ResponseMsg.Append("<PARAMETERS>");
                ResponseMsg.AppendFormat("<ErrCode>{0}</ErrCode>", "-25367");
                ResponseMsg.AppendFormat("<ErrMsg>{0}</ErrMsg>", "异常:" + exp.ToString());
                ResponseMsg.Append("</PARAMETERS>");
                ResponseMsg.Append("</PayPlatRequestParameter>");
            }
            return(ResponseMsg.ToString());
        }

        return(ResponseMsg.ToString());
    }