init(); // } self::$stInstance->init(); return self::$stInstance; } private function init() { $this->mAmountGoods = []; $this->mGoodsBlock = []; //$blocks = special_manager::instance()->special(62,$goods_ids); $formater = new special_formater(62,false); $blocks = $formater->format($goods_ids); foreach ($blocks as $block) { $item_type = $block['item_type']; $item_title = $block['item_title']; $amount = intval($item_title); if($item_type == 'home_goods' && $amount > 0) { $items = $block['items']; foreach ($items as $item) { $this->add($amount,$item); } } } krsort($this->mAmountGoods); } private function add($amount,$item) { $goods_id = intval($item['data']); if($goods_id <= 0) return; if(array_key_exists($amount,$this->mAmountGoods) == false) { $this->mAmountGoods[$amount] = []; } $this->mAmountGoods[$amount][] = $goods_id; $this->mGoodsBlock[$goods_id] = $item; } public function fetch($amount,$count) { $amount = intval($amount); if($amount <=0) return false; $gids = []; foreach ($this->mAmountGoods as $key => $val) { if($key <= $amount) { $gids = array_merge($gids,$val); } } return $gids; } }