新增医生证书申请命令执行
This commit is contained in:
parent
97a8cc6a59
commit
17cb41cc9a
133
app/Command/getCaCertCommand.php
Normal file
133
app/Command/getCaCertCommand.php
Normal file
@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\Command;
|
||||
|
||||
use App\Model\User;
|
||||
use App\Model\UserCaCert;
|
||||
use App\Model\UserDoctor;
|
||||
use App\Model\UserDoctorInfo;
|
||||
use Extend\Ca\CaOnline;
|
||||
use Hyperf\Command\Command as HyperfCommand;
|
||||
use Hyperf\Command\Annotation\Command;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
#[Command]
|
||||
class getCaCertCommand extends HyperfCommand
|
||||
{
|
||||
public function __construct(protected ContainerInterface $container)
|
||||
{
|
||||
parent::__construct('getCaCert:command');
|
||||
}
|
||||
|
||||
public function configure()
|
||||
{
|
||||
parent::configure();
|
||||
$this->setDescription('Ca证书申请');
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
$this->line('开始');
|
||||
|
||||
// 获取全部医生
|
||||
$params = array();
|
||||
$params['status'] = 1;
|
||||
$params['idcard_status'] = 1;
|
||||
$params['iden_auth_status'] = 1;
|
||||
$params['multi_point_status'] = 1;
|
||||
$user_doctors = UserDoctor::getList($params);
|
||||
if (empty($user_doctors)){
|
||||
$this->line('结束,无医生需处理');
|
||||
return;
|
||||
}
|
||||
|
||||
// 获取医院数据
|
||||
$params = array();
|
||||
$params['is_system'] = 1;
|
||||
$params['type'] = 2;
|
||||
$user_ca_cert = UserCaCert::getOne($params);
|
||||
if (empty($user_ca_cert)){
|
||||
$CaOnline = new CaOnline();
|
||||
|
||||
// 申请医院证书
|
||||
$data = array();
|
||||
$data['user_id'] = "5345345461";
|
||||
$data['mobile'] = "18601047315";
|
||||
$data['org_name'] = "成都金牛欣欣相照互联网医院有限公司";
|
||||
$data['org_number'] = "91510106MABTJY4K9R";
|
||||
|
||||
$result = $CaOnline->getCloudCert($data,'Organizational');
|
||||
|
||||
$data = array();
|
||||
$data['is_system'] = 1;
|
||||
$data['type'] = 2;
|
||||
$data['cert_base64'] = $result['certBase64'];
|
||||
$data['cert_chain_p7'] = $result['certP7'];
|
||||
$data['cert_serial_number'] = $result['certSerialnumber'];
|
||||
$data['ca_pin'] = "5345345461";
|
||||
$doctor_pharmacist_cert = UserCaCert::addDoctorPharmacistCert($data);
|
||||
if (empty($doctor_pharmacist_cert)){
|
||||
$this->line('错误:医院证书错误');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($user_doctors as $user_doctor){
|
||||
try {
|
||||
// 获取医生ca证书数据
|
||||
$params = array();
|
||||
$params['user_id'] = $user_doctor['user_id'];
|
||||
$user_ca_cert = UserCaCert::getOne($params);
|
||||
if (!empty($user_ca_cert)){
|
||||
continue;
|
||||
}
|
||||
|
||||
// 获取用户数据
|
||||
$params = array();
|
||||
$params['user_id'] = $user_doctor['user_id'];
|
||||
$user = User::getOne($params);
|
||||
if (empty($user)){
|
||||
continue;
|
||||
}
|
||||
|
||||
$params = array();
|
||||
$params['user_id'] = $user_doctor['user_id'];
|
||||
$user_doctor_info = UserDoctorInfo::getOne($params);
|
||||
if (empty($user_doctor_info)){
|
||||
continue;
|
||||
}
|
||||
|
||||
$CaOnline = new CaOnline();
|
||||
|
||||
$data = array();
|
||||
$data['user_id'] = $user_doctor['user_id'];
|
||||
$data['mobile'] = $user['mobile'];
|
||||
$data['card_name'] = $user_doctor_info['card_name'];
|
||||
$data['card_num'] = $user_doctor_info['card_num'];
|
||||
$data['orgDept'] = $user_doctor['department_custom_name'];
|
||||
$result = $CaOnline->getCloudCert($data);
|
||||
|
||||
$data = array();
|
||||
$data['user_id'] = $user_doctor['user_id'];
|
||||
$data['type'] = 2;
|
||||
$data['cert_base64'] = $result['certBase64'];
|
||||
$data['cert_chain_p7'] = $result['certP7'];
|
||||
$data['cert_serial_number'] = $result['certSerialnumber'];
|
||||
$data['ca_pin'] = $user_doctor['user_id'];
|
||||
$doctor_pharmacist_cert = UserCaCert::addDoctorPharmacistCert($data);
|
||||
if (empty($doctor_pharmacist_cert)){
|
||||
$this->line('错误');
|
||||
return;
|
||||
}
|
||||
|
||||
$this->line('成功');
|
||||
}catch (\Exception $e){
|
||||
$this->line('错误:' . $e->getMessage());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
$this->line('全部结束');
|
||||
}
|
||||
}
|
||||
@ -127,6 +127,17 @@ class UserDoctor extends Model
|
||||
return self::where($params)->first($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取数据-多
|
||||
* @param array $params
|
||||
* @param array $fields
|
||||
* @return Collection|array
|
||||
*/
|
||||
public static function getList(array $params = [], array $fields = ['*']): Collection|array
|
||||
{
|
||||
return self::where($params)->get($fields);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增医生-批量
|
||||
* @param array $data 新增数据
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user