123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Administrator
- * Date: 2022/8/2 0002
- * Time: 10:14
- */
- //产品生成流程时间记录
- class ProductProcessTime extends MyActiveRecord{
- public static function model($className = __CLASS__){
- return parent::model($className);
- }
- public function tableName(){
- return 'product_process_time';
- }
- public function updateDownloadTime($studentIds,$type,$examId){
- if(!$studentIds || !$type || !$examId){
- return array();
- }
- //查询所有已经生成PDF的学生
- $time = time();
- $sql = "select * from product_process_time where exam_id = {$examId}";
- $info = $this->getCommandBuilder()->createSqlCommand($sql)->queryAll();
- //判断该学生是否第一次下载 否更新download_last_time 是更新download_first_time
- if($info){
- $firstDownloadStudents = $lastDownloadStudents = array();
- foreach($info as $val){
- if(!$studentIds || ($studentIds && in_array($val['student_id'], $studentIds))){
- if(!$val['download_first_time']){
- $firstDownloadStudents[] = $val['student_id'];
- }else{
- $lastDownloadStudents[] = $val['student_id'];
- }
- }
- }
- if($firstDownloadStudents) {
- $firstDownloadStudents = implode(',', $firstDownloadStudents);
- $sql = "update product_process_time set download_first_time={$time},download_last_time={$time} where exam_id = {$examId} and product_type = {$type} and student_id in ({$firstDownloadStudents})";
- $this->getCommandBuilder()->createSqlCommand($sql)->execute();
- }
- if($lastDownloadStudents){
- $lastDownloadStudents = implode(',', $lastDownloadStudents);
- $sql = "update product_process_time set download_last_time={$time} where exam_id = {$examId} and product_type = {$type} and student_id in ({$lastDownloadStudents})";
- $this->getCommandBuilder()->createSqlCommand($sql)->execute();
- }
- }
- }
- }
|