123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\model\BuildingModel;
- use app\common\model\BusinessModel;
- use app\common\model\OfficeModel;
- use app\common\model\OfficeOrderModel;
- use app\common\model\Park;
- use think\Db;
- /**
- * 租赁管理
- */
- class Office extends Api
- {
- protected $noNeedLogin = ['lists', 'parkLists', 'listInfo', 'qustion', 'qustionInfo', 'buildInfo', 'protable', 'cityLists', 'NoticeInfo', 'GgInfo'];
- protected $noNeedRight = ['*'];
- /**
- * 园区列表
- */
- public function parkLists()
- {
- $parkModel = Park::where('switch', 1)->order('sort desc')->select();
- if ($parkModel) {
- return $this->success('', $parkModel);
- } else {
- return $this->success('暂无园区', []);
- }
- }
- /**
- * 搜索数据
- */
- public function cityLists()
- {
- $data['area'] = Db::name('city')->order('eng asc')->select();
- $data['num'] = [
- ['label' => "全部", 'value' => 1],
- ['label' => "0-10座", 'value' => 2],
- ['label' => "10-30座", 'value' => 3],
- ['label' => "30-50座", 'value' => 4],
- ['label' => "20-100座", 'value' => 5],
- ['label' => "100-200座", 'value' => 6],
- ['label' => "200-300座", 'value' => 7],
- ['label' => "300座以上", 'value' => 8],
- ];
- $data['money'] = [
- ['label' => "全部", 'value' => 1],
- ['label' => "0-100/60分钟", 'value' => 2],
- ['label' => "100-200/60分钟", 'value' => 3],
- ['label' => "200-500/60分钟", 'value' => 4],
- ['label' => "500-1000/60分钟", 'value' => 5],
- ['label' => "1000+/60分钟", 'value' => 6],
- ];
- return $this->success('', $data);
- }
- /**
- * 办公室列表
- * @param string $page 页数
- * @param string $limit 条数
- * @param string $area_name 条数
- * @param string $area_id 地区id
- * @param string $num 座位
- * @param string $money 租金
- */
- public function lists()
- {
- $page = $this->request->get('page');
- $limit = $this->request->get('limit');
- $area_name = $this->request->get('area_name');
- $area_id = $this->request->get('area_id');
- $num = $this->request->get('num');
- $money = $this->request->get('money');
- $mp = [];
- if (isset($area_id) && !empty($area_id)) $mp['c_id'] = $area_id;
- if (isset($area_name) && !empty($area_name)) {
- $name = Park::where('name','like','%'.$area_name.'%')->column('id');
- $idStr = implode(',',$name);
- if (!empty($idStr)) {
- $mp['p_id'] = ['in',$idStr];
- } else {
- $mp['p_id'] = 0;
- }
- };
- if (isset($num) && !empty($num)) {
- if ($num == 2) {
- $mp['num'] = ['between', '0,10'];
- } else if ($num == 3) {
- $mp['num'] = ['between', '10,30'];
- } else if ($num == 4) {
- $mp['num'] = ['between', '30,50'];
- } else if ($num == 5) {
- $mp['num'] = ['between', '50,100'];
- } else if ($num == 6) {
- $mp['num'] = ['between', '100,200'];
- } else if ($num == 7) {
- $mp['num'] = ['between', '200,300'];
- } else if ($num == 8) {
- $mp['num'] = ['>', '300'];
- }
- }
- if (isset($money) && !empty($money)) {
- if ($money == 2) {
- $mp['money_num'] = ['between', '0,100'];
- } else if ($money == 3) {
- $mp['money_num'] = ['between', '100,200'];
- } else if ($num == 4) {
- $mp['money_num'] = ['between', '200,500'];
- } else if ($money == 5) {
- $mp['money_num'] = ['between', '500,1000'];
- } else if ($money == 6) {
- $mp['money_num'] = ['>', '1000'];
- }
- }
- if (empty($area_name)) {
- $user = $this->auth->getUser();
- if ($user && $user['p_id'] != 0) $mp['p_id'] = $user['p_id'];
- };
- $mp['switch'] = 1;
- if (!$page) {
- $pages = '0,10';
- } else {
- $page = $page - 1;
- if ($page < 0) $page = 0;
- $pages = $page . ',' . $limit;
- }
- $officeModel = new OfficeModel();
- $field = 'id,image,title,money,wuye,mianji,address,num';
- $data = $officeModel->where($mp)->limit($pages)->field($field)->order('sort desc')->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('缺少参数');
- $officeModel = new OfficeModel();
- $data = $officeModel->where('switch', 1)
- ->where('id', $id)
- ->order('sort desc')
- ->find();
- if ($data) {
- return $this->success('', $data);
- } else {
- return $this->success('暂无数据');
- }
- }
- /**
- * 租办公室
- * @param string $oid 办公室id
- * @param string $name 用户
- * @param string $phone 手机号
- */
- public function order()
- {
- $oid = $this->request->get('oid');
- $name = $this->request->get('name');
- $phone = $this->request->get('phone');
- if (!isset($oid) || empty($oid)) return $this->error('参数错误');
- if (!isset($name) || empty($name)) return $this->error('参数错误');
- if (!isset($phone) || empty($phone)) return $this->error('参数错误');
- $user = $this->auth->getUser();
- $year = date('Y', time());
- $month = date('m', time());
- $day = date('d', time());
- $data = [
- 'uid' => $user['id'],
- 'oid' => $oid,
- 'name' => $name,
- 'phone' => $phone,
- 'create_time' => date('Y-m-d H:i:s', time()),
- 'number' => $year . $month . $day . 'N' . rand(0, 10000),
- ];
- $model = new OfficeOrderModel();
- $ins = $model->save($data);
- if ($ins) {
- $id = $model->getLastInsID();
- return $this->success('申请成功', ['id' => $id]);
- } else {
- return $this->error('申请失败哦!', ['id' => 0]);
- }
- }
- /**
- * 成功返回数据
- * @param string $id 订单id
- */
- public function orderInfo()
- {
- $id = $this->request->get('id');
- if (!isset($id) || empty($id)) return $this->error('参数错误');
- $model = new OfficeOrderModel();
- $data = $model
- ->with(['office'])
- ->where('id', $id)
- ->select();
- return $this->success('', $data);
- }
- }
|