setName('SyncGoodsToPerMinute')->setDescription('同步商品数据到ES'); $this->addArgument("goods_id"); $this->addArgument("div"); $this->addArgument("mod"); $this->addArgument("minute"); } protected function execute(Input $input, Output $output) { ini_set('memory_limit', '1024M'); $goods_id = $input->getArgument("goods_id"); $div = $input->getArgument("div"); $mod = $input->getArgument("mod"); $minute = $input->getArgument("minute"); $min_time = time() - $minute * 60; $limit = 100; while (TRUE) { $sql = "SELECT * FROM `yoshop_goods` WHERE goods_id > " . $goods_id . " AND goods_id % ". $div . " = ". $mod ." AND update_time > ".$min_time." order by update_time asc LIMIT ".$limit; $list = Db::query($sql); if (!$list) { return true; } $obj = new GoodsCateEs(); $res = $obj->addOrUpdateGoodsAndGoodsCate($list); var_dump($res); $goods_id = end($list)['goods_id']; } } }