ShopExtController.php 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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 20220710
  15. public function actionUpdateMtAlone()
  16. {
  17. $alone = Yii::$app->request->get('alone', 0);
  18. $shopId = $this->shopId;
  19. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  20. if (empty($ext)) {
  21. util::fail('没有找到门店');
  22. }
  23. $ext->mtAlone = $alone;
  24. $ext->save();
  25. util::complete();
  26. }
  27. //取出供应商的小菊颜色 ssh 20210907
  28. public function actionGetGhsXj()
  29. {
  30. $id = Yii::$app->request->get('ghsId', 0);
  31. $ghs = GhsClass::getById($id, true);
  32. GhsClass::valid($ghs, $this->shopId);
  33. $shopId = $ghs->shopId ?? 0;
  34. $list = XjClass::getAllByCondition(['shopId' => $shopId, 'delStatus' => 0, 'status' => 1], null, '*');
  35. if (!empty($list)) {
  36. foreach ($list as $key => $val) {
  37. $shortCover = $val['cover'] ?? '';
  38. $cover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  39. $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  40. $list[$key]['cover'] = $cover;
  41. $list[$key]['bigCover'] = $bigCover;
  42. $list[$key]['shortCover'] = $shortCover;
  43. }
  44. }
  45. util::success(['list' => $list]);
  46. }
  47. //添加打印机 ssh 20210712
  48. public function actionAddPrint()
  49. {
  50. $shopAdmin = $this->shopAdmin;
  51. $roleId = $shopAdmin['roleId'] ?? 0;
  52. $role = AdminRoleClass::getById($roleId);
  53. $roleName = $role['roleName'] ?? '';
  54. if ($roleName == '员工') {
  55. util::fail('没有权限操作哦');
  56. }
  57. $shopId = $this->shopId;
  58. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  59. $get = Yii::$app->request->get();
  60. $printSn = $get['printSn'] ?? '';
  61. $printKey = $get['printKey'] ?? '';
  62. $printLabelSn = $get['printLabelSn'] ?? '';
  63. $printLabelKey = $get['printLabelKey'] ?? '';
  64. $shop = $this->shop;
  65. $default = $shop->default ?? 0;
  66. $shopName = $shop->shopName ?? '';
  67. $sj = $this->sj;
  68. $sjName = $sj->name ?? '';
  69. $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
  70. if (!empty($printSn) && !empty($printKey)) {
  71. $print = new printUtil($printSn);
  72. $return = $print->addPrint($printKey, $name);
  73. if ($return) {
  74. $ext->printSn = $printSn;
  75. $ext->printKey = $printKey;
  76. $ext->save();
  77. }
  78. } else {
  79. $ext->printSn = '';
  80. $ext->printKey = '';
  81. $ext->save();
  82. }
  83. if (!empty($printLabelSn) && !empty($printLabelKey)) {
  84. $labelPrint = new printUtil($printLabelSn);
  85. $return = $labelPrint->addPrint($printLabelKey, $name);
  86. if ($return) {
  87. $ext->printLabelSn = $printLabelSn;
  88. $ext->printLabelKey = $printLabelKey;
  89. $ext->save();
  90. //将打印纸张设置为50X70
  91. $labelPrint->times = 1;
  92. $content = '<SIZE>50,70</SIZE>';
  93. $labelPrint->printLabelMsg($content);
  94. }
  95. } else {
  96. $ext->printLabelSn = '';
  97. $ext->printLabelKey = '';
  98. $ext->save();
  99. }
  100. util::complete();
  101. }
  102. //添加打印机 ssh 20210712
  103. public function actionAddMakePrint()
  104. {
  105. $shopAdmin = $this->shopAdmin;
  106. $roleId = $shopAdmin['roleId'] ?? 0;
  107. $role = AdminRoleClass::getById($roleId);
  108. $roleName = $role['roleName'] ?? '';
  109. if ($roleName == '员工') {
  110. util::fail('没有权限操作哦');
  111. }
  112. $shopId = $this->shopId;
  113. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  114. $get = Yii::$app->request->get();
  115. $printSn = $get['printSn'] ?? '';
  116. $printKey = $get['printKey'] ?? '';
  117. $printLabelSn = $get['printLabelSn'] ?? '';
  118. $printLabelKey = $get['printLabelKey'] ?? '';
  119. $shop = $this->shop;
  120. $default = $shop->default ?? 0;
  121. $shopName = $shop->shopName ?? '';
  122. $sj = $this->sj;
  123. $sjName = $sj->name ?? '';
  124. $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
  125. if (!empty($printSn) && !empty($printKey)) {
  126. $print = new printUtil($printSn);
  127. $return = $print->addPrint($printKey, $name);
  128. if ($return) {
  129. $ext->makePrintSn = $printSn;
  130. $ext->makePrintKey = $printKey;
  131. $ext->save();
  132. }
  133. } else {
  134. $ext->makePrintSn = '';
  135. $ext->makePrintKey = '';
  136. $ext->save();
  137. }
  138. if (!empty($printLabelSn) && !empty($printLabelKey)) {
  139. $labelPrint = new printUtil($printLabelSn);
  140. $return = $labelPrint->addPrint($printLabelKey, $name);
  141. if ($return) {
  142. $ext->makePrintLabelSn = $printLabelSn;
  143. $ext->makePrintLabelKey = $printLabelKey;
  144. $ext->save();
  145. //将打印纸张设置为50X70
  146. $labelPrint->times = 1;
  147. $content = '<SIZE>50,70</SIZE>';
  148. $labelPrint->printLabelMsg($content);
  149. }
  150. } else {
  151. $ext->makePrintLabelSn = '';
  152. $ext->makePrintLabelKey = '';
  153. $ext->save();
  154. }
  155. util::complete();
  156. }
  157. //添加美团制作单用的打印机 ssh 20210712
  158. public function actionAddMtPrint()
  159. {
  160. $shopAdmin = $this->shopAdmin;
  161. $roleId = $shopAdmin['roleId'] ?? 0;
  162. $role = AdminRoleClass::getById($roleId);
  163. $roleName = $role['roleName'] ?? '';
  164. if ($roleName == '员工') {
  165. util::fail('没有权限操作哦');
  166. }
  167. $shopId = $this->shopId;
  168. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  169. $get = Yii::$app->request->get();
  170. $printSn = $get['printSn'] ?? '';
  171. $printKey = $get['printKey'] ?? '';
  172. $printLabelSn = $get['printLabelSn'] ?? '';
  173. $printLabelKey = $get['printLabelKey'] ?? '';
  174. $shop = $this->shop;
  175. $default = $shop->default ?? 0;
  176. $shopName = $shop->shopName ?? '';
  177. $sj = $this->sj;
  178. $sjName = $sj->name ?? '';
  179. $name = $default == 1 ? $sjName : $sjName . ' ' . $shopName;
  180. if (!empty($printSn) && !empty($printKey)) {
  181. $print = new printUtil($printSn);
  182. $return = $print->addPrint($printKey, $name);
  183. if ($return) {
  184. $ext->mtPrintSn = $printSn;
  185. $ext->mtPrintKey = $printKey;
  186. $ext->save();
  187. }
  188. } else {
  189. $ext->makePrintSn = '';
  190. $ext->makePrintKey = '';
  191. $ext->save();
  192. }
  193. if (!empty($printLabelSn) && !empty($printLabelKey)) {
  194. $labelPrint = new printUtil($printLabelSn);
  195. $return = $labelPrint->addPrint($printLabelKey, $name);
  196. if ($return) {
  197. $ext->mtPrintLabelSn = $printLabelSn;
  198. $ext->mtPrintLabelKey = $printLabelKey;
  199. $ext->save();
  200. //将打印纸张设置为50X70
  201. $labelPrint->times = 1;
  202. $content = '<SIZE>50,70</SIZE>';
  203. $labelPrint->printLabelMsg($content);
  204. }
  205. } else {
  206. $ext->mtPrintLabelSn = '';
  207. $ext->mtPrintLabelKey = '';
  208. $ext->save();
  209. }
  210. util::complete();
  211. }
  212. //获取打印机信息
  213. public function actionGetPrint()
  214. {
  215. $shopId = $this->shopId;
  216. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  217. util::success($ext);
  218. }
  219. //获取云喇叭信息 ssh 20220105
  220. public function actionGetLb()
  221. {
  222. $shopId = $this->shopId;
  223. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  224. util::success($ext);
  225. }
  226. //添加喇叭 ssh 20220105
  227. public function actionAddLb()
  228. {
  229. $shopAdmin = $this->shopAdmin;
  230. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  231. util::fail('超管才能修改');
  232. }
  233. $shopId = $this->shopId;
  234. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  235. $get = Yii::$app->request->get();
  236. if (isset($get['lbSn'])) {
  237. $lbSn = $get['lbSn'] ?? '';
  238. $ext->lbSn = $lbSn;
  239. $ext->save();
  240. }
  241. if (isset($get['makeLbSn'])) {
  242. $makeLbSn = $get['makeLbSn'] ?? '';
  243. $ext->makeLbSn = $makeLbSn;
  244. $ext->save();
  245. }
  246. if (isset($get['mtLbSn'])) {
  247. $mtLbSn = $get['mtLbSn'] ?? '';
  248. $ext->mtLbSn = $mtLbSn;
  249. $ext->save();
  250. }
  251. util::complete('设置成功');
  252. }
  253. }