SignContractController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. namespace App\Http\Controllers\AdminApi;
  3. use App\Http\Controllers\AdminController;
  4. use App\Models\Contract;
  5. use App\Models\Firm;
  6. use App\Models\Member;
  7. use App\Servers\ESign\ESignContractServer;
  8. use App\Servers\Wps\WordServer;
  9. class SignContractController extends AdminController
  10. {
  11. /**
  12. * 获取项目合同
  13. * @return \Illuminate\Http\JsonResponse
  14. */
  15. function getContractList()
  16. {
  17. $search=request()->input('search');
  18. $where = [['is_del',0]];
  19. if(!empty($search)){
  20. $where[] = ['name','like','%'.$search.'%'];
  21. }
  22. $list = Contract::where($where)
  23. ->select(['id','name','texts','sign_party'])
  24. ->paginate(10);
  25. return $this->apiResponseSuccess('获取列表成功', [
  26. 'items' => $list->items(),
  27. 'total' => $list->total(),
  28. 'limit' => 10,
  29. ]);
  30. }
  31. /**
  32. * 获取机构列表
  33. * @return \Illuminate\Http\JsonResponse
  34. */
  35. function getFirmList(){
  36. $search=request()->input('search');
  37. $where = [['is_del',0], ['realnameStatus',1], ['authorizeUserInfo',1]];
  38. if(!empty($search)){
  39. $where[] = ['firm_name','like','%'.$search.'%'];
  40. }
  41. $list = Firm::where($where)
  42. ->select(['id','firm_name','license_number','legal_name','orgId','realnameStatus','authorizeUserInfo','created_at'])
  43. ->paginate(10);
  44. return $this->apiResponseSuccess('获取列表成功', [
  45. 'items' => $list->items(),
  46. 'total' => $list->total(),
  47. 'limit' => 10,
  48. ]);
  49. }
  50. /**
  51. * 获取用户列表
  52. * @return \Illuminate\Http\JsonResponse
  53. */
  54. function getMemberList(){
  55. $search=request()->input('search');
  56. $where = [['is_del',0], ['realnameStatus',1], ['authorizeUserInfo',1]];
  57. if(!empty($search)){
  58. $where[] = ['name','like','%'.$search.'%'];
  59. }
  60. $list = Member::where($where)
  61. ->select(['id','name','phone','id_number','psnId','realnameStatus','authorizeUserInfo','created_at'])
  62. ->paginate(10);
  63. return $this->apiResponseSuccess('获取列表成功', [
  64. 'items' => $list->items(),
  65. 'total' => $list->total(),
  66. 'limit' => 10,
  67. ]);
  68. }
  69. function createSignContract()
  70. {
  71. $contract_id=request()->input('contract_id');//合同id
  72. $contract_no=request()->input('contract_no');//合同编号
  73. $text_json=request()->input('textsJson');//替换文本json
  74. $sign_json=request()->input('signJson');//签署区域信息
  75. if(empty($contract_id)){
  76. return $this->apiResponseError('请选择合同');
  77. }
  78. if(empty($textsJson)){
  79. return $this->apiResponseError('请填写合同信息');
  80. }
  81. if(empty($signJson)){
  82. return $this->apiResponseError('请选择签署信息');
  83. }
  84. //获取合同信息
  85. $contract = Contract::where(['id'=>$contract_id])->first();
  86. if (empty($contract)){
  87. return $this->apiResponseError('合同不存在');
  88. }
  89. //替换合同信息
  90. $file_path = $contract->{'contracts_file'};
  91. // 获取所有信息
  92. $pathInfo = pathinfo($file_path);
  93. $file_name = $pathInfo['filename'].$contract_no.'.'.$pathInfo['extension'];
  94. //替换合同信息
  95. $local_file = WordServer::creatServer()->replaceWordText($file_path,$file_name,$textsJson);
  96. //上传文件到e签宝并获得文件id
  97. $file_id = ESignContractServer::creatServer()->fileUploadUrl($local_file);
  98. $data = compact('contract_id','contract_no','file_id','text_json','sign_json','local_file');
  99. }
  100. }