PingoodsController.class.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 PingoodsController extends CommonController {
  16. protected function _initialize()
  17. {
  18. parent::_initialize();
  19. $this->cur_page = 'index';
  20. }
  21. public function index(){
  22. //首页关键词
  23. $index_searchkeywords = C('index_searchkeywords');
  24. $keywords_arr = explode(',', $index_searchkeywords);
  25. $this->keywords_arr = $keywords_arr;
  26. $type = I('get.type', 'all');
  27. $this->type = $type;
  28. //all newman lottery
  29. //首页轮播导航
  30. //首页轮播导航
  31. $slider_nav_list=M('plugins_slider')->where( array('type' => 'pin_index_ad') )->order('sort_order desc')->find();
  32. if( !empty($slider_nav_list) )
  33. {
  34. $slider_nav_list['image'] = C('SITE_URL') . 'Uploads/image/'.$slider_nav_list['image'];
  35. }
  36. $this->slider_nav =$slider_nav_list;
  37. //1分拼团广告
  38. $slider_newman_list=M('plugins_slider')->where( array('type' => 'newman_wepro_head') )->order('sort_order desc')->find();
  39. if( !empty($slider_newman_list) )
  40. {
  41. $slider_newman_list['image'] = C('SITE_URL') . 'Uploads/image/'.$slider_newman_list['image'];
  42. }
  43. $this->slider_newman =$slider_newman_list;
  44. //抽奖广告
  45. $slider_lottery_list=M('plugins_slider')->where( array('type' => 'lottery_wepro_head') )->order('sort_order desc')->find();
  46. if( !empty($slider_lottery_list) )
  47. {
  48. $slider_lottery_list['image'] = C('SITE_URL') . 'Uploads/image/'.$slider_lottery_list['image'];
  49. }
  50. $this->slider_lottery =$slider_lottery_list;
  51. $appid_info = M('config')->where( array('name' => 'APPID') )->find();
  52. $appsecret_info = M('config')->where( array('name' => 'APPSECRET') )->find();
  53. $weixin_config = array();
  54. $weixin_config['appid'] = $appid_info['value'];
  55. $weixin_config['appscert'] = $appsecret_info['value'];
  56. $jssdk = new \Lib\Weixin\Jssdk( $weixin_config['appid'], $weixin_config['appscert']);
  57. $uid = is_login();
  58. $member_info = M('member')->where( array('member_id' => $uid) )->find();
  59. $sub_url = C('SHORT_URL');
  60. $site_title = C('SITE_TITLE');
  61. $site_name = C('SITE_NAME');
  62. $site_logo = C('SITE_ICON');
  63. $this->is_sub = $is_sub;
  64. $this->sub_url = $sub_url;
  65. $this->site_title = $site_title;
  66. $this->site_name = $site_name;
  67. $this->site_logo = $site_logo;
  68. $this->display();
  69. }
  70. public function pinlist()
  71. {
  72. $type = I('get.type','0');
  73. $this->type = $type;
  74. $page = I('post.page',1);
  75. $pre_page = 10;
  76. $offset = ($page -1) * $pre_page;
  77. $where = ' ';
  78. if($type == 1)
  79. {
  80. $where .= ' and p.state = 0 and p.end_time >'.time();
  81. } else if($type == 2){
  82. $where .= ' and p.state = 1 ';
  83. } else if($type == 3){
  84. $where .= ' and (p.state = 2 or (p.state =0 and p.end_time <'.time().')) ';
  85. }
  86. $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
  87. //og
  88. $sql = "select og.name,og.goods_images,p.need_count,p.state,p.is_lottery,p.lottery_state,p.end_time,o.order_id,og.price,po.pin_id,o.order_status_id from ".C('DB_PREFIX')."order as o, ".C('DB_PREFIX')."order_goods as og,
  89. ".C('DB_PREFIX')."pin as p,".C('DB_PREFIX')."goods as g ,".C('DB_PREFIX')."pin_order as po
  90. where po.order_id = o.order_id and o.order_id = og.order_id and og.goods_id = g.goods_id and po.pin_id = p.pin_id
  91. and o.member_id = ".is_login()." and o.order_status_id !=3 {$where} order by o.date_added desc limit {$offset},{$pre_page}";
  92. $list = M()->query($sql);
  93. $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
  94. foreach($list as $key => $val)
  95. {
  96. $val['price'] = round($val['price'],2);
  97. //if(!empty($val['fan_image'])){
  98. // $val['image']=resize($val['fan_image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  99. //}else {
  100. $val['image']=resize($val['goods_images'], C('common_image_thumb_width'), C('common_image_thumb_height'));
  101. //}
  102. $val['hash_order_id'] = $hashids->encode($val['order_id']);
  103. if($val['state'] == 0 && $val['end_time'] < time())
  104. {
  105. $val['state'] = 2;
  106. }
  107. $list[$key] = $val;
  108. } //order_status_id
  109. $this->list = $list;
  110. if($page > 1) {
  111. $result = array('code' => 0);
  112. if(!empty($list)) {
  113. $result['code'] = 1;
  114. $result['html'] = $this->fetch("Group:pin_ajax_fetch");
  115. }
  116. echo json_encode($result);
  117. die();
  118. }
  119. $this->display();
  120. }
  121. }