shish преди 1 година
родител
ревизия
686d771b0e
променени са 1 файла, в които са добавени 34 реда и са изтрити 16 реда
  1. 34 16
      biz-ghs/product/services/ProductService.php

+ 34 - 16
biz-ghs/product/services/ProductService.php

@@ -253,20 +253,15 @@ class ProductService extends BaseService
         //中央ID
         $classIds = ItemClassClass::getGhsItemClassAll($mainId);
 
-        $all = Yii::$app->request->get('all', 0);
-
         $where['mainId'] = $mainId;
-        $allName = $all == 0 ? '' : 'all';
-        if ($all == 0) {
-            $where['status'] = $status;
-        }
+        $where['status'] = $status;
         $where['delStatus'] = 0;
 
         $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], "*");
         $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
-
         $respond = self::assembleData($classIds, $itemInfoData, true);
         $data = $respond['classItem'] ?? [];
+
         $formatData = [];
 
         foreach ($data as $key => $class) {
@@ -275,7 +270,7 @@ class ProductService extends BaseService
                 continue;
             }
             $name = $class['className'] ?? '';
-            $formatData[] = ['name' => $name, 'price' => ''];
+            $formatData[] = ['name' => $name, 'price' => '', 'type' => 'className'];
             if (isset($class['child']) && !empty($class['child'])) {
                 foreach ($class['child'] as $cKey => $child) {
                     $cName = $child['name'] ?? '';
@@ -283,7 +278,22 @@ class ProductService extends BaseService
                     $formatData[] = [
                         'name' => $cName,
                         'price' => $price,
+                        'type' => 'item',
                     ];
+                    if (isset($child['reachNum']) && $child['reachNum'] > 0) {
+                        if (isset($child['reachNumDiscount']) && $child['reachNumDiscount'] > 0) {
+                            $bigUnit = $child['bigUnit'] ?? '扎';
+                            $reachPrice = bcsub($price, $child['reachNumDiscount'], 2);
+                            $reachPrice = floatval($reachPrice);
+                            $reachName = '    满' . $child['reachNum'] . $bigUnit;
+                            $formatData[] = [
+                                'name' => $reachName,
+                                'price' => $reachPrice,
+                                //满减活动花材
+                                'type' => 'reach',
+                            ];
+                        }
+                    }
                 }
             }
         }
@@ -307,9 +317,6 @@ class ProductService extends BaseService
         //$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader(date('n月j日') . " " . $levelName . "客户");
         //$objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader(date('n月j日') . " 编号 " . $level);
         $topLevelName = $levelName;
-        if ($level == CustomClass::LEVEL_SK) {
-            $topLevelName = '';
-        }
         $objPHPExcel->getActiveSheet()->getHeaderFooter()->setOddHeader(date('n月j日') . " " . $topLevelName);
 
         $objPHPExcel->getActiveSheet()->getPageMargins()->setTop(0.7);
@@ -321,8 +328,7 @@ class ProductService extends BaseService
 
         $i = 1;
         $letter = [1 => ['A', 'B'], 2 => ['C', 'D'], 3 => ['E', 'F'], 4 => ['G', 'H'], 5 => ['I', 'J'], 6 => ['K', 'L'], 7 => ['M', 'N'],
-            8 => ['O', 'P'], 9 => ['Q', 'R'], 10 => ['S', 'T'], 11 => ['U', 'V'], 12 => ['w', 'x'], 13 => ['y', 'z'],
-            14 => ['AA', 'AB'], 15 => ['AC', 'AD'], 16 => ['AE', 'AF'], 17 => ['AG', 'AH'], 18 => ['AI', 'AJ']];
+            8 => ['O', 'P'], 9 => ['Q', 'R'], 10 => ['S', 'T'], 11 => ['U', 'V']];
         $lastCell = '';
         //最大行
         $max = 50;
@@ -349,8 +355,20 @@ class ProductService extends BaseService
                 $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getAlignment()->setHorizontal(\PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
                 //垂直居中
                 $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
+            } else if (isset($product['type']) && $product['type'] == 'reach') {
+                $objPHPExcel->getActiveSheet()->setCellValue($before . $x, $product['name'])->setCellValue($after . $x, $product['price']);
+                //字体大小 加粗
+                $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getFont()->setSize(9)->setBold(true);
+                //红色
+                $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getFont()->getColor()->setARGB(\PHPExcel_Style_Color::COLOR_RED);
+                //垂直居中
+                $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getAlignment()->setVertical(\PHPExcel_Style_Alignment::VERTICAL_CENTER);
+                //字体大小 加粗
+                $objPHPExcel->getActiveSheet()->getStyle($after . $x)->getFont()->setSize(11)->setBold(true);
+                //红色
+                $objPHPExcel->getActiveSheet()->getStyle($after . $x)->getFont()->getColor()->setARGB(\PHPExcel_Style_Color::COLOR_RED);
             } else {
-                $objPHPExcel->getActiveSheet()->setCellValue($before . $x, $product['name'])->setCellValue($after . $x, '');
+                $objPHPExcel->getActiveSheet()->setCellValue($before . $x, $product['name'])->setCellValue($after . $x, $product['price']);
                 //字体大小
                 $objPHPExcel->getActiveSheet()->getStyle($before . $x)->getFont()->setSize(9);
                 //垂直居中
@@ -371,9 +389,9 @@ class ProductService extends BaseService
         if (file_exists($dir) == false) {
             mkdir($dir, 0777, true);
         }
-        $date = date("m-d");
+        $date = date("H");
 
-        $file = $date . '-hua' . $allName . '.xls';
+        $file = $date . '_stock.xls';
         $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
 
         if (file_exists($dir . '/' . $file)) {