where(['status' => TeamEnum::TEAM_STATUS_CONDUCT])->count(); $lists = (new TeamActivity()) ->field('id,name,start_time,end_time,status') ->where(['status' => TeamEnum::TEAM_STATUS_CONDUCT]) ->where($where) ->page($get['page_no'] ?? 1, $get['page_size'] ?? 25) ->select() ->toArray(); foreach ($lists as &$item) { $item['status_text'] = TeamEnum::getActivityStatusDesc($item['status']); $item['start_time'] = date('Y-m-d H:i:s', $item['start_time']); $item['end_time'] = date('Y-m-d H:i:s', $item['end_time']); $item['goods_num'] = (new TeamGoods())->where(['team_id'=>$item['id']])->count(); } return [ 'count' => $count, 'lists' => $lists, 'page_no' => $get['page_no'] ?? 1, 'page_size' => $get['page_no'] ?? 25 ]; break; case 'seckill': $count = (new SeckillActivity()) ->where(['status' => TeamEnum::TEAM_STATUS_CONDUCT])->count(); $lists = (new SeckillActivity()) ->field('id,name,start_time,end_time,status') ->where(['status' => TeamEnum::TEAM_STATUS_CONDUCT]) ->where($where) ->select() ->toArray(); foreach ($lists as &$item) { $item['status_text'] = SeckillEnum::getSeckillStatusDesc($item['status']); $item['start_time'] = date('Y-m-d H:i:s', $item['start_time']); $item['end_time'] = date('Y-m-d H:i:s', $item['end_time']); $item['goods_num'] = (new SeckillGoods())->where(['seckill_id'=>$item['id']])->count(); } return [ 'count' => $count, 'lists' => $lists, 'page_no' => $get['page_no'] ?? 1, 'page_size' => $get['page_no'] ?? 25 ]; break; case 'bargain': $count = (new BargainActivity())->where(['status' => TeamEnum::TEAM_STATUS_CONDUCT])->count(); $lists = (new BargainActivity()) ->field('id,name,start_time,end_time,status') ->where(['status' => TeamEnum::TEAM_STATUS_CONDUCT]) ->where($where) ->select() ->toArray(); foreach ($lists as &$item) { $item['status_text'] = SeckillEnum::getSeckillStatusDesc($item['status']); $item['goods_num'] = (new BargainGoods())->where(['activity_id'=>$item['id']])->count(); } return [ 'count' => $count, 'lists' => $lists, 'page_no' => $get['page_no'] ?? 1, 'page_size' => $get['page_no'] ?? 25 ]; break; case "presell": $count = Presell::where('status', PresellEnum::STATUS_START)->count(); $lists = Presell::where('status', PresellEnum::STATUS_START) ->where($where) ->append([ 'type_text', 'status_text', 'send_type_text', 'goods_num' ]) ->select() ->toArray(); return [ 'count' => $count, 'lists' => $lists, 'page_no' => $get['page_no'] ?? 1, 'page_size' => $get['page_no'] ?? 25 ]; break; } return []; } /** * @notes 获取活动商品列表数据 * @param $type * @param $activity_id * @param $keyword * @return array * @author 张无忌 * @date 2021/10/9 18:41 */ public static function getActivityGoods($type, $activity_id, $keyword='') { switch ($type) { case 'team': $where = []; if ($keyword) { $where[] = ['G.name', 'like', '%'.$keyword.'%']; } $lists = (new TeamGoods())->alias('TG') ->field('TG.*,G.total_stock,G.name,G.image,G.min_price,G.max_price') ->join('goods G', 'G.id = TG.goods_id') ->where('TG.team_id', '=', intval($activity_id)) ->where($where) ->select()->toArray(); $data = []; foreach ($lists as $item) { $data[] = [ 'id' => $item['id'], 'goods_id' => $item['goods_id'], 'name' => $item['name'], 'image' => FileService::getFileUrl($item['image']), 'total_stock' => $item['total_stock'], 'min_price' => $item['min_price'], 'max_price' => $item['max_price'], 'min_activity_price' => $item['min_team_price'], 'max_activity_price' => $item['max_team_price'] ]; } return $data; break; case 'seckill': $where = []; if ($keyword) { $where[] = ['G.name', 'like', '%'.$keyword.'%']; } $lists = (new SeckillGoods())->alias('SG') ->field('SG.*,G.total_stock,G.name,G.image,G.min_price,G.max_price') ->join('goods G', 'G.id = SG.goods_id') ->where('SG.seckill_id', '=', intval($activity_id)) ->where($where) ->select()->toArray(); $data = []; foreach ($lists as $item) { $data[] = [ 'id' => $item['id'], 'goods_id' => $item['goods_id'], 'name' => $item['name'], 'image' => FileService::getFileUrl($item['image']), 'total_stock' => $item['total_stock'], 'min_price' => $item['min_price'], 'max_price' => $item['max_price'], 'min_activity_price' => $item['min_seckill_price'], 'max_activity_price' => $item['max_seckill_price'], ]; } return $data; break; case 'bargain': $where = []; if ($keyword) { $where[] = ['G.name', 'like', '%'.$keyword.'%']; } $lists = (new BargainGoods())->alias('BG') ->field('BG.*,G.total_stock,G.name,G.image,G.min_price,G.max_price') ->join('goods G', 'G.id = BG.goods_id') ->where('BG.activity_id', '=', intval($activity_id)) ->where($where) ->select()->toArray(); $data = []; foreach ($lists as $item) { $data[] = [ 'id' => $item['id'], 'goods_id' => $item['goods_id'], 'name' => $item['name'], 'image' => FileService::getFileUrl($item['image']), 'total_stock' => $item['total_stock'], 'min_price' => $item['min_price'], 'max_price' => $item['max_price'], 'min_activity_price' => $item['min_price'], 'max_activity_price' => $item['max_price'] ]; } return $data; break; case 'presell': $where = []; if ($keyword) { $where[] = ['G.name', 'like', '%'.$keyword.'%']; } $lists = (new PresellGoods())->alias('PG') ->field([ 'PG.*' ]) ->with([ 'detail' ]) ->join('goods G', 'G.id = PG.goods_id') ->where('PG.presell_id', '=', intval($activity_id)) ->where($where) ->select()->toArray(); $data = []; foreach ($lists as $item) { $data[] = [ 'id' => $item['id'], 'goods_id' => $item['goods_id'], 'name' => $item['detail']['name'], 'image' => FileService::getFileUrl($item['detail']['image']), 'total_stock' => $item['detail']['total_stock'], 'min_price' => $item['detail']['min_price'], 'max_price' => $item['detail']['max_price'], 'min_activity_price' => $item['min_price'], 'max_activity_price' => $item['max_price'], ]; } return $data; break; } return []; } }