SmsJob.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2023 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\jobs\notice;
  12. use app\services\message\notice\SmsService;
  13. use crmeb\basic\BaseJobs;
  14. use crmeb\traits\QueueTrait;
  15. use think\facade\Log;
  16. class SmsJob extends BaseJobs
  17. {
  18. use QueueTrait;
  19. /**
  20. * 发送短信
  21. * @param $switch
  22. * @param $adminList
  23. * @param $order
  24. * @return bool
  25. */
  26. public function doJob($phone, array $data, string $template)
  27. {
  28. try{
  29. /** @var SmsService $smsServices */
  30. $smsServices = app()->make(SmsService::class);
  31. $smsServices->send(true, $phone, $data, $template);
  32. return true;
  33. }catch (\Throwable $e) {
  34. Log::error('发送短信失败,失败原因:' . $e->getMessage());
  35. }
  36. }
  37. }