openmeetAction.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /**
  3. * 会议相关
  4. * 请求地址如:http://oa.test/api.php?m=openmeet&a=test&openkey=fee5efd3a93ca5c6a85b679cde60faa2
  5. */
  6. class openmeetClassAction extends openapiAction
  7. {
  8. public function testAction() {
  9. $str = $this->postdata;
  10. return json_encode($str);
  11. }
  12. // 绑定设备
  13. public function bindDeviceAction() {
  14. $rawArr = $this->getpostarr();
  15. if (!isset($rawArr['device_id'])) {
  16. return [
  17. "code"=>-1,
  18. "message"=>"参数错误!"
  19. ];
  20. }
  21. $rawData = m('meeting_room')->getone(" mac like '%{$rawArr['device_id']}%'", "id");
  22. if ($rawData['id'] ?? 0 > 0) {
  23. return [
  24. "code"=>1,
  25. "message"=>"已绑定",
  26. "data"=>[
  27. "room_id"=>$rawData['id']
  28. ]
  29. ];
  30. } else {
  31. return [
  32. "code"=>0,
  33. "message"=>"未绑定"
  34. ];
  35. }
  36. }
  37. // 获取会议信息
  38. public function getMeetInfoAction() {
  39. $rawArr = $this->getpostarr();
  40. if (!isset($rawArr['room_id'])) {
  41. return [
  42. "code"=>-1,
  43. "message"=>"参数错误!"
  44. ];
  45. }
  46. $rawData = m('meeting_room')->getone(" id = '{$rawArr['room_id']}'");
  47. $meetData = m('meeting')->getone(" state = 1 and meeting_room = '{$rawData['room_name']}'");
  48. $topics = $this->db->getall("select `id`, `topic_title`, `topic_attendee`, `topic_state` from `[Q]topics` where mid = {$meetData['id']} order by sort");
  49. $res=[
  50. "code"=>1,
  51. "message"=>"请求成功!",
  52. "data"=>[
  53. "meet_id"=>$rawData['id'],
  54. "room_name"=>$rawData['room_name'],
  55. "meet_title"=>$meetData['title'],
  56. "meet_time"=>$meetData['meeting_time'],
  57. "attendees"=>$meetData['attendees'],
  58. "topics"=>$topics
  59. ]
  60. ];
  61. return $res;
  62. }
  63. // 切换议题
  64. public function switchTopicsAction() {
  65. $rawArr = $this->getpostarr();
  66. if (!isset($rawArr['meet_id']) || !isset($rawArr['topic_id'])) {
  67. return [
  68. "code"=>-1,
  69. "message"=>"参数错误!"
  70. ];
  71. }
  72. // 获取议题信息
  73. $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");
  74. $topic_id = $rawArr['topic_id'];
  75. for ($i = 0; $i < count($topics); $i++) {
  76. $info = $topics[$i];
  77. if ($topic_id == $info['id']) {
  78. $topics[$i]['topic_state'] = $topics[$i]['topic_state'] + 1;
  79. $topics[$i]['topic_state_info'] = $this->topicState($topics[$i]['topic_state']);
  80. if (isset($topics[$i - 1])) {
  81. $topics[$i-1]['topic_state'] = $topics[$i-1]['topic_state'] + 1;
  82. $topics[$i-1]['topic_state_info'] = $this->topicState($topics[$i-1]['topic_state']);
  83. }
  84. if (isset($topics[$i + 1])) {
  85. $topics[$i+1]['topic_state'] = $topics[$i+1]['topic_state'] + 1;
  86. $topics[$i+1]['topic_state_info'] = $this->topicState($topics[$i+1]['topic_state']);
  87. }
  88. // 发送短信给 topic_attendee_id
  89. } else {
  90. $topics[$i]['topic_state_info'] = $this->topicState($topics[$i]['topic_state']);
  91. }
  92. }
  93. return [
  94. "code"=>1,
  95. "message"=>"切换成功!",
  96. "data"=>$topics
  97. ];
  98. }
  99. protected function topicState($code): string
  100. {
  101. $info = '等待';
  102. switch ($code) {
  103. case 1:
  104. $info = '待进行';
  105. break;
  106. case 2:
  107. $info = '进行中';
  108. break;
  109. case 3:
  110. $info = '已进行';
  111. break;
  112. }
  113. return $info;
  114. }
  115. }