SStudentProductModel.php 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. /**
  3. * Created by 上海互教教育科技有限公司.
  4. * User: 刘红伟
  5. * QQ : 454303753
  6. * Date: 2017/6/21 0021
  7. * Time: 下午 20:36
  8. */
  9. class SStudentProductModel extends MyActiveRecord
  10. {
  11. public static function model($className = __CLASS__)
  12. {
  13. return parent::model($className);
  14. }
  15. public function tableName()
  16. {
  17. return 'student_product';
  18. }
  19. //根据班级读取plan_id
  20. public function getPlanId($classId,$subjectId,$type){
  21. $realType=$type;
  22. if(Yii::app()->params['season_product']==2){
  23. if($type==1){
  24. $realType=4;
  25. }elseif($type==2){
  26. $realType=5;
  27. }elseif($type==3){
  28. $realType=6;
  29. }
  30. }
  31. $sql="select rpc_id from review_product_class rpc ";
  32. $sql.="left join review_paper_product_set rpps on rpps.rprs_id=rpc.rprs_id ";
  33. $sql.=" where subject_id='{$subjectId}' and class_id='{$classId}' and rpps.category ='{$realType}'";
  34. $res =$this->getCommandBuilder()->createSqlCommand($sql)->queryRow();
  35. if($res){
  36. return $res['rpc_id'];
  37. }else{
  38. return null;
  39. }
  40. }
  41. //读取学生生成
  42. public function getStudentCreate($studentIds,$subjectId,$type,$semesterId,$isCreate=1){
  43. $__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";
  44. $__sql.=" left join review_product_class rpc on rpc.rpc_id=sp.plan_id";
  45. $__sql.=" left join review_paper_product_set rpps on rpps.rprs_id=rpc.rprs_id";
  46. $__sql.= " where sp.semester_id ='{$semesterId}' and student_id in(".implode(',',$studentIds).") and `type` ='{$type}' and rpps.subject_id='{$subjectId}' ";
  47. if($isCreate==1){
  48. $__sql = $__sql.' and is_pdf_created = 1 ';
  49. }
  50. $res =$this->getCommandBuilder()->createSqlCommand($__sql)->queryAll();
  51. return $res;
  52. }
  53. //读取学生下载
  54. public function getStudentCreateDown($studentIds,$subjectId,$type,$semesterId){
  55. $__sql = "select student_id,is_download,type,product_type,pdf_path,plan_id,pdf_time from student_product sp";
  56. $__sql.=" left join review_product_class rpc on rpc.rpc_id=sp.plan_id";
  57. $__sql.=" left join review_paper_product_set rpps on rpps.rprs_id=rpc.rprs_id";
  58. $__sql.= " where sp.semester_id ='{$semesterId}' and student_id in(".implode(',',$studentIds).") and `type` ='{$type}' and rpps.subject_id='{$subjectId}'";
  59. $sql = $__sql.' and is_pdf_created = 1 and is_download=1 ';
  60. $res =$this->getCommandBuilder()->createSqlCommand($sql)->queryAll();
  61. return $res;
  62. }
  63. }