You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
194 lines
5.2 KiB
194 lines
5.2 KiB
<?php
|
|
// +----------------------------------------------------------------------
|
|
// | Niucloud-admin 企业快速开发的多应用管理平台
|
|
// +----------------------------------------------------------------------
|
|
// | 官方网址:https://www.niucloud.com
|
|
// +----------------------------------------------------------------------
|
|
// | niucloud团队 版权所有 开源版本可自由商用
|
|
// +----------------------------------------------------------------------
|
|
|
|
namespace app\api\controller\student;
|
|
|
|
use app\service\api\student\ContractService;
|
|
use core\base\BaseController;
|
|
use think\Request;
|
|
use think\Response;
|
|
|
|
/**
|
|
* 学员合同管理控制器
|
|
* 用于学员端访问合同相关功能
|
|
*/
|
|
class ContractController extends BaseController
|
|
{
|
|
/**
|
|
* 获取学员合同列表
|
|
* @return Response
|
|
*/
|
|
public function getContractList()
|
|
{
|
|
$data = $this->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());
|
|
}
|
|
}
|
|
}
|