123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- declare (strict_types = 1);
- namespace app\command;
- use think\console\Command;
- use think\console\Input;
- use think\console\input\Argument;
- use think\console\input\Option;
- use think\console\Output;
- use app\admin\common\Ocr;
- use think\facade\Db;
- class license extends Command
- {
- protected function configure()
- {
- // 指令配置
- $this->setName('license')
- ->setDescription('the license command');
- }
- protected function execute(Input $input, Output $output)
- {
- // 指令输出
- $data=$this->getdata();
- $ocr =new Ocr();
- foreach ($data as $value){
- $datwa = $ocr->query("",$value['license_img']);
- if($datwa['code']==0 && isset($datwa['data']['result'])){
- $license = $datwa['data']['result'];
- $value['legaler']= isset($license['legal_representative'])?$license['legal_representative']:"";
- $value['addr']= isset($license['address'])?$license['address']:"";
- $value['registertime']= isset($license['found_date'])? $license['found_date']:"";
- $value['scope']= isset($license['business_scope'])?$license['business_scope']:"";
- $value['capital']= isset($license['registered_capital'])?$license['registered_capital']:"";
- $value['nature']= isset($license['type'])?$license['type']:"";
- $value['registercode']= isset($license['registration_number'])?$license['registration_number']:"";
- $value['status']=1;
- $value['ocr_status']=1;
- }else{
- $value['remark']="营业执照识别失败";
- $value['status']=0;
- $value['ocr_status']=2;
- }
- Db::name("supplier")->save($value);
- }
- $output->writeln('license');
- }
- public function getdata(){
- $sql = Db::name("supplier")->where(["ocr_status"=>2])->select();
- return $sql;
- }
- }
|