shopAdmin; if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) { util::fail('超管才能修改'); } $shopId = $this->shopId; $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true); $get = Yii::$app->request->get(); $wcPrintSn = $get['wcPrintSn'] ?? ''; $wcPrintKey = $get['wcPrintKey'] ?? ''; $wcPrintSn2 = $get['wcPrintSn2'] ?? ''; $wcPrintKey2 = $get['wcPrintKey2'] ?? ''; $wcPrintSn3 = $get['wcPrintSn3'] ?? ''; $wcPrintKey3 = $get['wcPrintKey3'] ?? ''; $shop = $this->shop; $default = $shop->default ?? 0; $shopName = $shop->shopName ?? ''; $sj = $this->sj; $sjName = $sj->name ?? ''; $name = $default == 1 && $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName; if (empty($wcPrintSn) && !empty($wcPrintSn2)) { util::fail('请先填写小票机编号1'); } if (empty($wcPrintSn2) && !empty($wcPrintSn3)) { util::fail('请先填写小票机编号2'); } $hasFail = 0; if (!empty($wcPrintSn) && !empty($wcPrintKey)) { $print = new printUtil($wcPrintSn); $return = $print->addPrint($wcPrintKey, $name); if ($return) { $ext->wcPrintSn = $wcPrintSn; $ext->wcPrintKey = $wcPrintKey; $ext->save(); } else { $hasFail = 1; } } else { $ext->wcPrintSn = ''; $ext->wcPrintKey = ''; $ext->save(); } if (!empty($wcPrintSn2) && !empty($wcPrintKey2)) { $print = new printUtil($wcPrintSn2); $return = $print->addPrint($wcPrintKey2, $name); if ($return) { $ext->wcPrintSn2 = $wcPrintSn2; $ext->wcPrintKey2 = $wcPrintKey2; $ext->save(); } else { $hasFail = 1; } } else { $ext->wcPrintSn2 = ''; $ext->wcPrintKey2 = ''; $ext->save(); } if (!empty($wcPrintSn3) && !empty($wcPrintKey3)) { $print = new printUtil($wcPrintSn3); $return = $print->addPrint($wcPrintKey3, $name); if ($return) { $ext->wcPrintSn3 = $wcPrintSn3; $ext->wcPrintKey3 = $wcPrintKey3; $ext->save(); } else { $hasFail = 1; } } else { $ext->wcPrintSn3 = ''; $ext->wcPrintKey3 = ''; $ext->save(); } $wcPrintNum = 1; if (isset($ext->wcPrintSn2) && !empty($ext->wcPrintSn2)) { $wcPrintNum = 2; } if (isset($ext->wcPrintSn3) && !empty($ext->wcPrintSn3)) { $wcPrintNum = 3; } ShopExtClass::updateByCondition(['shopId' => $this->shopId], ['wcPrintNum' => $wcPrintNum]); if ($hasFail == 1) { util::success(['hasFail' => 1], '出现添加失败的情况'); } util::complete(); } //添加打印机 ssh 20210712 public function actionAddPrint() { $shopAdmin = $this->shopAdmin; if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) { util::fail('超管才能修改'); } $hasFail = 0; $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'] ?? ''; $wlLabelSn = $get['wlLabelSn'] ?? ''; $wlLabelKey = $get['wlLabelKey'] ?? ''; $shop = $this->shop; $default = $shop->default ?? 0; $shopName = $shop->shopName ?? ''; $sj = $this->sj; $sjName = $sj->name ?? ''; $name = $default == 1 && $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName; if (!empty($printSn) && !empty($printKey)) { $print = new printUtil($printSn); $return = $print->addPrint($printKey, $name); if ($return) { $ext->printSn = $printSn; $ext->printKey = $printKey; $ext->save(); } else { $hasFail = 1; } } else { $ext->printSn = ''; $ext->printKey = ''; $ext->save(); } if (!empty($printLabelSn) && !empty($printLabelKey)) { $labelPrint = new printUtil($printLabelSn); $return = $labelPrint->addPrint($printLabelKey, $name); if ($return) { $ext->printLabelSn = $printLabelSn; $ext->printLabelKey = $printLabelKey; $ext->save(); //将打印纸张设置为50X40 $labelPrint->times = 1; $content = '50,40'; $labelPrint->printLabelMsg($content); } else { $hasFail = 1; } } else { $ext->printLabelSn = ''; $ext->printLabelKey = ''; $ext->save(); } if (!empty($wlLabelSn) && !empty($wlLabelKey)) { $labelPrint = new printUtil($wlLabelSn); $return = $labelPrint->addPrint($wlLabelKey, $name); if ($return) { $ext->wlLabelSn = $wlLabelSn; $ext->wlLabelKey = $wlLabelKey; $ext->save(); //将打印纸张设置为60X100 $labelPrint->times = 1; $content = '60,100'; $labelPrint->printLabelMsg($content); } else { $hasFail = 1; } } else { $ext->wlLabelSn = ''; $ext->wlLabelKey = ''; $ext->save(); } if ($hasFail == 1) { util::success(['hasFail' => 1], '出现添加失败的情况'); } util::complete(); } //获取打印机信息 public function actionGetPrint() { $shopId = $this->shopId; $ext = ShopExtClass::getByCondition(['shopId' => $shopId]); util::success($ext); } //获取云喇叭信息 ssh 20220105 public function actionGetLb() { $shopId = $this->shopId; $ext = ShopExtClass::getByCondition(['shopId' => $shopId]); util::success($ext); } //添加喇叭 ssh 20220105 public function actionAddLb() { $shopAdmin = $this->shopAdmin; if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) { util::fail('超管才能修改'); } $shopId = $this->shopId; $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true); $get = Yii::$app->request->get(); $lbSn = $get['lbSn'] ?? ''; $lbVersion = $get['lbVersion'] ?? ''; $ext->lbSn = $lbSn; $ext->lbVersion = $lbVersion; $ext->save(); util::complete('设置成功'); } //小菊启用和停用 ssh 20211210 public function actionReplaceXj() { $act = Yii::$app->request->get('act', 'start'); $id = Yii::$app->request->get('id', 0); $xj = XjClass::getById($id, true); if (empty($xj)) { util::fail('没有找到小菊'); } $status = $act == 'start' ? 1 : 2; $xj->status = $status; $xj->save(); util::complete(); } }