Watch.php 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace Act\Lib;
  3. use Dever;
  4. class Watch
  5. {
  6. # 获取当前小刊的观看数
  7. public function get($id, $type = 3)
  8. {
  9. $where['type'] = $type;
  10. $where['data_id'] = $id;
  11. $where['state'] = 1;
  12. $info = Dever::db('act/watch')->total($where);
  13. return $info;
  14. }
  15. # 观看
  16. public function submit($uid, $id, $type = 3)
  17. {
  18. $where['uid'] = $uid;
  19. $where['data_id'] = $id;
  20. $where['type'] = $type;
  21. $info = Dever::db('act/watch')->one($where);
  22. if (!$info) {
  23. Dever::db('act/watch')->insert($where);
  24. }
  25. if ($type == 3) {
  26. # 更新观看数
  27. $where = array();
  28. $where['data_id'] = $id;
  29. $where['type'] = $type;
  30. $where['state'] = 1;
  31. $total = Dever::db('act/watch')->total($where);
  32. $table = Dever::config('base')->type_table[$type];
  33. Dever::db($table)->update(array('where_id' => $id, 'num_user' => $total));
  34. Dever::score($uid, 'submit_watch', '观看直播');
  35. }
  36. return true;
  37. }
  38. }