Find.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use think\Db;
  5. /**
  6. * 发现
  7. */
  8. class Find extends Api
  9. {
  10. protected $noNeedLogin = ['acvitityLists', 'Info', 'listInfo', 'qustion', 'qustionInfo', 'buildInfo', 'protable', 'trueTime', 'chooseTime', 'GgInfo'];
  11. protected $noNeedRight = ['*'];
  12. /**
  13. * 个人
  14. * @param string $search 搜索
  15. */
  16. public function gerenLists()
  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. $search = $this->request->get('search');
  28. $where = [];
  29. $our = $this->auth->getUser();
  30. if (isset($search) && !empty($search)) $where['username'] = ['like', '%' . $search . '%'];
  31. $data = Db::name('user')
  32. ->where('group_id', 0)
  33. ->where($where)
  34. ->where('id','neq',$our['id'])
  35. ->limit($pages)
  36. ->field('id,username,position,company,avatar')
  37. ->select();
  38. // $our = $this->auth->getUser();
  39. foreach ($data as $k => $v) {
  40. $data[$k]['is_guanzhu'] = 0;
  41. $isGuanzhu = Db::name('follow')->where('uid', $our['id'])->where('be_uid', $v['id'])->find();
  42. if ($isGuanzhu) {
  43. $data[$k]['is_guanzhu'] = 1;
  44. unset($data[$k]);
  45. } else {
  46. if (empty($v['company'])) {
  47. $data[$k]['company_notice'] = '';
  48. } else {
  49. $qiye = Db::name('user')->where('company', $v['company'])->where('group_id', '>', 0)->find();
  50. if ($qiye) {
  51. if ($qiye['group_id'] == 1) {
  52. $company = Db::name('user_shangjia')->where('uid', $qiye['id'])->find();
  53. if ($company) {
  54. $data[$k]['company_notice'] = $company['str'];
  55. } else {
  56. $data[$k]['company_notice'] = '';
  57. }
  58. } else {
  59. $company = Db::name('user_qiye')->where('uid', $qiye['id'])->find();
  60. if ($company) {
  61. $data[$k]['company_notice'] = $company['notice'];
  62. } else {
  63. $data[$k]['company_notice'] = '';
  64. }
  65. }
  66. } else {
  67. $data[$k]['company_notice'] = '';
  68. }
  69. }
  70. }
  71. }
  72. return json(['code' =>1 ,'data'=>$data]);
  73. return $this->success('', $data);
  74. }
  75. /**
  76. * 企业
  77. * @param string $search 搜索
  78. */
  79. public function qiyeLists()
  80. {
  81. $page = $this->request->get('page');
  82. $limit = $this->request->get('limit');
  83. if (!$page) {
  84. $pages = '0,10';
  85. } else {
  86. $page = $page - 1;
  87. if ($page < 0) $page = 0;
  88. $pages = $page . ',' . $limit;
  89. }
  90. $search = $this->request->get('search');
  91. $where = [];
  92. if (isset($search) && !empty($search)) $where['company'] = ['like', '%' . $search . '%'];
  93. $our = $this->auth->getUser();
  94. $data = Db::name('user')
  95. ->where('group_id', 2)
  96. ->where('shenhe_status', 2)
  97. ->where($where)
  98. ->where('id','neq',$our['id'])
  99. ->limit($pages)
  100. ->field('id,company')
  101. ->select();
  102. if (empty($data)) return $this->success('',[]);
  103. foreach ($data as $k => $v) {
  104. $notice = Db::name('user_qiye')->where('uid',$v['id'])->order('id desc')->find();
  105. $data[$k]['address'] = $notice['company_address'];
  106. $data[$k]['company_label'] = $notice['company_label'];
  107. $data[$k]['avatar_image'] = $notice['avatar_image'];
  108. // $data[$k]['category'] = $notice['category'];
  109. }
  110. return $this->success('',$data);
  111. }
  112. /**
  113. * 企业详情
  114. * @param string $id 企业id
  115. */
  116. public function qiyeInfo()
  117. {
  118. $id = $this->request->get('id');
  119. if (!$id) return $this->error('参数错误');
  120. $data = Db::name('user')->where('id',$id)->field('id,company,mobile')->find();
  121. $data['info'] = Db::name('user_qiye')->where('uid',$data['id'])->find();
  122. $data['fuwu_images'] = explode(',',$data['info']['fuwu_images']);
  123. $data['wall_images'] = explode(',',$data['info']['wall_images']);
  124. $our = $this->auth->getUser();
  125. $data['is_guanzhu'] = 0;
  126. $isGuanzhu = Db::name('follow')->where('uid', $our['id'])->where('be_uid', $id)->find();
  127. if ($isGuanzhu) $data['is_guanzhu'] = 1;
  128. return $this->success('',$data);
  129. }
  130. /**
  131. *
  132. * 商家列表
  133. *
  134. * @param string $search 搜索
  135. */
  136. public function shangjiaLIsts()
  137. {
  138. $page = $this->request->get('page');
  139. $limit = $this->request->get('limit');
  140. if (!$page) {
  141. $pages = '0,10';
  142. } else {
  143. $page = $page - 1;
  144. if ($page < 0) $page = 0;
  145. $pages = $page . ',' . $limit;
  146. }
  147. $search = $this->request->get('search');
  148. $where = [];
  149. if (isset($search) && !empty($search)) $where['company'] = ['like', '%' . $search . '%'];
  150. $our = $this->auth->getUser();
  151. $data = Db::name('user')
  152. ->where('group_id', 1)
  153. ->where('shenhe_status', 2)
  154. ->where($where)
  155. ->where('id','neq',$our['id'])
  156. ->limit($pages)
  157. ->field('id,company,avatar')
  158. ->select();
  159. if (empty($data)) return $this->success('',[]);
  160. foreach ($data as $k => $v) {
  161. $notice = Db::name('user_qiye')->where('uid',$v['id'])->order('id desc')->find();
  162. $data[$k]['address'] = $notice['address'];
  163. // $data[$k]['category'] = $notice['category'];
  164. }
  165. return $this->success('',$data);
  166. }
  167. /**
  168. * 商家详情
  169. * @param string $id 企业id
  170. */
  171. public function shangjiaInfo()
  172. {
  173. $id = $this->request->get('id');
  174. if (!$id) return $this->error('参数错误');
  175. $data = Db::name('user')->where('id',$id)->field('id,company,mobile,avatar')->find();
  176. $data['info'] = Db::name('user_shangjia')->where('uid',$data['id'])->find();
  177. $data['wall_images'] = explode(',',$data['info']['wall_images']);
  178. $data['str_images'] = explode(',',$data['info']['str_images']);
  179. $our = $this->auth->getUser();
  180. $data['is_guanzhu'] = 0;
  181. $isGuanzhu = Db::name('follow')->where('uid', $our['id'])->where('be_uid', $id)->find();
  182. if ($isGuanzhu) $data['is_guanzhu'] = 1;
  183. return $this->success('',$data);
  184. }
  185. }