UserNotice.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2020 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. $model = new self;
  29. $model->order('id desc');
  30. if(!empty($where)){
  31. $data=($data=$model->page((int)$where['page'],(int)$where['limit'])->select()) && count($data) ? $data->toArray() : [];
  32. foreach ($data as &$item){
  33. if($item["uid"] != ''){
  34. $uids = explode(",",$item["uid"]);
  35. array_splice($uids,0,1);
  36. array_splice($uids,count($uids)-1,1);
  37. $item["uid"] = $uids;
  38. }
  39. $item['send_time']=date('Y-m-d H:i:s',$item['send_time']);
  40. }
  41. $count=self::count();
  42. return compact('data','count');
  43. }
  44. return self::page($model,function($item,$key){
  45. if($item["uid"] != ''){
  46. $uids = explode(",",$item["uid"]);
  47. array_splice($uids,0,1);
  48. array_splice($uids,count($uids)-1,1);
  49. $item["uid"] = $uids;
  50. }
  51. });
  52. }
  53. /**
  54. * 获取用户通知
  55. * @param array $where
  56. * @return array
  57. */
  58. public static function getUserList($where = array()){
  59. $model = new self;
  60. if(isset($where['title']) && $where['title'] != '') $model = $model->where('title','LIKE',"%".$where['title']."%");
  61. $model = $model->where('type',2);
  62. $model = $model->where('is_send',0);
  63. $model = $model->order('id desc');
  64. return self::page($model,$where);
  65. }
  66. }