1, self::PRODUCT_TYPE_ISP => 2, self::PRODUCT_TYPE_WB_ISP => 3, self::PRODUCT_TYPE_STAGE_REVIEW => array(1,2,3), self::PRODUCT_TYPE_SECOND_RUN => 5, self::PRODUCT_TYPE_HTB => 9, self::PRODUCT_TYPE_MICRO => array(1,2,3), self::PRODUCT_TYPE_HOLIDAY_REPORT => '', self::PRODUCT_TYPE_EN_MRV => array(3, 12), self::PRODUCT_TYPE_EN_READING => 6, self::PRODUCT_TYPE_EN_MAGIC_WORD => 11, self::PRODUCT_TYPE_EN_INTEREST_WORD => 11, self::PRODUCT_TYPE_PERSONAL => 30, self::PRODUCT_TYPE_METHOD => 31, self::PRODUCT_TYPE_SPECIAL => 31, self::PRODUCT_TYPE_WRITING => 32, self::PRODUCT_TYPE_HOLIDAY_HOMEWORK=>50, self::PRODUCT_TYPE_EN_READING_JICHU => 57, self::PRODUCT_TYPE_EN_READING_WAIKAN => 61, self::PRODUCT_TYPE_EN_READING_REDIAN => 58, self::PRODUCT_TYPE_WRONG_REFINE=>56, self::PRODUCT_TYPE_CORRECT=>66, ); //打包状态 public static $pack_status = array( self::PACK_STATUS_DOING => '打包中', self::PACK_STATUS_SUCCESS => '打包完成', self::PACK_STATUS_FAIL => '打包失败', self::PACK_STATUS_COPIED => '已复制', ); public static $desc = array( 1 => '错题本', 30 => '个性化学习宝', 31 => '方法宝', 29 => '专题宝', 50 => '假期作业', 56 => '错题精练', 66=>'纠错本' ); private $classify; public function __construct($product_type) { $classify_arr = self::$order_classify; $this->classify= isset($classify_arr[$product_type]) ? $classify_arr[$product_type] : ''; } /** * 获取以生成产品的学生和产品路径 * @param $table_name * @param $unique_column * @param $pdf_path_column * @param $is_generate_column * @param $unique_val * @param $studentsIds * @param $absentFilter * @param $condition * @return boolean|array */ public function getGenerateStu($table_name, $unique_column, $pdf_path_column, $is_generate_column, $unique_val, $studentsIds, $absentFilter=false,$condition=array()) { try { $studentsArr = array(); $sql = "select student_id,{$pdf_path_column} from {$table_name} where {$unique_column} = '{$unique_val}' and {$is_generate_column} = 1"; if($studentsIds){ $studentsIds = is_array($studentsIds) ? implode(',',$studentsIds) : trim($studentsIds); $sql .= " and student_id in ({$studentsIds})"; }elseif($table_name=='english_week_student'){ $sql.=" and student_id>0 "; } if($absentFilter){ $sql .= " and is_del=0"; } if($condition){ foreach ($condition as $key=>$item){ $sql .= sprintf(' and %s=%s',$key,$item); } } $stuArr = $this->getDbConnection()->createCommand($sql)->queryAll(); if ($stuArr) { foreach ($stuArr as $k => $v) { $studentsArr['studentIds'][] = $v['student_id']; $studentsArr['pathArr'][] = $v["$pdf_path_column"]; } } if (!$studentsArr || empty($studentsArr)) { return false; //echo json_encode(array("success" => 0, "message" => "无生成的学生"));exit(); } return $studentsArr; }catch (\Exception $e){ return false; //echo json_encode(array("success" => 0, "message" => $e->getMessage()));exit(); } } /** * 获取可以下载的学生 * @param $students * @param $intarr * @param $schoolId * @return array */ public function getCanDownloadStu($students, $intarr, $schoolId) { $classify = is_array($this->classify) ? $this->classify : array($this->classify); $canDownloadStu = array(); $basic = imsBasicAuth($schoolId . '_' . Yii::app()->session['coachInfo']['coach_name'], Yii::app()->params["zsy_api_key"]); foreach ($classify as $item){ $intarr['students'] = $students; if(empty($item)){ $rs = json_decode(Curl::http_post_Basic_json(Yii::app()->params["get_all_limit_url_gather"], json_encode($intarr),$basic)); }else{ $intarr['classify'] = $item; $rs = json_decode(Curl::http_post_Basic_json(Yii::app()->params["get_limit_url"], json_encode($intarr), $basic)); } if (!$rs) { echo json_encode(array("success" => 0, "message" => "接口错误"));exit(); } if ($rs->errCode != "00") { echo json_encode(array("success" => 0, "message" => $rs->errMsg));exit(); } if (!empty($rs->data)) { $canDownloadStu = array_merge($canDownloadStu,$rs->data); } } if(empty($canDownloadStu)){ echo json_encode(array("success" => 0, "message" => "请先购买商品"));exit(); } return array_unique($canDownloadStu); } }