123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260 |
- <?php
- /**
- * 狮子鱼社区团购系统
- *
- * ==========================================================================
- * @link http://www.liofis.com/
- * @copyright Copyright (c) 2015 liofis.com.
- * @license http://www.liofis.com/license.html License
- * ==========================================================================
- *
- * @author fish
- *
- */
- namespace Home\Widget;
- use Think\Controller;
- /**
- * 商品
- */
- class ProductWidget extends Controller{
-
- /**
- *
- */
- function index_ajax_goods_list()
- {
- $page = I('get.page',1);
- $pre_page = 10;
- //'seller_count' =>
- $condition = array('status'=>1,'quantity' =>array('gt',0) );
- $offset = ($page -1) * $pre_page;
-
- $list = M('goods')->where($condition)->order('seller_count desc,goods_id asc')->limit($offset,$pre_page)->select();
-
-
-
- //M('') $map['id'] = array('gt',100);
- $this->list = $list;
- //$content = $this->fetch('Widget:index_ajax_goods_list');
-
- $this->display('Widget:index_ajax_goods_list');
- }
- /**
- 商品详情底部状态
- **/
- public function goods_button_html()
- {
- $id=I('get.id');
- $pin_id = I('get.pin_id',0);
- $this->id = $id;
- $this->pin_id = $pin_id;
- $this->display('Widget:goods_button_info');
- }
- /**
- * 首页的商品
- *
- */
- function home_goods_list($title,$order_by,$limit){
- $key='home_goods_cache'.$order_by;
-
- if (!$home_goods_cache = S($key)) {
- $sql='SELECT goods_id,image,price,name FROM '.C('DB_PREFIX').'goods WHERE status=1 ORDER BY '.$order_by.' LIMIT 0,'.$limit;
- $list=M()->query($sql);
-
- $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
- foreach ($list as $k => $v) {
-
- $list[$k]['image']=resize($v['image'], C('common_image_thumb_width'), C('common_image_thumb_height'));
- $list[$k]['goods_id']=$hashids->encode($v['goods_id']);
- }
- S($key, $list);
-
- $home_goods_cache=$list;
- }
- $this->products=$home_goods_cache;
- $this->title=$title;
- $this->display('Widget:home_goods_list');
- }
- //详情页热门产品
- function hot_goods_list($title,$order_by,$limit){
- $key='hot_goods_cache'.$order_by;
-
- if (!$hot_goods_cache = S($key)) {
- $sql='SELECT goods_id,image,price,name FROM '.C('DB_PREFIX').'goods WHERE status=1 ORDER BY '.$order_by.' LIMIT 0,'.$limit;
- $list=M()->query($sql);
-
- $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
- foreach ($list as $k => $v) {
-
- $list[$k]['image']=resize($v['image'], C('goods_cart_thumb_width'), C('goods_cart_thumb_height'));
- $list[$k]['goods_id']=$hashids->encode($v['goods_id']);
- }
- S($key, $list);
-
- $hot_goods_cache=$list;
- }
- $this->products=$hot_goods_cache;
- $this->title=$title;
- $this->display('Widget:goods_show_hot_goods_list');
- }
- /**
- 拼团详情页 关联拼团活动
- **/
- function relapin_goods_list($goods_id)
- {
- $goods_info = M('goods')->where( array('goods_id' =>$goods_id) )->find();
- $goods_model = D('Home/Goods');
-
- if(!empty($goods_info))
- {
- //begin_time end_time
- $now_time = time();
- $where_time = " and pg.begin_time < {$now_time} and pg.end_time > {$now_time} ";
-
- $goods_cate = M('goods_to_category')->where( array('goods_id' =>$goods_id) )->find();
-
- $sql='SELECT g.goods_id,g.image,g.seller_count,g.virtual_count,g.fan_image,pg.pin_price,g.danprice,g.name FROM '.C('DB_PREFIX').'goods as g,
- '.C('DB_PREFIX').'pin_goods as pg,
- '.C('DB_PREFIX').'goods_to_category as gtc
- WHERE g.goods_id = pg.goods_id and gtc.goods_id=g.goods_id and gtc.class_id1='.$goods_cate['class_id1'].'
- and g.goods_id != '.$goods_id.' '.$where_time.' and g.status=1 and g.quantity >0 and g.type="pintuan" ORDER BY rand() LIMIT 0,20';
-
- }else{
- $now_time = time();
- $where_time = " and pg.begin_time < {$now_time} and pg.end_time > {$now_time} ";
-
- $sql='SELECT g.goods_id,g.image,g.seller_count,g.virtual_count,g.fan_image,pg.pin_price,g.danprice,g.name FROM '.C('DB_PREFIX').'goods as g,
- '.C('DB_PREFIX').'pin_goods as pg
- WHERE g.goods_id = pg.goods_id '.$where_time.'
- and g.status=1 and g.quantity >0 ORDER BY rand() LIMIT 0,20';
- }
-
-
- $list=M()->query($sql);
- foreach ($list as $k => $v) {
-
- // $list[$k]['image']=resize($v['image'], C('goods_related_thumb_width'), C('goods_related_thumb_height'));
- //pin_price
- $price_arr = $goods_model->get_goods_price($v['goods_id']);
-
- $list[$k]['pin_price'] = $price_arr['pin_price'];
-
-
- $list[$k]['seller_count'] = $list[$k]['seller_count'] + $list[$k]['virtual_count'];
-
- if(!empty($v['fan_image'])){
- $list[$k]['image']=resize($v['fan_image'], 480,480);
- //$list[$k]['image']='/Uploads/image/'.$v['fan_image'];
- }else {
- $list[$k]['image']=resize($v['image'], 480,480);
- //$list[$k]['image']='/Uploads/image/'.$v['image'];
- }
- }
-
- $this->related_goods=$list;
-
-
- $this->display('Widget:relapin_goods_list');
-
- }
- //详情页推荐的关联产品
- function related_goods_list($goods_id ){
-
- //var_dump($goods_id);die(); type != "integral" and type != "bargain"
- $goods_model = D('Home/Goods');
- $goods_cate = M('goods_to_category')->where( array('goods_id' =>$goods_id) )->find();
-
- $sql='SELECT g.goods_id,g.image,g.fan_image,g.danprice,g.name FROM '.C('DB_PREFIX').'goods as g,'.C('DB_PREFIX').'goods_to_category as gtc WHERE gtc.goods_id=g.goods_id and gtc.class_id1='.$goods_cate['class_id1'].' and g.type != "integral" and g.type != "bargain" and g.status=1 ORDER BY rand() LIMIT 0,20';
- $list=M()->query($sql);
-
-
- foreach($list as $k =>$v)
- {
-
-
- $price_arr = $goods_model->get_goods_price($v['goods_id']);
-
- $list[$k]['danprice'] = $price_arr['danprice'];
-
- //$val['danprice'] = $price_arr['price'];
-
- }
-
-
- $member_id = is_login();
- $goods_model = D('Home/Goods');
-
-
-
- $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
- foreach ($list as $k => $v) {
-
- //$list[$k]['image']=resize($v['image'], 468, 658);
- $list[$k]['image']=resize($v['image'], 400, 400);
- }
-
- $this->related_goods=$list;
-
- $this->display('Widget:related_goods_list');
- }
-
- function related_usecenter_goods_list()
- {
- $sql='SELECT goods_id,image,fan_image,danprice,name FROM '.C('DB_PREFIX').'goods WHERE status=1 and type != "integral" and type != "bargain" and quantity>0 ORDER BY rand() LIMIT 0,12';
- $list=M()->query($sql);
-
- $goods_model = D('Home/Goods');
-
-
-
- $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
- foreach ($list as $k => $v) {
-
- //$list[$k]['image']=resize($v['image'], C('goods_related_thumb_width'), C('goods_related_thumb_height'));
-
- $price_arr = $goods_model->get_goods_price($v['goods_id']);
-
- $list[$k]['danprice'] = $price_arr['danprice'];
-
- //$val['danprice'] = $price_arr['price'];
-
- if(!empty($v['fan_image'])){
- $list[$k]['image']=resize($v['fan_image'], 480,480);
- //$list[$k]['image']='/Uploads/image/'.$v['fan_image'];
- }else {
- $list[$k]['image']=resize($v['image'], 480,480);
- //$list[$k]['image']='/Uploads/image/'.$v['image'];
- }
- }
-
- $this->related_goods=$list;
-
- $this->display('Widget:related_usercenter_goods_list');
- }
-
- //拼团详情页推荐的关联产品
- function related_group_goods_list()
- {
- $sql='SELECT goods_id,image,fan_image,price,name,pinprice FROM '.C('DB_PREFIX').'goods WHERE status=1 ORDER BY rand() LIMIT 0,9';
- $list=M()->query($sql);
-
- $hashids = new \Lib\Hashids(C('PWD_KEY'), C('URL_ID'));
- foreach ($list as $k => $v) {
-
- $list[$k]['image']=resize($v['image'], C('goods_related_thumb_width'), C('goods_related_thumb_height'));
-
- if(!empty($v['fan_image'])){
- $list[$k]['image']=resize($v['fan_image'], C('goods_related_thumb_width'), C('goods_related_thumb_height'));
- }else {
- $list[$k]['image']=resize($v['image'], C('goods_related_thumb_width'), C('goods_related_thumb_height'));
- }
- //$list[$k]['goods_id']=$hashids->encode($v['goods_id']);
- }
-
- $this->related_goods=$list;
-
- $this->display('Widget:related_group_goods_list');
- }
-
- }
|