Selaa lähdekoodia

操作台小票机

shish 4 vuotta sitten
vanhempi
commit
db15f2fac4

+ 64 - 0
app-hd/controllers/ShopExtController.php

@@ -52,10 +52,12 @@ class ShopExtController extends BaseController
         $shopId = $this->shopId;
         $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
         $get = Yii::$app->request->get();
+
         $printSn = $get['printSn'] ?? '';
         $printKey = $get['printKey'] ?? '';
         $printLabelSn = $get['printLabelSn'] ?? '';
         $printLabelKey = $get['printLabelKey'] ?? '';
+
         $shop = $this->shop;
         $default = $shop->default ?? 0;
         $shopName = $shop->shopName ?? '';
@@ -96,6 +98,68 @@ class ShopExtController extends BaseController
         util::complete();
     }
 
+    //添加打印机 ssh 20210712
+    public function actionAddMakePrint()
+    {
+
+        $shopAdmin = $this->shopAdmin;
+        $roleId = $shopAdmin['roleId'] ?? 0;
+        $role = AdminRoleClass::getById($roleId);
+        $roleName = $role['roleName'] ?? '';
+        if ($roleName == '员工') {
+            util::fail('没有权限操作哦');
+        }
+
+        $shopId = $this->shopId;
+        $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
+        $get = Yii::$app->request->get();
+
+        $printSn = $get['printSn'] ?? '';
+        $printKey = $get['printKey'] ?? '';
+        $printLabelSn = $get['printLabelSn'] ?? '';
+        $printLabelKey = $get['printLabelKey'] ?? '';
+
+        $shop = $this->shop;
+        $default = $shop->default ?? 0;
+        $shopName = $shop->shopName ?? '';
+        $sj = $this->sj;
+        $sjName = $sj->name ?? '';
+        $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
+        if (!empty($printSn) && !empty($printKey)) {
+            $print = new printUtil($printSn);
+            $return = $print->addPrint($printKey, $name);
+            if ($return) {
+                $ext->makePrintSn = $printSn;
+                $ext->makePrintKey = $printKey;
+                $ext->save();
+            }
+        } else {
+            $ext->makePrintSn = '';
+            $ext->makePrintKey = '';
+            $ext->save();
+        }
+        if (!empty($printLabelSn) && !empty($printLabelKey)) {
+            $labelPrint = new printUtil($printLabelSn);
+            $return = $labelPrint->addPrint($printLabelKey, $name);
+            if ($return) {
+                $ext->makePrintLabelSn = $printLabelSn;
+                $ext->makePrintLabelKey = $printLabelKey;
+                $ext->save();
+
+                //将打印纸张设置为50X70
+                $labelPrint->times = 1;
+                $content = '<SIZE>50,70</SIZE>';
+                $labelPrint->printLabelMsg($content);
+            }
+        } else {
+            $ext->makePrintLabelSn = '';
+            $ext->makePrintLabelKey = '';
+            $ext->save();
+        }
+        util::complete();
+    }
+
+
     //获取打印机信息
     public function actionGetPrint()
     {

+ 4 - 1
biz-hd/order/classes/OrderClass.php

@@ -403,7 +403,7 @@ class OrderClass extends BaseClass
     }
 
     //云打印 ssh 20210709
-    public static function onlinePrint($order, $must = false)
+    public static function onlinePrint($order, $must = false, $port = 'front')
     {
         if (empty($order)) {
             return false;
@@ -420,6 +420,9 @@ class OrderClass extends BaseClass
         $shopId = $order->shopId ?? 0;
         $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
         $printSn = $ext['printSn'] ?? '';
+        if ($port == 'make') {
+            $printSn = $ext['makePrintSn'] ?? '';
+        }
         if (empty($printSn)) {
             return false;
         }

+ 2 - 2
biz-hd/work/classes/WorkClass.php

@@ -51,11 +51,11 @@ class WorkClass extends BaseClass
             if (empty($order)) {
                 util::fail('没有找到订单');
             }
-            OrderClass::onlinePrint($order);
+            OrderClass::onlinePrint($order,false,'make');
         } else {
             $shopId = $shop->id ?? 0;
             $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
-            $printLabelSn = $ext->printLabelSn ?? '';
+            $printLabelSn = $ext->makePrintLabelSn ?? '';
             if (empty($printLabelSn)) {
                 if ($mustPrint) {
                     util::fail('请设置标签打印机');