RankController.class.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. <?php
  2. /**
  3. * 小梦科技资源nanodreamtech.com
  4. *
  5. * ==========================================================================
  6. * @link https://www.nanodreamtech.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license https://www.nanodreamtech.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Home\Controller;
  15. class RankController extends CommonController {
  16. protected function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->cur_page = 'rank';
  20. }
  21. public function info()
  22. {
  23. //subject
  24. $per_page = 10;
  25. $page = I('post.page',1);
  26. $offset = ($page - 1) * $per_page;
  27. $sql = 'select * from '.C('DB_PREFIX')."subject where type='normal' order by add_time desc limit {$offset},{$per_page}";
  28. $list = M()->query($sql);
  29. $result = array();
  30. if(!empty($list))
  31. {
  32. foreach($list as $key =>$subject)
  33. {
  34. $subsql = 'select sg.state,g.goods_id,g.name,g.quantity,g.pinprice,g.price,g.danprice,g.pin_count,g.image,g.fan_image,g.store_id,g.seller_count,g.virtual_count from '.C('DB_PREFIX')."subject_goods as sg , ".C('DB_PREFIX')."goods as g
  35. where subject_id = ".$subject['id']." and sg.state =1 and sg.goods_id = g.goods_id and g.status =1 and g.quantity >0 order by sg.id asc limit 10 ";
  36. $sub_goods = M()->query($subsql);
  37. if( empty($sub_goods)) {
  38. continue;
  39. }
  40. foreach($sub_goods as $k => $v){
  41. $sub_goods[$k]['seller_count'] += $v['virtual_count'];
  42. // $sub_goods[$k]['image']=resize($v['image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  43. if(!empty($v['fan_image'])){
  44. $sub_goods[$k]['image']=resize($v['fan_image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  45. }else {
  46. $sub_goods[$k]['image']=resize($v['image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  47. }
  48. }
  49. $subject['list'] = $sub_goods;
  50. $result[$key] = $subject;
  51. //$list[$key] = $subject;
  52. }
  53. }
  54. $this->list = $result;
  55. if($page > 1) {
  56. $result = array('code' => 0);
  57. if(!empty($list)) {
  58. $result['code'] = 1;
  59. $result['html'] = $this->fetch('Rank:rank_ajax_info_fetch');
  60. }
  61. echo json_encode($result);
  62. die();
  63. }
  64. return $result;
  65. /**
  66. if($subject){
  67. $sql = 'select sg.state,g.goods_id,g.name,g.quantity,g.pinprice,g.price,g.danprice,g.pin_count,g.image,g.store_id,g.seller_count from '.C('DB_PREFIX')."subject_goods as sg , ".C('DB_PREFIX')."goods as g
  68. where subject_id = ".$subject['id']." and sg.state =1 and sg.goods_id = g.goods_id and g.status =1 and g.quantity >0 order by sg.id asc limit {$offset},{$per_page}";
  69. $list = M()->query($sql);
  70. $this->list = $list;
  71. }
  72. **/
  73. }
  74. //进行中
  75. public function index(){
  76. //type='normal' and lock_type='normal' and
  77. $hot_where = " status =1 and quantity >0 ";
  78. $hot_goods_list = M('goods')->where( $hot_where )->order('seller_count desc ')->limit(10)->select();
  79. foreach($hot_goods_list as $key => $val)
  80. {
  81. $hot_goods_list[$key]['seller_count'] += $val['virtual_count'];
  82. //$hot_goods_list[$key]['image']=resize($val['image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  83. if(!empty($val['fan_image'])){
  84. $hot_goods_list[$key]['image']=resize($val['fan_image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  85. }else {
  86. $hot_goods_list[$key]['image']=resize($val['image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  87. }
  88. }
  89. $this->hot_goods_list = $hot_goods_list;
  90. //type='normal' and lock_type='normal' and
  91. $new_where = " status =1 and quantity >0 ";
  92. $new_goods_list = M('goods')->where( $new_where )->order('goods_id desc ')->limit(10)->select();
  93. foreach($new_goods_list as $key => $val)
  94. {
  95. $new_goods_list[$key]['seller_count'] += $val['virtual_count'];
  96. //$new_goods_list[$key]['image']=resize($val['image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  97. if(!empty($val['fan_image'])){
  98. $new_goods_list[$key]['image']=resize($val['fan_image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  99. }else {
  100. $new_goods_list[$key]['image']=resize($val['image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  101. }
  102. }
  103. $this->new_goods_list = $new_goods_list;
  104. $list = $this->info();
  105. $this->list = $list;
  106. $this->display();
  107. }
  108. }