|
@@ -38,6 +38,7 @@ class Education
|
|
|
->paginate($pageSize, false, ['page' => $page]);
|
|
->paginate($pageSize, false, ['page' => $page]);
|
|
|
|
|
|
|
|
$result = ['grlist' => $grlist->items(), 'total' => $grlist->total()];
|
|
$result = ['grlist' => $grlist->items(), 'total' => $grlist->total()];
|
|
|
|
|
+ $result['grlist'] = $this->getCountAndAlll($result['grlist']);
|
|
|
|
|
|
|
|
return app('json')->success($result);
|
|
return app('json')->success($result);
|
|
|
}
|
|
}
|
|
@@ -65,18 +66,32 @@ class Education
|
|
|
* 获取课程组列表
|
|
* 获取课程组列表
|
|
|
* @return mixed
|
|
* @return mixed
|
|
|
*/
|
|
*/
|
|
|
- public function getCourseList()
|
|
|
|
|
|
|
+// public function getCourseList()
|
|
|
|
|
+// {
|
|
|
|
|
+// $where['audit'] = 1;
|
|
|
|
|
+// $type1 = input('type', '');
|
|
|
|
|
+// if ($type1 !== '') {
|
|
|
|
|
+// $where['type1'] = $type1;
|
|
|
|
|
+// }
|
|
|
|
|
+// $grlist = \app\model\api\Education::where($where)
|
|
|
|
|
+// ->limit(20)
|
|
|
|
|
+// ->order('od asc,recommend desc,gr_id desc')
|
|
|
|
|
+// ->select()
|
|
|
|
|
+// ->toArray();
|
|
|
|
|
+// foreach ($grlist as &$v) {
|
|
|
|
|
+// $count = EducationCourse::where('course_status', 1)
|
|
|
|
|
+// ->where('gr_id', $v['gr_id'])
|
|
|
|
|
+// ->where('course_audit', 1)
|
|
|
|
|
+// ->field('count(*) as count,sum(course_play_count) as alll')
|
|
|
|
|
+// ->find();
|
|
|
|
|
+// $v['count'] = $count['count'];
|
|
|
|
|
+// $count['alll'] += $v['times'];
|
|
|
|
|
+// $v['alll'] = $count['alll'] ? $count['alll'] : 0;
|
|
|
|
|
+// }
|
|
|
|
|
+// return app('json')->success(['data' => $grlist]);
|
|
|
|
|
+// }
|
|
|
|
|
+ private function getCountAndAlll($grlist)
|
|
|
{
|
|
{
|
|
|
- $where['audit'] = 1;
|
|
|
|
|
- $type1 = input('type', '');
|
|
|
|
|
- if ($type1 !== '') {
|
|
|
|
|
- $where['type1'] = $type1;
|
|
|
|
|
- }
|
|
|
|
|
- $grlist = \app\model\api\Education::where($where)
|
|
|
|
|
- ->limit(20)
|
|
|
|
|
- ->order('od asc,recommend desc,gr_id desc')
|
|
|
|
|
- ->select()
|
|
|
|
|
- ->toArray();
|
|
|
|
|
foreach ($grlist as &$v) {
|
|
foreach ($grlist as &$v) {
|
|
|
$count = EducationCourse::where('course_status', 1)
|
|
$count = EducationCourse::where('course_status', 1)
|
|
|
->where('gr_id', $v['gr_id'])
|
|
->where('gr_id', $v['gr_id'])
|
|
@@ -87,7 +102,7 @@ class Education
|
|
|
$count['alll'] += $v['times'];
|
|
$count['alll'] += $v['times'];
|
|
|
$v['alll'] = $count['alll'] ? $count['alll'] : 0;
|
|
$v['alll'] = $count['alll'] ? $count['alll'] : 0;
|
|
|
}
|
|
}
|
|
|
- return app('json')->success(['data' => $grlist]);
|
|
|
|
|
|
|
+ return $grlist;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|