diff --git a/app/Command/getProductCommand.php b/app/Command/getProductCommand.php index 4c0107a..c9cb8a0 100644 --- a/app/Command/getProductCommand.php +++ b/app/Command/getProductCommand.php @@ -58,6 +58,10 @@ class getProductCommand extends HyperfCommand if ($result['count'] > $page * $page_size) { for ($i = 2; $i < $count; $i++) { $result = $prescription->getProd($i, $page_size); + if (!isset($result['rows'])){ + continue; + } + foreach ($result['rows'] as $item) { $concurrent->create(function () use($item) { // 执行入库 diff --git a/app/Command/getProductStockCommand.php b/app/Command/getProductStockCommand.php index 235c598..d7a1db8 100644 --- a/app/Command/getProductStockCommand.php +++ b/app/Command/getProductStockCommand.php @@ -55,7 +55,7 @@ class getProductStockCommand extends HyperfCommand for ($i = 2; $i <= $product['last_page']; $i++) { // 获取商品 $params = array(); - $product = Product::getPage($params,['*'],1,10); + $product = Product::getPage($params,['*'],$i,10); if (empty($product['data'])){ $this->line("商品库存更新成功,无可更新库存商品"); return; diff --git a/app/Model/Product.php b/app/Model/Product.php index da9132e..2f4b1b7 100644 --- a/app/Model/Product.php +++ b/app/Model/Product.php @@ -158,4 +158,14 @@ class Product extends Model return $data; } + + /** + * 新增 + * @param array $data + * @return \Hyperf\Database\Model\Model|Product + */ + public static function addProduct(array $data): \Hyperf\Database\Model\Model|Product + { + return self::create($data); + } }