86647423279379c834dc35346f5a4e5ceab0617c.svn-base 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. package com.chinacreator.videoalliance.smc.dao;
  2. import com.chinacreator.videoalliance.common.util.DataSource;
  3. import com.chinacreator.videoalliance.smc.bean.TlVerifiCationCodeBean;
  4. import com.frameworkset.common.poolman.PreparedDBUtil;
  5. import java.sql.SQLException;
  6. /**
  7. * 短信验证码数据层类
  8. * @author lizhiyong
  9. *
  10. */
  11. public class SendSmsCodeDao {
  12. /**
  13. * 检查验证码是否超时(大于60秒)
  14. * @param cpid
  15. * @param userid
  16. * @return 时间差
  17. * @throws SQLException
  18. */
  19. public String checkValidatTime(String cpid, String userid) throws SQLException{
  20. PreparedDBUtil pdb = new PreparedDBUtil();
  21. String sql="select (SYSDATE - TO_DATE (MAKETIME, 'yyyy-mm-dd hh24:mi:ss')) * 24 * 3600 from TL_VERIFICATION_CODE where USERID=? AND CPID=? and (SYSDATE - TO_DATE (MAKETIME, 'yyyy-mm-dd hh24:mi:ss')) * 24 * 3600<60";
  22. pdb.preparedSelect(DataSource.NET3G, sql);
  23. pdb.setString(1, userid);
  24. pdb.setString(2, cpid);
  25. pdb.executePrepared();
  26. if(pdb.size() > 0) {
  27. System.out.println(pdb);
  28. System.out.println(pdb.getInt(0, 0) + "");
  29. return pdb.getInt(0, 0) + "";
  30. }
  31. return "61";
  32. }
  33. public static void main(String[] args) throws SQLException {
  34. PreparedDBUtil pdb = new PreparedDBUtil();
  35. SendSmsCodeDao sendSmsCodeDao = new SendSmsCodeDao();
  36. String pptv = sendSmsCodeDao.checkValidatTime("pptv", "17673136322");
  37. }
  38. public int checkTransfer(String userid) throws SQLException{
  39. if(userid != null){
  40. PreparedDBUtil pdb = new PreparedDBUtil();
  41. String sql="select count(*) count from wosdk.tb_transfer_number where userid='"+userid.trim()+"' and status='0'";
  42. pdb.preparedSelect(DataSource.NET3G, sql);
  43. pdb.executePrepared();
  44. if(pdb.size() > 0) {
  45. return pdb.getInt(0, 0);
  46. }
  47. }
  48. return 0;
  49. }
  50. public int checkArea(String userid) throws SQLException{
  51. if(userid != null && userid.length()>=7){
  52. PreparedDBUtil pdb = new PreparedDBUtil();
  53. String sql="select count(*) count from TB_CALLER_AREACODE t where operators='联通' and status='0' and callerhead='"+userid.substring(0,7)+"'";
  54. pdb.preparedSelect(DataSource.NET3G, sql);
  55. pdb.executePrepared();
  56. if(pdb.size() > 0) {
  57. return pdb.getInt(0, 0);
  58. }
  59. }
  60. return 0;
  61. }
  62. /**
  63. * 插入用户成功获取验证码的信息
  64. * @param tvcc 确认验证码实体类
  65. * @throws SQLException
  66. */
  67. public void insertTlVerifiCationCode(TlVerifiCationCodeBean tvcc) throws SQLException{
  68. PreparedDBUtil pdp=new PreparedDBUtil();
  69. String sql="insert into TL_VERIFICATION_CODE(ROWNO,CPID,USERID,VERCODE,MAKETIME,SENDSTATUS,REMARK,CHANNEL)values"
  70. + "(to_char(sysdate,'yyyyMMddhh24miss')||SEQ_COMMON6.nextval,?,?,?,?,?,?,?)";
  71. pdp.preparedInsert(DataSource.NET3G, sql);
  72. pdp.setString(1, tvcc.getCpid());
  73. pdp.setString(2, tvcc.getUserid());
  74. pdp.setString(3, tvcc.getVercode());
  75. pdp.setString(4, tvcc.getMakeTime());
  76. pdp.setString(5, tvcc.getSendStatus());
  77. pdp.setString(6, tvcc.getRemark());
  78. pdp.setString(7, tvcc.getChannel());
  79. pdp.executePrepared();
  80. }
  81. }