ShopExtController.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. <?php
  2. namespace hd\controllers;
  3. use biz\ghs\classes\GhsClass;
  4. use biz\product\classes\XjClass;
  5. use biz\shop\classes\ShopExtClass;
  6. use common\components\imgUtil;
  7. use common\components\util;
  8. use biz\admin\classes\AdminRoleClass;
  9. use common\components\printUtil;
  10. use Yii;
  11. class ShopExtController extends BaseController
  12. {
  13. public $guestAccess = [];
  14. //取出供应商的小菊颜色 ssh 20210907
  15. public function actionGetGhsXj()
  16. {
  17. $id = Yii::$app->request->get('ghsId', 0);
  18. $ghs = GhsClass::getById($id, true);
  19. GhsClass::valid($ghs, $this->shopId);
  20. $shopId = $ghs->shopId ?? 0;
  21. $list = XjClass::getAllByCondition(['shopId' => $shopId, 'delStatus' => 0, 'status' => 1], null, '*');
  22. if (!empty($list)) {
  23. foreach ($list as $key => $val) {
  24. $shortCover = $val['cover'] ?? '';
  25. $cover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  26. $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  27. $list[$key]['cover'] = $cover;
  28. $list[$key]['bigCover'] = $bigCover;
  29. $list[$key]['shortCover'] = $shortCover;
  30. }
  31. }
  32. util::success(['list' => $list]);
  33. }
  34. //添加打印机 ssh 20210712
  35. public function actionAddPrint()
  36. {
  37. $shopAdmin = $this->shopAdmin;
  38. $roleId = $shopAdmin['roleId'] ?? 0;
  39. $role = AdminRoleClass::getById($roleId);
  40. $roleName = $role['roleName'] ?? '';
  41. if ($roleName == '员工') {
  42. util::fail('没有权限操作哦');
  43. }
  44. $shopId = $this->shopId;
  45. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  46. $get = Yii::$app->request->get();
  47. $printSn = $get['printSn'] ?? '';
  48. $printKey = $get['printKey'] ?? '';
  49. $printLabelSn = $get['printLabelSn'] ?? '';
  50. $printLabelKey = $get['printLabelKey'] ?? '';
  51. $shop = $this->shop;
  52. $default = $shop->default ?? 0;
  53. $shopName = $shop->shopName ?? '';
  54. $sj = $this->sj;
  55. $sjName = $sj->name ?? '';
  56. $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
  57. if (!empty($printSn) && !empty($printKey)) {
  58. $print = new printUtil($printSn);
  59. $return = $print->addPrint($printKey, $name);
  60. if ($return) {
  61. $ext->printSn = $printSn;
  62. $ext->printKey = $printKey;
  63. $ext->save();
  64. }
  65. } else {
  66. $ext->printSn = '';
  67. $ext->printKey = '';
  68. $ext->save();
  69. }
  70. if (!empty($printLabelSn) && !empty($printLabelKey)) {
  71. $labelPrint = new printUtil($printLabelSn);
  72. $return = $labelPrint->addPrint($printLabelKey, $name);
  73. if ($return) {
  74. $ext->printLabelSn = $printLabelSn;
  75. $ext->printLabelKey = $printLabelKey;
  76. $ext->save();
  77. //将打印纸张设置为50X70
  78. $labelPrint->times = 1;
  79. $content = '<SIZE>50,70</SIZE>';
  80. $labelPrint->printLabelMsg($content);
  81. }
  82. } else {
  83. $ext->printLabelSn = '';
  84. $ext->printLabelKey = '';
  85. $ext->save();
  86. }
  87. util::complete();
  88. }
  89. //添加打印机 ssh 20210712
  90. public function actionAddMakePrint()
  91. {
  92. $shopAdmin = $this->shopAdmin;
  93. $roleId = $shopAdmin['roleId'] ?? 0;
  94. $role = AdminRoleClass::getById($roleId);
  95. $roleName = $role['roleName'] ?? '';
  96. if ($roleName == '员工') {
  97. util::fail('没有权限操作哦');
  98. }
  99. $shopId = $this->shopId;
  100. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  101. $get = Yii::$app->request->get();
  102. $printSn = $get['printSn'] ?? '';
  103. $printKey = $get['printKey'] ?? '';
  104. $printLabelSn = $get['printLabelSn'] ?? '';
  105. $printLabelKey = $get['printLabelKey'] ?? '';
  106. $shop = $this->shop;
  107. $default = $shop->default ?? 0;
  108. $shopName = $shop->shopName ?? '';
  109. $sj = $this->sj;
  110. $sjName = $sj->name ?? '';
  111. $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
  112. if (!empty($printSn) && !empty($printKey)) {
  113. $print = new printUtil($printSn);
  114. $return = $print->addPrint($printKey, $name);
  115. if ($return) {
  116. $ext->makePrintSn = $printSn;
  117. $ext->makePrintKey = $printKey;
  118. $ext->save();
  119. }
  120. } else {
  121. $ext->makePrintSn = '';
  122. $ext->makePrintKey = '';
  123. $ext->save();
  124. }
  125. if (!empty($printLabelSn) && !empty($printLabelKey)) {
  126. $labelPrint = new printUtil($printLabelSn);
  127. $return = $labelPrint->addPrint($printLabelKey, $name);
  128. if ($return) {
  129. $ext->makePrintLabelSn = $printLabelSn;
  130. $ext->makePrintLabelKey = $printLabelKey;
  131. $ext->save();
  132. //将打印纸张设置为50X70
  133. $labelPrint->times = 1;
  134. $content = '<SIZE>50,70</SIZE>';
  135. $labelPrint->printLabelMsg($content);
  136. }
  137. } else {
  138. $ext->makePrintLabelSn = '';
  139. $ext->makePrintLabelKey = '';
  140. $ext->save();
  141. }
  142. util::complete();
  143. }
  144. //获取打印机信息
  145. public function actionGetPrint()
  146. {
  147. $shopId = $this->shopId;
  148. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  149. util::success($ext);
  150. }
  151. //获取云喇叭信息 ssh 20220105
  152. public function actionGetLb()
  153. {
  154. $shopId = $this->shopId;
  155. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  156. util::success($ext);
  157. }
  158. //添加喇叭 ssh 20220105
  159. public function actionAddLb()
  160. {
  161. $shopAdmin = $this->shopAdmin;
  162. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  163. util::fail('超管才能修改');
  164. }
  165. $shopId = $this->shopId;
  166. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  167. $get = Yii::$app->request->get();
  168. $lbSn = $get['lbSn'] ?? '';
  169. $ext->lbSn = $lbSn;
  170. $ext->save();
  171. util::complete('设置成功');
  172. }
  173. }