IntegralController.class.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. <?php
  2. /**
  3. * lionfish 商城系统
  4. *
  5. * ==========================================================================
  6. * @link http://www.liofis.com/
  7. * @copyright Copyright (c) 2015 liofis.com.
  8. * @license http://www.liofis.com/license.html License
  9. * ==========================================================================
  10. *
  11. * @author fish
  12. *
  13. */
  14. namespace Home\Controller;
  15. class IntegralController extends CommonController {
  16. protected function _initialize()
  17. {
  18. parent::_initialize();
  19. }
  20. public function index(){
  21. $goods_model = D('Home/Goods');
  22. $pre_page = 10;
  23. $page = I('get.page',1);
  24. $condition = array('type' => 'integral', 'status'=>1,'quantity' =>array('gt',0) );
  25. $offset = ($page -1) * $pre_page;
  26. $list = M('goods')->where($condition)->order('seller_count+virtual_count desc,goods_id asc')->limit($offset,$pre_page)->select();
  27. if(!empty($list)) {
  28. foreach($list as $key => $v){
  29. $goods_price_arr = $goods_model->get_goods_price($v['goods_id']);
  30. $list[$key]['pinprice'] = $goods_price_arr['price'];
  31. $list[$key]['image']=C('SITE_URL'). resize($v['image'], 400, 400);
  32. }
  33. }
  34. foreach($list as $key => $val)
  35. {
  36. $val['seller_count'] += $val['virtual_count'];
  37. $list[$key] = $val;
  38. }
  39. $this->list = $list;
  40. if($page > 1) {
  41. $result = array('code' => 0);
  42. if(!empty($list)) {
  43. $result['code'] = 1;
  44. $result['html'] = $this->fetch('Widget:integral_ajax_goods_list_fetch');
  45. }
  46. echo json_encode($result);
  47. die();
  48. }
  49. $integral_rules = C('integral_description');
  50. $qian=array("\r\n");
  51. $hou=array("@F@");
  52. $integral_rules_str = str_replace($qian,$hou,$integral_rules);
  53. $integral_rules_str = explode('@F@',$integral_rules_str);
  54. $this->integral_rules_str = $integral_rules_str;
  55. $ad_info = M('plugins_slider')->where( array('type' => 'wepro_integral_mall') )->order('slider_id desc')->find();
  56. $this->ad_info = $ad_info;
  57. $this->display();
  58. }
  59. }