using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Data;
|
|
|
|
/// <summary>
|
|
/// 网站配置
|
|
/// </summary>
|
|
|
|
namespace Basic.BLL
|
|
{
|
|
public class sms
|
|
{
|
|
|
|
public static DataTable GetListByUser(Basic.Model.user muser)
|
|
{
|
|
Basic.DAL.address daladd = new Basic.DAL.address();
|
|
|
|
string strWhere = " id=0 ";
|
|
if (muser != null)
|
|
{
|
|
strWhere = " user_id=" + muser.id;
|
|
}
|
|
|
|
DataTable dst = daladd.GetList(0,strWhere," status desc , id desc ").Tables[0];
|
|
return dst;
|
|
}
|
|
/// <summary>
|
|
/// 判断当前这个手机号是否可以再发一次验证码
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public static bool IsRepeat(string strMobile)
|
|
{
|
|
bool Flag = false;
|
|
Basic.DAL.sms dals = new Basic.DAL.sms();
|
|
Basic.Model.sms models = dals.GetModel(strMobile);
|
|
if (models != null)
|
|
{
|
|
if (DateTime.Now.Subtract(models.add_time).TotalSeconds < 60)
|
|
{
|
|
Flag = true;
|
|
}
|
|
}
|
|
return Flag;
|
|
}
|
|
/// <summary>
|
|
/// 获取一个随机的验证码,然后添加一条sms
|
|
/// </summary>
|
|
/// <param name="strPhone"></param>
|
|
/// <returns></returns>
|
|
public static string GetSmsCode(string strPhone)
|
|
{
|
|
long ran = new Random().Next(10000, 100000);
|
|
|
|
Basic.DAL.sms dals=new Basic.DAL.sms();
|
|
Basic.Model.sms models=new Basic.Model.sms();
|
|
|
|
models.phone=strPhone;
|
|
models.smscode=ran.ToString();
|
|
models.add_time=DateTime.Now;
|
|
dals.Add(models);
|
|
return models.smscode;
|
|
}
|
|
}
|
|
}
|