shish hace 2 años
padre
commit
7b3e607ac8
Se han modificado 2 ficheros con 42 adiciones y 31 borrados
  1. 3 1
      app-ghs/controllers/OrderController.php
  2. 39 30
      biz-ghs/order/classes/OrderClass.php

+ 3 - 1
app-ghs/controllers/OrderController.php

@@ -50,7 +50,9 @@ class OrderController extends BaseController
         $date = date("Ymd", strtotime($order->addTime));
         $orderSn = $order->orderSn ?? '';
         $name = $customName . '_' . $date . '_' . $orderSn;
-        $respond = OrderClass::createImgOrder($order);
+        $shop = $this->shop;
+        $staff = $this->shopAdmin;
+        $respond = OrderClass::createImgOrder($order, $shop, $staff);
         $imgUrl = $respond['imgFile'] ?? '';
         $file = fopen($imgUrl, "rb");
         Header("Content-type:  application/octet-stream ");

+ 39 - 30
biz-ghs/order/classes/OrderClass.php

@@ -1893,10 +1893,17 @@ class OrderClass extends BaseClass
         Yii::$app->redis->executeCommand('LPUSH', [$newOrderKey, $id]);
     }
 
-    public static function createImgOrder($order)
+    public static function createImgOrder($order, $shop, $staff)
     {
+        $staffName = $staff->name ?? '';
+        $shopName = $shop->shopName ?? '';
+        $sjName = $shop->merchantName ?? '';
+        $fullSjName = $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
         $mainId = $order->mainId ?? 0;
         $orderSn = $order->orderSn ?? '';
+        $addTime = $order->addTime ?? '';
+        $customName = $order->customName ?? '';
+        $currentDate = date("Y-m-d", strtotime($addTime));
         $dir = Yii::getAlias('@app/web/html/' . $mainId . '/');
         if (!file_exists($dir)) {
             //检查是否有该文件夹,如果没有就创建,并给予最高权限
@@ -1927,15 +1934,17 @@ XL;
                     $index = bcadd($key, $start);
                     $index++;
                     $name = $item->name ?? '';
-                    $num = 0;
-                    $bigUnit = '扎';
-                    $unitPrice = 133;
-                    $amount = 433;
+                    $num = $item->xhNum;
+                    $refundNum = $item->refundNum ?? 0;
+                    $realNum = bcsub($num, $refundNum);
+                    $bigUnit = $item->xhUnitName;
+                    $unitPrice = $item->xhUnitPrice ?? 0;
+                    $amount = bcmul($realNum, $unitPrice, 2);
                     $remark = '';
                     $tableList .= "<tr>";
                     $tableList .= "<td>{$index}</td>";
                     $tableList .= "<td>{$name}</td>";
-                    $tableList .= "<td>{$num}</td>";
+                    $tableList .= "<td>{$realNum}</td>";
                     $tableList .= "<td>{$bigUnit}</td>";
                     $tableList .= "<td>{$unitPrice}</td>";
                     $tableList .= "<td>{$amount}</td>";
@@ -1946,13 +1955,13 @@ XL;
                 $content .= <<<XL
 		<div style="width:760px;height:4px;background-color:black;margin-bottom:10px;"></div>
 		<div style="width:750px;text-align:center;font-weight:bold;margin-bottom:20px;font-size:18px;">
-			<div>厦门中花汇信息科技有限公司</div>
+			<div>{$fullSjName}</div>
 			<div style="margin-top:5px;">销售单</div>
 		</div>
 		<div style="width:750px;">
-			<span>单据日期:2024-3-9</span>
-			<span style="margin-left:130px;">客户:花元</span>
-			<span style="float:right;">编号:XSD5645688</span>
+			<span>单据日期:{$currentDate}</span>
+			<span style="margin-left:130px;">客户:{$customName}</span>
+			<span style="float:right;">编号:{$orderSn}</span>
 		<div>
 		<table border="1" style="border: 1px solid black;border-collapse:collapse;text-align:center;font-size:14px;width:750px;margin-top:5px;">
 		  <tr style="font-weight:bold;">
@@ -1967,12 +1976,12 @@ XL;
 {$tableList}
 		</table>
 		<div style="margin-top:5px;margin-bottom:20px;">
-		<span>制单人:</span>
+		<span>制单人:{$staffName}</span>
 		<span style="margin-left:200px;">上次欠款:</span>
 		<span style="margin-left:200px;">应付款余额:</span>
 		</div>
 XL;
-                
+
             }
         }
 
@@ -1988,22 +1997,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];
+    }
 
-        }
+}