You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

BaseSms.php 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace crmeb\basic;
  3. use think\facade\Config;
  4. /**
  5. * Class BaseSms
  6. */
  7. abstract class BaseSms extends BaseStorage
  8. {
  9. /**
  10. * 模板id
  11. * @var array
  12. */
  13. protected $templateIds = [];
  14. /**
  15. * 初始化
  16. * @param array $config
  17. * @return mixed|void
  18. */
  19. protected function initialize(array $config)
  20. {
  21. $this->templateIds = Config::get($this->configFile . '.stores.' . $this->name . '.template_id', []);
  22. }
  23. /**
  24. * 获取模板id
  25. * @return array
  26. */
  27. public function getTemplateId()
  28. {
  29. return $this->templateIds;
  30. }
  31. /**
  32. * 提取模板code
  33. * @param string $templateId
  34. * @return null
  35. */
  36. protected function getTemplateCode(string $templateId)
  37. {
  38. return $this->templateIds[$templateId] ?? null;
  39. }
  40. /**
  41. * 发送短信
  42. * @param string $phone
  43. * @param string $templateId
  44. * @param array $data
  45. * @return mixed
  46. */
  47. abstract public function send(string $phone, string $templateId, array $data = []);
  48. }