public function actiondownrepeatfolder() { $ret = array('status' => 0, 'msg' => '', 'err_data' => array()); try { $brandid = isset($_SESSION['brandid']) ? $_SESSION['brandid'] : 0; $memcache = md5('getbrandsku' . $brandid); $boo = Yii::app()->cache->get($memcache); $arr = array(); //缓存 不存在时候调用 if (empty($boo)) { $arr = Yii::app()->db->createCommand()->select('code_start,code_end')->from('beu_brand')->where("id={$brandid}")->queryRow(); if (!empty($arr)) { $output = json_encode($arry); Yii::app()->cache->set($output, $memcache, 18000); //添加缓存 } } else { $arr = json_decode($boo, true); } $order_array = array(); $url = ''; if (Yii::app()->request->getParam('orderinfo')) { $order_array = Yii::app()->request->getParam('orderinfo'); //时间排序 } // $order_array=array(array('orderid'=>'73','brandnumber'=>'115230C211262','ordername'=>'z005C007'), // array('orderid'=>'74','brandnumber'=>'115250C032734','ordername'=>'z005C007'), // array('orderid'=>'75','brandnumber'=>'115230E321115','ordername'=>'z005C008'), // array('orderid'=>'76','brandnumber'=>'115220A620517','ordername'=>'z005C009') // ); if (count($order_array) == 0 || $brandid == 0 || count($arr) == 0 || empty($arr['code_end'])) { $ret['msg'] = '信息错误'; echo json_encode($ret); exit; } $rand = rand(0, 9999999); $url = 'floderzip/repeat_skc_folder_' . $rand . '.zip'; $zipname = $url; //服务器中zip的名字 $zip = new ZipArchive(); if ($zip->open($zipname, ZipArchive::OVERWRITE) === TRUE) { $start = $arr['code_start']; //品牌款号开始位置 $end = $arr['code_end']; //品牌款号结束位置 $orderclass = new orderclass(); foreach ($order_array as $value) { $brand_sku = $this->SKCToSKU($start, $end, $value['brandnumber']); $fileurl = 'orderlist/' . $value['ordername'] . '/' . $brand_sku . '/' . $value['brandnumber']; //$fileurl='orderlist/'.$value['ordername'].'/'.$value['brandnumber']; $orderclass->addFileToZip($fileurl, $zip); } $zip->close(); //关闭处理的zip文件 //调用方法,对要打包的根目录进行操作,并将ZipArchive的对象传递给方法 } $ret['status'] = 1; $ret['url'] = $url; } catch (Exception $e) { $ret['msg'] = $e->getMessage(); } echo json_encode($ret); exit; }