Ver Fonte

app 条形码

shish há 4 anos atrás
pai
commit
3d3258fa7b
1 ficheiros alterados com 19 adições e 20 exclusões
  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']);
                         }
@@ -333,8 +333,7 @@ class ProductService extends BaseService
         if (file_exists($dir) == false) {
             mkdir($dir, 0777, true);
         }
-        //$date = date("m-d") . "-" . $levelName . "-编号" . $level;
-        $date = date("m-d");
+        $date = "条形码_" . date("m-d");
 
         $file = $date . '.xls';
         $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
@@ -344,7 +343,7 @@ class ProductService extends BaseService
         }
         $objWriter->save($dir . '/' . $file);
 
-        return ['file' => '/barcodeTable/' . $shopId . '/' . $file, 'shortFile' => '条形码'.$file];
+        return ['file' => '/barcodeTable/' . $shopId . '/' . $file, 'shortFile' => $file];
     }
 
 }