FirmController.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Http\Controllers\ApiController;
  4. use App\Models\Firm;
  5. use App\Servers\ESign\ESignFirmServer;
  6. use App\Servers\System\CommonServer;
  7. use App\Servers\System\JobServer;
  8. class FirmController extends ApiController
  9. {
  10. /**
  11. * 添加&编辑用户
  12. * @return \Illuminate\Http\JsonResponse
  13. * @throws \Throwable
  14. */
  15. function createFirm(){
  16. $firm_name=request()->input('firm_name','');//姓名
  17. $phone=request()->input('phone','');//电话
  18. $license_number=request()->input('license_number','');//统一社会信用代码
  19. $license_img=request()->input('license_img','');//营业执照
  20. $registered_address=request()->input('registered_address','');//注册地址
  21. $legal_identity_one=request()->input('legal_identity_one','');//法人身份证正明
  22. $legal_identity_two=request()->input('legal_identity_two','');//法人身份证背面
  23. $legal_id_number=request()->input('legal_id_number','');//身份证号
  24. if (empty($firm_name)) return $this->apiResponseError('请填写姓名');
  25. if (mb_strlen($firm_name) > 100) return $this->apiResponseError('姓名最大100');
  26. if (empty($phone)) return $this->apiResponseError('请填写手机号');
  27. if (!CommonServer::creatServer()->verifyPhoneNumber($phone)) return $this->apiResponseError('手机号错误');
  28. if (empty($license_number)) return $this->apiResponseError('请填写统一社会信用代码');
  29. if (empty($license_img)) return $this->apiResponseError('请上传营业执照');
  30. if (empty($registered_address)) return $this->apiResponseError('注册地址不能为空');
  31. if (empty($legal_identity_one)) return $this->apiResponseError('请传身份证正面');
  32. if (empty($legal_identity_two)) return $this->apiResponseError('请传身份证反面');
  33. if (empty($legal_id_number)) return $this->apiResponseError('请填身份证号码');
  34. //检查该统一社会信用代码是否存在
  35. $firm = Firm::where('license_number',$license_number)->where('is_del',0)->select(['id'])->first();
  36. if (!empty($firm)){
  37. return $this->apiResponseError('统一社会信用代码已存在');
  38. }
  39. $authType = 'ORG';
  40. $data = compact('firm_name','phone','license_number','license_img','registered_address','authType','legal_identity_one','legal_identity_two','legal_id_number');
  41. $res = Firm::create($data);
  42. $firm_id = $res->{'id'};
  43. //查询个人认证信息
  44. ESignFirmServer::creatServer()->organizationsIdentityInfo($firm_id,$firm_name);
  45. if ($res) {
  46. return $this->apiResponseSuccess('操作成功');
  47. } else {
  48. return $this->apiResponseError('操作失败');
  49. }
  50. }
  51. /**
  52. * 获取详情
  53. * @return \Illuminate\Http\JsonResponse
  54. */
  55. function getFirmInfo()
  56. {
  57. $id = request()->input('id','');//获取需要删除的id
  58. if(empty($id)) return $this->apiResponseError('缺少必要参数');
  59. $info = Firm::where('id',$id)->select(['id','firm_name','phone','license_number','license_img','registered_address','authType','legal_identity_one','legal_identity_two','legal_id_number'])->first();
  60. if (empty($info)) {
  61. return $this->apiResponseError('该企业不存在');
  62. }
  63. return $this->apiResponseSuccess('成功',$info);
  64. }
  65. }