123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\model\BusinessModel;
- use think\Db;
- /**
- * 企业服务
- */
- class Business extends Api
- {
- protected $noNeedLogin = ['lists', 'banner', 'listInfo', 'gg', 'parkMessage', 'type', 'protable', 'protableInfo', 'NoticeInfo', 'GgInfo'];
- protected $noNeedRight = ['*'];
- /**
- * 企业服务轮播图
- */
- public function banner()
- {
- $data = Db::name('business_banner')
- ->order('sort desc')
- ->select();
- if ($data) {
- foreach ($data as &$v) {
- $v['image'] = config('site.httpurl') . $v['image'];
- }
- return $this->success('', $data);
- } else {
- return $this->success('暂无数据');
- }
- }
- /**
- * 企业服务分类
- */
- public function type()
- {
- $data = Db::name('business_type')
- ->where('switch',1)
- ->order('sort desc')
- ->select();
- if ($data) {
- foreach ($data as &$v) {
- $v['image'] = config('site.httpurl') . $v['image'];
- }
- return $this->success('', $data);
- } else {
- return $this->success('暂无数据');
- }
- }
- /**
- * 企业服务列表
- * @param string $page 页数
- * @param string $limit 条数
- * @param string $type 分类id
- */
- public function lists()
- {
- $page = $this->request->get('page');
- $limit = $this->request->get('limit');
- $type = $this->request->get('type');
- if (!$page) {
- $pages = '0,10';
- } else {
- $page = $page - 1;
- if ($page < 0) $page = 0;
- $pages = $page . ',' . $limit;
- }
- $businessModel = new BusinessModel();
- $data = $businessModel->where('switch', 1)
- ->where('type_id',$type)
- ->order('sort desc')
- ->limit($pages)
- ->select();
- if ($data) {
- return $this->success('', $data);
- } else {
- return $this->success('暂无数据');
- }
- }
- /**
- * 企业服务详情
- * @param string $id id
- *
- */
- public function listInfo()
- {
- $id = $this->request->get('id');
- if (!isset($id) || empty($id)) return $this->error('缺少参数');
- $businessModel = new BusinessModel();
- $data = $businessModel
- ->where('id', $id)
- ->where('switch', 1)
- ->order('sort desc')
- ->find();
- if ($data) {
- return $this->success('', $data);
- } else {
- return $this->success('暂无数据');
- }
- }
- /**
- * 政策入住申请
- * @ApiMethod (POST)
- * @param string $lid id
- * @param string $name id
- * @param string $mobile id
- * @param string $notice id
- *
- */
- public function declare()
- {
- $data = $this->request->post();
- if (!isset($data['lid']) || empty($data['lid'])) return $this->error('参数错误');
- if (!isset($data['name']) || empty($data['name'])) return $this->error('请输入姓名');
- if (!isset($data['mobile']) || empty($data['mobile'])) return $this->error('请输入手机号');
- if (!isset($data['notice']) || empty($data['notice'])) return $this->error('请输入具体需求');
- $user = $this->auth->getUser();
- if (!$user) return $this->error(__('Please login first'), null, 401);
- $data['uid'] = $user['id'];
- $data['create_time'] = date('Y-m-d H:i:s',time());
- $isert = Db::name('business_declare')->where('uid',$user['id'])->where('lid',$data['lid'])->find();
- if ($isert) return $this->error('您已经申请过了');
- $add = Db::name('business_declare')->insert($data);
- if ($add ) {
- $id = Db::name('business_declare')->getLastInsID();
- $data['id'] = $id;
- return $this->success('提交成功',$data);
- } else {
- return $this->error('提交失败');
- }
- }
- /**
- * 申报返回数据
- * @param string $id 注册返回的id
- */
- public function shenbaoInfo()
- {
- $data = $this->request->param();
- if (!isset($data['id']) || empty($data['id'])) return $this->error('参数错误');
- $res = Db::name('business_declare')->where('id',$data['id'])->find();
- return $this->success('',$res);
- }
- }
|