ShopExtController.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\product\classes\XjClass;
  4. use biz\shop\classes\ShopExtClass;
  5. use common\components\printUtil;
  6. use common\components\util;
  7. use Yii;
  8. class ShopExtController extends BaseController
  9. {
  10. public $guestAccess = [];
  11. //添加打印机 ssh 20210712
  12. public function actionAddPrint()
  13. {
  14. $shopAdmin = $this->shopAdmin;
  15. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  16. util::fail('超管才能修改');
  17. }
  18. $shopId = $this->shopId;
  19. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  20. $get = Yii::$app->request->get();
  21. $printSn = $get['printSn'] ?? '';
  22. $printKey = $get['printKey'] ?? '';
  23. $printLabelSn = $get['printLabelSn'] ?? '';
  24. $printLabelKey = $get['printLabelKey'] ?? '';
  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 && $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
  31. if (!empty($printSn) && !empty($printKey)) {
  32. $print = new printUtil($printSn);
  33. $return = $print->addPrint($printKey, $name);
  34. if ($return) {
  35. $ext->printSn = $printSn;
  36. $ext->printKey = $printKey;
  37. $ext->save();
  38. }
  39. } else {
  40. $ext->printSn = '';
  41. $ext->printKey = '';
  42. $ext->save();
  43. }
  44. if (!empty($printLabelSn) && !empty($printLabelKey)) {
  45. $labelPrint = new printUtil($printLabelSn);
  46. $return = $labelPrint->addPrint($printLabelKey, $name);
  47. if ($return) {
  48. $ext->printLabelSn = $printLabelSn;
  49. $ext->printLabelKey = $printLabelKey;
  50. $ext->save();
  51. //将打印纸张设置为50X70
  52. $labelPrint->times = 1;
  53. $content = '<SIZE>50,70</SIZE>';
  54. $labelPrint->printLabelMsg($content);
  55. }
  56. } else {
  57. $ext->printLabelSn = '';
  58. $ext->printLabelKey = '';
  59. $ext->save();
  60. }
  61. util::complete();
  62. }
  63. //获取打印机信息
  64. public function actionGetPrint()
  65. {
  66. $shopId = $this->shopId;
  67. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  68. util::success($ext);
  69. }
  70. //获取云喇叭信息 ssh 20220105
  71. public function actionGetLb()
  72. {
  73. $shopId = $this->shopId;
  74. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  75. util::success($ext);
  76. }
  77. //添加喇叭 ssh 20220105
  78. public function actionAddLb()
  79. {
  80. $shopAdmin = $this->shopAdmin;
  81. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  82. util::fail('超管才能修改');
  83. }
  84. $shopId = $this->shopId;
  85. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  86. $get = Yii::$app->request->get();
  87. $lbSn = $get['lbSn'] ?? '';
  88. $lbVersion = $get['lbVersion'] ?? '';
  89. $ext->lbSn = $lbSn;
  90. $ext->lbVersion = $lbVersion;
  91. $ext->save();
  92. util::complete('设置成功');
  93. }
  94. //小菊启用和停用 ssh 20211210
  95. public function actionReplaceXj()
  96. {
  97. $act = Yii::$app->request->get('act', 'start');
  98. $id = Yii::$app->request->get('id', 0);
  99. $xj = XjClass::getById($id, true);
  100. if (empty($xj)) {
  101. util::fail('没有找到小菊');
  102. }
  103. $status = $act == 'start' ? 1 : 2;
  104. $xj->status = $status;
  105. $xj->save();
  106. util::complete();
  107. }
  108. }