ShopExtController.php 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\admin\classes\AdminRoleClass;
  4. use biz\product\classes\XjClass;
  5. use biz\shop\classes\ShopExtClass;
  6. use common\components\printUtil;
  7. use common\components\util;
  8. use Yii;
  9. class ShopExtController extends BaseController
  10. {
  11. public $guestAccess = [];
  12. //添加打印机 shish 20210712
  13. public function actionAddPrint()
  14. {
  15. $shopAdmin = $this->shopAdmin;
  16. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  17. util::fail('超管才能修改');
  18. }
  19. $shopId = $this->shopId;
  20. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  21. $get = Yii::$app->request->get();
  22. $printSn = $get['printSn'] ?? '';
  23. $printKey = $get['printKey'] ?? '';
  24. $print = new printUtil($printSn);
  25. $shop = $this->shop;
  26. $default = $shop->default ?? 0;
  27. $shopName = $shop->shopName ?? '';
  28. $sj = $this->sj;
  29. $sjName = $sj->name ?? '';
  30. $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
  31. if (!empty($printSn) && !empty($printKey)) {
  32. $return = $print->addPrint($printKey, $name);
  33. if ($return) {
  34. $ext->printSn = $printSn;
  35. $ext->printKey = $printKey;
  36. $ext->save();
  37. util::complete('添加成功');
  38. }
  39. }
  40. if (empty($printSn) && empty($printKey)) {
  41. $ext->printSn = '';
  42. $ext->printKey = '';
  43. $ext->save();
  44. util::complete('修改成功');
  45. }
  46. util::fail('添加失败');
  47. }
  48. //获取打印机信息
  49. public function actionGetPrint()
  50. {
  51. $shopId = $this->shopId;
  52. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  53. util::success($ext);
  54. }
  55. //获取云喇叭信息 shish 20220105
  56. public function actionGetLb()
  57. {
  58. $shopId = $this->shopId;
  59. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  60. util::success($ext);
  61. }
  62. //添加喇叭 shish 20220105
  63. public function actionAddLb()
  64. {
  65. $shopAdmin = $this->shopAdmin;
  66. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  67. util::fail('超管才能修改');
  68. }
  69. $shopId = $this->shopId;
  70. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  71. $get = Yii::$app->request->get();
  72. $lbSn = $get['lbSn'] ?? '';
  73. $ext->lbSn = $lbSn;
  74. $ext->save();
  75. util::complete('设置成功');
  76. }
  77. //小菊启用和停用 shish 20211210
  78. public function actionReplaceXj()
  79. {
  80. $act = Yii::$app->request->get('act', 'start');
  81. $id = Yii::$app->request->get('id', 0);
  82. $xj = XjClass::getById($id, true);
  83. if (empty($xj)) {
  84. util::fail('没有找到小菊');
  85. }
  86. $status = $act == 'start' ? 1 : 2;
  87. $xj->status = $status;
  88. $xj->save();
  89. util::complete();
  90. }
  91. }