67 lines
1.5 KiB
PHP
67 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Command;
|
|
|
|
use App\Model\Product;
|
|
use Extend\Prescription\Prescription;
|
|
use Hyperf\Command\Command as HyperfCommand;
|
|
use Hyperf\Command\Annotation\Command;
|
|
use Psr\Container\ContainerInterface;
|
|
|
|
/**
|
|
* 更新商品库存
|
|
*/
|
|
#[Command]
|
|
class getProductStockCommand extends HyperfCommand
|
|
{
|
|
public function __construct(protected ContainerInterface $container)
|
|
{
|
|
parent::__construct('getProductStock:command');
|
|
}
|
|
|
|
public function configure()
|
|
{
|
|
parent::configure();
|
|
$this->setDescription('获取处方平台商品库存数据');
|
|
}
|
|
|
|
public function handle()
|
|
{
|
|
$this->line("商品库存更新开始");
|
|
|
|
try {
|
|
// 获取商品
|
|
$params = array();
|
|
$product = Product::getPage($params);
|
|
if (empty($product['data'])){
|
|
$this->line("商品库存更新成功,无可更新库存商品");
|
|
return;
|
|
}
|
|
|
|
$prescription = new Prescription();
|
|
|
|
foreach ($product['data'] as $item){
|
|
if (!empty($item['product_pharmacy_code'])){
|
|
|
|
}
|
|
|
|
$result = $prescription->getProdStock($item['product_pharmacy_code']);
|
|
dump($result);die;
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
$this->line("商品库存更新失败:" . $e->getMessage());
|
|
}
|
|
|
|
|
|
|
|
$this->line("商品库存更新成功");
|
|
}
|
|
}
|