You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

65 lines
1.9 KiB

пре 3 година
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Data;
  6. /// <summary>
  7. /// 网站配置
  8. /// </summary>
  9. namespace Basic.BLL
  10. {
  11. public class sms
  12. {
  13. public static DataTable GetListByUser(Basic.Model.user muser)
  14. {
  15. Basic.DAL.address daladd = new Basic.DAL.address();
  16. string strWhere = " id=0 ";
  17. if (muser != null)
  18. {
  19. strWhere = " user_id=" + muser.id;
  20. }
  21. DataTable dst = daladd.GetList(0,strWhere," status desc , id desc ").Tables[0];
  22. return dst;
  23. }
  24. /// <summary>
  25. /// 判断当前这个手机号是否可以再发一次验证码
  26. /// </summary>
  27. /// <returns></returns>
  28. public static bool IsRepeat(string strMobile)
  29. {
  30. bool Flag = false;
  31. Basic.DAL.sms dals = new Basic.DAL.sms();
  32. Basic.Model.sms models = dals.GetModel(strMobile);
  33. if (models != null)
  34. {
  35. if (DateTime.Now.Subtract(models.add_time).TotalSeconds < 60)
  36. {
  37. Flag = true;
  38. }
  39. }
  40. return Flag;
  41. }
  42. /// <summary>
  43. /// 获取一个随机的验证码,然后添加一条sms
  44. /// </summary>
  45. /// <param name="strPhone"></param>
  46. /// <returns></returns>
  47. public static string GetSmsCode(string strPhone)
  48. {
  49. long ran = new Random().Next(10000, 100000);
  50. Basic.DAL.sms dals=new Basic.DAL.sms();
  51. Basic.Model.sms models=new Basic.Model.sms();
  52. models.phone=strPhone;
  53. models.smscode=ran.ToString();
  54. models.add_time=DateTime.Now;
  55. dals.Add(models);
  56. return models.smscode;
  57. }
  58. }
  59. }