rank.action.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | FANWE 直播系统
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2011 http://www.fanwe.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: 云淡风轻(1956838968@qq.com)
  8. // +----------------------------------------------------------------------
  9. class rankModule extends baseModule
  10. {
  11. /**
  12. * 贡献排行榜 from_user_id 送 无关注 贡献(消费)榜是按:送出的钻石 排序 ===》total_diamonds
  13. * 分为 : 日榜(缓存时间最低:1800s)、月榜(缓存时间最低:28800s)、总榜(缓存时间最低:86400s)
  14. * 缓存时间由后台设置,不得低于最低缓存时间
  15. */
  16. public function contribution(){
  17. $root = array('status' => 1,'error'=>'');
  18. //分页
  19. $page = intval($_REQUEST['p']);//当前页
  20. $page_size = 30;//分页数量
  21. if ($page == 0) {
  22. $page = 1;
  23. }
  24. $rank_name = strim($_REQUEST['rank_name']);//贡献榜 名称 日,月,总
  25. $user_id = intval($GLOBALS['user_info']['id']);//登录用户id
  26. $table = createPropTable();
  27. $rank_names = array('day','month','all');
  28. $m_config = load_auto_cache("m_config");//初始化手机端配置
  29. //贡献榜
  30. if(in_array($rank_name,$rank_names)){
  31. $rank_cache_name = "rank_".$rank_name;
  32. $rank_cache_time = $m_config[$rank_cache_name];
  33. $rank_cache_default =array("rank_day"=>1,"rank_month"=>28800,"rank_all"=>86400);
  34. if($rank_cache_time<$rank_cache_default[$rank_cache_name]){
  35. $rank_cache_time = $rank_cache_default[$rank_cache_name];
  36. }
  37. $rank_cache_time = $rank_cache_time!=''?$rank_cache_time:86400;
  38. $param = array('rank_name'=>$rank_name,'table'=>$table,'page'=>$page,'page_size'=>$page_size,'cache_time'=>$rank_cache_time);
  39. $list = load_auto_cache("rank_contribution",$param);
  40. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserFollwRedisService.php');
  41. $user_redis = new UserFollwRedisService($user_id);
  42. $keys = $user_redis->following();
  43. foreach($list as $k=>$v) {
  44. $list[$k]['head_image'] = get_spec_image($v['head_image']);
  45. $list[$k]['nick_name'] = htmlspecialchars_decode($v['nick_name']);
  46. $list[$k]['nick_name'] = emoji_decode($v['nick_name']);
  47. $list[$k]['ticket'] =intval($v['ticket']) ;
  48. if($user_id>0){
  49. if (in_array($v['user_id'],$keys)){
  50. $list[$k]['is_focus'] = 1;
  51. }else{
  52. $list[$k]['is_focus'] = 0;
  53. }
  54. }else{
  55. $list[$k]['is_focus'] = 0;
  56. }
  57. if($list[$k]['ticket'] == 0)
  58. {
  59. unset($list[$k]);
  60. }
  61. }
  62. $root['list'] = $list;
  63. $count = count($list);
  64. }else{
  65. $root['status'] = 0;
  66. $root['error'] = '参数错误!';
  67. ajax_return($root);
  68. }
  69. $root['page']=$page;
  70. $has_next = ($count > $page * $page_size) ? 1 : 0;
  71. $root['has_next']=$has_next;
  72. ajax_return($root);
  73. }
  74. /**
  75. * 收入排行榜 to_user_id 收 无关注 收入榜:按收到的印票 排序 ===> sum(total_ticket) where is_red_envelope = 0
  76. * 分为 : 日榜(缓存时间最低:1800s)、月榜(缓存时间最低:28800s)、总榜(缓存时间最低:86400s)
  77. * 缓存时间由后台设置,不得低于最低缓存时间
  78. */
  79. public function consumption(){
  80. $root = array('status' => 1,'error'=>'');
  81. //分页
  82. $page = intval($_REQUEST['p']);//当前页
  83. $page_size = 30;//分页数量
  84. if ($page == 0) {
  85. $page = 1;
  86. }
  87. $rank_name = strim($_REQUEST['rank_name']);//收入榜名称
  88. $user_id = intval($GLOBALS['user_info']['id']);//登录用户id
  89. $table = createPropTable();
  90. $rank_names = array('day','month','all');
  91. $m_config = load_auto_cache("m_config");//初始化手机端配置
  92. //收入榜
  93. if(in_array($rank_name,$rank_names)){
  94. $rank_cache_name = "rank_".$rank_name;
  95. $rank_cache_time = $m_config[$rank_cache_name];
  96. $rank_cache_default =array("rank_day"=>1,"rank_month"=>28800,"rank_all"=>86400);
  97. if($rank_cache_time<$rank_cache_default[$rank_cache_name]){
  98. $rank_cache_time = $rank_cache_default[$rank_cache_name];
  99. }
  100. $rank_cache_time = $rank_cache_time!=''?$rank_cache_time:86400;
  101. $param = array('rank_name'=>$rank_name,'table'=>$table,'page'=>$page,'page_size'=>$page_size,'cache_time'=>$rank_cache_time);
  102. $list = load_auto_cache("rank_consumption",$param);
  103. fanwe_require(APP_ROOT_PATH.'mapi/lib/redis/UserFollwRedisService.php');
  104. $user_redis = new UserFollwRedisService($user_id);
  105. $keys = $user_redis->following();
  106. foreach($list as $k=>$v) {
  107. $list[$k]['head_image'] = get_spec_image($v['head_image'],150,150);
  108. $list[$k]['nick_name'] = htmlspecialchars_decode($v['nick_name']);
  109. $list[$k]['nick_name'] = emoji_decode($v['nick_name']);
  110. $list[$k]['ticket'] =intval($v['ticket']) ;
  111. if($user_id>0){
  112. if (in_array($v['user_id'],$keys)){
  113. $list[$k]['is_focus'] = 1;
  114. }else{
  115. $list[$k]['is_focus'] = 0;
  116. }
  117. }else{
  118. $list[$k]['is_focus'] = 0;
  119. }
  120. if($list[$k]['ticket'] == 0)
  121. {
  122. unset($list[$k]);
  123. }
  124. }
  125. $root['list'] = $list;
  126. $count = count($list);
  127. }else{
  128. $root['status'] = 0;
  129. $root['error'] = '参数错误!';
  130. ajax_return($root);
  131. }
  132. $root['page']=$page;
  133. $has_next = ($count > $page * $page_size) ? 1 : 0;
  134. $root['has_next']=$has_next;
  135. ajax_return($root);
  136. }
  137. }
  138. ?>