UserNotice.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\admin\model\user;
  12. use app\admin\model\wechat\WechatUser;
  13. use app\admin\model\user\UserNoticeSee;
  14. use traits\ModelTrait;
  15. use basic\ModelBasic;
  16. /**
  17. * 用户通知 model
  18. * Class UserNotice
  19. * @package app\admin\model\user
  20. */
  21. class UserNotice extends ModelBasic
  22. {
  23. use ModelTrait;
  24. /**
  25. * @return array
  26. */
  27. public static function getList($where = [])
  28. {
  29. $model = new self;
  30. $model->order('id desc');
  31. if (!empty($where)) {
  32. $data = ($data = $model->page((int)$where['page'], (int)$where['limit'])->select()) && count($data) ? $data->toArray() : [];
  33. foreach ($data as &$item) {
  34. if ($item["uid"] != '') {
  35. $uids = explode(",", $item["uid"]);
  36. array_splice($uids, 0, 1);
  37. array_splice($uids, count($uids) - 1, 1);
  38. $item["uid"] = $uids;
  39. }
  40. $item['send_time'] = date('Y-m-d H:i:s', $item['send_time']);
  41. }
  42. $count = self::count();
  43. return compact('data', 'count');
  44. }
  45. return self::page($model, function ($item, $key) {
  46. if ($item["uid"] != '') {
  47. $uids = explode(",", $item["uid"]);
  48. array_splice($uids, 0, 1);
  49. array_splice($uids, count($uids) - 1, 1);
  50. $item["uid"] = $uids;
  51. }
  52. });
  53. }
  54. /**
  55. * 获取用户通知
  56. * @param array $where
  57. * @return array
  58. */
  59. public static function getUserList($where = array())
  60. {
  61. $model = new self;
  62. if (isset($where['title']) && $where['title'] != '') $model = $model->where('title', 'LIKE', "%" . $where['title'] . "%");
  63. $model = $model->where('type', 2);
  64. $model = $model->where('is_send', 0);
  65. $model = $model->order('id desc');
  66. return self::page($model, $where);
  67. }
  68. }