array('elt',time()), 'gb.end_time' =>array('egt',time()), 'gb.is_end' =>0, 'g.is_on_sale' =>1 ); $count = $GroupBuy->alias('gb')->join('__GOODS__ g', 'g.goods_id = gb.goods_id')->alias('gb')->where($where)->count('gb.goods_id');// 查询满足要求的总记录数 $Page = new Page($count, 20);// 实例化分页类 传入总记录数和每页显示的记录数 $show = $Page->show();// 分页显示输出 $this->assign('page', $show);// 赋值分页输出 $list = $GroupBuy ->alias('gb') ->with(['goods','specGoodsPrice']) ->join('__GOODS__ g', 'g.goods_id = gb.goods_id') ->where($where) ->limit($Page->firstRow.','.$Page->listRows) ->select(); $this->assign('list', $list); return $this->fetch(); } // 促销活动页面 public function promoteList() { $goods_where['p.start_time'] = array('lt',time()); $goods_where['p.end_time'] = array('gt',time()); $goods_where['p.is_end'] = 0; $goods_where['g.prom_type'] = 3; $goods_where['g.is_on_sale'] = 1; $goodsList = Db::name('goods') ->field('g.*,p.end_time,s.item_id,s.price') ->alias('g') ->join('__PROM_GOODS__ p', 'g.prom_id = p.id') ->join('__SPEC_GOODS_PRICE__ s','g.prom_id = s.prom_id AND s.goods_id = g.goods_id','LEFT') ->group('g.goods_id') ->where($goods_where) ->cache(true,5) ->select(); $brandList = Db::name('brand')->cache(true)->getField("id,name,logo"); $this->assign('brandList',$brandList); $this->assign('goodsList',$goodsList); return $this->fetch(); } /** * 抢购活动列表 */ public function flash_sale_list() { $time_space = flash_sale_time_space(); $this->assign('time_space', $time_space); return $this->fetch(); } /** * 抢购活动列表ajax */ public function ajax_flash_sale() { $p = I('p',1); $start_time = I('start_time'); $end_time = I('end_time'); $where = array( 'fl.start_time'=>array('egt',$start_time), 'fl.end_time'=>array('elt',$end_time), 'g.is_on_sale'=>1, 'fl.is_end'=>0 ); $FlashSale = new FlashSale(); $flash_sale_goods = $FlashSale->alias('fl')->join('__GOODS__ g', 'g.goods_id = fl.goods_id')->with(['specGoodsPrice','goods']) ->field('*,100*(FORMAT(buy_num/goods_num,2)) as percent') ->where($where) ->page($p,10) ->select(); $this->assign('flash_sale_goods',$flash_sale_goods); $this->assign('now',time()); return $this->fetch(); } public function coupon_list() { $atype = I('atype', 1); $user = session('user'); $p = I('p', ''); $activityLogic = new ActivityLogic(); $result = $activityLogic->getCouponList($atype, $user['user_id'], $p); $this->assign('coupon_list', $result); if (request()->isAjax()) { return $this->fetch('ajax_coupon_list'); } return $this->fetch(); } /** * 领券 */ public function get_coupon() { $id = I('coupon_id/d'); if (empty($id)){ $this->error('参数错误'); } $user = session('user'); if ($user) { $activityLogic = new ActivityLogic(); $result = $activityLogic->get_coupon($id, $user['user_id']); } else { $this->redirect(U('User/login')); } $this->assign('res',$result); return $this->fetch(); } public function pre_sell_list() { $PreSell = new PreSell(); $count = $PreSell->where(['sell_end_time'=>['gt',time()],'is_finished' => 0])->count(); $page = new Page($count,10);// 实例化分页类 传入总记录数和每页显示的记录数 $pre_sell_list = $PreSell->where(['sell_end_time'=>['gt',time()],'is_finished' => 0])->order(['pre_sell_id' => 'desc'])->limit($page->firstRow.','.$page->listRows)->select(); $this->assign('pre_sell_list', $pre_sell_list); $this->assign('page', $page); return $this->fetch(); } }