123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use think\Db;
- /**
- * 发现
- */
- class Find extends Api
- {
- protected $noNeedLogin = ['acvitityLists', 'Info', 'listInfo', 'qustion', 'qustionInfo', 'buildInfo', 'protable', 'trueTime', 'chooseTime', 'GgInfo'];
- protected $noNeedRight = ['*'];
- /**
- * 个人
- * @param string $search 搜索
- */
- public function gerenLists()
- {
- $page = $this->request->get('page');
- $limit = $this->request->get('limit');
- if (!$page) {
- $pages = '0,10';
- } else {
- $page = $page - 1;
- if ($page < 0) $page = 0;
- $pages = $page . ',' . $limit;
- }
- $search = $this->request->get('search');
- $where = [];
- $our = $this->auth->getUser();
- if (isset($search) && !empty($search)) $where['username'] = ['like', '%' . $search . '%'];
- $data = Db::name('user')
- ->where('group_id', 0)
- ->where($where)
- ->where('id','neq',$our['id'])
- ->limit($pages)
- ->field('id,username,position,company,avatar')
- ->select();
- // $our = $this->auth->getUser();
- foreach ($data as $k => $v) {
- $data[$k]['is_guanzhu'] = 0;
- $isGuanzhu = Db::name('follow')->where('uid', $our['id'])->where('be_uid', $v['id'])->find();
- if ($isGuanzhu) {
- $data[$k]['is_guanzhu'] = 1;
- unset($data[$k]);
- } else {
- if (empty($v['company'])) {
- $data[$k]['company_notice'] = '';
- } else {
- $qiye = Db::name('user')->where('company', $v['company'])->where('group_id', '>', 0)->find();
- if ($qiye) {
- if ($qiye['group_id'] == 1) {
- $company = Db::name('user_shangjia')->where('uid', $qiye['id'])->find();
- if ($company) {
- $data[$k]['company_notice'] = $company['str'];
- } else {
- $data[$k]['company_notice'] = '';
- }
- } else {
- $company = Db::name('user_qiye')->where('uid', $qiye['id'])->find();
- if ($company) {
- $data[$k]['company_notice'] = $company['notice'];
- } else {
- $data[$k]['company_notice'] = '';
- }
- }
- } else {
- $data[$k]['company_notice'] = '';
- }
- }
- }
- }
- return json(['code' =>1 ,'data'=>$data]);
- return $this->success('', $data);
- }
- /**
- * 企业
- * @param string $search 搜索
- */
- public function qiyeLists()
- {
- $page = $this->request->get('page');
- $limit = $this->request->get('limit');
- if (!$page) {
- $pages = '0,10';
- } else {
- $page = $page - 1;
- if ($page < 0) $page = 0;
- $pages = $page . ',' . $limit;
- }
- $search = $this->request->get('search');
- $where = [];
- if (isset($search) && !empty($search)) $where['company'] = ['like', '%' . $search . '%'];
- $our = $this->auth->getUser();
- $data = Db::name('user')
- ->where('group_id', 2)
- ->where('shenhe_status', 2)
- ->where($where)
- ->where('id','neq',$our['id'])
- ->limit($pages)
- ->field('id,company')
- ->select();
- if (empty($data)) return $this->success('',[]);
- foreach ($data as $k => $v) {
- $notice = Db::name('user_qiye')->where('uid',$v['id'])->order('id desc')->find();
- $data[$k]['address'] = $notice['company_address'];
- $data[$k]['company_label'] = $notice['company_label'];
- $data[$k]['avatar_image'] = $notice['avatar_image'];
- // $data[$k]['category'] = $notice['category'];
- }
- return $this->success('',$data);
- }
- /**
- * 企业详情
- * @param string $id 企业id
- */
- public function qiyeInfo()
- {
- $id = $this->request->get('id');
- if (!$id) return $this->error('参数错误');
- $data = Db::name('user')->where('id',$id)->field('id,company,mobile')->find();
- $data['info'] = Db::name('user_qiye')->where('uid',$data['id'])->find();
- $data['fuwu_images'] = explode(',',$data['info']['fuwu_images']);
- $data['wall_images'] = explode(',',$data['info']['wall_images']);
- $our = $this->auth->getUser();
- $data['is_guanzhu'] = 0;
- $isGuanzhu = Db::name('follow')->where('uid', $our['id'])->where('be_uid', $id)->find();
- if ($isGuanzhu) $data['is_guanzhu'] = 1;
- return $this->success('',$data);
- }
- /**
- *
- * 商家列表
- *
- * @param string $search 搜索
- */
- public function shangjiaLIsts()
- {
- $page = $this->request->get('page');
- $limit = $this->request->get('limit');
- if (!$page) {
- $pages = '0,10';
- } else {
- $page = $page - 1;
- if ($page < 0) $page = 0;
- $pages = $page . ',' . $limit;
- }
- $search = $this->request->get('search');
- $where = [];
- if (isset($search) && !empty($search)) $where['company'] = ['like', '%' . $search . '%'];
- $our = $this->auth->getUser();
- $data = Db::name('user')
- ->where('group_id', 1)
- ->where('shenhe_status', 2)
- ->where($where)
- ->where('id','neq',$our['id'])
- ->limit($pages)
- ->field('id,company,avatar')
- ->select();
- if (empty($data)) return $this->success('',[]);
- foreach ($data as $k => $v) {
- $notice = Db::name('user_qiye')->where('uid',$v['id'])->order('id desc')->find();
- $data[$k]['address'] = $notice['address'];
- // $data[$k]['category'] = $notice['category'];
- }
- return $this->success('',$data);
- }
- /**
- * 商家详情
- * @param string $id 企业id
- */
- public function shangjiaInfo()
- {
- $id = $this->request->get('id');
- if (!$id) return $this->error('参数错误');
- $data = Db::name('user')->where('id',$id)->field('id,company,mobile,avatar')->find();
- $data['info'] = Db::name('user_shangjia')->where('uid',$data['id'])->find();
- $data['wall_images'] = explode(',',$data['info']['wall_images']);
- $data['str_images'] = explode(',',$data['info']['str_images']);
- $our = $this->auth->getUser();
- $data['is_guanzhu'] = 0;
- $isGuanzhu = Db::name('follow')->where('uid', $our['id'])->where('be_uid', $id)->find();
- if ($isGuanzhu) $data['is_guanzhu'] = 1;
- return $this->success('',$data);
- }
- }
|