修改更新商品库存

This commit is contained in:
wucongxing 2023-05-18 14:33:10 +08:00
parent f577c6c3cd
commit ca6351ca2e
3 changed files with 15 additions and 1 deletions

View File

@ -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) {
// 执行入库

View File

@ -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;

View File

@ -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);
}
}