| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119 |
- <?php
- namespace ghs\controllers;
- use biz\admin\classes\AdminRoleClass;
- use biz\product\classes\XjClass;
- use biz\shop\classes\ShopExtClass;
- use common\components\printUtil;
- use common\components\util;
- use Yii;
- class ShopExtController extends BaseController
- {
- public $guestAccess = [];
- //添加打印机 ssh 20210712
- public function actionAddPrint()
- {
- $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();
- $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->printSn = $printSn;
- $ext->printKey = $printKey;
- $ext->save();
- }
- } 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();
- //将打印纸张设置为50X70
- $labelPrint->times = 1;
- $content = '<SIZE>50,70</SIZE>';
- $labelPrint->printLabelMsg($content);
- }
- } else {
- $ext->printLabelSn = '';
- $ext->printLabelKey = '';
- $ext->save();
- }
- 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'] ?? '';
- $ext->lbSn = $lbSn;
- $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();
- }
- }
|