SignContractCommand.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Models\SignContract;
  4. use App\Servers\ESign\ESignContractServer;
  5. use Illuminate\Console\Command;
  6. /**
  7. * 合同签署任务
  8. * Class SignContractCommand
  9. * @package App\Console\Commands
  10. */
  11. class SignContractCommand extends Command
  12. {
  13. /**
  14. * The name and signature of the console command.
  15. *
  16. * @var string
  17. */
  18. protected $signature = 'sign:contract';
  19. /**
  20. * The console command description.
  21. *
  22. * @var string
  23. */
  24. protected $description = '合同签署任务';
  25. /**
  26. * Create a new command instance.
  27. *
  28. * @return void
  29. */
  30. public function __construct()
  31. {
  32. parent::__construct();
  33. }
  34. /**
  35. * Execute the console command.
  36. *
  37. * @return mixed
  38. */
  39. public function handle()
  40. {
  41. $this->info('发起合同签署检查');
  42. //获取所有文件待转的记录
  43. $list = SignContract::where('status',0)->where('is_del',0)->get();
  44. foreach ($list as $value){
  45. $sign_id = $value->{'id'};
  46. $file_id = $value->{'file_id'};
  47. $sign_json = $value->{'sign_json'};
  48. $file_path = $value->{'local_file'};
  49. // 获取所有信息
  50. $pathInfo = pathinfo($file_path);
  51. $file_name = $pathInfo['filename'];
  52. //获取文件状态
  53. $file_status = ESignContractServer::creatServer()->getFileStatus($value->{'file_id'});
  54. $this->info('文件状态:'.$file_status);
  55. if(!in_array($file_status,[2,5])){
  56. continue;
  57. }
  58. //发起合同签署
  59. $result = ESignContractServer::creatServer()->setContractContract($sign_id,$file_id,$sign_json,$file_name);
  60. if ($result['code'] == 0){
  61. SignContract::where('id',$sign_id)->where('is_del',0)->update(['status'=>10,'msg'=>$result['msg']]);
  62. }
  63. }
  64. $this->info('合同签署发起完成');
  65. return true;
  66. }
  67. }