| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- <?php
- /**
- * 会议相关
- * 请求地址如:http://oa.test/api.php?m=openmeet&a=test&openkey=fee5efd3a93ca5c6a85b679cde60faa2
- */
- class openmeetClassAction extends openapiAction
- {
- public function testAction() {
- $str = $this->postdata;
- return json_encode($str);
- }
- // 绑定设备
- public function bindDeviceAction() {
- $rawArr = $this->getpostarr();
- if (!isset($rawArr['device_id'])) {
- return [
- "code"=>-1,
- "message"=>"参数错误!"
- ];
- }
- $rawData = m('meeting_room')->getone(" mac like '%{$rawArr['device_id']}%'", "id");
- if ($rawData['id'] ?? 0 > 0) {
- return [
- "code"=>1,
- "message"=>"已绑定",
- "data"=>[
- "room_id"=>$rawData['id']
- ]
- ];
- } else {
- return [
- "code"=>0,
- "message"=>"未绑定"
- ];
- }
- }
- // 获取会议信息
- public function getMeetInfoAction() {
- $rawArr = $this->getpostarr();
- if (!isset($rawArr['room_id'])) {
- return [
- "code"=>-1,
- "message"=>"参数错误!"
- ];
- }
- $rawData = m('meeting_room')->getone(" id = '{$rawArr['room_id']}'");
- $meetData = m('meeting')->getone(" state = 1 and meeting_room = '{$rawData['room_name']}'");
- $topics = $this->db->getall("select `id`, `topic_title`, `topic_attendee`, `topic_state` from `[Q]topics` where mid = {$meetData['id']} order by sort");
- $res=[
- "code"=>1,
- "message"=>"请求成功!",
- "data"=>[
- "meet_id"=>$rawData['id'],
- "room_name"=>$rawData['room_name'],
- "meet_title"=>$meetData['title'],
- "meet_time"=>$meetData['meeting_time'],
- "attendees"=>$meetData['attendees'],
- "topics"=>$topics
- ]
- ];
- return $res;
- }
- // 切换议题
- public function switchTopicsAction() {
- $rawArr = $this->getpostarr();
- if (!isset($rawArr['meet_id']) || !isset($rawArr['topic_id'])) {
- return [
- "code"=>-1,
- "message"=>"参数错误!"
- ];
- }
- // 获取议题信息
- $topics = $this->db->getall("select `id`, `topic_title`, `topic_attendee`, `topic_attendee_id`, `topic_state` from `[Q]topics` where mid = {$rawArr['meet_id']} order by sort");
- $topic_id = $rawArr['topic_id'];
- for ($i = 0; $i < count($topics); $i++) {
- $info = $topics[$i];
- if ($topic_id == $info['id']) {
- $topics[$i]['topic_state'] = $topics[$i]['topic_state'] + 1;
- $topics[$i]['topic_state_info'] = $this->topicState($topics[$i]['topic_state']);
- if (isset($topics[$i - 1])) {
- $topics[$i-1]['topic_state'] = $topics[$i-1]['topic_state'] + 1;
- $topics[$i-1]['topic_state_info'] = $this->topicState($topics[$i-1]['topic_state']);
- }
- if (isset($topics[$i + 1])) {
- $topics[$i+1]['topic_state'] = $topics[$i+1]['topic_state'] + 1;
- $topics[$i+1]['topic_state_info'] = $this->topicState($topics[$i+1]['topic_state']);
- }
- // 发送短信给 topic_attendee_id
- } else {
- $topics[$i]['topic_state_info'] = $this->topicState($topics[$i]['topic_state']);
- }
- }
- return [
- "code"=>1,
- "message"=>"切换成功!",
- "data"=>$topics
- ];
- }
- protected function topicState($code): string
- {
- $info = '等待';
- switch ($code) {
- case 1:
- $info = '待进行';
- break;
- case 2:
- $info = '进行中';
- break;
- case 3:
- $info = '已进行';
- break;
- }
- return $info;
- }
- }
|