ShopExtController.php 3.9 KB

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