12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- /**
- * Created by 上海互教教育科技有限公司.
- * User: 刘红伟
- * QQ : 454303753
- * Date: 2017/6/21 0021
- * Time: 下午 20:36
- */
- class SStudentProductModel extends MyActiveRecord
- {
- public static function model($className = __CLASS__)
- {
- return parent::model($className);
- }
- public function tableName()
- {
- return 'student_product';
- }
- //根据班级读取plan_id
- public function getPlanId($classId,$subjectId,$type){
- $realType=$type;
- if(Yii::app()->params['season_product']==2){
- if($type==1){
- $realType=4;
- }elseif($type==2){
- $realType=5;
- }elseif($type==3){
- $realType=6;
- }
- }
- $sql="select rpc_id from review_product_class rpc ";
- $sql.="left join review_paper_product_set rpps on rpps.rprs_id=rpc.rprs_id ";
- $sql.=" where subject_id='{$subjectId}' and class_id='{$classId}' and rpps.category ='{$realType}'";
- $res =$this->getCommandBuilder()->createSqlCommand($sql)->queryRow();
- if($res){
- return $res['rpc_id'];
- }else{
- return null;
- }
- }
- //读取学生生成
- public function getStudentCreate($studentIds,$subjectId,$type,$semesterId,$isCreate=1){
- $__sql = "select student_id,is_download,type,product_type,pdf_path,pdf_page_size,pdf_sheet_size,plan_id,pdf_time from student_product sp";
- $__sql.=" left join review_product_class rpc on rpc.rpc_id=sp.plan_id";
- $__sql.=" left join review_paper_product_set rpps on rpps.rprs_id=rpc.rprs_id";
- $__sql.= " where sp.semester_id ='{$semesterId}' and student_id in(".implode(',',$studentIds).") and `type` ='{$type}' and rpps.subject_id='{$subjectId}' ";
- if($isCreate==1){
- $__sql = $__sql.' and is_pdf_created = 1 ';
- }
- $res =$this->getCommandBuilder()->createSqlCommand($__sql)->queryAll();
- return $res;
- }
- //读取学生下载
- public function getStudentCreateDown($studentIds,$subjectId,$type,$semesterId){
- $__sql = "select student_id,is_download,type,product_type,pdf_path,plan_id,pdf_time from student_product sp";
- $__sql.=" left join review_product_class rpc on rpc.rpc_id=sp.plan_id";
- $__sql.=" left join review_paper_product_set rpps on rpps.rprs_id=rpc.rprs_id";
- $__sql.= " where sp.semester_id ='{$semesterId}' and student_id in(".implode(',',$studentIds).") and `type` ='{$type}' and rpps.subject_id='{$subjectId}'";
- $sql = $__sql.' and is_pdf_created = 1 and is_download=1 ';
- $res =$this->getCommandBuilder()->createSqlCommand($sql)->queryAll();
- return $res;
- }
- }
|