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.
187 lines
4.9 KiB
187 lines
4.9 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\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()
|
|
{
|
|
$data = $this->request->params([
|
|
['contract_id', 0],
|
|
['student_id', 0],
|
|
['form_data', []],
|
|
['signature_image', '']
|
|
]);
|
|
|
|
$this->validate($data, [
|
|
'contract_id' => 'require|integer|gt:0',
|
|
'student_id' => 'require|integer|gt:0',
|
|
'form_data' => 'require|array'
|
|
]);
|
|
|
|
try {
|
|
$service = new ContractService();
|
|
$result = $service->signContract($data);
|
|
|
|
return success($result, '合同签署成功');
|
|
|
|
} 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());
|
|
}
|
|
}
|
|
}
|