license.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\command;
  4. use think\console\Command;
  5. use think\console\Input;
  6. use think\console\input\Argument;
  7. use think\console\input\Option;
  8. use think\console\Output;
  9. use app\admin\common\Ocr;
  10. use think\facade\Db;
  11. class license extends Command
  12. {
  13. protected function configure()
  14. {
  15. // 指令配置
  16. $this->setName('license')
  17. ->setDescription('the license command');
  18. }
  19. protected function execute(Input $input, Output $output)
  20. {
  21. // 指令输出
  22. $data=$this->getdata();
  23. $ocr =new Ocr();
  24. foreach ($data as $value){
  25. $datwa = $ocr->query("",$value['license_img']);
  26. if($datwa['code']==0 && isset($datwa['data']['result'])){
  27. $license = $datwa['data']['result'];
  28. $value['legaler']= isset($license['legal_representative'])?$license['legal_representative']:"";
  29. $value['addr']= isset($license['address'])?$license['address']:"";
  30. $value['registertime']= isset($license['found_date'])? $license['found_date']:"";
  31. $value['scope']= isset($license['business_scope'])?$license['business_scope']:"";
  32. $value['capital']= isset($license['registered_capital'])?$license['registered_capital']:"";
  33. $value['nature']= isset($license['type'])?$license['type']:"";
  34. $value['registercode']= isset($license['registration_number'])?$license['registration_number']:"";
  35. $value['status']=1;
  36. $value['ocr_status']=1;
  37. }else{
  38. $value['remark']="营业执照识别失败";
  39. $value['status']=0;
  40. $value['ocr_status']=2;
  41. }
  42. Db::name("supplier")->save($value);
  43. }
  44. $output->writeln('license');
  45. }
  46. public function getdata(){
  47. $sql = Db::name("supplier")->where(["ocr_status"=>2])->select();
  48. return $sql;
  49. }
  50. }