shish 2 years ago
parent
commit
c387b97b8f
1 changed files with 54 additions and 37 deletions
  1. 54 37
      biz-ghs/order/classes/OrderClass.php

+ 54 - 37
biz-ghs/order/classes/OrderClass.php

@@ -1906,25 +1906,6 @@ class OrderClass extends BaseClass
         if (empty($itemList)) {
             return ['url' => ''];
         }
-        $tableList = '';
-        foreach ($itemList as $key => $item) {
-            $index = bcadd($key, 1);
-            $name = $item->name ?? '';
-            $num = 0;
-            $bigUnit = '扎';
-            $unitPrice = 133;
-            $amount = 433;
-            $remark = '';
-            $tableList .= "<tr>";
-            $tableList .= "<td>{$index}</td>";
-            $tableList .= "<td>{$name}</td>";
-            $tableList .= "<td>{$num}</td>";
-            $tableList .= "<td>{$bigUnit}</td>";
-            $tableList .= "<td>{$unitPrice}</td>";
-            $tableList .= "<td>{$amount}</td>";
-            $tableList .= "<td>{$remark}</td>";
-            $tableList .= "</tr>";
-        }
 
         $content = <<<XL
 <html>
@@ -1932,6 +1913,36 @@ class OrderClass extends BaseClass
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
 </head>
 <body>
+XL;
+
+        $total = count($itemList);
+        $pageSize = 14;
+        $totalPage = ceil($total / $pageSize);
+        for ($page = 1; $page <= $totalPage; $page++) {
+            $start = ($page - 1) * $pageSize;
+            $currentList = array_slice($itemList, $start, $pageSize);
+            if (!empty($currentList)) {
+                $tableList = '';
+                foreach ($currentList as $key => $item) {
+                    $index = bcadd($key, $start);
+                    $name = $item->name ?? '';
+                    $num = 0;
+                    $bigUnit = '扎';
+                    $unitPrice = 133;
+                    $amount = 433;
+                    $remark = '';
+                    $tableList .= "<tr>";
+                    $tableList .= "<td>{$index}</td>";
+                    $tableList .= "<td>{$name}</td>";
+                    $tableList .= "<td>{$num}</td>";
+                    $tableList .= "<td>{$bigUnit}</td>";
+                    $tableList .= "<td>{$unitPrice}</td>";
+                    $tableList .= "<td>{$amount}</td>";
+                    $tableList .= "<td>{$remark}</td>";
+                    $tableList .= "</tr>";
+                }
+
+                $content .= <<<XL
 <div style="border-left:1px solid black;">
 	<div style="width:760px;height:8px;background-color:black;margin-bottom:5px;"></div>
 	<div style="margin-left:8px;">
@@ -1963,6 +1974,12 @@ class OrderClass extends BaseClass
 		</div>
 	</div>
 </div>
+XL;
+                
+            }
+        }
+
+        $content .= <<<XL
 </body>
 <style>
 body{
@@ -1974,22 +1991,22 @@ td{
 </style>
 </html>
 XL;
-        $file = $dir . $orderSn . '.html';
-        $imgFile = $dir . $orderSn . '.png';
-        if (file_exists($file)) {
-            unlink($file);
-        }
-        if (file_exists($imgFile)) {
-            unlink($imgFile);
-        }
-        file_put_contents($file, $content);
-        $con = new Converter(null, [
-            "fmt" => "png",
-            "in" => $file,
-            "out" => $imgFile,
-        ]);
-        $con->convert();
-        return ['imgFile' => $imgFile];
-    }
+                $file = $dir . $orderSn . '.html';
+                $imgFile = $dir . $orderSn . '.png';
+                if (file_exists($file)) {
+                    unlink($file);
+                }
+                if (file_exists($imgFile)) {
+                    unlink($imgFile);
+                }
+                file_put_contents($file, $content);
+                $con = new Converter(null, [
+                    "fmt" => "png",
+                    "in" => $file,
+                    "out" => $imgFile,
+                ]);
+                $con->convert();
+                return ['imgFile' => $imgFile];
+            }
 
-}
+        }