...
|
...
|
@@ -16,6 +16,9 @@ use think\db\exception\BindParamException; |
|
|
use think\exception\DbException;
|
|
|
use think\exception\PDOException;
|
|
|
use think\exception\ValidateException;
|
|
|
use http\Header;
|
|
|
use think\Env;
|
|
|
use app\api\controller\Login;
|
|
|
|
|
|
/**
|
|
|
* 学生管理
|
...
|
...
|
@@ -296,5 +299,61 @@ class Study extends Backend |
|
|
$this->success();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 下载分享码
|
|
|
*
|
|
|
* @param $ids
|
|
|
* @return void
|
|
|
*/
|
|
|
public function multi($ids = null)
|
|
|
{
|
|
|
$ids = $this->request->param('ids');
|
|
|
$product = new \app\admin\model\Study();
|
|
|
$ids = explode(',', $ids);
|
|
|
$arr = $product->whereIn('id' , $ids)->field('barcode')->select();
|
|
|
foreach ($arr as $v){
|
|
|
$v['barcode'] = substr($v['barcode'],20);
|
|
|
$as = ROOT_PATH.'public/'.$v['barcode'];
|
|
|
$data[]=$as;
|
|
|
}
|
|
|
$url = ROOT_PATH.'public/';
|
|
|
// $data = [
|
|
|
// ROOT_PATH.'public/uploads/QR/20230301/_18.jpg'
|
|
|
// ];
|
|
|
// zip 临时文件
|
|
|
$tmp_dir = $url . 'temp/';
|
|
|
// zip名称
|
|
|
$zip_name = 'quality_'.time().'.zip';
|
|
|
// 打包
|
|
|
$zipName = $this->zip_files($data, $tmp_dir.$zip_name);
|
|
|
//下载
|
|
|
$down = 'http://campus.shs.broing.cn/temp/'.$zip_name;
|
|
|
downloads($down);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 打包成zip
|
|
|
* @param $pathArr
|
|
|
* @param $zipName
|
|
|
* @return array
|
|
|
*/
|
|
|
public function zip_files($pathArr,$zipName)
|
|
|
{
|
|
|
|
|
|
$zip = new \ZipArchive();
|
|
|
if($zip->open($zipName,\ZipArchive::CREATE|\ZipArchive::OVERWRITE)){
|
|
|
foreach($pathArr as $file){
|
|
|
if(!file_exists($file)){
|
|
|
continue;
|
|
|
}
|
|
|
$zip->addFile($file,basename($file)); //向压缩包中添加文件
|
|
|
}
|
|
|
$zip->close();
|
|
|
return $zipName;
|
|
|
}else{
|
|
|
return '';
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
} |
...
|
...
|
|