| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398 |
- <?php
- namespace ghs\controllers;
- use biz\product\classes\XjClass;
- use biz\shop\classes\ShopExtClass;
- use bizGhs\product\classes\ProductClass;
- use common\components\printUtil;
- use common\components\util;
- use Yii;
- class ShopExtController extends BaseController
- {
- public $guestAccess = [];
- //修改拓展信息表 ssh 20251005
- public function actionModifyExt()
- {
- $post = Yii::$app->request->post();
- $hdArr = [];
- $ghsArr = [];
- if (isset($post['orderFlow'])) {
- $hdArr['orderFlow'] = $post['orderFlow'];
- $ghsArr['orderFlow'] = $post['orderFlow'];
- }
- if (isset($post['thirdSend'])) {
- $hdArr['thirdSend'] = $post['thirdSend'];
- $ghsArr['thirdSend'] = $post['thirdSend'];
- }
- if (isset($post['thirdSendFee'])) {
- $hdArr['thirdSendFee'] = $post['thirdSendFee'];
- $ghsArr['thirdSendFee'] = $post['thirdSendFee'];
- }
- // 组建零售数据
- if (!empty($post['hcMap']) && $post['hcMap'] != '[]') {
- $str = $post['hcMap'];
- $map = json_decode($str, true);
- if (!empty($map)) {
- foreach ($map as $v) {
- foreach ($v as $v1) {
- if(!is_numeric($v1)){
- util::fail('请填写完整');
- }
- }
- }
- $hdArr['hcMap'] = json_encode($map);
- }
- }else{
- $hdArr['hcMap'] = '';
- }
- if(isset($post['hsFreeKm'])){
- $hdArr['hsFreeKm'] = intval($post['hsFreeKm']);
- }
- if(isset($post['hsAddFee'])){
- $hdArr['hsAddFee'] = $post['hsAddFee'];
- }
- if(isset($post['hcFreeKm'])){
- $hdArr['hcFreeKm'] = intval($post['hcFreeKm']);
- }
- // 组建批发数据
- if (!empty($post['pfHcMap']) && $post['pfHcMap'] != '[]') {
- $str = $post['pfHcMap'];
- $map = json_decode($str, true);
- if (!empty($map)) {
- foreach ($map as $v) {
- foreach ($v as $v1) {
- if(!is_numeric($v1)){
- util::fail('请填写完整');
- }
- }
- }
- $ghsArr['hcMap'] = json_encode($map);
- }
- }else{
- $ghsArr['hcMap'] = '';
- }
- if(isset($post['pfHcFreeKm'])){
- $ghsArr['hcFreeKm'] = intval($post['pfHcFreeKm']);
- }
- if(!empty($ghsArr)){
- //批发端更新
- $shopId = $this->shopId;
- ShopExtClass::updateByCondition(['shopId' => $shopId], $ghsArr);
- }
- if(!empty($hdArr)){
- //零售端更新
- $shop = $this->shop;
- $lsShopId = $shop->lsShopId;
- ShopExtClass::updateByCondition(['shopId' => $lsShopId], $hdArr);
- }
- util::complete('修改成功');
- }
- //设置处理花材、扫码收款和直接收款使用的花材 ssh 20250905
- public function actionSetItem()
- {
- $post = Yii::$app->request->post();
- $shopId = $this->shopId;
- $shop = $this->shop;
- $lsShopId = $shop->lsShopId ?? 0;
- $lsExt = null;
- //零售端需要同步修改
- if (!empty($lsShopId)) {
- $lsExt = \bizHd\shop\classes\ShopExtClass::getByCondition(['shopId' => $lsShopId], 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($lsExt)) {
- $lsExt->losingItem = $losingItem;
- $lsExt->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($lsExt)) {
- $lsExt->zjGatheringItem = $zjGatheringItem;
- $lsExt->save();
- }
- }
- util::complete('修改成功');
- }
- public function actionInfo()
- {
- $ext = $this->shopExt;
- $losingItemId = $ext->losingItem ?? 0;
- $losingItem = ProductClass::getById($losingItemId, true);
- $losingItemName = $losingItem->name ?? '';
- $zjGatheringItemId = $ext->zjGatheringItem ?? 0;
- $zjGatheringItem = ProductClass::getById($zjGatheringItemId, true);
- $zjGatheringItemName = $zjGatheringItem->name ?? '';
- //零售 shopExt
- $shop = $this->shop;
- $lsShopId = $shop->lsShopId;
- $shopObj = ShopExtClass::getByCondition(['shopId' => $lsShopId], true, 'id,hcMap,hcFreeKm,hsFreeKm,hsAddFee');
- $arr = $shopObj->attributes;
- //批发 shopExt
- $arr['pfHcMap'] = $ext['hcMap'];
- $arr['pfHcFreeKm'] = $ext['hcFreeKm'];
- $arr['losingItemName'] = $losingItemName;
- $arr['zjGatheringItemName'] = $zjGatheringItemName;
- $arr['main'] = $this->main;
- util::success($arr);
- }
- //添加外采打印机 ssh 20230618
- public function actionAddWcPrint()
- {
- $shopAdmin = $this->shopAdmin;
- if (!isset($shopAdmin->super) || $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();
- }
- }
|