svideo_select_weibo_info.auto_cache.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. <?php
  2. class svideo_select_weibo_info_auto_cache extends auto_cache{
  3. private $key = "select:weibo_info:";
  4. public function load($param)
  5. {
  6. // $type = intval($param['type']);
  7. // $this->key .= $type;
  8. fanwe_require(APP_ROOT_PATH.'mapi/xr/core/common.php');
  9. $this->key .= md5(serialize($param));
  10. $page=$param['page']>0?$param['page']:1;
  11. $page_size=$param['page_size']>0?$param['page_size']:20;
  12. $limit = (($page-1) * $page_size) . "," . $page_size;
  13. $weibo_id = intval($param['weibo_id']);
  14. $key_bf = $this->key.'_bf';
  15. //$list = $GLOBALS['cache']->get($this->key,true);
  16. $list = false;
  17. if ($list === false) {
  18. $is_ok = $GLOBALS['cache']->set_lock($this->key);
  19. if(false){
  20. $list = $GLOBALS['cache']->get($key_bf,true);
  21. }else{
  22. if($page == 1){
  23. $weibo_info = $GLOBALS['db']->getRow("select w.user_id,w.id as weibo_id,u.head_image,u.is_authentication,w.content,w.red_count,w.unlike_count,w.digg_count,w.comment_count,w.video_count,w.data,u.v_icon,u.nick_name,w.sort_num,w.photo_image,u.city,w.is_top,w.price,w.type,w.create_time
  24. from ".DB_PREFIX."weibo as w left join ".DB_PREFIX."user as u on w.user_id = u.id where w.id = ".$weibo_id);
  25. if(!$weibo_info){
  26. $root['error'] = "动态不存在!";
  27. $root['status'] = 0;
  28. api_ajax_return($root);
  29. }
  30. $weibo_info['left_time'] = time_tran($weibo_info['create_time']);
  31. if($weibo_info['head_image']){
  32. $weibo_info['head_image'] = deal_weio_image($weibo_info['head_image']);
  33. }
  34. if($weibo_info['photo_image']){
  35. $weibo_info['photo_image'] = deal_weio_image($weibo_info['photo_image'],$weibo_info['type'].'_info');
  36. }
  37. $weibo_info['images_count'] = 0;
  38. if($weibo_info['type']=='video'){
  39. $weibo_info['images'] = array();
  40. $url = $weibo_info['data'];
  41. $weibo_info['video_url'] = get_file_oss_url($url);
  42. }else{
  43. $images = unserialize($weibo_info['data']);
  44. // if(in_array($weibo_info['weibo_id'],$order_list_array)){
  45. // $is_pay =1;
  46. // }else{
  47. // $is_pay =0;
  48. // }
  49. if(count($images)>0){
  50. $weibo_info['images'] = $images;
  51. $weibo_info['images_count'] = count($images);
  52. }else{
  53. $weibo_info['images'] = array();
  54. }
  55. $weibo_info['video_url'] = '';
  56. }
  57. $root['info'] = $weibo_info;
  58. //点赞列表
  59. $digg_list = $GLOBALS['db']->getAll("select wc.user_id,u.v_icon,u.nick_name,u.head_image,u.is_authentication from ".DB_PREFIX."weibo_comment as wc
  60. left join ".DB_PREFIX."user as u on wc.user_id = u.id where wc.weibo_id = ".$weibo_id." and type = 2 order by wc.comment_id desc limit 0,7");
  61. $digg_user_list = array();
  62. if($digg_list){
  63. foreach($digg_list as $k=>$v){
  64. if($v){
  65. $digg_user_list[] = $v['user_id'];
  66. $digg_list[$k]['head_image'] = get_spec_image($v['head_image']);
  67. }
  68. }
  69. }
  70. $root['digg_user_list'] = $digg_user_list;
  71. $root['digg_list'] = $digg_list;
  72. // 踩一下列表
  73. $unlike_list = $GLOBALS['db']->getAll("select wc.user_id,u.v_icon,u.nick_name,u.head_image,u.is_authentication from ".DB_PREFIX."weibo_comment as wc
  74. left join ".DB_PREFIX."user as u on wc.user_id = u.id where wc.weibo_id = ".$weibo_id." and type = 3 order by wc.comment_id desc limit 0,7");
  75. $unlike_user_list = array();
  76. if($unlike_list){
  77. foreach($unlike_list as $k=>$v){
  78. if($v){
  79. $unlike_user_list[] = $v['user_id'];
  80. $unlike_list[$k]['head_image'] = get_spec_image($v['head_image']);
  81. }
  82. }
  83. }
  84. $root['unlike_user_list'] = $unlike_user_list;
  85. $root['unlike_list'] = $unlike_list;
  86. }
  87. //评论列表
  88. $comment_list = $GLOBALS['db']->getAll("select wc.comment_id, wc.user_id,u.v_icon,u.nick_name,u.head_image,wc.content,wc.to_comment_id,wc.to_user_id,wc.create_time,u.is_authentication from ".DB_PREFIX."weibo_comment as wc
  89. left join ".DB_PREFIX."user as u on wc.user_id = u.id where wc.weibo_id = ".$weibo_id." and type = 1 and is_del = 0 order by wc.comment_id desc limit $limit");
  90. if($comment_list){
  91. $to_comment_user = array();
  92. foreach($comment_list as $k=>$v){
  93. if($v){
  94. $comment_list[$k]['head_image'] = get_spec_image($v['head_image']);
  95. $comment_list[$k]['left_time'] = time_tran($v['create_time']);
  96. if($v['to_comment_id']){
  97. $comment_list[$k]['is_to_comment'] =1;
  98. $to_comment_user[] = $v['to_user_id'];
  99. }else{
  100. $comment_list[$k]['is_to_comment'] = 0;
  101. }
  102. $comment_list[$k]['to_nick_name'] = '';
  103. }
  104. }
  105. if(count($to_comment_user)>0){
  106. $user_list = $GLOBALS['db']->getAll("select id,nick_name from ".DB_PREFIX."user where id in (".implode(',',$to_comment_user).")");
  107. $user_array = array();
  108. foreach($user_list as $k=>$v){
  109. $user_array[$v['id']] = $v['nick_name'];
  110. }
  111. foreach($comment_list as $k=>$v){
  112. if( $v['to_user_id']){
  113. $comment_list[$k]['to_nick_name'] = $user_array[$v['to_user_id']];
  114. }
  115. }
  116. }
  117. }
  118. $root['comment_list'] = $comment_list;
  119. $list = $root;
  120. //$GLOBALS['cache']->set($this->key, $list, 5, true);
  121. //$GLOBALS['cache']->set($key_bf, $list, 86400, true);//备份
  122. //echo $this->key;
  123. }
  124. }
  125. if ($list == false) $list = array();
  126. return $list;
  127. }
  128. public function rm()
  129. {
  130. //$GLOBALS['cache']->clear_by_name($this->key);
  131. }
  132. public function clear_all()
  133. {
  134. //$GLOBALS['cache']->clear_by_name($this->key);
  135. }
  136. }
  137. ?>