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); } }