shish há 1 ano atrás
pai
commit
d2b39e7c6e

+ 49 - 0
app-ghs/controllers/OrderController.php

@@ -19,12 +19,14 @@ use bizGhs\product\classes\ProductClass;
 use common\components\baiduAip;
 use common\components\dict;
 use common\components\dateUtil;
+use common\components\dirUtil;
 use common\components\freight;
 use common\components\httpUtil;
 use common\components\noticeUtil;
 use common\components\oss;
 use common\components\payUtil;
 use common\components\qrCodeUtil;
+use common\components\stringUtil;
 use Yii;
 use common\components\util;
 use biz\shop\classes\ShopAdminClass;
@@ -2602,4 +2604,51 @@ class OrderController extends BaseController
         util::complete('修改成功');
     }
 
+    //导入开单 ssh 20241126
+    public function actionImportCreate()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? '';
+        $file = $_FILES['file'];
+        if (!is_uploaded_file($file['tmp_name'])) {
+            util::fail('please upload img');
+        }
+        $mainId = $this->sjId;
+        $shopId = $this->shopId;
+        $month = date("Ym");
+        $date = date("d");
+        $path = dirUtil::getImgUploadDir() . "/{$mainId}/kd/{$shopId}/{$month}/{$date}/";
+        if (!file_exists($path)) {
+            //检查是否有该文件夹,如果没有就创建,并给予最高权限
+            mkdir($path, 0700, true);
+        }
+        $preFileName = stringUtil::uniqueFileName();
+        $newFile = $preFileName . ".xls";
+        $fullPathFile = $path . $newFile;
+        if (move_uploaded_file($file['tmp_name'], $fullPathFile)) {
+
+            $phpExcelFile = Yii::getAlias("@vendor/phpoffice/phpexcel/");
+            require_once($phpExcelFile . 'Classes/PHPExcel/IOFactory.php');
+            $spreadsheet = \PHPExcel_IOFactory::load($fullPathFile);
+
+            // 获取活动工作表
+            $worksheet = $spreadsheet->getActiveSheet();
+
+            // 遍历每一行
+            foreach ($worksheet->getRowIterator() as $row) {
+                $cellIterator = $row->getCellIterator();
+                $cellIterator->setIterateOnlyExistingCells(FALSE); // 这里设置为迭代所有单元格,包括空单元格
+                // 遍历每列
+                $rowData = [];
+                foreach ($cellIterator as $cell) {
+                    $rowData[] = $cell->getValue();
+                }
+                // 输出当前行数据
+                echo implode(", ", $rowData) . "<br/>";
+            }
+        } else {
+            util::fail('上传失败');
+        }
+    }
+
 }

+ 37 - 8
app-ghs/controllers/PurchaseOrderController.php

@@ -13,6 +13,7 @@ use bizGhs\shop\classes\ShopClass;
 use bizHd\purchase\classes\PurchaseClass;
 use common\components\dateUtil;
 use common\components\dict;
+use common\components\dirUtil;
 use common\components\noticeUtil;
 use common\components\printUtil;
 use common\components\stringUtil;
@@ -405,7 +406,7 @@ class PurchaseOrderController extends BaseController
         if (getenv('YII_ENV') == 'production') {
             //小向花卉采购控制
             if ($this->mainId == 23390) {
-                if (!in_array($this->adminId, [24586, 24115, 24759, 26390, 23960, 25011, 25004, 24655, 28521,4])) {
+                if (!in_array($this->adminId, [24586, 24115, 24759, 26390, 23960, 25011, 25004, 24655, 28521, 4])) {
                     util::fail('你不能采购哦');
                 }
             }
@@ -764,27 +765,27 @@ class PurchaseOrderController extends BaseController
 
         $mainId = $this->mainId;
         $staff = $this->shopAdmin;
-        $addTime = $orderData['addTime']??'';
+        $addTime = $orderData['addTime'] ?? '';
         $currentTime = time();
         $hasOver = false;
         $overTime = $currentTime - strtotime($addTime);
         $overDay = ceil($overTime / 86400);
-        if($overDay>3){
+        if ($overDay > 3) {
             $hasOver = true;
         }
         if (getenv('YII_ENV') == 'production') {
             //花大苪没有财务权限的人,采购单只能看最近3天
-            if($mainId == 8164){
+            if ($mainId == 8164) {
                 if (!isset($staff->finance) || $staff->finance == 0) {
-                    if($hasOver){
+                    if ($hasOver) {
                         util::fail('超过3天,无法查看');
                     }
                 }
             }
-        }else{
-            if($mainId == 644){
+        } else {
+            if ($mainId == 644) {
                 if (!isset($staff->finance) || $staff->finance == 0) {
-                    if($hasOver){
+                    if ($hasOver) {
                         util::fail('超过3天,无法查看');
                     }
                 }
@@ -957,4 +958,32 @@ class PurchaseOrderController extends BaseController
         util::complete('修改成功');
     }
 
+    //导入采购 ssh 20241126
+    public function actionImportCreate()
+    {
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? '';
+        $file = $_FILES['file'];
+        if (!is_uploaded_file($file['tmp_name'])) {
+            util::fail('please upload img');
+        }
+        $mainId = $this->sjId;
+        $shopId = $this->shopId;
+        $month = date("Ym");
+        $date = date("d");
+        $path = dirUtil::getImgUploadDir() . "/{$mainId}/cg/{$shopId}/{$month}/{$date}/";
+        if (!file_exists($path)) {
+            //检查是否有该文件夹,如果没有就创建,并给予最高权限
+            mkdir($path, 0700, true);
+        }
+        $preFileName = stringUtil::uniqueFileName();
+        $newFile = $preFileName . ".xls";
+        $fullPathFile = $path . $newFile;
+        if (move_uploaded_file($file['tmp_name'], $fullPathFile)) {
+            util::complete($fullPathFile . ' id:' . $id);
+        } else {
+            util::fail('fail');
+        }
+    }
+
 }

+ 0 - 56
app-ghs/controllers/UploadController.php

@@ -199,60 +199,4 @@ class UploadController extends BaseController
         }
     }
 
-    //导入开单 ssh 20241126
-    public function actionImportKd()
-    {
-        $get = Yii::$app->request->get();
-        $id = $get['id'] ?? '';
-        $file = $_FILES['file'];
-        if (!is_uploaded_file($file['tmp_name'])) {
-            util::fail('please upload img');
-        }
-        $mainId = $this->sjId;
-        $shopId = $this->shopId;
-        $month = date("Ym");
-        $date = date("d");
-        $path = dirUtil::getImgUploadDir() . "/{$mainId}/kd/{$shopId}/{$month}/{$date}/";
-        if (!file_exists($path)) {
-            //检查是否有该文件夹,如果没有就创建,并给予最高权限
-            mkdir($path, 0700, true);
-        }
-        $preFileName = stringUtil::uniqueFileName();
-        $newFile = $preFileName . ".xls";
-        $fullPathFile = $path . $newFile;
-        if (move_uploaded_file($file['tmp_name'], $fullPathFile)) {
-            util::complete($fullPathFile . ' id:' . $id);
-        } else {
-            util::fail('fail');
-        }
-    }
-
-    //导入采购 ssh 20241126
-    public function actionImportCg()
-    {
-        $get = Yii::$app->request->get();
-        $id = $get['id'] ?? '';
-        $file = $_FILES['file'];
-        if (!is_uploaded_file($file['tmp_name'])) {
-            util::fail('please upload img');
-        }
-        $mainId = $this->sjId;
-        $shopId = $this->shopId;
-        $month = date("Ym");
-        $date = date("d");
-        $path = dirUtil::getImgUploadDir() . "/{$mainId}/cg/{$shopId}/{$month}/{$date}/";
-        if (!file_exists($path)) {
-            //检查是否有该文件夹,如果没有就创建,并给予最高权限
-            mkdir($path, 0700, true);
-        }
-        $preFileName = stringUtil::uniqueFileName();
-        $newFile = $preFileName . ".xls";
-        $fullPathFile = $path . $newFile;
-        if (move_uploaded_file($file['tmp_name'], $fullPathFile)) {
-            util::complete($fullPathFile . ' id:' . $id);
-        } else {
-            util::fail('fail');
-        }
-    }
-
 }