123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\common\logic;
-
- use app\common\basics\Logic;
- use app\common\enum\NoticeEnum;
- use app\common\model\Notice;
- use app\common\server\ConfigServer;
- use app\common\server\UrlServer;
-
-
- class SystemNoticeLogic extends Logic
- {
-
-
- public static function index($user_id)
- {
-
- $server = Notice::where([
- ['user_id', '=', $user_id],
- ['send_type', '=', NoticeEnum::SYSTEM_NOTICE],
- ['scene', 'not in', [NoticeEnum::GET_EARNINGS_NOTICE, NoticeEnum::GET_FUTURE_EARNINGS_NOTICE]],
- ])->order('id desc')->find();
-
-
- $earning = Notice::where([
- ['user_id', '=', $user_id],
- ['send_type', '=', NoticeEnum::SYSTEM_NOTICE],
- ['scene', 'in', [NoticeEnum::GET_EARNINGS_NOTICE, NoticeEnum::GET_FUTURE_EARNINGS_NOTICE]],
- ])->order('id desc')->find();
-
- $data['system'] = [
- 'title' => '系统通知',
- 'content' => $server['content'] ?? '暂无系统消息',
- 'img' => UrlServer::getFileUrl(ConfigServer::get('website', 'system_notice')),
- 'type' => 'system',
- ];
- $data['earning'] = [
- 'title' => '收益通知',
- 'content' => $earning['content'] ?? '暂无收益消息',
- 'img' => UrlServer::getFileUrl(ConfigServer::get('website', 'earning_notice')),
- 'type' => 'earning',
- ];
- $res = array_values($data);
- return $res;
- }
-
-
-
-
-
- public static function lists($user_id, $type, $page, $size)
- {
- $where = [];
- $where[] = ['user_id', '=', $user_id];
- $where[] = ['send_type', '=', NoticeEnum::SYSTEM_NOTICE];
-
- if ($type == 'earning') {
- $where[] = ['scene', 'in', [NoticeEnum::GET_EARNINGS_NOTICE, NoticeEnum::GET_FUTURE_EARNINGS_NOTICE]];
- } else {
- $where[] = ['scene', 'not in', [NoticeEnum::GET_EARNINGS_NOTICE, NoticeEnum::GET_FUTURE_EARNINGS_NOTICE]];
- }
-
- $count = Notice::where($where)->count();
- $lists = Notice::where($where)
- ->order('id desc')
- ->page($page, $size)
- ->select();
-
-
- Notice::where($where)
- ->where('read', '<>', 1)
- ->update(['read' => 1]);
-
- return [
- 'list' => $lists,
- 'page' => $page,
- 'size' => $size,
- 'count' => $count,
- 'more' => is_more($count, $page, $size)
- ];
- }
-
-
-
-
- public static function unRead($user_id)
- {
- $un_read = Notice::where([
- 'user_id' => $user_id,
- 'read' => 0,
- 'send_type' => NoticeEnum::SYSTEM_NOTICE
- ])->find();
- if ($un_read) {
- return true;
- }
- return false;
- }
- }
|