|
|
@@ -73,7 +73,7 @@ class EducationModel extends Model
|
|
|
$items = $this->table(self::CATE_TABLE_NAME)
|
|
|
->where(['status' => 'Y'])
|
|
|
->order('sort', 'asc')
|
|
|
- ->getField('id,pid,name,sort');
|
|
|
+ ->column('id,pid,name,sort','id');
|
|
|
|
|
|
$tree = array(); //格式化好的树
|
|
|
foreach ($items as $key => $item) {
|
|
|
@@ -96,7 +96,7 @@ class EducationModel extends Model
|
|
|
$items = $this->table(self::CATE_TABLE_NAME)
|
|
|
->where(['status' => 'Y', 'pid' => 0])
|
|
|
->order('sort', 'asc')
|
|
|
- ->getField('id,pid,name,sort');
|
|
|
+ ->column('id,pid,name,sort','id');
|
|
|
|
|
|
return $items;
|
|
|
}
|
|
|
@@ -189,6 +189,87 @@ class EducationModel extends Model
|
|
|
}
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+ public function getCourseListByCates($cates = array(), $pageSize = 3, $page = 1, $userInfo=null)
|
|
|
+ {
|
|
|
+ $firstRow = (($page < 1) ? 0 : ($page - 1)) * $pageSize;
|
|
|
+ $where = array(
|
|
|
+ 'course_audit' => 1,
|
|
|
+ 'course_status' => 1,
|
|
|
+ 'course_only_for_employee' => 0,
|
|
|
+ 'course_cate_id' => array('in', $cates)
|
|
|
+ );
|
|
|
+ $fields = 'course_id, course_cate_id, course_topic, course_intro, course_cover, course_speaker_intro, course_play_count, ';
|
|
|
+ if ($userInfo){
|
|
|
+ // 假如当前用户是从业人员,那就删除条件
|
|
|
+ if ($userInfo["is_employee"]){
|
|
|
+ unset($where["course_only_for_employee"]);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据用户类型选择不同字段
|
|
|
+ switch ($userInfo["user_type"]){
|
|
|
+ case "1":
|
|
|
+ $fields .= "course_price_2 as course_price";
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ $fields .= "course_price_3 as course_price";
|
|
|
+ break;
|
|
|
+ default :
|
|
|
+ $fields .= "course_price";
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $fields .= "course_price";
|
|
|
+ }
|
|
|
+
|
|
|
+ $result = array();
|
|
|
+ if ($cates) {
|
|
|
+ $result = $this->where( $where )
|
|
|
+ ->order('course_id desc')
|
|
|
+ ->limit($firstRow, $pageSize)
|
|
|
+ ->column($fields);
|
|
|
+ }
|
|
|
+
|
|
|
+ return (array)$result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public function getCourseListLikeTopic($topic, $pageSize = 50, $page = 1)
|
|
|
+ {
|
|
|
+ $firstRow = (($page < 1) ? 0 : ($page - 1)) * $pageSize;
|
|
|
+ $result = array();
|
|
|
+ if ($topic) {
|
|
|
+ $result = $this->where(
|
|
|
+ array(
|
|
|
+ 'course_audit' => 1,
|
|
|
+ 'course_status' => 1,
|
|
|
+ 'course_topic' => array('like', '%' . $topic . '%')
|
|
|
+ )
|
|
|
+ )
|
|
|
+ ->order('course_id desc')
|
|
|
+ ->limit($firstRow, $pageSize)
|
|
|
+ ->column(
|
|
|
+ 'course_id,
|
|
|
+ course_cate_id,
|
|
|
+ course_topic,
|
|
|
+ course_price,
|
|
|
+ course_intro,
|
|
|
+ course_cover,
|
|
|
+ course_speaker_intro,
|
|
|
+ course_play_count,
|
|
|
+ gr_id'
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+ return (array)$result;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|