Message.php 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\model\CommunityModel;
  5. use think\Db;
  6. /**
  7. * 消息通知
  8. */
  9. class Message extends Api
  10. {
  11. protected $noNeedLogin = ['acvitityLists', 'Info', 'listInfo', 'qustion', 'qustionInfo', 'buildInfo', 'protable', 'trueTime', 'chooseTime', 'GgInfo'];
  12. protected $noNeedRight = ['*'];
  13. /**
  14. * 论坛动态
  15. */
  16. public function luntan()
  17. {
  18. $page = $this->request->get('page');
  19. $limit = $this->request->get('limit');
  20. if (!$page) {
  21. $pages = '0,10';
  22. } else {
  23. $page = $page - 1;
  24. if ($page < 0) $page = 0;
  25. $pages = $page . ',' . $limit;
  26. }
  27. $user = $this->auth->getUser();
  28. if ($user['luntan']==0) return $this->success('',[]);
  29. $userCommunity = CommunityModel::where('uid',$user['id'])->column('id');
  30. $str = implode(',',$userCommunity);
  31. $comment = Db::name('community_comment')
  32. ->where('c_id',"in",$str)
  33. ->limit($pages)
  34. ->order('create_time desc')->select();
  35. if (empty($comment)) return $this->success('',$comment);
  36. foreach ($comment as $k=>$v) {
  37. $comment[$k]['user'] = Db::name('user')->where('id',$v['uid'])
  38. ->where('status',1)
  39. ->field('id,avatar,username')
  40. ->find();
  41. }
  42. return json(['code'=>1,'data'=>$comment]);
  43. }
  44. /**
  45. * 活动动态
  46. */
  47. public function huodong()
  48. {
  49. $user = $this->auth->getUser();
  50. if ($user['huodong']==0) return $this->success('',[]);
  51. $data1 = Db::name('park_order o')
  52. ->join('park_activity a','o.a_id=a.id')
  53. ->where('o.uid',$user['id'])
  54. ->order('o.create_time desc')
  55. ->field('a.id,a.image')
  56. ->select();
  57. if (!empty($data1)) {
  58. foreach ($data1 as $k=>$v) {
  59. $data1[$k]['image'] = config('site.httpurl').$data1[$k]['image'];
  60. $data1[$k]['type'] = 1;
  61. }
  62. }
  63. $data2 = Db::name('acitivity_order o')
  64. ->join('avcitity a','o.a_id=a.id')
  65. ->where('o.uid',$user['id'])
  66. ->order('o.create_time desc')
  67. ->field('a.id,a.image')
  68. ->select();
  69. if (!empty($data2)) {
  70. foreach ($data2 as $m=>$n) {
  71. // $data2[$m]['image'] = config('site.httpurl').$data2[$m]['image'];
  72. $data2[$m]['type'] = 2;
  73. }
  74. }
  75. $data = array_merge($data1,$data2);
  76. return json(['code' =>1 ,'data'=>$data]);
  77. }
  78. /**
  79. * 服务动态
  80. */
  81. public function fuwu()
  82. {
  83. $page = $this->request->get('page');
  84. $limit = $this->request->get('limit');
  85. if (!$page) {
  86. $pages = '0,10';
  87. } else {
  88. $page = $page - 1;
  89. if ($page < 0) $page = 0;
  90. $pages = $page . ',' . $limit;
  91. }
  92. $user = $this->auth->getUser();
  93. if ($user['huodong']==0) return $this->success('',[]);
  94. $data = Db::name('business_declare d')
  95. ->join('business_lists l','d.lid=l.id')
  96. ->where('d.uid',$user['id'])
  97. ->limit($pages)
  98. ->order('d.create_time desc')
  99. ->field('l.id,l.image,l.title')
  100. ->select();
  101. if (empty($data)) return $this->success('',[]);
  102. foreach ( $data as $k=>$v) {
  103. $data[$k]['image'] = config('site.httpurl'). $data[$k]['image'];
  104. }
  105. return $this->success('',$data);
  106. }
  107. /**
  108. * 平台信息
  109. */
  110. public function pingtai()
  111. {
  112. $page = $this->request->get('page');
  113. $limit = $this->request->get('limit');
  114. if (!$page) {
  115. $pages = '0,10';
  116. } else {
  117. $page = $page - 1;
  118. if ($page < 0) $page = 0;
  119. $pages = $page . ',' . $limit;
  120. }
  121. $data = Db::name('admin_message')->limit($pages)->order('create_time desc')->select();
  122. return $this->success('',$data);
  123. }
  124. }