ShopExtController.php 9.8 KB

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