海南旅游SAAS
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.

47 lines
1.1 KiB

  1. <?php
  2. namespace App\Service\Admin;
  3. use App\Models\WorkorderItem;
  4. use App\Traits\DemandTraits;
  5. use Dcat\Admin\Admin;
  6. use Illuminate\Support\Facades\Cache;
  7. use Illuminate\Support\Facades\DB;
  8. /**
  9. * 全局通知-后台
  10. * Class GlobalNoticeService
  11. * @package App\Service
  12. */
  13. class GlobalNoticeService
  14. {
  15. public function unreadWOrder($pointType)
  16. {
  17. $cacheNotice = Cache::get('w_order_notice', '[]');
  18. $cacheNoticeIds = json_decode($cacheNotice, true);
  19. $res = WorkorderItem::query()
  20. ->has('workorder')
  21. ->where(function ($query) use ($pointType) {
  22. $query->where('point_id',Admin::user()->id)
  23. ->where('point_type',$pointType);
  24. })
  25. ->where('is_read', 0)
  26. ->whereIn('id', $cacheNoticeIds)
  27. ->pluck('id')
  28. ->toArray();
  29. $cacheNoticeIds = array_diff($cacheNoticeIds, $res);
  30. Cache::forever('w_order_notice', json_encode($cacheNoticeIds));
  31. return empty($res) ? 0 : 1;
  32. }
  33. public function cacheWOrderNotice($id)
  34. {
  35. $cacheNotice = Cache::get('w_order_notice', '[]');
  36. $cacheNoticeIds = json_decode($cacheNotice, true);
  37. $cacheNoticeIds[] = $id;
  38. Cache::forever('w_order_notice', json_encode($cacheNoticeIds));
  39. }
  40. }