'1', 'gu.status'=> '1' ]; $field = 'gu.*,g.id as goods_id,g.name as goods_name,g.image as goods_image,g.min_price as goods_min_price'; //查询抢购商品 $lists = GroupbuyGoods::alias('gu') ->leftJoin('goods g', 'g.id=gu.goods_id') ->group('g.id') ->field($field) ->where($where) ->order("gu.activity_price asc") ->select() ->toArray(); //分页处理 $count = count($lists); $index = ($get['page_no']-1) * $get['page_size']; $lists = array_slice($lists, $index, $get['page_size']); //处理列表数据 foreach($lists as &$item) { // 图片加域名 $item['goods_image'] = UrlServer::getFileUrl($item['goods_image']); } $data = GroupbuyConfig::select(); $config = array(); if (!empty($data)) { $result = $data->toArray(); foreach ($result as &$v) { if ($v['name'] == 'end_time') { $v['value'] = strtotime($v['value']); } if ($v['name'] == 'service' && $v['value']) { $v['value'] = explode(',', $v['value']); } $config[$v['name']] = $v['value']; } } return [ 'count' => $count, 'lists' => $lists, 'page_no' => $get['page_no'], 'page_size' => $get['page_size'], 'more' => is_more($count, $get['page_no'], $get['page_size']), 'config' => $config, ]; } public static function isGroupbuy($item_id){ $where = [ 'item_id'=>$item_id, 'status'=>1, 'del'=>1 ]; $groupBuy = GroupbuyGoods::where($where)->find(); return $groupBuy; } }