0
0

Notice.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. namespace app\common\model;
  3. use think\Db;
  4. class Notice extends Base
  5. {
  6. public function lists($page,$size,$userId,$orgId){
  7. $createYmd = Db::name('notice')
  8. ->field('create_yyyymmdd')
  9. ->where('org_id',$orgId)
  10. ->where('del',0)
  11. ->where('user_id',$userId)
  12. ->group('create_yyyymmdd')
  13. ->order('create_yyyymmdd desc')
  14. ->page($page,$size)
  15. ->select();
  16. $ret = [];
  17. foreach ($createYmd as $k=>$v) {
  18. $lists = Db::name('notice')
  19. ->alias('n')
  20. ->field('n.id,n.create_time,n.is_read,n.create_yyyymmdd,n.title,nc.name')
  21. ->join('notice_cate nc','nc.id=n.cate_id')
  22. ->where('n.org_id',$orgId)
  23. ->where('n.user_id',$userId)
  24. ->where('n.del',0)
  25. ->where('n.create_yyyymmdd',$v['create_yyyymmdd'])
  26. ->select();
  27. $ret[$v['create_yyyymmdd']]=$lists;
  28. }
  29. return $ret;
  30. }
  31. public function details($id){
  32. $ret = Db::name('notice')
  33. ->where('id',$id)
  34. ->find();
  35. if($ret){
  36. $ret['real_name'] = Db::name('user')->where('id',$ret['create_user_id'])->value('real_name');
  37. if($ret['is_read'] == 0){
  38. Db::name('notice')->where('id',$id)->update(['is_read'=>1]);
  39. }
  40. }
  41. return $ret;
  42. }
  43. }