SignContractCommand.php 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. if(!in_array($file_status,[2,5])){
  55. continue;
  56. }
  57. //发起合同签署
  58. $result = ESignContractServer::creatServer()->setContractContract($sign_id,$file_id,$sign_json,$file_name);
  59. if ($result['code'] == 0){
  60. SignContract::where('id',$sign_id)->where('is_del',0)->update(['status'=>10,'msg'=>$result['msg']]);
  61. }
  62. }
  63. $this->info('合同签署发起完成');
  64. return true;
  65. }
  66. }