Note.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace Act\Lib;
  3. use Dever;
  4. class Note
  5. {
  6. # 获取当前用户是否预约
  7. public function get($uid, $id, $type)
  8. {
  9. $where['uid'] = $uid;
  10. $where['type'] = $type;
  11. $where['data_id'] = $id;
  12. $where['state'] = 1;
  13. $info = Dever::db('act/live_note')->one($where);
  14. if ($info) {
  15. return 1;
  16. } else {
  17. return 2;
  18. }
  19. }
  20. # 预约
  21. public function submit($uid, $id, $type)
  22. {
  23. $where['uid'] = $uid;
  24. $where['data_id'] = $id;
  25. $where['type'] = $type;
  26. $info = Dever::db('act/live_note')->one($where);
  27. if (!$info) {
  28. Dever::db('act/live_note')->insert($where);
  29. } else {
  30. if ($info['state'] == 1) {
  31. Dever::db('act/live_note')->update(array('where_id' => $info['id'], 'state' => 2));
  32. } else {
  33. Dever::db('act/live_note')->update(array('where_id' => $info['id'], 'state' => 1));
  34. }
  35. }
  36. return true;
  37. }
  38. # 提醒 后续实现
  39. }