| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- <?php
- namespace backend\controllers;
- use common\components\util;
- use common\services\xhTrainStudentService;
- use common\models\xhTrainUserCourse;
- use common\models\xhTrainStudent;
- use Yii;
- use yii\web\Controller;
- use yii\filters\AccessControl;
- use yii\data\Pagination;
- use common\models\xhTrainCourse;
- use common\services\xhUserService;
- class CourseController extends BackendController
- {
- public function actionList()
- {
- $query = xhTrainUserCourse::find();
- $merchantId = $this->merchantId;
- $query->where(['merchantId' =>$merchantId,'status' => 1]);
- $query->orderBy('attendTime desc');
- $countQuery = clone $query;
- $pages = new Pagination(['totalCount' => $countQuery->count(),'pageSize' => 50]);
- $models = $query->offset($pages->offset)->limit($pages->limit)->with('xhUser')->asArray()->all();
-
- $weekReturn = Yii::$app->redis->executeCommand('ZREVRANGE', ["merchant{$this->merchantId}UserWeek".date("Y-W")."PraiseNum", 0,10, 'WITHSCORES']);
- $weekRank = [];
- if(!empty($weekReturn)){
- $i = 0;
- $x = 0;
- foreach($weekReturn as $key => $val){
- $i++;
- if($i%2 == 0){
- $weekRank[$x]['praiseNum'] = $val;
- $x++;
- }else{
- $userInfo = xhUserService::getById($val);
- unset($userInfo['payPassword']);
- unset($userInfo['password']);
- $weekRank[$x]['userInfo'] = $userInfo;
- $weekRank[$x]['userId'] = $val;
- }
- }
- }
- $monthReturn = Yii::$app->redis->executeCommand('ZREVRANGE', ["merchant{$this->merchantId}UserMonth".date("Y-m")."PraiseNum", 0,10, 'WITHSCORES']);
- $monthRank = [];
- if(!empty($monthReturn)){
- $i = 0;
- $x = 0;
- foreach($monthReturn as $key => $val){
- $i++;
- if($i%2 == 0){
- $monthRank[$x]['praiseNum'] = $val;
- $x++;
- }else{
- $userInfo = xhUserService::getById($val);
- unset($userInfo['payPassword']);
- unset($userInfo['password']);
- $monthRank[$x]['userInfo'] = $userInfo;
- $monthRank[$x]['userId'] = $val;
- }
- }
- }
- return $this->render('list', ['models' => $models,'pages' => $pages,'monthRank' => $monthRank,'weekRank' => $weekRank]);
- }
- public function actionDetail()
- {
- $get = Yii::$app->request->get();
- $id = isset($get['id']) ? $get['id'] : 0;
- $student = xhTrainStudent::getByCondition(['id' => $id]);
- if(empty($student)){
- util::stop('没有获取到学员信息哦~');
- }
- $course = xhTrainUserCourse::getAllByCondition(['studentId' => $id]);
- return $this->render('detail',['course' => $course]);
- }
- }
|