| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576 |
- <?php
- // +----------------------------------------------------------------------
- // | LARAVEL8.0 框架 [ LARAVEL ][ RXThinkCMF ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 LARAVEL研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: laravel开发员 <laravel.qq.com>
- // +----------------------------------------------------------------------
- namespace App\Services;
- use App\Models\ConfigModel;
- /**
- * 手机短信管理-服务类
- * @author
- * @since 2020/11/11
- * Class SmsService
- * @package App\Services
- */
- class SmsService extends BaseService
- {
- // 静态对象
- protected static $instance = null;
- /**
- * 静态入口
- * @return static|null
- */
- public static function make()
- {
- if(!self::$instance){
- self::$instance = (new static());
- }
- return self::$instance;
- }
- /**
- * 发送手机短信
- * @param $email
- * @param string $scene 场景:默认reg-注册
- * @return bool
- */
- public function sendCode($mobile, $scene='reg')
- {
- return true;
- }
- /**
- * 验证手机短信
- * @param $mobile
- * @param $code
- * @param string $scene 场景:默认reg-注册
- * @return bool
- */
- public function check($mobile, $code, $scene='reg')
- {
- $cacheKey = "stores:codes:mobile_{$scene}:" . md5($mobile);
- $codeData = RedisService::get($cacheKey);
- $checkCode = isset($codeData['code'])? $codeData['code'] : 0;
- $checkMobile = isset($codeData['mobile'])? $codeData['mobile'] : '';
- if(empty($codeData) || empty($checkCode)){
- $this->error = 2010;
- return false;
- }
- if($checkMobile != $mobile || $checkCode != $code){
- $this->error = 2006;
- return false;
- }
- return true;
- }
- }
|