shish 4 lat temu
rodzic
commit
54d95c3c7c
1 zmienionych plików z 59 dodań i 2 usunięć
  1. 59 2
      app-hd/controllers/ShopExtController.php

+ 59 - 2
app-hd/controllers/ShopExtController.php

@@ -40,7 +40,6 @@ class ShopExtController extends BaseController
     //添加打印机 ssh 20210712
     public function actionAddPrint()
     {
-
         $shopAdmin = $this->shopAdmin;
         $roleId = $shopAdmin['roleId'] ?? 0;
         $role = AdminRoleClass::getById($roleId);
@@ -101,7 +100,6 @@ class ShopExtController extends BaseController
     //添加打印机 ssh 20210712
     public function actionAddMakePrint()
     {
-
         $shopAdmin = $this->shopAdmin;
         $roleId = $shopAdmin['roleId'] ?? 0;
         $role = AdminRoleClass::getById($roleId);
@@ -159,6 +157,65 @@ class ShopExtController extends BaseController
         util::complete();
     }
 
+    //添加美团制作单用的打印机 ssh 20210712
+    public function actionAddMtPrint()
+    {
+        $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->mtPrintSn = $printSn;
+                $ext->mtPrintKey = $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->mtPrintLabelSn = $printLabelSn;
+                $ext->mtPrintLabelKey = $printLabelKey;
+                $ext->save();
+
+                //将打印纸张设置为50X70
+                $labelPrint->times = 1;
+                $content = '<SIZE>50,70</SIZE>';
+                $labelPrint->printLabelMsg($content);
+            }
+        } else {
+            $ext->mtPrintLabelSn = '';
+            $ext->mtPrintLabelKey = '';
+            $ext->save();
+        }
+        util::complete();
+    }
 
     //获取打印机信息
     public function actionGetPrint()