shish пре 3 година
родитељ
комит
539e0930a7
2 измењених фајлова са 42 додато и 35 уклоњено
  1. 4 2
      app-ghs/controllers/OrderController.php
  2. 38 33
      biz-ghs/order/classes/OrderClass.php

+ 4 - 2
app-ghs/controllers/OrderController.php

@@ -1341,7 +1341,9 @@ class OrderController extends BaseController
     //打印订单 ssh 20210714
     public function actionCloudPrintOrder()
     {
-        $id = Yii::$app->request->get('id', 0);
+        $get = Yii::$app->request->get();
+        $id = $get['id'] ?? 0;
+        $showPrice = $get['showPrice'] ?? 1;
         $order = OrderClass::getById($id, true);
         OrderClass::valid($order, $this->shopId);
         if ($order->status == OrderClass::ORDER_STATUS_UN_PAY) {
@@ -1354,7 +1356,7 @@ class OrderController extends BaseController
         if (isset($ext->printSn) == false || isset($ext->printKey) == false || empty($ext->printSn) || empty($ext->printKey)) {
             util::success(['hasNoPrint' => 1]);
         }
-        OrderClass::onlinePrint($order);
+        OrderClass::onlinePrint($order, $showPrice);
         $order->printNum += 1;
         $order->save();
         util::complete();

+ 38 - 33
biz-ghs/order/classes/OrderClass.php

@@ -906,21 +906,23 @@ class OrderClass extends BaseClass
         return $list;
     }
 
-    public static function printGroup($current, $content)
+    public static function printGroup($current, $content, $showPrice = 1)
     {
         //58mm的机器,一行打印16个汉字,32个字母
         $name = $current['name'] ?? '';
         $productNum = $current['num'] ?? '';
         $count = $current['count'] ?? '';
         $content .= '<B>' . $name . ' ' . $count . '</B><BR>';
-        $productPrice = $current['price'] ?? '';
-        $content .= $productNum . '=' . $productPrice . '<BR>';
+        if ($showPrice == 1) {
+            $productPrice = $current['price'] ?? '';
+            $content .= $productNum . '=' . $productPrice . '<BR>';
+        }
         $content .= '--------------------------------<BR>';
         return $content;
     }
 
     //云打印 ssh 20210709
-    public static function onlinePrint($orderInfo)
+    public static function onlinePrint($orderInfo, $showPrice = 1)
     {
         $showItem = OrderClass::getShowItem(true, $orderInfo);
 
@@ -971,7 +973,7 @@ class OrderClass extends BaseClass
 
         if (isset($respond['product']) && !empty($respond['product'])) {
             foreach ($respond['product'] as $current) {
-                $content = self::printGroup($current, $content);
+                $content = self::printGroup($current, $content, $showPrice);
             }
             $content .= '--------------------------------<BR>';
         }
@@ -983,42 +985,45 @@ class OrderClass extends BaseClass
                 $name = $current['name'] ?? '';
                 $count = $current['count'] ?? '';
                 $content .= '<B>' . $name . ' ' . $count . '</B><BR>';
-                $productNum = $current['num'] ?? '';
-                $productPrice = $current['price'] ?? '';
-                $content .= $productNum . '=' . $productPrice . '<BR>';
+                if ($showPrice == 1) {
+                    $productNum = $current['num'] ?? '';
+                    $productPrice = $current['price'] ?? '';
+                    $content .= $productNum . '=' . $productPrice . '<BR>';
+                }
             }
             $content .= '--------------------------------<BR>';
             $content .= '--------------------------------<BR>';
         }
 
-        if (isset($orderInfo['itemPrice']) && $orderInfo['itemPrice'] > 0) {
-            $content .= '商品金额:' . floatval($orderInfo['itemPrice']) . '<BR>';
-        }
-        if (isset($respond['sendCost']) && $respond['sendCost'] > 0) {
-            $content .= '    运费:' . floatval($respond['sendCost']) . '<BR>';
-        }
-        if (isset($orderInfo['packCost']) && $orderInfo['packCost'] > 0) {
-            $content .= '  打包费:' . floatval($orderInfo['packCost']) . '<BR>';
-        }
-        $content .= '合计金额:' . floatval($respond['prePrice']) . '<BR>';
-        if (isset($respond['discountAmount']) && !empty($respond['discountAmount']) && $respond['discountAmount'] > 0) {
-            $content .= '优惠扣除:-' . floatval($respond['discountAmount']) . '<BR>';
-        }
+        if ($showPrice == 1) {
+            if (isset($orderInfo['itemPrice']) && $orderInfo['itemPrice'] > 0) {
+                $content .= '商品金额:' . floatval($orderInfo['itemPrice']) . '<BR>';
+            }
+            if (isset($respond['sendCost']) && $respond['sendCost'] > 0) {
+                $content .= '    运费:' . floatval($respond['sendCost']) . '<BR>';
+            }
+            if (isset($orderInfo['packCost']) && $orderInfo['packCost'] > 0) {
+                $content .= '  打包费:' . floatval($orderInfo['packCost']) . '<BR>';
+            }
+            $content .= '合计金额:' . floatval($respond['prePrice']) . '<BR>';
+            if (isset($respond['discountAmount']) && !empty($respond['discountAmount']) && $respond['discountAmount'] > 0) {
+                $content .= '优惠扣除:-' . floatval($respond['discountAmount']) . '<BR>';
+            }
 
-        if (isset($respond['refundPrice']) && $respond['refundPrice'] > 0) {
-            $content .= '退款金额:' . floatval($respond['refundPrice']) . '<BR>';
-        }
+            if (isset($respond['refundPrice']) && $respond['refundPrice'] > 0) {
+                $content .= '退款金额:' . floatval($respond['refundPrice']) . '<BR>';
+            }
 
-        $content .= '<B>订单金额:' . floatval($respond['realPrice']) . '</B><BR>';
-        if (isset($respond['debt']) && $respond['debt'] == 1) {
-            $content .= '实付金额:0<BR>';
-        } else {
-            $content .= '实付金额:' . floatval($respond['realPrice']) . '<BR>';
-        }
-        if ($debtAmount > 0) {
-            $content .= '累计欠款:' . floatval($debtAmount) . '<BR>';
+            $content .= '<B>订单金额:' . floatval($respond['realPrice']) . '</B><BR>';
+            if (isset($respond['debt']) && $respond['debt'] == 1) {
+                $content .= '实付金额:0<BR>';
+            } else {
+                $content .= '实付金额:' . floatval($respond['realPrice']) . '<BR>';
+            }
+            if ($debtAmount > 0) {
+                $content .= '累计欠款:' . floatval($debtAmount) . '<BR>';
+            }
         }
-
         $shopId = $orderInfo['shopId'] ?? 0;
         $shop = ShopClass::getById($shopId, true);
         $sjId = $shop->sjId ?? 0;