videoModel.class.php 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /**
  3. *
  4. */
  5. class videoModel extends NewModel
  6. {
  7. public function getLiveVideoByUserId($user_id, $field = '')
  8. {
  9. return $this->field($field)->selectOne(array('user_id' => intval($user_id), 'live_in' => 1));
  10. }
  11. public function getOneWithUser($where)
  12. {
  13. $field = [
  14. 'v.id room_id',
  15. 'v.sort_num',
  16. 'v.group_id',
  17. 'v.user_id',
  18. 'v.city',
  19. 'v.title',
  20. 'v.cate_id',
  21. 'v.live_in',
  22. 'v.video_type',
  23. 'v.create_type',
  24. 'v.room_type',
  25. ['(v.robot_num + v.virtual_watch_number + v.watch_number) as watch_number'],
  26. 'u.head_image',
  27. 'u.thumb_head_image',
  28. 'v.xpoint',
  29. 'v.ypoint',
  30. 'u.v_type',
  31. 'u.v_icon',
  32. 'u.nick_name',
  33. 'u.user_level',
  34. 'v.live_image',
  35. 'v.is_live_pay',
  36. 'v.live_pay_type',
  37. 'v.live_fee',
  38. 'u.create_time user_create_time',
  39. ];
  40. $where['u.id'] = ['v.user_id'];
  41. $where['v.live_in'] = ['in', [1]];
  42. $where['v.is_bm'] = 1;
  43. $where['u.mobile'] = ['not in', ['13888888888', '13999999999']];
  44. $room = $this->table('user u,video v')->field($field)->selectOne($where);
  45. if ($room) {
  46. $room['today_create'] = intval(date('Y-m-d') == date('Y-m-d', $room['user_create_time'] + 3600 * 8));
  47. if (!$room['live_image']) {
  48. $room['live_image'] = $room['head_image'];
  49. }
  50. if (!$room['thumb_head_image']) {
  51. $room['thumb_head_image'] = $room['head_image'];
  52. }
  53. $room['live_image'] = get_spec_image($room['live_image']);
  54. $room['head_image'] = get_spec_image($room['head_image']);
  55. $room['thumb_head_image'] = get_spec_image($room['thumb_head_image'], 150, 150);
  56. }
  57. return $room;
  58. }
  59. }