|
@@ -3,6 +3,7 @@ |
|
@@ -3,6 +3,7 @@ |
3
|
namespace app\admin\controller\mobile\course;
|
3
|
namespace app\admin\controller\mobile\course;
|
4
|
|
4
|
|
5
|
use app\common\controller\Backend;
|
5
|
use app\common\controller\Backend;
|
|
|
6
|
+use think\Db;
|
6
|
|
7
|
|
7
|
/**
|
8
|
/**
|
8
|
* 精品课程管理
|
9
|
* 精品课程管理
|
|
@@ -53,20 +54,20 @@ class Course extends Backend |
|
@@ -53,20 +54,20 @@ class Course extends Backend |
53
|
$total = $this->model
|
54
|
$total = $this->model
|
54
|
|
55
|
|
55
|
->where($where)
|
56
|
->where($where)
|
56
|
- ->order('is_top desc')
|
57
|
+ ->order(['is_top' => 'desc','top_time' => 'desc', 'createtime' => 'desc'])
|
57
|
->order($sort, $order)
|
58
|
->order($sort, $order)
|
58
|
->count();
|
59
|
->count();
|
59
|
|
60
|
|
60
|
$list = $this->model
|
61
|
$list = $this->model
|
61
|
|
62
|
|
62
|
->where($where)
|
63
|
->where($where)
|
63
|
- ->order('is_top desc')
|
64
|
+ ->order(['is_top' => 'desc','top_time' => 'desc', 'createtime' => 'desc'])
|
64
|
->order($sort, $order)
|
65
|
->order($sort, $order)
|
65
|
->limit($offset, $limit)
|
66
|
->limit($offset, $limit)
|
66
|
->select();
|
67
|
->select();
|
67
|
|
68
|
|
68
|
foreach ($list as $row) {
|
69
|
foreach ($list as $row) {
|
69
|
- $row->visible(['id','title','cover','current_price','original_price','study_num_rate','study_num_real','teacher_avatar','teacher_name','teacher_desc','is_top']);
|
70
|
+ $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']);
|
70
|
|
71
|
|
71
|
}
|
72
|
}
|
72
|
$list = collection($list)->toArray();
|
73
|
$list = collection($list)->toArray();
|
|
@@ -77,6 +78,45 @@ class Course extends Backend |
|
@@ -77,6 +78,45 @@ class Course extends Backend |
77
|
return $this->view->fetch();
|
78
|
return $this->view->fetch();
|
78
|
}
|
79
|
}
|
79
|
|
80
|
|
|
|
81
|
+ /**
|
|
|
82
|
+ * 置顶
|
|
|
83
|
+ */
|
|
|
84
|
+ public function top($ids = null)
|
|
|
85
|
+ {
|
|
|
86
|
+ if($ids) {
|
|
|
87
|
+ $row = $this->model->get($ids);
|
|
|
88
|
+ if (!$row) {
|
|
|
89
|
+ $this->error(__('No Results were found'));
|
|
|
90
|
+ }
|
|
|
91
|
+ $adminIds = $this->getDataLimitAdminIds();
|
|
|
92
|
+ if (is_array($adminIds)) {
|
|
|
93
|
+ if (!in_array($row[$this->dataLimitField], $adminIds)) {
|
|
|
94
|
+ $this->error(__('You have no permission'));
|
|
|
95
|
+ }
|
|
|
96
|
+ }
|
|
|
97
|
+ $params = $this->request->param();
|
|
|
98
|
+ $params['top_time'] = $params['is_top'] == '1' ? time() : 0;
|
|
|
99
|
+ Db::startTrans();
|
|
|
100
|
+ try {
|
|
|
101
|
+ $result = $row->allowField(true)->save($params);
|
|
|
102
|
+ Db::commit();
|
|
|
103
|
+ } catch (ValidateException $e) {
|
|
|
104
|
+ Db::rollback();
|
|
|
105
|
+ $this->error($e->getMessage());
|
|
|
106
|
+ } catch (PDOException $e) {
|
|
|
107
|
+ Db::rollback();
|
|
|
108
|
+ $this->error($e->getMessage());
|
|
|
109
|
+ } catch (\think\Exception $e) {
|
|
|
110
|
+ Db::rollback();
|
|
|
111
|
+ $this->error($e->getMessage());
|
|
|
112
|
+ }
|
|
|
113
|
+ if(!$result) {
|
|
|
114
|
+ $this->error('操作失败');
|
|
|
115
|
+ }
|
|
|
116
|
+ $this->success('操作成功');
|
|
|
117
|
+ }
|
|
|
118
|
+ }
|
|
|
119
|
+
|
80
|
public function selectpage()
|
120
|
public function selectpage()
|
81
|
{
|
121
|
{
|
82
|
return parent::selectpage(); // TODO: Change the autogenerated stub
|
122
|
return parent::selectpage(); // TODO: Change the autogenerated stub
|