Captcha.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\common\service\message\passport;
  13. use app\common\service\message\Basics;
  14. use app\common\enum\setting\sms\Scene as SettingSmsScene;
  15. /**
  16. * 消息通知服务 [短信验证码]
  17. * Class Captcha
  18. * @package app\common\service\message\passport
  19. */
  20. class Captcha extends Basics
  21. {
  22. /**
  23. * 发送消息通知
  24. * @param array $param
  25. * @return bool|mixed
  26. * @throws \think\Exception
  27. * @throws \think\db\exception\DataNotFoundException
  28. * @throws \think\db\exception\DbException
  29. * @throws \think\db\exception\ModelNotFoundException
  30. */
  31. public function send(array $param)
  32. {
  33. // 短信api参数
  34. $sceneConfig = ['acceptPhone' => $param['mobile']];
  35. $templateParams = ['code' => $param['code']];
  36. // 发送短信
  37. if (!$this->sendSms(SettingSmsScene::CAPTCHA, $templateParams, $sceneConfig)) {
  38. throwError('短信发送失败:' . $this->getError());
  39. }
  40. return true;
  41. }
  42. }