| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- <?php
- namespace App\Http\Controllers\AdminApi;
- use App\Http\Controllers\AdminController;
- use App\Models\Firm;
- use App\Servers\ESign\ESignFirmServer;
- use App\Servers\System\CommonServer;
- use App\Servers\System\JobServer;
- class FirmController extends AdminController
- {
- /**
- * 获取机构列表
- * @return \Illuminate\Http\JsonResponse
- */
- function getFirmList(){
- $where = [['is_del',0]];
- $list = Firm::where($where)
- ->select(['id','firm_name','license_number','legal_name','orgId','authUrl','authShortUrl','realnameStatus','authorizeUserInfo','created_at'])
- ->paginate(10);
- return $this->apiResponseSuccess('获取列表成功', [
- 'items' => $list->items(),
- 'total' => $list->total(),
- 'limit' => 10,
- ]);
- }
- /**
- * 通知企业认证
- * @return \Illuminate\Http\JsonResponse
- */
- function noticeFirmAuth(){
- $id=request()->input('id','');//id
- if(empty($id)) return $this->apiResponseError('缺少必要参数');
- $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();
- if (empty($info)) {
- return $this->apiResponseError('没有找到该记录');
- }
- //查询个人认证信息
- ESignFirmServer::creatServer()->organizationsIdentityInfo($id,$info->{'firm_name'});
- return $this->apiResponseSuccess('成功');
- }
- /**
- * 添加&编辑用户
- * @return \Illuminate\Http\JsonResponse
- * @throws \Throwable
- */
- function saveFirm(){
- $id=request()->input('id','');//id
- $firm_name=request()->input('firm_name','');//姓名
- $phone=request()->input('phone','');//电话
- $license_number=request()->input('license_number','');//统一社会信用代码
- $license_img=request()->input('license_img','');//营业执照
- $registered_address=request()->input('registered_address','');//注册地址
- $legal_identity_one=request()->input('legal_identity_one','');//法人身份证正明
- $legal_identity_two=request()->input('legal_identity_two','');//法人身份证背面
- $legal_id_number=request()->input('legal_id_number','');//身份证号
- $legal_name=request()->input('legal_name','');//法人姓名
- if (empty($firm_name)) return $this->apiResponseError('请填写姓名');
- if (empty($legal_name)) return $this->apiResponseError('请填写法人姓名');
- if (mb_strlen($firm_name) > 100) return $this->apiResponseError('姓名最大100');
- if (empty($phone)) return $this->apiResponseError('请填写手机号');
- if (!CommonServer::creatServer()->verifyPhoneNumber($phone)) return $this->apiResponseError('手机号错误');
- if (empty($license_number)) return $this->apiResponseError('请填写统一社会信用代码');
- if (empty($license_img)) return $this->apiResponseError('请上传营业执照');
- if (empty($registered_address)) return $this->apiResponseError('注册地址不能为空');
- if (empty($legal_identity_one)) return $this->apiResponseError('请传身份证正面');
- if (empty($legal_identity_two)) return $this->apiResponseError('请传身份证反面');
- if (empty($legal_id_number)) return $this->apiResponseError('请填身份证号码');
- $authType = 'ORG';
- $data = compact('firm_name','phone','license_number','license_img','registered_address','authType','legal_identity_one','legal_identity_two','legal_id_number','legal_name');
- if(empty($id)){//不存在id就创建
- //检查该统一社会信用代码是否存在
- $firm = Firm::where('license_number',$license_number)->where('is_del',0)->select(['id'])->first();
- if (!empty($firm)){
- return $this->apiResponseError('统一社会信用代码已存在');
- }
- $res = Firm::create($data);
- $firm_id = $res->{'id'};
- }else{//存在就更新
- $info = Firm::where('id',$id)->select(['id'])->first();
- if (empty($info)) {
- return $this->apiResponseError('没有找到该记录');
- }
- //检查该统一社会信用代码是否存在
- $firm = Firm::where('license_number',$license_number)->where('id','<>',$id)->where('is_del',0)->select(['id'])->first();
- if (!empty($firm)){
- return $this->apiResponseError('统一社会信用代码已存在');
- }
- $res = $info->update($data);
- $firm_id = $id;
- }
- //查询个人认证信息
- ESignFirmServer::creatServer()->organizationsIdentityInfo($firm_id,$firm_name);
- if ($res) {
- return $this->apiResponseSuccess('操作成功');
- } else {
- return $this->apiResponseError('操作失败');
- }
- }
- /**
- * 获取详情
- * @return \Illuminate\Http\JsonResponse
- */
- function getFirmInfo()
- {
- $id = request()->input('id','');//获取需要删除的id
- if(empty($id)) return $this->apiResponseError('缺少必要参数');
- $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','legal_name'])->first();
- if (empty($info)) {
- return $this->apiResponseError('没有找到该记录');
- }
- return $this->apiResponseSuccess('成功',$info);
- }
- }
|