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.
|
|
<?php
namespace App\Service\Admin;
use App\Models\WorkorderItem;use App\Traits\DemandTraits;use Dcat\Admin\Admin;use Illuminate\Support\Facades\Cache;use Illuminate\Support\Facades\DB;
/** * 全局通知-后台 * Class GlobalNoticeService * @package App\Service */class GlobalNoticeService{ public function unreadWOrder($pointType) {
$cacheNotice = Cache::get('w_order_notice', '[]'); $cacheNoticeIds = json_decode($cacheNotice, true);
$builder = WorkorderItem::query() ->has('workorder') ->where(function ($query) use ($pointType) { $query->where('point_id',Admin::user()->id) ->where('point_type',$pointType); }) ->where('is_read', 0);
$count = $builder->count();
$res = $builder ->whereIn('id', $cacheNoticeIds) ->pluck('id') ->toArray();
$cacheNoticeIds = array_diff($cacheNoticeIds, $res); Cache::forever('w_order_notice', json_encode($cacheNoticeIds)); $notice = empty($res) ? 0 : 1; return json_encode(['notice' => $notice, 'badge' => $count]); }
public function cacheWOrderNotice($id) { $cacheNotice = Cache::get('w_order_notice', '[]'); $cacheNoticeIds = json_decode($cacheNotice, true); $cacheNoticeIds[] = $id; Cache::forever('w_order_notice', json_encode($cacheNoticeIds)); }}
|