1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\common\logic;
-
-
- use app\common\basics\Logic;
- use app\common\cache\CommunityArticleCache;
- use app\common\enum\CommunityArticleEnum;
- use app\common\model\community\CommunityFollow;
-
-
- class CommunityArticleLogic extends Logic
- {
-
-
-
- public static function noticeFans($user_id, $status)
- {
- if ($status != CommunityArticleEnum::STATUS_SUCCESS) {
- return true;
- }
-
- $fans = CommunityFollow::where(['follow_id' => $user_id, 'status' => 1])
- ->column('user_id');
-
- if (empty($fans)) {
- return true;
- }
-
-
- foreach ($fans as $item) {
- $cache = new CommunityArticleCache('unread_user'. $item, ['has_new' => 1]);
- $cache->set();
- }
- return true;
- }
-
-
-
-
- public static function hasNew($user_id)
- {
- if (empty($user_id)) {
- return 0;
- }
- $cache = new CommunityArticleCache('unread_user'. $user_id);
- $isEmpty = $cache->isEmpty();
- return !$isEmpty ? 1 : 0;
- }
-
-
-
-
- public static function delUnRead($user_id)
- {
- $cache = new CommunityArticleCache('unread_user'. $user_id);
- return $cache->del();
- }
-
- }
|