浏览代码

Wesmiler 校企小程序 更新

wesmiler 4 年之前
父节点
当前提交
b1f9c1e653

+ 37 - 0
app/api/controller/Banner.php

@@ -0,0 +1,37 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types = 1);
+
+namespace app\api\controller;
+
+use app\api\model\Banner as BannerModel;
+
+/**
+ * 幻灯片控制器
+ * Class Banner
+ * @package app\api\controller
+ */
+class Banner extends Controller
+{
+    /**
+     * 文章列表
+     * @param int $position
+     * @return array
+     * @throws \think\db\exception\DbException
+     */
+    public function list(int $position = 0)
+    {
+        $model = new BannerModel;
+        $list = $model->getList(['position'=> $position], 6);
+        return $this->renderSuccess(compact('list'));
+    }
+
+}

+ 20 - 5
app/api/controller/School.php

@@ -3,6 +3,7 @@
 namespace app\api\controller;
 
 use app\api\model\School as SchoolModel;
+use app\api\model\SchoolSpeciality;
 use app\api\model\SchoolNew;
 use app\api\model\UserDynamic;
 use app\api\service\User as UserService;
@@ -83,17 +84,31 @@ class School extends Controller
         $schoolId = $this->request->param('school_id', 0);
         $userInfo = UserService::getCurrentLoginUser(true);
         $userId = isset($userInfo['user_id'])? intval($userInfo['user_id']) : 0;
-        if($schoolId<=0){
-            $schoolId = isset($userInfo['info']['school_id'])? intval($userInfo['info']['school_id']) : 0;
-            $userType = isset($userInfo['user_type'])? $userInfo['user_type'] : 0;
-            $schoolId = $userType != 3? 0 : $schoolId;
+        if($schoolId <= 0){
+            return $this->renderSuccess('您无权访问或未绑定学校信息,请先绑定');
         }
 
+        $list = $model->getListBySchool($schoolId, $userId, $this->request->param());
+        return $this->renderSuccess(compact('list'));
+    }
+
+    /**
+     * 校园专业时态
+     * @return \think\response\Json
+     * @throws \think\db\exception\DbException
+     */
+    public function specialityDynamic(){
+        $model = new SchoolSpeciality;
+        $userInfo = UserService::getCurrentLoginUser(true);
+        $userId = isset($userInfo['user_id'])? intval($userInfo['user_id']) : 0;
+        $schoolId = isset($userInfo['info']['school_id'])? intval($userInfo['info']['school_id']) : 0;
+        $userType = isset($userInfo['user_type'])? $userInfo['user_type'] : 0;
+        $schoolId = $userType != 3? 0 : $schoolId;
         if($schoolId <= 0){
             return $this->renderSuccess('您无权访问或未绑定学校信息,请先绑定');
         }
 
-        $list = $model->getListBySchool($schoolId, $userId, $this->request->param());
+        $list = $model->getList(['school_id'=> $schoolId]);
         return $this->renderSuccess(compact('list'));
     }
 }

+ 10 - 3
app/api/controller/SchoolSpeciality.php

@@ -12,10 +12,17 @@ use think\response\Json;
  */
 class SchoolSpeciality extends Controller
 {
-
-    public function options(): Json
+    /**
+     * 学校列表
+     * @return \think\response\Json
+     * @throws \think\db\exception\DbException
+     */
+    public function list()
     {
+        // 获取列表数据
         $model = new SchoolSpecialityModel;
-
+        $pageSize = $this->request->param('pageSize', 12);
+        $list = $model->getList($this->request->param(), $pageSize);
+        return $this->renderSuccess(compact('list'));
     }
 }

+ 94 - 0
app/api/model/Banner.php

@@ -0,0 +1,94 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\api\model;
+
+use app\common\exception\BaseException;
+use app\common\library\helper;
+use app\common\model\Banner as BannerModel;
+use app\common\model\Region;
+
+/**
+ * 轮播幻灯片模型
+ * Class Banner
+ * @package app\api\model
+ */
+class Banner extends BannerModel
+{
+    /**
+     * 隐藏字段
+     * @var array
+     */
+    protected $hidden = [
+        'create_time',
+        'update_time'
+    ];
+
+    /**
+     * 获取列表
+     * @param array $param 查询条件
+     * @param int $listRows 分页数量
+     * @return mixed|\think\model\Collection|\think\Paginator
+     * @throws \think\db\exception\DbException
+     */
+    public function getList(array $param = [], int $listRows = 15)
+    {
+        // 整理查询参数
+        $params = array_merge($param, ['status' => 1]);
+        // 获取商品列表
+        $list = parent::getList($params, $listRows);
+        if ($list->isEmpty()) {
+            return $list;
+        }
+        // 隐藏冗余的字段
+        $list->hidden(array_merge($this->hidden, ['albums']));
+        // 整理列表数据并返回
+        return $this->setListDataFromApi($list);
+    }
+
+    /**
+     * 设置展示的数据 api模块
+     * @param $info
+     * @return mixed
+     */
+    private function setListDataFromApi($info)
+    {
+        return $this->setListData($info, function ($data){
+            // 整理数据 api模块
+            $this->setDataFromApi($data);
+        });
+    }
+
+    /**
+     * 整理数据 api模块
+     * @param $info
+     * @return mixed
+     */
+    private function setDataFromApi($info)
+    {
+        return $this->setData($info, function ($data) {
+            $this->hidden(['update_time','status']);
+        });
+    }
+
+    /**
+     * 获取图片预览
+     * @param $value
+     * @return string
+     */
+    public function getImageAttr($value)
+    {
+        return $value? getPreview($value) : '';
+    }
+
+
+}

+ 22 - 0
app/api/model/School.php

@@ -56,6 +56,28 @@ class School extends SchoolModel
     }
 
     /**
+     * 获取专业同类学校列表
+     * @param array $param 查询条件
+     * @param int $listRows 分页数量
+     * @return mixed|\think\model\Collection|\think\Paginator
+     * @throws \think\db\exception\DbException
+     */
+    public function getSpecialityList(int $specialityId, array $param = [], int $listRows = 15)
+    {
+        // 整理查询参数
+        $params = array_merge($param, ['audit_status' => 1]);
+        // 获取商品列表
+        $list = parent::getList($params, $listRows);
+        if ($list->isEmpty()) {
+            return $list;
+        }
+        // 隐藏冗余的字段
+        $list->hidden(array_merge($this->hidden, ['albums']));
+        // 整理列表数据并返回
+        return $this->setListDataFromApi($list);
+    }
+
+    /**
      * 设置展示的数据 api模块
      * @param $info
      * @return mixed

+ 70 - 0
app/api/model/SchoolSpeciality.php

@@ -11,6 +11,8 @@
 declare (strict_types=1);
 
 namespace app\api\model;
+use app\common\library\helper;
+use app\common\model\Region;
 use app\common\model\SchoolSpeciality as SchoolSpecialityModel;
 
 /**
@@ -32,6 +34,71 @@ class SchoolSpeciality extends SchoolSpecialityModel
     ];
 
     /**
+     * 获取列表
+     * @param array $param 查询条件
+     * @param int $listRows 分页数量
+     * @return mixed|\think\model\Collection|\think\Paginator
+     * @throws \think\db\exception\DbException
+     */
+    public function getList(array $param = [], int $listRows = 12)
+    {
+        // 整理查询参数
+        $params = array_merge($param, ['status' => 1]);
+        // 获取商品列表
+        $list = parent::getList($params, $listRows);
+        if ($list->isEmpty()) {
+            return $list;
+        }
+
+        // 整理列表数据并返回
+        return $this->setListDataFromApi($list);
+    }
+
+    /**
+     * 设置展示的数据 api模块
+     * @param $info
+     * @return mixed
+     */
+    private function setListDataFromApi($info)
+    {
+        return $this->setListData($info, function ($data){
+
+            // 整理数据 api模块
+            $this->setDataFromApi($data);
+
+            // 隐藏冗余的字段
+            $this->hidden(array_merge($this->hidden, ['introduce','curriculum','job_direction','get_certificate','status']));
+
+        });
+    }
+
+    /**
+     * 整理数据 api模块
+     * @param $info
+     * @return mixed
+     */
+    private function setDataFromApi($info)
+    {
+        return $this->setData($info, function ($data) {
+            // logo封面
+            $data['speciality_logo'] = $data['speciality_logo']? getPreview($data['speciality_logo']) : '';
+
+            // 已报名人数
+            if(!is_null($data['recruit_num'])){
+                $bookNum = SpecialityBook::getBooks($data['speciality_id']);
+                $data['book_num'] = intval($bookNum);
+                $data['remainder_num'] = max(0,$data['recruit_num'] - $bookNum);
+            }
+
+            // 浏览数
+            if(!is_null($data['views'])){
+                $data['views'] = $data['views']? ($data['views']<10000? "{$data['views']}" : round($data['views']/10000,1).'w') :'';
+            }
+        });
+    }
+
+
+    /**
      * 获取学校的专业
      * @param int $school_id  学校ID
      * @param string $field 返回字段
@@ -49,4 +116,7 @@ class SchoolSpeciality extends SchoolSpecialityModel
             ->limit($limit?? 3)
             ->select()??[];
     }
+
+
+
 }

+ 104 - 0
app/api/model/SpecialityBook.php

@@ -0,0 +1,104 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\api\model;
+use app\common\model\SpecialityBook as SpecialityBookModel;
+
+/**
+ * 学校专业模型类
+ * Class SpecialityBook
+ * @package app\api\model
+ */
+class SpecialityBook extends SpecialityBookModel
+{
+
+    protected $globalScope = [''];
+
+    /**
+     * 隐藏字段
+     * @var array
+     */
+    protected $hidden = [
+        'update_time'
+    ];
+
+    /**
+     * 获取列表
+     * @param array $param 查询条件
+     * @param int $listRows 分页数量
+     * @return mixed|\think\model\Collection|\think\Paginator
+     * @throws \think\db\exception\DbException
+     */
+    public function getList(array $param = [], int $listRows = 12)
+    {
+        // 整理查询参数
+        $params = array_merge($param);
+
+        // 获取商品列表
+        $list = parent::getList($params, $listRows);
+        if ($list->isEmpty()) {
+            return $list;
+        }
+
+        // 整理列表数据并返回
+        return $this->setListDataFromApi($list);
+    }
+
+    /**
+     * 设置展示的数据 api模块
+     * @param $info
+     * @return mixed
+     */
+    private function setListDataFromApi($info)
+    {
+        return $this->setListData($info, function ($data){
+
+            // 整理数据 api模块
+            $this->setDataFromApi($data);
+
+            // 隐藏冗余的字段
+            $this->hidden(array_merge($this->hidden, ['transaction_id']));
+
+        });
+    }
+
+    /**
+     * 整理数据 api模块
+     * @param $info
+     * @return mixed
+     */
+    private function setDataFromApi($info)
+    {
+        return $this->setData($info, function ($data) {
+
+        });
+    }
+
+
+    /**
+     * 获取学校的专业
+     * @param int $school_id  学校ID
+     * @param string $field 返回字段
+     * @param int $limit 返回数量
+     * @return SpecialityBook[]|array|\think\Collection
+     * @throws \think\db\exception\DataNotFoundException
+     * @throws \think\db\exception\DbException
+     * @throws \think\db\exception\ModelNotFoundException
+     */
+    public static function getBooks(int $speciality_id)
+    {
+        return self::where(['speciality_id'=>$speciality_id])->where('status','>', 2)->count('id');
+    }
+
+
+
+}

+ 2 - 0
app/api/model/User.php

@@ -49,6 +49,8 @@ class User extends UserModel
         return strlen($value) === 11 ? hide_mobile($value) : $value;
     }
 
+
+
     /**
      * 获取用户信息
      * @param string $token

+ 140 - 0
app/common/model/Banner.php

@@ -0,0 +1,140 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\common\model;
+
+use cores\BaseModel;
+use think\model\Collection;
+use think\model\relation\HasOne;
+use think\Paginator;
+
+/**
+ * 轮播幻灯片模型类
+ * Class Banner
+ * @package app\common\model
+ */
+class Banner extends BaseModel
+{
+    protected $globalScope = [''];
+
+    // 定义表名
+    protected $name = 'banners';
+
+    // 定义主键
+    protected $pk = 'id';
+
+    /**
+     * 获取列表
+     * @param array $param 查询条件
+     * @param int $listRows 分页数量
+     * @return mixed
+     * @throws \think\db\exception\DbException
+     */
+    public function getList(array $param = [], int $listRows = 15)
+    {
+        // 筛选条件
+        $query = $this->getQueryFilter($param);
+        // 排序条件
+        $sort = $this->setQuerySort($param);
+
+        // 执行查询
+        $list = $query->alias($this->name)
+            ->order($sort)
+            ->paginate($listRows);
+
+        // 整理列表数据并返回
+        return $list;
+    }
+
+    /**
+     * 设置商品展示的数据
+     * @param Collection|Paginator $list 商品列表
+     * @param callable|null $callback 回调函数
+     * @return mixed
+     */
+    protected function setListData($list, callable $callback = null)
+    {
+        if ($list->isEmpty()) return $list;
+        // 遍历商品列表整理数据
+        foreach ($list as &$item) {
+            $data = $this->setData($item, $callback);
+        }
+        return $list;
+    }
+
+    /**
+     * 整理数据
+     * @param Collection|static $info
+     * @param callable|null $callback
+     * @return mixed
+     */
+    protected function setData($info, callable $callback = null)
+    {
+        // 回调函数
+        is_callable($callback) && call_user_func($callback, $info);
+        return $info->hidden(array_merge($this->hidden, ['update_time']));
+    }
+
+    /**
+     * 检索查询条件
+     * @param array $params
+     * @return \think\db\BaseQuery
+     */
+    private function getQueryFilter(array $params)
+    {
+        $filter = [];
+
+        // 实例化新查询对象
+        $query = $this->getNewQuery();
+
+        // 位置
+        !empty($params['position']) && $filter[] = ['position', '=', "{$params['position']}"];
+
+        // 类型
+        !empty($params['type']) && $filter[] = ['type', '=', "{$params['type']}"];
+
+        // 状态
+        !empty($params['status']) && $filter[] = ['status', '=', "{$params['status']}"];
+
+        // 实例化新查询对象
+        return $query->where($filter)->where(function($query) use ($params){
+            // 关键词
+            if(!empty($params['keyword'])){
+                $query->where('name','like', "%{$params['keyword']}%");
+          }
+        });
+    }
+
+
+    /**
+     * 检索排序条件
+     * @param array $param
+     * @return array|string[]
+     */
+    private function setQuerySort(array $param = [])
+    {
+        $params = $this->setQueryDefaultValue($param, [
+            'sortType' => 'all',    // 排序类型
+            'sort_order' => false,   // 排序 (true高到低 false低到高)
+        ]);
+        // 排序规则
+        $sort = [];
+        if ($params['sortType'] === 'all') {
+            $sort = ['sort_order' => 'desc','id'=>'desc'];
+        } elseif ($params['sortType'] === 'pay') {
+            $sort = ['id' => 'desc'];
+        }
+
+        return array_merge($sort, [$this->getPk() => 'desc']);
+    }
+
+}

+ 105 - 1
app/common/model/SchoolSpeciality.php

@@ -13,7 +13,8 @@ declare (strict_types=1);
 namespace app\common\model;
 
 use cores\BaseModel;
-use think\model\relation\HasOne;
+use think\model\Collection;
+use think\Paginator;
 
 /**
  * 学校专业模型类
@@ -28,6 +29,109 @@ class SchoolSpeciality extends BaseModel
     // 定义主键
     protected $pk = 'speciality_id';
 
+    /**
+     * 获取列表
+     * @param array $param 查询条件
+     * @param int $listRows 分页数量
+     * @return mixed
+     * @throws \think\db\exception\DbException
+     */
+    public function getList(array $param = [], int $listRows = 15)
+    {
+        // 筛选条件
+        $query = $this->getQueryFilter($param);
+        // 排序条件
+        $sort = $this->setQuerySort($param);
 
+        // 执行查询
+        $list = $query->alias($this->name)
+            ->leftJoin('schools s','s.id='.$this->name.'.school_id')
+            ->field($this->name.'.*,s.school_name')
+            ->order($sort)
+            ->paginate($listRows);
+
+        // 整理列表数据并返回
+        return $list;
+    }
+
+    /**
+     * 设置商品展示的数据
+     * @param Collection|Paginator $list 商品列表
+     * @param callable|null $callback 回调函数
+     * @return mixed
+     */
+    protected function setListData($list, callable $callback = null)
+    {
+        if ($list->isEmpty()) return $list;
+        // 遍历商品列表整理数据
+        foreach ($list as &$item) {
+            $data = $this->setData($item, $callback);
+        }
+        return $list;
+    }
+
+    /**
+     * 整理数据
+     * @param Collection|static $info
+     * @param callable|null $callback
+     * @return mixed
+     */
+    protected function setData($info, callable $callback = null)
+    {
+        // 回调函数
+        is_callable($callback) && call_user_func($callback, $info);
+        return $info->hidden(array_merge($this->hidden, ['']));
+    }
+
+    /**
+     * 检索查询条件
+     * @param array $params
+     * @return \think\db\BaseQuery
+     */
+    private function getQueryFilter(array $params)
+    {
+        $filter = [];
+
+        // 实例化新查询对象
+        $query = $this->getNewQuery();
+
+        // 学校层次,类型
+        !empty($params['school_id']) && $filter[] = ['school_id', '=', "{$params['school_id']}"];
+
+        // 状态
+        !empty($params['status']) && $filter[] = [$this->name.'.status', '=', "{$params['status']}"];
+
+        // 实例化新查询对象
+        return $query->where($filter)->where(function($query) use ($params){
+            // 关键词
+            if(!empty($params['keyword'])){
+                $query->where('speciality_name','like', "%{$params['keyword']}%")
+                    ->whereOr('s.school_name','like', "%{$params['keyword']}%");
+          }
+        });
+    }
+
+
+    /**
+     * 检索排序条件
+     * @param array $param
+     * @return array|string[]
+     */
+    private function setQuerySort(array $param = [])
+    {
+        $params = $this->setQueryDefaultValue($param, [
+            'sortType' => 'all',    // 排序类型
+            $this->name.'.views' => false,   // 热门排序 (true高到低 false低到高)
+        ]);
+        // 排序规则
+        $sort = [];
+        if ($params['sortType'] === 'all') {
+            $sort = [$this->name.'.views' => 'desc'];
+        } elseif ($params['sortType'] === 'view') {
+            $sort = ['speciality_id' => 'desc'];
+        }
+
+        return array_merge($sort, [$this->getPk() => 'desc']);
+    }
 
 }

+ 168 - 0
app/common/model/SpecialityBook.php

@@ -0,0 +1,168 @@
+<?php
+// +----------------------------------------------------------------------
+// | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
+// +----------------------------------------------------------------------
+// | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
+// +----------------------------------------------------------------------
+// | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
+// +----------------------------------------------------------------------
+// | Author: 萤火科技 <admin@yiovo.com>
+// +----------------------------------------------------------------------
+declare (strict_types=1);
+
+namespace app\common\model;
+
+use cores\BaseModel;
+use think\model\Collection;
+use think\model\relation\HasOne;
+use think\Paginator;
+
+/**
+ * 学校专业模型类
+ * Class SpecialityBook
+ * @package app\common\model
+ */
+class SpecialityBook extends BaseModel
+{
+    // 定义表名
+    protected $name = 'speciality_book';
+
+    // 定义主键
+    protected $pk = 'id';
+
+    /**
+     * 获取列表
+     * @param array $param 查询条件
+     * @param int $listRows 分页数量
+     * @return mixed
+     * @throws \think\db\exception\DbException
+     */
+    public function getList(array $param = [], int $listRows = 15)
+    {
+        // 筛选条件
+        $query = $this->getQueryFilter($param);
+        // 排序条件
+        $sort = $this->setQuerySort($param);
+
+        // 执行查询
+        $list = $query->alias($this->name)
+            ->order($sort)
+            ->paginate($listRows);
+
+        // 整理列表数据并返回
+        return $list;
+    }
+
+    /**
+     * 设置商品展示的数据
+     * @param Collection|Paginator $list 商品列表
+     * @param callable|null $callback 回调函数
+     * @return mixed
+     */
+    protected function setListData($list, callable $callback = null)
+    {
+        if ($list->isEmpty()) return $list;
+        // 遍历商品列表整理数据
+        foreach ($list as &$item) {
+            $data = $this->setData($item, $callback);
+        }
+        return $list;
+    }
+
+    /**
+     * 整理数据
+     * @param Collection|static $info
+     * @param callable|null $callback
+     * @return mixed
+     */
+    protected function setData($info, callable $callback = null)
+    {
+        // 回调函数
+        is_callable($callback) && call_user_func($callback, $info);
+        return $info->hidden(array_merge($this->hidden, ['transaction_id']));
+    }
+
+    /**
+     * 检索查询条件
+     * @param array $params
+     * @return \think\db\BaseQuery
+     */
+    private function getQueryFilter(array $params)
+    {
+        $filter = [];
+
+        // 实例化新查询对象
+        $query = $this->getNewQuery();
+
+        // 报名用户
+        !empty($params['user_id']) && $filter[] = ['user_id', '=', "{$params['user_id']}"];
+
+        // 专业学校
+        !empty($params['school_id']) && $filter[] = ['school_id', '=', "{$params['school_id']}"];
+
+        // 专业
+        !empty($params['speciality_id']) && $filter[] = ['speciality_id', '=', "{$params['speciality_id']}"];
+
+        // 状态
+        !empty($params['status']) && $filter[] = ['status', '=', "{$params['status']}"];
+
+        // 实例化新查询对象
+        return $query->where($filter)->where(function($query) use ($params){
+            // 关键词
+            if(!empty($params['keyword'])){
+                $query->where('order_no','like', "%{$params['keyword']}%");
+          }
+        });
+    }
+
+
+    /**
+     * 检索排序条件
+     * @param array $param
+     * @return array|string[]
+     */
+    private function setQuerySort(array $param = [])
+    {
+        $params = $this->setQueryDefaultValue($param, [
+            'sortType' => 'all',    // 排序类型
+            'create_time' => false,   // 排序 (true高到低 false低到高)
+        ]);
+        // 排序规则
+        $sort = [];
+        if ($params['sortType'] === 'all') {
+            $sort = ['create_time' => 'desc','pay_time'=>'desc'];
+        } elseif ($params['sortType'] === 'pay') {
+            $sort = ['pay_time' => 'desc'];
+        }
+
+        return array_merge($sort, [$this->getPk() => 'desc']);
+    }
+
+    /**
+     * @return HasOne
+     */
+    public function speciality(): HasOne
+    {
+        return $this->HasOne('SchoolSpeciality','speciality_id','speciality_id')->bind(['speciality_name','speciality_logo']);
+    }
+
+
+    /**
+     * @return HasOne
+     */
+    public function school(): HasOne
+    {
+        return $this->HasOne('School','id','school_id')->bind(['school_name','logo as school_logo']);
+    }
+
+    /**
+     * @return HasOne
+     */
+    public function user(): HasOne
+    {
+        return $this->HasOne('User','user_id','user_id')
+            ->with('avatar')
+            ->field('user_id,gender,nick_name,preview_url as avatar_url')
+            ->bind(['nick_name','avatar_url']);
+    }
+}