MenuEnum::getMenuContent(1, true), '个人中心' => MenuEnum::getMenuContent(2, true), '分销' => MenuEnum::getMenuContent(3, true), ]; } /** * @notes 获取普通商品 */ public static function getOrdinaryGoods($get) { $where[] = ['del','=',0]; if(isset($get['goods_name']) && $get['goods_name']){ $where[] = ['name','like','%'.$get['goods_name'].'%']; } $lists = Goods::where($where) ->paginate(['list_rows'=>$get['limit'],'page'=>$get['page']]); $list = $lists->items(); foreach ($list as $key => $goods){ $price = $goods['min_price'].'~'.$goods['max_price']; if($goods['min_price'] !== $goods['max_price']){ $price = $goods['min_price']; } $list[$key]['price'] = $price; } $count = $lists->total(); return ['count'=>$count,'lists'=>$list]; } /** * @notes 获取平台商品分类 */ public static function getPlatformGoodsCategory($get) { $lists = GoodsCategoryModel::field('id,name') ->where(['level'=>1,'is_show'=>1,'del'=>0]) ->order('sort', 'asc') ->select() ->toArray(); $count = GoodsCategoryModel::where(['level'=>1,'is_show'=>1,'del'=>0])->count(); return ['count'=>$count,'lists'=>$lists]; } /** * @notes 获取商家列表 */ public static function getShopList($get) { $where = [ ['del', '=', 0], ['del', '=', 0] ]; $model = new Shop(); $lists = $model->field('id,name') ->where($where) ->order('id', 'desc') ->paginate([ 'page' => $get['page'], 'list_rows' => $get['limit'], 'var_page' => 'page' ]) ->toArray(); return ['count'=>$lists['total'], 'lists'=>$lists['data']]; } /** * @notes 获取活动专区 */ public static function getActivityArea($get) { $where[] = ['del', '=', 0]; $where[] = ['status', '=', 1]; $lists = ActivityArea::where($where) ->field('id,name') ->page($get['page'], $get['limit']) ->select(); $count = ActivityArea::where($where) ->count(); return ['count' => $count, 'lists' => $lists]; } /** * @notes 获取秒杀商品 */ public static function getSeckillGoods($get) { $where = [ ['sg.del', '=', 0], ]; // 商品名称 if(isset($get['goods_name']) && !($get['goods_name'] == '')) { $where[] = ['g.name', 'like', '%'.trim($get['goods_name']).'%']; } $lists = SeckillGoods::alias('sg') ->leftJoin('goods g', 'sg.goods_id=g.id') ->field('sg.seckill_id,g.name,g.image,g.min_price,g.max_price,start_date,end_date,g.id') ->where($where) ->group('sg.goods_id') ->order(['sg.id' => 'desc']) ->select() ->toArray(); foreach($lists as &$item) { // 秒杀价格 $price = SeckillGoods::where([ 'del' => 0, 'seckill_id' => $item['seckill_id'], 'goods_id' => $item['id'], 'start_date' => $item['start_date'], 'end_date' => $item['end_date'], ])->column('price', 'id'); $seckill_min_price = min($price); $seckill_max_price = max($price); $item['seckill_price'] = $seckill_min_price == $seckill_max_price ? '¥ ' .$seckill_min_price : '¥ '. $seckill_min_price . ' ~ ¥ ' . $seckill_max_price; // 商品价格 $item['goods_price'] = $item['min_price'] == $item['max_price'] ? '¥ ' .$item['min_price'] : '¥ '. $item['min_price'] .' ~ ¥ '. $item['max_price']; } // 分页 $count = count($lists); $index = ($get['page'] -1) * $get['limit']; $lists = array_slice($lists, $index, $get['limit']); return ['count' => $count,'lists' => $lists]; } /** * @notes 获取拼团商品 */ public static function getTeamGoods($get) { $where[] = ['T.del', '=', 0]; $where[] = ['T.status', '=', 1]; if (!empty($get['goods_name']) and $get['goods_name']) { $where[] = ['G.name', 'like', '%'.$get['goods_name'].'%']; } $model = new TeamActivity(); $lists = $model->alias('T')->field('G.id,G.name,G.image,TG.team_price') ->where($where) ->join('goods G', 'G.id = T.goods_id') ->join('team_goods TG', 'TG.team_id = T.id') ->paginate([ 'page' => $get['page'] ?? 1, 'list_rows' => $get['limit'] ?? 20, 'var_page' => 'page' ])->toArray(); return ['count'=>$lists['total'], 'lists'=>$lists['data']]; } }