浏览代码

园区模糊搜索

chenhao 4 年之前
父节点
当前提交
82cb09e981

+ 97 - 1
application/api/controller/Meeting.php

@@ -4,15 +4,17 @@ 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', 'cityLists', 'NoticeInfo', 'GgInfo'];
+    protected $noNeedLogin = ['lists', 'parkLists', 'listInfo', 'qustion', 'qustionInfo', 'buildInfo', 'protable', 'trueTime', 'NoticeInfo', 'GgInfo'];
     protected $noNeedRight = ['*'];
     /**
      * 会议室列表
@@ -153,5 +155,99 @@ class Meeting extends Api
             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']);
+        }
+
+
+
+
+    }
 }

+ 1 - 1
application/common/controller/Api.php

@@ -115,7 +115,7 @@ class Api
             $this->auth->init($token);
             //检测是否登录
             if (!$this->auth->isLogin()) {
-                $this->error(__('Please login first'), null, 401);
+                $this->error(__('Please login first'), null, 100);
             }
             // 判断是否需要验证权限
             if (!$this->auth->match($this->noNeedRight)) {

+ 19 - 0
application/common/model/MeetingOrder.php

@@ -0,0 +1,19 @@
+<?php
+
+namespace app\common\model;
+
+use think\Cache;
+use think\Model;
+
+/**
+ * 会议室订单模型
+ */
+class MeetingOrder extends Model
+{
+    protected $name = 'meeting_order';
+
+    public function meeting()
+    {
+        return $this->belongsTo('MeetingModel','m_id','id');
+    }
+}