| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245 |
- <?php
- namespace ghs\controllers;
- use biz\product\classes\XjClass;
- use biz\shop\classes\ShopExtClass;
- use bizGhs\order\classes\PurchaseOrderClass;
- use common\components\printUtil;
- use common\components\util;
- use Yii;
- class ShopExtController extends BaseController
- {
- public $guestAccess = [];
- //添加外采打印机 ssh 20230618
- public function actionAddWcPrint()
- {
- $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();
- $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 = '<SIZE>50,40</SIZE>';
- $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 = '<SIZE>60,100</SIZE>';
- $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();
- }
- }
|