input('search'); $where = [['is_del',0]]; if(!empty($search)){ $where[] = ['name','like','%'.$search.'%']; } $list = Contract::where($where) ->select(['id','name','texts','sign_party']) ->paginate(10); return $this->apiResponseSuccess('获取列表成功', [ 'items' => $list->items(), 'total' => $list->total(), 'limit' => 10, ]); } /** * 获取机构列表 * @return \Illuminate\Http\JsonResponse */ function getFirmList(){ $search=request()->input('search'); $where = [['is_del',0], ['realnameStatus',1], ['authorizeUserInfo',1]]; if(!empty($search)){ $where[] = ['firm_name','like','%'.$search.'%']; } $list = Firm::where($where) ->select(['id','firm_name','license_number','legal_name','authType','orgId','realnameStatus','authorizeUserInfo','created_at']) ->paginate(10); return $this->apiResponseSuccess('获取列表成功', [ 'items' => $list->items(), 'total' => $list->total(), 'limit' => 10, ]); } /** * 获取用户列表 * @return \Illuminate\Http\JsonResponse */ function getMemberList(){ $search=request()->input('search'); $where = [['is_del',0], ['realnameStatus',1], ['authorizeUserInfo',1]]; if(!empty($search)){ $where[] = ['name','like','%'.$search.'%']; } $list = Member::where($where) ->select(['id','name','phone','id_number','authType','psnId','realnameStatus','authorizeUserInfo','created_at']) ->paginate(10); return $this->apiResponseSuccess('获取列表成功', [ 'items' => $list->items(), 'total' => $list->total(), 'limit' => 10, ]); } /** * 获取签署列表 * @return \Illuminate\Http\JsonResponse */ function getSignContractList() { $search=request()->input('search'); $where = [['is_del',0]]; if(!empty($search)){ $where[] = ['contracts_no','like','%'.$search.'%']; } $list = SignContract::where($where) ->select(['id','contract_no','status','contract_id','created_at']) ->paginate(10); foreach ($list as $key => $value) { $value->{'contracts_name'} = Contract::where('id',$value->contracts_id)->value('name'); } return $this->apiResponseSuccess('获取列表成功', [ 'items' => $list->items(), 'total' => $list->total(), 'limit' => 10, ]); } /** * 创建合同签署 * @return \Illuminate\Http\JsonResponse * @throws \PhpOffice\PhpWord\Exception\Exception */ function createSignContract() { $contract_id=request()->input('contract_id','');//合同id $contract_no=request()->input('contract_no','');//合同编号 $text_json=request()->input('textsJson','');//替换文本json $sign_json=request()->input('signJson','');//签署区域信息 if(empty($contract_id)){ return $this->apiResponseError('请选择合同'); } if(empty($text_json)){ return $this->apiResponseError('请填写合同信息'); } if(empty($sign_json)){ return $this->apiResponseError('请选择签署信息'); } //获取合同信息 $contract = Contract::where(['id'=>$contract_id])->first(); if (empty($contract)){ return $this->apiResponseError('合同不存在'); } //替换合同信息 $file_path = $contract->{'contracts_file'}; // 获取所有信息 $pathInfo = pathinfo($file_path); $file_name = $pathInfo['filename'].$contract_no.'.'.$pathInfo['extension']; //替换合同信息 $local_file = WordServer::creatServer()->replaceWordText($file_path,$file_name,$text_json); //上传文件到e签宝并获得文件id $file_id = ESignContractServer::creatServer()->fileUploadUrl($local_file); $data = compact('contract_id','contract_no','file_id','text_json','sign_json','local_file'); //存入数据库 $sign = SignContract::create($data); if (empty($sign)){ return $this->apiResponseError('保存失败'); } return $this->apiResponseSuccess('保存成功'); } }