123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253 |
- <?php
- namespace app\api\controller;
- use app\common\controller\Api;
- use app\common\model\MeetingModel;
- use app\common\model\MeetingOrder;
- use app\common\model\OfficeModel;
- use app\common\model\Park;
- use think\Db;
- /**
- * 会议室管理
- */
- class Meeting extends Api
- {
- protected $noNeedLogin = ['lists', 'parkLists', 'listInfo', 'qustion', 'qustionInfo', 'buildInfo', 'protable', 'trueTime', 'NoticeInfo', 'GgInfo'];
- protected $noNeedRight = ['*'];
- /**
- * 会议室列表
- * @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['yizi_count'] = ['between', '0,10'];
- } else if ($num == 3) {
- $mp['yizi_count'] = ['between', '10,30'];
- } else if ($num == 4) {
- $mp['yizi_count'] = ['between', '30,50'];
- } else if ($num == 5) {
- $mp['yizi_count'] = ['between', '50,100'];
- } else if ($num == 6) {
- $mp['yizi_count'] = ['between', '100,200'];
- } else if ($num == 7) {
- $mp['yizi_count'] = ['between', '200,300'];
- } else if ($num == 8) {
- $mp['yizi_count'] = ['>', '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;
- }
- $meetingModel = new MeetingModel();
- $field = 'id,image,title,mongey,mianji,address,yizi';
- $data = $meetingModel->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('缺少参数');
- $meetingModel = new MeetingModel();
- $data = $meetingModel->where('switch', 1)
- ->where('id', $id)
- ->order('sort desc')
- ->find();
- $count = count($data['gongzuori_shijina_ids']);
- $data['gongzui_start_time'] = $data['gongzuori_shijina_ids'][0];
- $data['gongzui_start_end'] = $data['gongzuori_shijina_ids'][$count-1];
- $count = count($data['xiuxiri_shijian_ids']);
- $data['xiuxi_start_time'] = $data['xiuxiri_shijian_ids'][0];
- $data['xiuxi_start_end'] = $data['xiuxiri_shijian_ids'][$count-1];
- $user = $this->auth->getUser();
- if ($user) $data['miangei_time'] = $user['edu'];
- if ($data) {
- return $this->success('', $data);
- } else {
- return $this->success('暂无数据');
- }
- }
- /**
- * 获取租赁有效时间
- * @param string $id 会议室id
- * @param string $date 所选日期 2021-03-11
- */
- public function trueTime()
- {
- $id = $this->request->get('id');
- $date = $this->request->get('date');
- if (!isset($id) || empty($id)) return $this->error('缺少参数101');
- if (!isset($date) || empty($date)) return $this->error('缺少参数102');
- $meetingModel = new MeetingModel();
- $data = $meetingModel->where('switch', 1)
- ->where('id', $id)
- ->order('sort desc')
- ->find();
- $count = count($data['gongzuori_shijina_ids']);
- $data['gongzui_start_time'] = $data['gongzuori_shijina_ids'][0];
- $data['gongzui_start_end'] = $data['gongzuori_shijina_ids'][$count-1];
- $count = count($data['xiuxiri_shijian_ids']);
- $data['xiuxi_start_time'] = $data['xiuxiri_shijian_ids'][0];
- $data['xiuxi_start_end'] = $data['xiuxiri_shijian_ids'][$count-1];
- $orderModel = new MeetingOrder();
- $order= $orderModel->with(['meeting'])
- ->where('make_day',$date)
- ->where('m_id',$id)
- ->column('make_time');
- if (empty($order)) {
- $week = date('w',strtotime($date));
- if ($week==6|| $week==0) {
- return $this->success('',$data['xiuxiri_shijian_ids']);
- } else {
- return $this->success('',$data['gongzuori_shijina_ids']);
- }
- } else {
- }
- dump($order);die;
- }
- /**
- * 预约订单信息
- * @ApiMethod (POST)
- * @param string $m_id 会议室id
- * @param string $make_day 所选日期2021-03-11
- * @param string $make_time 所选时间段多个用,号分割
- */
- public function order()
- {
- $data = $this->request->post();
- if (!isset($data['id']) || empty($data['id'])) return $this->success('参数错误101');
- if (!isset($data['make_day']) || empty($data['make_day'])) return $this->success('参数错误102');
- if (!isset($data['make_time']) || empty($data['make_time'])) return $this->success('参数错误103');
- $meetingModel = new MeetingModel();
- $data['meeting'] = $meetingModel->where('id',$data['id'])->find();
- $week = date('w',strtotime($data['make_day']));
- $countTime = count(explode(',',$data['make_time']));
- $data['langTime'] = (60*$countTime).'分钟';
- if ($week==6|| $week==0) {
- // $data['money'] =
- } else {
- return $this->success('',$data['gongzuori_shijina_ids']);
- }
- }
- }
|