Live.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. namespace app\job\event;
  3. use app\common\enum\settings\SettingEnum;
  4. use app\common\model\plus\live\WxLive as WxLiveModel;
  5. use app\common\model\settings\Setting as SettingModel;
  6. use think\facade\Cache;
  7. /**
  8. * 用户等级事件管理
  9. */
  10. class Live
  11. {
  12. /**
  13. * 执行函数
  14. */
  15. public function handle($app_id)
  16. {
  17. try {
  18. $cacheKey = "task_space_Live_".$app_id;
  19. if (!Cache::has($cacheKey)) {
  20. $auto_syn = SettingModel::getItem(SettingEnum::LIVE, $app_id)['auto_syn'];
  21. if($auto_syn){
  22. $model = new WxLiveModel();
  23. $model->syn($app_id);
  24. }
  25. Cache::set($cacheKey, time(), 120);
  26. }
  27. log_write('Live TASK : ' . $app_id . '__success', 'task');
  28. } catch (\Throwable $e) {
  29. echo 'ERROR Live: ' . $e->getMessage() . PHP_EOL;
  30. log_write('Live TASK : ' . $app_id . '__ ' . $e->getMessage(), 'task');
  31. }
  32. return true;
  33. }
  34. }