shish 4 лет назад
Родитель
Сommit
e8a84f3077
1 измененных файлов с 19 добавлено и 20 удалено
  1. 19 20
      biz-ghs/product/services/ProductService.php

+ 19 - 20
biz-ghs/product/services/ProductService.php

@@ -246,9 +246,9 @@ class ProductService extends BaseService
         $where['sjId'] = $sjId;
         $where['shopId'] = $shopId;
         $where['delStatus'] = 0;
-        $product = ProductClass::getAllByCondition($where, null, "*");
+        $product = ProductClass::getAllByCondition($where,null,"*");
         $data = [];
-        foreach ($product as $v) {
+        foreach ($product as $v){
             $tmp = [];
             $tmp['id'] = $v['id'];
             $tmp['name'] = $v['name'];
@@ -274,40 +274,40 @@ class ProductService extends BaseService
         $i = 1;
         $page = 0;
         $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) {
+            if($i >=30){
                 $i = 1;
-                $page++;
+                $page ++;
                 $objPHPExcel->createSheet();
                 $objPHPExcel->setActiveSheetIndex($page);
             }
-            $productData = $data[$v['id']] ?? [];
-            if (empty($productData)) {
+            $productData = $data[$v['id']]??[];
+            if(empty($productData)){
                 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}")->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()->getStyle("$title_array[$ck]$i")->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
                     }
                     $i++;
-                    foreach ($c as $ck => $cv) {
+                    foreach ($c as $ck=>$cv){
                         $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']);
                         }
@@ -343,9 +343,8 @@ class ProductService extends BaseService
             unlink($dir . '/' . $file);
         }
         $objWriter->save($dir . '/' . $file);
-        $shortFile = 'barcodeTable/' . $shopId . '/' . $file;
-        $fullFile = '/barcodeTable/' . $shopId . '/' . $file;
-        return ['file' => $fullFile, 'shortFile' => $shortFile];
+
+        return ['file' => '/barcodeTable/' . $shopId . '/' . $file, 'shortFile' => $file];
     }
 
 }