<?php
|
|
namespace app\shop\controller\plus\release;
|
|
use app\shop\controller\Controller;
|
use app\shop\model\plus\release\DemandProject as ProjectModel;
|
|
/**
|
* 项目
|
*/
|
class DemandProject extends Controller
|
{
|
/**
|
* 列表
|
*/
|
public function index()
|
{
|
$model = new ProjectModel;
|
$list = $model->getList($this->postData());
|
return $this->renderSuccess('', compact('list'));
|
}
|
|
/**
|
* 获取默认数据(分类)
|
*/
|
public function defaultData()
|
{
|
$model = new ProjectModel;
|
$data = $model->getDefaultData();
|
return $this->renderSuccess('', compact('data'));
|
}
|
|
/**
|
* 后台发布需求
|
*/
|
public function add()
|
{
|
$model = new ProjectModel;
|
$data = $this->postData();
|
// 获取表单数据
|
$formData = json_decode($data['formData'], true);
|
// 获取用户ID
|
$user_id = isset($data['user_id']) ? intval($data['user_id']) : 0;
|
if ($user_id <= 0) {
|
return $this->renderError('请选择发布用户');
|
}
|
// 是否支付连盟币(可选)
|
$pay_points = isset($data['pay_points']) ? intval($data['pay_points']) : 0;
|
|
if ($model->addByAdmin($formData, $user_id, $pay_points)) {
|
return $this->renderSuccess('发布成功');
|
}
|
return $this->renderError($model->getError() ?: '发布失败');
|
}
|
|
/**
|
* 审核
|
*/
|
public function submit($project_id)
|
{
|
$model = ProjectModel::detail($project_id);
|
if ($model->submit($this->postData())) {
|
return $this->renderSuccess('操作成功');
|
}
|
return $this->renderError($model->getError() ?: '操作失败');
|
}
|
|
|
/**
|
* 编辑
|
*/
|
public function edit()
|
{
|
$model = new ProjectModel;
|
$data = $this->postData();
|
// 获取表单数据
|
$formData = json_decode($data['formData'], true);
|
// 获取项目ID
|
$project_id = isset($data['project_id']) ? intval($data['project_id']) : 0;
|
if ($project_id <= 0) {
|
return $this->renderError('项目ID不能为空');
|
}
|
|
if ($model->editByAdmin($project_id, $formData)) {
|
return $this->renderSuccess('编辑成功');
|
}
|
return $this->renderError($model->getError() ?: '编辑失败');
|
}
|
|
/**
|
* 删除
|
*/
|
public function delete($project_id)
|
{
|
// 详情
|
$model = ProjectModel::detail($project_id);
|
if (!$model->setDelete()) {
|
return $this->renderError('删除失败');
|
}
|
return $this->renderSuccess('删除成功');
|
}
|
|
}
|