ShopExtController.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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. //添加打印机 ssh 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. $printLabelSn = $get['printLabelSn'] ?? '';
  25. $printLabelKey = $get['printLabelKey'] ?? '';
  26. $shop = $this->shop;
  27. $default = $shop->default ?? 0;
  28. $shopName = $shop->shopName ?? '';
  29. $sj = $this->sj;
  30. $sjName = $sj->name ?? '';
  31. $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
  32. if (!empty($printSn) && !empty($printKey)) {
  33. $print = new printUtil($printSn);
  34. $return = $print->addPrint($printKey, $name);
  35. if ($return) {
  36. $ext->printSn = $printSn;
  37. $ext->printKey = $printKey;
  38. $ext->save();
  39. }
  40. } else {
  41. $ext->printSn = '';
  42. $ext->printKey = '';
  43. $ext->save();
  44. }
  45. if (!empty($printLabelSn) && !empty($printLabelKey)) {
  46. $labelPrint = new printUtil($printLabelSn);
  47. $return = $labelPrint->addPrint($printLabelKey, $name);
  48. if ($return) {
  49. $ext->printSn = $printLabelSn;
  50. $ext->printKey = $printLabelKey;
  51. $ext->save();
  52. }
  53. } else {
  54. $ext->printLabelSn = '';
  55. $ext->printLabelKey = '';
  56. $ext->save();
  57. }
  58. util::complete();
  59. }
  60. //获取打印机信息
  61. public function actionGetPrint()
  62. {
  63. $shopId = $this->shopId;
  64. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  65. util::success($ext);
  66. }
  67. //获取云喇叭信息 ssh 20220105
  68. public function actionGetLb()
  69. {
  70. $shopId = $this->shopId;
  71. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  72. util::success($ext);
  73. }
  74. //添加喇叭 ssh 20220105
  75. public function actionAddLb()
  76. {
  77. $shopAdmin = $this->shopAdmin;
  78. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  79. util::fail('超管才能修改');
  80. }
  81. $shopId = $this->shopId;
  82. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  83. $get = Yii::$app->request->get();
  84. $lbSn = $get['lbSn'] ?? '';
  85. $ext->lbSn = $lbSn;
  86. $ext->save();
  87. util::complete('设置成功');
  88. }
  89. //小菊启用和停用 ssh 20211210
  90. public function actionReplaceXj()
  91. {
  92. $act = Yii::$app->request->get('act', 'start');
  93. $id = Yii::$app->request->get('id', 0);
  94. $xj = XjClass::getById($id, true);
  95. if (empty($xj)) {
  96. util::fail('没有找到小菊');
  97. }
  98. $status = $act == 'start' ? 1 : 2;
  99. $xj->status = $status;
  100. $xj->save();
  101. util::complete();
  102. }
  103. }