Meeting.php 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. <?php
  2. namespace app\api\controller;
  3. use app\common\controller\Api;
  4. use app\common\model\MeetingModel;
  5. use app\common\model\MeetingOrder;
  6. use app\common\model\OfficeModel;
  7. use app\common\model\Park;
  8. use think\Db;
  9. /**
  10. * 会议室管理
  11. */
  12. class Meeting extends Api
  13. {
  14. protected $noNeedLogin = ['lists', 'parkLists', 'listInfo', 'qustion', 'qustionInfo', 'buildInfo', 'protable', 'trueTime', 'NoticeInfo', 'GgInfo'];
  15. protected $noNeedRight = ['*'];
  16. /**
  17. * 会议室列表
  18. * @param string $page 页数
  19. * @param string $limit 条数
  20. * @param string $area_name 条数
  21. * @param string $area_id 地区id
  22. * @param string $num 座位
  23. * @param string $money 租金
  24. */
  25. public function lists()
  26. {
  27. $page = $this->request->get('page');
  28. $limit = $this->request->get('limit');
  29. $area_name = $this->request->get('area_name');
  30. $area_id = $this->request->get('area_id');
  31. $num = $this->request->get('num');
  32. $money = $this->request->get('money');
  33. $mp = [];
  34. if (isset($area_id) && !empty($area_id)) $mp['c_id'] = $area_id;
  35. if (isset($area_name) && !empty($area_name)) {
  36. $name = Park::where('name','like','%'.$area_name.'%')->column('id');
  37. $idStr = implode(',',$name);
  38. if (!empty($idStr)) {
  39. $mp['p_id'] = ['in',$idStr];
  40. } else {
  41. $mp['p_id'] = 0;
  42. }
  43. };
  44. if (isset($num) && !empty($num)) {
  45. if ($num == 2) {
  46. $mp['yizi_count'] = ['between', '0,10'];
  47. } else if ($num == 3) {
  48. $mp['yizi_count'] = ['between', '10,30'];
  49. } else if ($num == 4) {
  50. $mp['yizi_count'] = ['between', '30,50'];
  51. } else if ($num == 5) {
  52. $mp['yizi_count'] = ['between', '50,100'];
  53. } else if ($num == 6) {
  54. $mp['yizi_count'] = ['between', '100,200'];
  55. } else if ($num == 7) {
  56. $mp['yizi_count'] = ['between', '200,300'];
  57. } else if ($num == 8) {
  58. $mp['yizi_count'] = ['>', '300'];
  59. }
  60. }
  61. if (isset($money) && !empty($money)) {
  62. if ($money == 2) {
  63. $mp['money_num'] = ['between', '0,100'];
  64. } else if ($money == 3) {
  65. $mp['money_num'] = ['between', '100,200'];
  66. } else if ($num == 4) {
  67. $mp['money_num'] = ['between', '200,500'];
  68. } else if ($money == 5) {
  69. $mp['money_num'] = ['between', '500,1000'];
  70. } else if ($money == 6) {
  71. $mp['money_num'] = ['>', '1000'];
  72. }
  73. }
  74. if (empty($area_name)) {
  75. $user = $this->auth->getUser();
  76. if ($user && $user['p_id'] != 0) $mp['p_id'] = $user['p_id'];
  77. };
  78. $mp['switch'] = 1;
  79. if (!$page) {
  80. $pages = '0,10';
  81. } else {
  82. $page = $page - 1;
  83. if ($page < 0) $page = 0;
  84. $pages = $page . ',' . $limit;
  85. }
  86. $meetingModel = new MeetingModel();
  87. $field = 'id,image,title,mongey,mianji,address,yizi';
  88. $data = $meetingModel->where($mp)->limit($pages)->field($field)->order('sort desc')->select();
  89. if ($data) {
  90. return $this->success('', $data);
  91. } else {
  92. return $this->success('暂无数据');
  93. }
  94. }
  95. /**
  96. * 会议详情
  97. * @param string $id id
  98. *
  99. */
  100. public function listInfo()
  101. {
  102. $id = $this->request->get('id');
  103. if (!isset($id) || empty($id)) return $this->error('缺少参数');
  104. $meetingModel = new MeetingModel();
  105. $data = $meetingModel->where('switch', 1)
  106. ->where('id', $id)
  107. ->order('sort desc')
  108. ->find();
  109. $count = count($data['gongzuori_shijina_ids']);
  110. $data['gongzui_start_time'] = $data['gongzuori_shijina_ids'][0];
  111. $data['gongzui_start_end'] = $data['gongzuori_shijina_ids'][$count-1];
  112. $count = count($data['xiuxiri_shijian_ids']);
  113. $data['xiuxi_start_time'] = $data['xiuxiri_shijian_ids'][0];
  114. $data['xiuxi_start_end'] = $data['xiuxiri_shijian_ids'][$count-1];
  115. $user = $this->auth->getUser();
  116. if ($user) $data['miangei_time'] = $user['edu'];
  117. if ($data) {
  118. return $this->success('', $data);
  119. } else {
  120. return $this->success('暂无数据');
  121. }
  122. }
  123. /**
  124. * 获取租赁有效时间
  125. * @param string $id 会议室id
  126. * @param string $date 所选日期 2021-03-11
  127. */
  128. public function trueTime()
  129. {
  130. $id = $this->request->get('id');
  131. $date = $this->request->get('date');
  132. if (!isset($id) || empty($id)) return $this->error('缺少参数101');
  133. if (!isset($date) || empty($date)) return $this->error('缺少参数102');
  134. $meetingModel = new MeetingModel();
  135. $data = $meetingModel->where('switch', 1)
  136. ->where('id', $id)
  137. ->order('sort desc')
  138. ->find();
  139. $count = count($data['gongzuori_shijina_ids']);
  140. $data['gongzui_start_time'] = $data['gongzuori_shijina_ids'][0];
  141. $data['gongzui_start_end'] = $data['gongzuori_shijina_ids'][$count-1];
  142. $count = count($data['xiuxiri_shijian_ids']);
  143. $data['xiuxi_start_time'] = $data['xiuxiri_shijian_ids'][0];
  144. $data['xiuxi_start_end'] = $data['xiuxiri_shijian_ids'][$count-1];
  145. $orderModel = new MeetingOrder();
  146. $order= $orderModel->with(['meeting'])
  147. ->where('make_day',$date)
  148. ->where('m_id',$id)
  149. ->column('make_time');
  150. if (empty($order)) {
  151. $week = date('w',strtotime($date));
  152. if ($week==6|| $week==0) {
  153. return $this->success('',$data['xiuxiri_shijian_ids']);
  154. } else {
  155. return $this->success('',$data['gongzuori_shijina_ids']);
  156. }
  157. } else {
  158. }
  159. dump($order);die;
  160. }
  161. /**
  162. * 预约订单信息
  163. * @ApiMethod (POST)
  164. * @param string $m_id 会议室id
  165. * @param string $make_day 所选日期2021-03-11
  166. * @param string $make_time 所选时间段多个用,号分割
  167. */
  168. public function order()
  169. {
  170. $data = $this->request->post();
  171. if (!isset($data['id']) || empty($data['id'])) return $this->success('参数错误101');
  172. if (!isset($data['make_day']) || empty($data['make_day'])) return $this->success('参数错误102');
  173. if (!isset($data['make_time']) || empty($data['make_time'])) return $this->success('参数错误103');
  174. $meetingModel = new MeetingModel();
  175. $data['meeting'] = $meetingModel->where('id',$data['id'])->find();
  176. $week = date('w',strtotime($data['make_day']));
  177. $countTime = count(explode(',',$data['make_time']));
  178. $data['langTime'] = (60*$countTime).'分钟';
  179. if ($week==6|| $week==0) {
  180. // $data['money'] =
  181. } else {
  182. return $this->success('',$data['gongzuori_shijina_ids']);
  183. }
  184. }
  185. }