request->params([ ['student_id', 0], ['status', ''], ['page', 1], ['limit', 10] ]); $this->validate($data, [ 'student_id' => 'require|integer|gt:0', 'page' => 'integer|egt:1', 'limit' => 'integer|between:1,50' ]); try { $service = new ContractService(); $result = $service->getContractList($data); return success($result, '获取合同列表成功'); } catch (\Exception $e) { return fail($e->getMessage()); } } /** * 获取合同详情 * @return Response */ public function getContractDetail() { $data = $this->request->params([ ['contract_id', 0], ['student_id', 0] ]); $this->validate($data, [ 'contract_id' => 'require|integer|gt:0', 'student_id' => 'require|integer|gt:0' ]); try { $service = new ContractService(); $result = $service->getContractDetail($data['contract_id'], $data['student_id']); return success($result, '获取合同详情成功'); } catch (\Exception $e) { return fail($e->getMessage()); } } /** * 获取合同签署表单配置 * @return Response */ public function getSignForm() { $data = $this->request->params([ ['contract_id', 0], ['student_id', 0] ]); $this->validate($data, [ 'contract_id' => 'require|integer|gt:0', 'student_id' => 'require|integer|gt:0' ]); try { $service = new ContractService(); $result = $service->getSignForm($data['contract_id'], $data['student_id']); return success($result, '获取签署表单成功'); } catch (\Exception $e) { return fail($e->getMessage()); } } /** * 提交合同签署 * @return Response */ public function signContract(Request $request) { $contract_id = $this->request->param('contract_id', 0); $sign_file = $this->request->param('sign_file', ''); if (empty($contract_id)) { return fail('合同ID不能为空'); } if (empty($sign_file)) { return fail('签名文件不能为空'); } $data = [ 'contract_id' => $contract_id, 'personnel_id' => $this->member_id, 'sign_file' => $sign_file ]; try { $service = new \app\service\api\apiService\ContractService(); $res = $service->signContract($data); if (!$res['code']) { return fail($res['msg']); } return success($res['data']); } catch (\Exception $e) { return fail('签订合同失败:' . $e->getMessage()); } } /** * 下载合同文件 * @return Response */ public function downloadContract() { $data = $this->request->params([ ['contract_id', 0], ['student_id', 0] ]); $this->validate($data, [ 'contract_id' => 'require|integer|gt:0', 'student_id' => 'require|integer|gt:0' ]); try { $service = new ContractService(); $result = $service->downloadContract($data['contract_id'], $data['student_id']); return success($result, '获取下载链接成功'); } catch (\Exception $e) { return fail($e->getMessage()); } } /** * 获取学员基本信息 * @return Response */ public function getStudentInfo() { $data = $this->request->params([ ['student_id', 0] ]); $this->validate($data, [ 'student_id' => 'require|integer|gt:0' ]); try { $service = new ContractService(); $result = $service->getStudentInfo($data['student_id']); return success($result, '获取学员信息成功'); } catch (\Exception $e) { return fail($e->getMessage()); } } }