diff --git a/app/Command/getProductCommand.php b/app/Command/getProductCommand.php index e303f7c..aa4a64c 100644 --- a/app/Command/getProductCommand.php +++ b/app/Command/getProductCommand.php @@ -43,7 +43,7 @@ class getProductCommand extends HyperfCommand $page = 1; $page_size = 100; $result = $prescription->getProd(1, 100); - if (!empty($result['rows'])){ + if (!empty($result['rows'])) { foreach ($result['rows'] as $item) { // 执行入库 $this->handleData($item); @@ -55,7 +55,7 @@ class getProductCommand extends HyperfCommand for ($i = 2; $i < $count; $i++) { try { $result = $prescription->getProd($i, $page_size); - if (!isset($result['rows'])){ + if (!isset($result['rows'])) { continue; } @@ -63,7 +63,7 @@ class getProductCommand extends HyperfCommand // 执行入库 $this->handleData($item); } - }catch (\Exception $e){ + } catch (\Exception $e) { $this->line("部分商品更新失败:" . $e->getMessage()); } } @@ -109,6 +109,23 @@ class getProductCommand extends HyperfCommand return false; } + if (empty($item['thirdCode'])) { + Db::rollBack(); +// $this->line("商品更新失败,缺少药品价格" . json_encode($item, JSON_UNESCAPED_UNICODE)); + return false; + } + + $pharmacy_code = \Hyperf\Config\config("prescription_platform.pharmacy_code"); + if (empty($pharmacy_code)) { + $pharmacy_code = "JG-10009"; + } + + // 非药店编码 + if ($pharmacy_code != $item['thirdCode']) { + Db::rollBack(); + return false; + } + // 查询是否存在 $params = array(); $params['product_platform_code'] = $item['drugCode']; @@ -254,7 +271,7 @@ class getProductCommand extends HyperfCommand $data['product_platform_code'] = $item['drugCode']; // 第三方药店商品编码 - if (isset($item['thirdDrugCode'])){ + if (isset($item['thirdDrugCode'])) { $data['product_pharmacy_code'] = $item['thirdDrugCode']; }