Esempio n. 1
0
 public function getAds()
 {
     $data = array();
     try {
         $result = Yii::app()->cnhutong_user->createCommand()->select('id, picture, text, link')->from('com_ads')->queryAll();
         // 判断数据是否为空数组
         if (ApiPublicController::array_is_null($result)) {
             $data[] = [];
         }
         foreach ($result as $row) {
             $ads = array();
             $ads['adPicture'] = $row['picture'];
             $ads['adContent'] = $row['text'];
             $ads['adUrl'] = $row['link'];
             $data[] = $ads;
         }
     } catch (Exception $e) {
         error_log($e);
     }
     return $data;
 }
Esempio n. 2
0
 public function getAppVersion()
 {
     $data = array();
     try {
         $result = Yii::app()->cnhutong_user->createCommand()->select('id, last_version, new_version, download')->from('com_channel')->queryAll();
         // 判断数据是否为空数组
         if (ApiPublicController::array_is_null($result)) {
             $data[] = [];
         }
         foreach ($result as $row) {
             $version = array();
             $version['lastVersion'] = $row['last_version'];
             $version['updateVersion'] = $row['new_version'];
             $version['downloadUrl'] = $row['download'];
             $data[] = $version;
         }
     } catch (Exception $e) {
         error_log($e);
     }
     return $data;
 }
Esempio n. 3
0
 /**
  * 获取某一次课时的具体详情
  * @param $userId                   -- 用户ID
  * @param $token                    -- 用户验证token
  * @param $memberId                 -- 用户当前绑定的学员所对应的ID
  * @param $lessonStudentId          -- 课时唯一编号
  * @return array|int
  */
 public function lessonDetails($userId, $token, $memberId, $lessonStudentId)
 {
     $data = array();
     try {
         // 用户ID验证
         $user = User::model()->IsUserId($userId);
         if (!$user) {
             return 10010;
             // MSG_ERR_FAIL_USER
         }
         // 用户token验证
         $userToken = UserToken::model()->IsToken($userId, $token);
         //            var_dump($userToken);exit;
         if (!$userToken) {
             return 10009;
             // MSG_ERR_FAIL_TOKEN
         }
         $isExistUserMemberId = UserMember::model()->IsExistMemberId($userId, $memberId);
         if (!$isExistUserMemberId) {
             return 40003;
             // MSG_ERR_FAIL_MEMBER
         }
         $isLessonStudentId = self::IsLessonStudentId($memberId, $lessonStudentId);
         if (!$isLessonStudentId) {
             return 60002;
         }
         $result = Yii::app()->cnhutong->createCommand()->select('id as lessonStudentId, lesson_serial as lessonSerial, date, time,
             step, teacher_id as teacherId, student_rating, student_comment, lesson_content')->from('ht_lesson_student')->where('student_id = :studentId And id = :id', array(':studentId' => $memberId, ':id' => $lessonStudentId))->order('date')->queryAll();
         // 判断数据是否为空数组
         if (ApiPublicController::array_is_null($result)) {
             $data[] = [];
         }
         foreach ($result as $row) {
             // 获取数据
             $lessonDetail = array();
             $lessonDetail['lessonStudentId'] = $row['lessonStudentId'];
             $lessonDetail['lessonSerial'] = $row['lessonSerial'];
             $lessonDetail['lessonDate'] = $row['date'] . ' ' . $row['time'];
             $lessonDetail['lessonStatus'] = self::getLessonStatus($row['step']);
             $lessonDetail['teacherId'] = $row['teacherId'];
             $lessonDetail['teacherName'] = ApiPublicLesson::model()->getNameByMemberId($row['teacherId']);
             $lessonDetail['lessonScore'] = $row['student_rating'];
             if (empty($lessonDetail['lessonScore'])) {
                 $lessonDetail['lessonScore'] = '';
             }
             $lessonDetail['lessonCharge'] = $row['student_comment'];
             $lessonDetail['lessonContent'] = $row['lesson_content'];
             if (empty($lessonDetail['lessonContent'])) {
                 $lessonDetail['lessonContent'] = '';
             }
             $data[] = $lessonDetail;
         }
         //            $data = $result;
     } catch (Exception $e) {
         error_log($e);
     }
     return $data;
 }
 /**
  * 获取某一次课时的具体详情
  * @param $userId                   -- 用户ID
  * @param $token                    -- 用户验证token
  * @param $memberId                 -- 用户当前绑定的学员所对应的ID
  * @param $lessonStudentId          -- 课时唯一编号
  * @return array|int
  */
 public function lessonDetails($userId, $token, $memberId, $lessonStudentId)
 {
     $data = array();
     try {
         // 用户ID验证
         $user = User::model()->IsUserId($userId);
         if (!$user) {
             return 20008;
             // MSG_ERR_FAIL_USER
         }
         // 用户token验证
         $userToken = UserToken::model()->IsToken($userId, $token);
         //            var_dump($userToken);exit;
         if (!$userToken) {
             return 20007;
             // MSG_ERR_FAIL_TOKEN
         }
         $isExistUserMemberId = UserMember::model()->IsExistMemberId($userId, $memberId);
         if (!$isExistUserMemberId) {
             return 20017;
             // MSG_ERR_FAIL_MEMBER
         }
         $isLessonStudentId = self::IsLessonStudentId($memberId, $lessonStudentId);
         if (!$isLessonStudentId) {
             return 20021;
         }
         $result = Yii::app()->cnhutong->createCommand()->select('id as lessonStudentId, lesson_serial as lessonSerial, date, time, status_id,
             step, teacher_id as teacherId, student_rating, student_comment, lesson_content')->from('ht_lesson_student')->where('student_id = :studentId And id = :id', array(':studentId' => $memberId, ':id' => $lessonStudentId))->order('date')->queryAll();
         // 判断数据是否为空数组
         if (ApiPublicController::array_is_null($result)) {
             $data[] = [];
         }
         foreach ($result as $row) {
             // 获取数据
             $lessonDetail = array();
             $lessonDetail['lessonStudentId'] = $row['lessonStudentId'];
             $lessonDetail['lessonSerial'] = $row['lessonSerial'];
             $lessonDetail['lessonDate'] = $row['date'] . ' ' . $row['time'];
             //                $lessonDetail['lessonStatus']                   = self::getLessonStatusNow($row['step']);
             $lessonDetail['lessonStatus'] = self::lessonStatus($row['step'], $row['status_id'], $row['student_rating']);
             // 此课程状态和课程表的课时状态保持一致;状态为3表示未上,可以请假,其他状态都不可请假
             $lessonDetail['teacherId'] = $row['teacherId'];
             $lessonDetail['teacherName'] = ApiPublicLesson::model()->getNameByMemberId($row['teacherId']);
             //                $lessonDetail['lessonScore']                    = $row['student_rating'];
             $eval = Yii::app()->cnhutong_user->createCommand()->select('teach_attitude, teach_content, teach_environment, statement')->from('lesson_student_eval')->where('member_id = :memberId And lesson_student_id = :lessonStudentId', array(':memberId' => $memberId, ':lessonStudentId' => $lessonStudentId))->queryRow();
             $lessonDetail['teachAttitude'] = isset($eval['teach_attitude']) ? $eval['teach_attitude'] : '';
             $lessonDetail['teachContent'] = isset($eval['teach_content']) ? $eval['teach_content'] : '';
             $lessonDetail['teachEnvironment'] = isset($eval['teach_environment']) ? $eval['teach_environment'] : '';
             $lessonDetail['lessonCharge'] = isset($eval['statement']) ? $eval['statement'] : '';
             //                $lessonDetail['lessonCharge']                   = $row['student_comment'];
             $lessonDetail['lessonContent'] = $row['lesson_content'];
             if (empty($lessonDetail['lessonContent'])) {
                 $lessonDetail['lessonContent'] = '';
             }
             // 课时状态数组 aStatus
             $aStatus = array(1, 2, 4, 5);
             if (in_array($lessonDetail['lessonStatus'], $aStatus)) {
                 $step = 4;
             } elseif ($lessonDetail['lessonStatus'] == 1) {
                 $leave = self::getHtReminder($memberId, $lessonStudentId);
                 $step = $leave['step'];
             }
             $lessonDetail['step'] = $step;
             $data[] = $lessonDetail;
         }
         //            $data = $result;
     } catch (Exception $e) {
         var_dump($e);
         error_log($e);
     }
     return $data;
 }