12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- <?php
- /*
- * @Author: wang jun
- * @Date: 2021-09-03 16:33:07
- * @Last Modified by: wang jun
- * @Last Modified time: 2021-09-03 17:58:59
- */
- namespace app\index\logic;
- use app\index\model\smscoderecordmodel;
- use app\index\model\userinfomodel;
- class smslogic
- {
- /***
- * 20210903
- * wj
- * 创建验证码
- */
- public function createCode($arr)
- {
- $m_scr = new smscoderecordmodel();
- $m_u = new userinfomodel();
- if (!isset($arr['smscode']) || !empty($arr['smscode']) || !is_numeric($arr['smscode'])) {
- return false;
- }
- $tel = $arr['tel'];
- $wuInfo = $m_u->getInfo(['telno' => $tel]);
- $wid = empty($wuInfo) ? 0 : $wuInfo['id'];
- $insertData = [
- 'tel' => $tel,
- 'wid' => $wid,
- 'smscode' => $arr['smscode'],
- 'createtime' => time(),
- ];
- $id = $m_scr->insinfo($insertData);
- return $id;
- }
- /***
- * 20210903
- * wj
- * 根据id删除验证码
- */
- public function deleteCoeById($id)
- {
- $m_scr = new smscoderecordmodel();
- $result = $m_scr->delbyid($id);
- return $result;
- }
- public function getinfobyid($id)
- {
- $m_scr = new smscoderecordmodel();
- $sccInfo = $m_scr->getinfobyid($id);
- return $sccInfo;
- }
- public function getlastinfobytel($tel)
- {
- $m_scr = new smscoderecordmodel();
- $sccInfo = $m_scr->getlastinfobytel($tel);
- return $sccInfo;
- }
- public function deletebytime($tel)
- {
- $m_scr = new smscoderecordmodel();
- //间隔时间大于2分钟删除
- //$maxtime = 120;
- $maxtime = 120;
- $time = time();
- $where['tel'] = $tel;
- $sccInfo = $m_scr->getinfo($where, false);
- foreach ($sccInfo as $value) {
- $createTime = $value['createtime'];
- if ($time > $createTime && $time - $createTime >= $maxtime) {
- $result = $m_scr->deletebyid($value['id']);
- }
- }
- }
- }
|