Notify.php 1.1 KB

1234567891011121314151617181920212223242526
  1. <?php namespace Msg\Lib\Type;
  2. use Dever;
  3. class Notify
  4. {
  5. # 发送通知
  6. public function send($template, $account = [], $param = [], $project = 'api')
  7. {
  8. if ($template['content']) {
  9. $template['content'] = \Dever\Helper\Str::val($template['content'], $param);
  10. }
  11. foreach ($template['method'] as $k => $v) {
  12. $config = Dever::db('account', 'msg')->find(['method' => $v]);
  13. if ($config) {
  14. $handle = Dever::load('method/' . $config['method'], 'msg');
  15. $data['account'] = $handle->init($template['id'], $config['id'], $account, $project);
  16. if ($config['test'] == 2) {
  17. $api = Dever::load('account', 'api')->get($config['api_account_id'], $project);
  18. $data['record'] = $handle->send($api, $template['content'], $param);
  19. }
  20. $data['content'] = $template['content'];
  21. Dever::db('notify', 'msg')->insert($data);
  22. }
  23. }
  24. return '通知发送成功';
  25. }
  26. }