多药房
Build Docker / build (push) Canceled after 0s

This commit is contained in:
haomingming
2026-09-08 10:09:07 +08:00
parent 4dfcdacb12
commit d3fce247e5
20 changed files with 782 additions and 65 deletions
+21 -7
View File
@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace App\Command;
use App\Model\Pharmacy;
use App\Model\Product;
use App\Model\ProductPlatform;
use App\Utils\Log;
@@ -21,6 +22,18 @@ use Symfony\Component\Console\Input\InputArgument;
#[Command]
class getProductCommand extends HyperfCommand
{
protected array $active_pharmacies = [];
protected function getPharmacy(string $code)
{
if (empty($this->active_pharmacies)) {
$list = Pharmacy::where('status', 1)->get();
foreach ($list as $p) {
$this->active_pharmacies[$p->pharmacy_code] = $p;
}
}
return $this->active_pharmacies[$code] ?? null;
}
public function __construct(protected ContainerInterface $container)
{
parent::__construct('getProduct:command');
@@ -117,13 +130,8 @@ class getProductCommand extends HyperfCommand
try {
Db::beginTransaction();
$pharmacy_code = \Hyperf\Config\config("prescription_platform.pharmacy_code");
if (empty($pharmacy_code)) {
$pharmacy_code = "JG-10009";
}
// 非药店编码
if ($pharmacy_code != $item['thirdCode']) {
$pharmacy = $this->getPharmacy($item['thirdCode']);
if (empty($pharmacy)) {
Db::rollBack();
return false;
}
@@ -133,6 +141,7 @@ class getProductCommand extends HyperfCommand
$params['product_platform_code'] = $item['drugCode'];
$params['product_pharmacy_code'] = $item['thirdDrugCode'];
$params['license_number'] = $item['approvalNumber'];
$params['pharmacy_code'] = $item['thirdCode'];
$product_platform = ProductPlatform::getOne($params);
if (!empty($product_platform)) {
// 已存在,更新
@@ -214,6 +223,10 @@ class getProductCommand extends HyperfCommand
}
}
$product_platform_data['pharmacy_code'] = $item['thirdCode'];
$product_data['pharmacy_code'] = $item['thirdCode'];
$product_data['pharmacy_id'] = (string)$pharmacy->pharmacy_id;
if (!empty($product_platform_data)) {
// 更新商品表-处方平台
$params = array();
@@ -236,6 +249,7 @@ class getProductCommand extends HyperfCommand
} else {
// 不存在,创建
$data = array();
$data['pharmacy_code'] = $item['thirdCode'];
// 商品名称
if (isset($item['tradeName'])) {
$data['product_name'] = $item['tradeName'];