|
@@ -246,9 +246,9 @@ class ProductService extends BaseService
|
|
|
$where['sjId'] = $sjId;
|
|
$where['sjId'] = $sjId;
|
|
|
$where['shopId'] = $shopId;
|
|
$where['shopId'] = $shopId;
|
|
|
$where['delStatus'] = 0;
|
|
$where['delStatus'] = 0;
|
|
|
- $product = ProductClass::getAllByCondition($where,null,"*");
|
|
|
|
|
|
|
+ $product = ProductClass::getAllByCondition($where, null, "*");
|
|
|
$data = [];
|
|
$data = [];
|
|
|
- foreach ($product as $v){
|
|
|
|
|
|
|
+ foreach ($product as $v) {
|
|
|
$tmp = [];
|
|
$tmp = [];
|
|
|
$tmp['id'] = $v['id'];
|
|
$tmp['id'] = $v['id'];
|
|
|
$tmp['name'] = $v['name'];
|
|
$tmp['name'] = $v['name'];
|
|
@@ -274,40 +274,40 @@ class ProductService extends BaseService
|
|
|
$i = 1;
|
|
$i = 1;
|
|
|
$page = 0;
|
|
$page = 0;
|
|
|
$objPHPExcel->setActiveSheetIndex($page);
|
|
$objPHPExcel->setActiveSheetIndex($page);
|
|
|
- foreach ($classIds as $k=>$v){
|
|
|
|
|
|
|
+ foreach ($classIds as $k => $v) {
|
|
|
//if(($i%30==1|| $i%30==2 || $i%30==3 || $i%30==0 ) && $i >=30){
|
|
//if(($i%30==1|| $i%30==2 || $i%30==3 || $i%30==0 ) && $i >=30){
|
|
|
- if($i >=30){
|
|
|
|
|
|
|
+ if ($i >= 30) {
|
|
|
$i = 1;
|
|
$i = 1;
|
|
|
- $page ++;
|
|
|
|
|
|
|
+ $page++;
|
|
|
$objPHPExcel->createSheet();
|
|
$objPHPExcel->createSheet();
|
|
|
$objPHPExcel->setActiveSheetIndex($page);
|
|
$objPHPExcel->setActiveSheetIndex($page);
|
|
|
}
|
|
}
|
|
|
- $productData = $data[$v['id']]??[];
|
|
|
|
|
- if(empty($productData)){
|
|
|
|
|
|
|
+ $productData = $data[$v['id']] ?? [];
|
|
|
|
|
+ if (empty($productData)) {
|
|
|
continue;
|
|
continue;
|
|
|
}
|
|
}
|
|
|
- $cate_name = $v['name']??'';
|
|
|
|
|
- $objPHPExcel->getActiveSheet()->mergeCells("{$column_start}{$i}:{$column_end}{$i}")->setCellValue("A".$i,$cate_name);
|
|
|
|
|
|
|
+ $cate_name = $v['name'] ?? '';
|
|
|
|
|
+ $objPHPExcel->getActiveSheet()->mergeCells("{$column_start}{$i}:{$column_end}{$i}")->setCellValue("A" . $i, $cate_name);
|
|
|
//居中
|
|
//居中
|
|
|
$objPHPExcel->getActiveSheet()->getStyle("{$column_start}{$i}:{$column_end}{$i}")->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
$objPHPExcel->getActiveSheet()->getStyle("{$column_start}{$i}:{$column_end}{$i}")->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
//加粗
|
|
//加粗
|
|
|
$objPHPExcel->getActiveSheet()->getStyle("{$column_start}{$i}:{$column_end}{$i}")->getFont()->setSize(18)->setBold(true);
|
|
$objPHPExcel->getActiveSheet()->getStyle("{$column_start}{$i}:{$column_end}{$i}")->getFont()->setSize(18)->setBold(true);
|
|
|
- $i ++;
|
|
|
|
|
|
|
+ $i++;
|
|
|
|
|
|
|
|
- if($productData){
|
|
|
|
|
- $newChunk = array_chunk($productData,6); //6个一组
|
|
|
|
|
- foreach ($newChunk as $c){
|
|
|
|
|
|
|
+ if ($productData) {
|
|
|
|
|
+ $newChunk = array_chunk($productData, 6); //6个一组
|
|
|
|
|
+ foreach ($newChunk as $c) {
|
|
|
|
|
|
|
|
- foreach ($c as $ck=>$cv){
|
|
|
|
|
|
|
+ foreach ($c as $ck => $cv) {
|
|
|
$objPHPExcel->getActiveSheet()->setCellValue($title_array[$ck] . $i, $cv['name']);
|
|
$objPHPExcel->getActiveSheet()->setCellValue($title_array[$ck] . $i, $cv['name']);
|
|
|
//居中
|
|
//居中
|
|
|
$objPHPExcel->getActiveSheet()->getStyle("$title_array[$ck]$i")->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
$objPHPExcel->getActiveSheet()->getStyle("$title_array[$ck]$i")->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
|
|
|
}
|
|
}
|
|
|
$i++;
|
|
$i++;
|
|
|
- foreach ($c as $ck=>$cv){
|
|
|
|
|
|
|
+ foreach ($c as $ck => $cv) {
|
|
|
$objDrawing = new \PHPExcel_Worksheet_Drawing;
|
|
$objDrawing = new \PHPExcel_Worksheet_Drawing;
|
|
|
- $p = dirUtil::getBarcodeDir().$cv['id'].".jpg";
|
|
|
|
|
- if(!file_exists($p)){
|
|
|
|
|
|
|
+ $p = dirUtil::getBarcodeDir() . $cv['id'] . ".jpg";
|
|
|
|
|
+ if (!file_exists($p)) {
|
|
|
//生成条形码
|
|
//生成条形码
|
|
|
barcodeUtil::generatorProductBarcode($cv['id']);
|
|
barcodeUtil::generatorProductBarcode($cv['id']);
|
|
|
}
|
|
}
|
|
@@ -343,8 +343,9 @@ class ProductService extends BaseService
|
|
|
unlink($dir . '/' . $file);
|
|
unlink($dir . '/' . $file);
|
|
|
}
|
|
}
|
|
|
$objWriter->save($dir . '/' . $file);
|
|
$objWriter->save($dir . '/' . $file);
|
|
|
-
|
|
|
|
|
- return ['file' => '/barcodeTable/' . $shopId . '/' . $file, 'shortFile' => $file];
|
|
|
|
|
|
|
+ $shortFile = 'barcodeTable/' . $shopId . '/' . $file;
|
|
|
|
|
+ $fullFile = '/barcodeTable/' . $shopId . '/' . $file;
|
|
|
|
|
+ return ['file' => $fullFile, 'shortFile' => $shortFile];
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
}
|
|
}
|