...
|
...
|
@@ -3,6 +3,7 @@ |
|
|
namespace app\admin\controller\mobile\course;
|
|
|
|
|
|
use app\common\controller\Backend;
|
|
|
use think\Db;
|
|
|
|
|
|
/**
|
|
|
* 精品课程管理
|
...
|
...
|
@@ -53,20 +54,20 @@ class Course extends Backend |
|
|
$total = $this->model
|
|
|
|
|
|
->where($where)
|
|
|
->order('is_top desc')
|
|
|
->order(['is_top' => 'desc','top_time' => 'desc', 'createtime' => 'desc'])
|
|
|
->order($sort, $order)
|
|
|
->count();
|
|
|
|
|
|
$list = $this->model
|
|
|
|
|
|
->where($where)
|
|
|
->order('is_top desc')
|
|
|
->order(['is_top' => 'desc','top_time' => 'desc', 'createtime' => 'desc'])
|
|
|
->order($sort, $order)
|
|
|
->limit($offset, $limit)
|
|
|
->select();
|
|
|
|
|
|
foreach ($list as $row) {
|
|
|
$row->visible(['id','title','cover','current_price','original_price','study_num_rate','study_num_real','teacher_avatar','teacher_name','teacher_desc','is_top']);
|
|
|
$row->visible(['id','title','cover','current_price','original_price','study_num_rate','study_num_real','teacher_avatar','teacher_name','teacher_desc','is_top','pay_times']);
|
|
|
|
|
|
}
|
|
|
$list = collection($list)->toArray();
|
...
|
...
|
@@ -77,6 +78,45 @@ class Course extends Backend |
|
|
return $this->view->fetch();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 置顶
|
|
|
*/
|
|
|
public function top($ids = null)
|
|
|
{
|
|
|
if($ids) {
|
|
|
$row = $this->model->get($ids);
|
|
|
if (!$row) {
|
|
|
$this->error(__('No Results were found'));
|
|
|
}
|
|
|
$adminIds = $this->getDataLimitAdminIds();
|
|
|
if (is_array($adminIds)) {
|
|
|
if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
$this->error(__('You have no permission'));
|
|
|
}
|
|
|
}
|
|
|
$params = $this->request->param();
|
|
|
$params['top_time'] = $params['is_top'] == '1' ? time() : 0;
|
|
|
Db::startTrans();
|
|
|
try {
|
|
|
$result = $row->allowField(true)->save($params);
|
|
|
Db::commit();
|
|
|
} catch (ValidateException $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
} catch (PDOException $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
} catch (\think\Exception $e) {
|
|
|
Db::rollback();
|
|
|
$this->error($e->getMessage());
|
|
|
}
|
|
|
if(!$result) {
|
|
|
$this->error('操作失败');
|
|
|
}
|
|
|
$this->success('操作成功');
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public function selectpage()
|
|
|
{
|
|
|
return parent::selectpage(); // TODO: Change the autogenerated stub
|
...
|
...
|
|