AsyncSms.php 760 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace crmeb\services\async\task;
  3. use crmeb\repositories\ShortLetterRepositories;
  4. /**
  5. * 异步发短信
  6. */
  7. class AsyncSms extends Task {
  8. const CMD = 'sms';
  9. protected static function getCmd()
  10. {
  11. return self::CMD;
  12. }
  13. public static function exec(array $task)
  14. {
  15. if (!self::checkTask($task)) {
  16. return false;
  17. }
  18. $params = $task['params'];
  19. return ShortLetterRepositories::send(true, $params['phone'], $params['data'], $params['template']);
  20. }
  21. public static function push(string $phone, array $data, string $template)
  22. {
  23. return self::put([
  24. 'phone' => $phone,
  25. 'data' => $data,
  26. 'template' => $template,
  27. ]);
  28. }
  29. }