ShopExtController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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->printLabelSn = $printLabelSn;
  50. $ext->printLabelKey = $printLabelKey;
  51. $ext->save();
  52. //将打印纸张设置为50X70
  53. $labelPrint->times = 1;
  54. $content = '<SIZE>50,70</SIZE>';
  55. $labelPrint->printLabelMsg($content);
  56. }
  57. } else {
  58. $ext->printLabelSn = '';
  59. $ext->printLabelKey = '';
  60. $ext->save();
  61. }
  62. util::complete();
  63. }
  64. //获取打印机信息
  65. public function actionGetPrint()
  66. {
  67. $shopId = $this->shopId;
  68. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  69. util::success($ext);
  70. }
  71. //获取云喇叭信息 ssh 20220105
  72. public function actionGetLb()
  73. {
  74. $shopId = $this->shopId;
  75. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  76. util::success($ext);
  77. }
  78. //添加喇叭 ssh 20220105
  79. public function actionAddLb()
  80. {
  81. $shopAdmin = $this->shopAdmin;
  82. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  83. util::fail('超管才能修改');
  84. }
  85. $shopId = $this->shopId;
  86. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  87. $get = Yii::$app->request->get();
  88. $lbSn = $get['lbSn'] ?? '';
  89. $ext->lbSn = $lbSn;
  90. $ext->save();
  91. util::complete('设置成功');
  92. }
  93. //小菊启用和停用 ssh 20211210
  94. public function actionReplaceXj()
  95. {
  96. $act = Yii::$app->request->get('act', 'start');
  97. $id = Yii::$app->request->get('id', 0);
  98. $xj = XjClass::getById($id, true);
  99. if (empty($xj)) {
  100. util::fail('没有找到小菊');
  101. }
  102. $status = $act == 'start' ? 1 : 2;
  103. $xj->status = $status;
  104. $xj->save();
  105. util::complete();
  106. }
  107. }