SmsJob.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 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\sms\SmsSendServices;
  13. use crmeb\basic\BaseJobs;
  14. use crmeb\traits\QueueTrait;
  15. use think\facade\Log;
  16. /**
  17. * 短信
  18. * Class SmsJob
  19. * @package app\jobs\notice
  20. */
  21. class SmsJob extends BaseJobs
  22. {
  23. use QueueTrait;
  24. /**
  25. * 发送短信
  26. * @param $switch
  27. * @param $adminList
  28. * @param $order
  29. * @return bool
  30. */
  31. public function doJob($phone, array $data, string $template)
  32. {
  33. try {
  34. /** @var SmsSendServices $smsServices */
  35. $smsServices = app()->make(SmsSendServices::class);
  36. $smsServices->send(true, $phone, $data, $template);
  37. return true;
  38. } catch (\Throwable $e) {
  39. Log::error('发送短信消息失败,失败原因:' . $e->getMessage());
  40. }
  41. }
  42. }