Notification.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace addons\shopro\controller;
  3. use addons\shopro\exception\Exception;
  4. use addons\shopro\model\NotificationConfig;
  5. use think\Cache;
  6. class Notification extends Base
  7. {
  8. protected $noNeedLogin = ['*'];
  9. protected $noNeedRight = ['*'];
  10. public function template()
  11. {
  12. $platform = request()->header('platform');
  13. $templates = [];
  14. if (in_array($platform, ['wxMiniProgram', 'wxOfficialAccount'])) {
  15. $platform = $platform == 'wxOfficialAccount' ? 'wxOfficialAccountBizsend' : $platform;
  16. // 获取订阅消息模板
  17. $notificationConfig = NotificationConfig::cache(300)->where('platform', $platform)->select();
  18. foreach ($notificationConfig as $k => $config) {
  19. if ($config['status'] && $config['content_arr'] && $config['content_arr']['template_id']) {
  20. $templates[$config['event']] = $config['content_arr']['template_id'];
  21. }
  22. }
  23. }
  24. $this->success('获取成功', $templates);
  25. }
  26. }