| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394 |
- <?php
- namespace hd\controllers;
- use biz\ghs\classes\GhsClass;
- use biz\product\classes\XjClass;
- use biz\shop\classes\ShopExtClass;
- use bizHd\item\classes\ItemClass;
- use bizHd\product\classes\ProductClass;
- use common\components\imgUtil;
- use common\components\util;
- use biz\admin\classes\AdminRoleClass;
- use common\components\printUtil;
- use Yii;
- class ShopExtController extends BaseController
- {
- public $guestAccess = [];
- public function actionModifyExt()
- {
- $post = Yii::$app->request->post();
- $arr = [];
- if (isset($post['orderFlow'])) {
- $arr['orderFlow'] = $post['orderFlow'];
- }
- if (isset($post['thirdSend'])) {
- $arr['thirdSend'] = $post['thirdSend'];
- }
- if (isset($post['thirdSendFee'])) {
- $arr['thirdSendFee'] = $post['thirdSendFee'];
- }
- if (isset($post['needWork'])) {
- $arr['needWork'] = $post['needWork'];
- }
- if (empty($arr)) {
- util::fail('没有需要修改');
- }
- $shopId = $this->shopId;
- \bizHd\shop\classes\ShopExtClass::updateByCondition(['shopId' => $shopId], $arr);
- util::complete('修改成功');
- }
- public function actionMyInfo()
- {
- $shopId = $this->shopId;
- $ext = \bizHd\shop\classes\ShopExtClass::getByCondition(['shopId' => $shopId], true);
- $losingItemId = $ext->losingItem ?? 0;
- $losingItem = ProductClass::getById($losingItemId, true);
- $losingItemName = $losingItem->name ?? '';
- $zjGatheringItemId = $ext->zjGatheringItem ?? 0;
- $zjGatheringItem = ProductClass::getById($zjGatheringItemId, true);
- $zjGatheringItemName = $zjGatheringItem->name ?? '';
- $arr = $ext->attributes ?? [];
- $arr['losingItemName'] = $losingItemName;
- $arr['zjGatheringItemName'] = $zjGatheringItemName;
- $arr['main'] = $this->main;
- util::success($arr);
- }
- //设置处理花材、扫码收款和直接收款使用的花材 ssh 20250905
- public function actionSetItem()
- {
- $post = Yii::$app->request->post();
- $shopId = $this->shopId;
- $shop = $this->shop;
- $pfShopId = $shop->pfShopId ?? 0;
- $pfExt = null;
- //批发端需要同步修改
- if (!empty($pfShopId)) {
- $pfExt = \bizHd\shop\classes\ShopExtClass::getByCondition(['shopId' => $pfShopId], true);
- }
- $ext = \bizHd\shop\classes\ShopExtClass::getByCondition(['shopId' => $shopId], true);
- $losingItem = $post['losingItem'] ?? 0;
- if (!empty($losingItem)) {
- $info = ProductClass::getById($losingItem, true);
- if ($info->mainId != $this->mainId) {
- util::fail('不是你的花材呢,编号099323');
- }
- $ext->losingItem = $losingItem;
- $ext->save();
- if (!empty($pfExt)) {
- $pfExt->losingItem = $losingItem;
- $pfExt->save();
- }
- }
- $zjGatheringItem = $post['zjGatheringItem'] ?? 0;
- if (!empty($zjGatheringItem)) {
- $info = ProductClass::getById($losingItem, true);
- if ($info->mainId != $this->mainId) {
- util::fail('不是你的花材呢,编号099324');
- }
- $ext->zjGatheringItem = $zjGatheringItem;
- $ext->save();
- if (!empty($pfExt)) {
- $pfExt->zjGatheringItem = $zjGatheringItem;
- $pfExt->save();
- }
- }
- util::complete('修改成功');
- }
- //美团制作单属性状态更新 ssh 20220710
- public function actionUpdateMtAlone()
- {
- $alone = Yii::$app->request->get('alone', 0);
- $shopId = $this->shopId;
- $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
- if (empty($ext)) {
- util::fail('没有找到门店35');
- }
- $ext->mtAlone = $alone;
- $ext->save();
- util::complete();
- }
- //取出供货商的小菊颜色 ssh 20210907
- public function actionGetGhsXj()
- {
- $id = Yii::$app->request->get('ghsId', 0);
- $ptItemId = Yii::$app->request->get('ptItemId', 0);
- $ghs = GhsClass::getById($id, true);
- GhsClass::valid($ghs, $this->shopId);
- $ghsMainId = $ghs->mainId ?? 0;
- $itemInfo = ItemClass::getByCondition(['mainId' => $ghsMainId, 'itemId' => $ptItemId], true);
- if (empty($itemInfo)) {
- util::fail('没有花材');
- }
- $list = XjClass::getAllByCondition(['mainId' => $ghsMainId, 'ptItemId' => $ptItemId, 'delStatus' => 0, 'status' => 1], null, '*');
- if (!empty($list)) {
- foreach ($list as $key => $val) {
- $shortCover = $val['cover'] ?? '';
- $cover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
- $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
- $list[$key]['cover'] = $cover;
- $list[$key]['bigCover'] = $bigCover;
- $list[$key]['shortCover'] = $shortCover;
- }
- }
- util::success(['list' => $list, 'itemInfo' => $itemInfo]);
- }
- //添加打印机 ssh 20210712
- public function actionAddPrint()
- {
- $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 && $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 {
- $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();
- }
- //添加打印机 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 && $shopName == '首店' ? $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();
- }
- //添加美团制作单用的打印机 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 && $shopName == '首店' ? $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()
- {
- $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();
- if (isset($get['lbSn'])) {
- $lbSn = $get['lbSn'] ?? '';
- $lbVersion = $get['lbVersion'] ?? '';
- $ext->lbSn = $lbSn;
- $ext->lbVersion = $lbVersion;
- $ext->save();
- }
- if (isset($get['makeLbSn'])) {
- $makeLbSn = $get['makeLbSn'] ?? '';
- $makeLbVersion = $get['makeLbVersion'] ?? '';
- $ext->makeLbSn = $makeLbSn;
- $ext->makeLbVersion = $makeLbVersion;
- $ext->save();
- }
- if (isset($get['mtLbSn'])) {
- $mtLbSn = $get['mtLbSn'] ?? '';
- $mtLbVersion = $get['mtLbVersion'] ?? '';
- $ext->mtLbSn = $mtLbSn;
- $ext->mtLbVersion = $mtLbVersion;
- $ext->save();
- }
- util::complete('设置成功');
- }
- public function actionInfo()
- {
- $shopId = $this->shopId;
- $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
- util::success(['ext' => $ext]);
- }
- public function actionModifyGatherRepeat()
- {
- $staff = $this->shopAdmin;
- if ($staff->founder != 2) {
- util::fail('超超管才能修改');
- }
- $get = Yii::$app->request->get();
- $gatherRepeat = $get['gatherRepeat'] ?? 0;
- $shopId = $this->shopId;
- ShopExtClass::updateByCondition(['shopId' => $shopId], ['gatherRepeat' => $gatherRepeat]);
- util::complete('修改成功');
- }
- }
|