ShopExtController.php 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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 bizHd\product\classes\ProductClass;
  8. use common\components\imgUtil;
  9. use common\components\util;
  10. use biz\admin\classes\AdminRoleClass;
  11. use common\components\printUtil;
  12. use Yii;
  13. class ShopExtController extends BaseController
  14. {
  15. public $guestAccess = [];
  16. //设置处理花材、扫码收款和直接收款使用的花材 ssh 20250905
  17. public function actionSetItem()
  18. {
  19. $post = Yii::$app->request->post();
  20. $shopId = $this->shopId;
  21. $shop = $this->shop;
  22. $pfShopId = $shop->pfShopId ?? 0;
  23. $pfExt = null;
  24. //批发端需要同步修改
  25. if (!empty($pfShopId)) {
  26. $pfExt = \bizHd\shop\classes\ShopExtClass::getByCondition(['shopId' => $pfShopId], true);
  27. }
  28. $ext = \bizHd\shop\classes\ShopExtClass::getByCondition(['shopId' => $shopId], true);
  29. $losingItem = $post['losingItem'] ?? 0;
  30. if (!empty($losingItem)) {
  31. if (empty($ext->losingItem)) {
  32. $info = ProductClass::getById($losingItem, true);
  33. if ($info->mainId != $this->mainId) {
  34. util::fail('不是你的花材呢,编号099323');
  35. }
  36. $ext->losingItem = $losingItem;
  37. $ext->save();
  38. if (!empty($pfExt)) {
  39. $pfExt->losingItem = $losingItem;
  40. $pfExt->save();
  41. }
  42. }
  43. }
  44. $gatheringItem = $post['gatheringItem'] ?? 0;
  45. if (!empty($gatheringItem)) {
  46. if (empty($ext->gatheringItem)) {
  47. $info = ProductClass::getById($losingItem, true);
  48. if ($info->mainId != $this->mainId) {
  49. util::fail('不是你的花材呢,编号099324');
  50. }
  51. $ext->gatheringItem = $gatheringItem;
  52. $ext->save();
  53. if (!empty($pfExt)) {
  54. $pfExt->gatheringItem = $gatheringItem;
  55. $pfExt->save();
  56. }
  57. }
  58. }
  59. $zjGatheringItem = $post['zjGatheringItem'] ?? 0;
  60. if (!empty($zjGatheringItem)) {
  61. if (empty($ext->zjGatheringItem)) {
  62. $info = ProductClass::getById($losingItem, true);
  63. if ($info->mainId != $this->mainId) {
  64. util::fail('不是你的花材呢,编号099324');
  65. }
  66. $ext->zjGatheringItem = $zjGatheringItem;
  67. $ext->save();
  68. if (!empty($pfExt)) {
  69. $pfExt->zjGatheringItem = $zjGatheringItem;
  70. $pfExt->save();
  71. }
  72. }
  73. }
  74. util::complete('修改成功');
  75. }
  76. //美团制作单属性状态更新 ssh 20220710
  77. public function actionUpdateMtAlone()
  78. {
  79. $alone = Yii::$app->request->get('alone', 0);
  80. $shopId = $this->shopId;
  81. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  82. if (empty($ext)) {
  83. util::fail('没有找到门店35');
  84. }
  85. $ext->mtAlone = $alone;
  86. $ext->save();
  87. util::complete();
  88. }
  89. //取出供货商的小菊颜色 ssh 20210907
  90. public function actionGetGhsXj()
  91. {
  92. $id = Yii::$app->request->get('ghsId', 0);
  93. $ptItemId = Yii::$app->request->get('ptItemId', 0);
  94. $ghs = GhsClass::getById($id, true);
  95. GhsClass::valid($ghs, $this->shopId);
  96. $ghsMainId = $ghs->mainId ?? 0;
  97. $itemInfo = ItemClass::getByCondition(['mainId' => $ghsMainId, 'itemId' => $ptItemId], true);
  98. if (empty($itemInfo)) {
  99. util::fail('没有花材');
  100. }
  101. $list = XjClass::getAllByCondition(['mainId' => $ghsMainId, 'ptItemId' => $ptItemId, 'delStatus' => 0, 'status' => 1], null, '*');
  102. if (!empty($list)) {
  103. foreach ($list as $key => $val) {
  104. $shortCover = $val['cover'] ?? '';
  105. $cover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  106. $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  107. $list[$key]['cover'] = $cover;
  108. $list[$key]['bigCover'] = $bigCover;
  109. $list[$key]['shortCover'] = $shortCover;
  110. }
  111. }
  112. util::success(['list' => $list, 'itemInfo' => $itemInfo]);
  113. }
  114. //添加打印机 ssh 20210712
  115. public function actionAddPrint()
  116. {
  117. $shopAdmin = $this->shopAdmin;
  118. $roleId = $shopAdmin['roleId'] ?? 0;
  119. $role = AdminRoleClass::getById($roleId);
  120. $roleName = $role['roleName'] ?? '';
  121. if ($roleName == '员工') {
  122. util::fail('无法操作哦');
  123. }
  124. $shopId = $this->shopId;
  125. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  126. $get = Yii::$app->request->get();
  127. $printSn = $get['printSn'] ?? '';
  128. $printKey = $get['printKey'] ?? '';
  129. $printLabelSn = $get['printLabelSn'] ?? '';
  130. $printLabelKey = $get['printLabelKey'] ?? '';
  131. $shop = $this->shop;
  132. $default = $shop->default ?? 0;
  133. $shopName = $shop->shopName ?? '';
  134. $sj = $this->sj;
  135. $sjName = $sj->name ?? '';
  136. $name = $default == 1 && $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
  137. if (!empty($printSn) && !empty($printKey)) {
  138. $print = new printUtil($printSn);
  139. $return = $print->addPrint($printKey, $name);
  140. if ($return) {
  141. $ext->printSn = $printSn;
  142. $ext->printKey = $printKey;
  143. $ext->save();
  144. }
  145. } else {
  146. $ext->printSn = '';
  147. $ext->printKey = '';
  148. $ext->save();
  149. }
  150. if (!empty($printLabelSn) && !empty($printLabelKey)) {
  151. $labelPrint = new printUtil($printLabelSn);
  152. $return = $labelPrint->addPrint($printLabelKey, $name);
  153. if ($return) {
  154. $ext->printLabelSn = $printLabelSn;
  155. $ext->printLabelKey = $printLabelKey;
  156. $ext->save();
  157. //将打印纸张设置为50X70
  158. $labelPrint->times = 1;
  159. $content = '<SIZE>50,70</SIZE>';
  160. $labelPrint->printLabelMsg($content);
  161. }
  162. } else {
  163. $ext->printLabelSn = '';
  164. $ext->printLabelKey = '';
  165. $ext->save();
  166. }
  167. util::complete();
  168. }
  169. //添加打印机 ssh 20210712
  170. public function actionAddMakePrint()
  171. {
  172. $shopAdmin = $this->shopAdmin;
  173. $roleId = $shopAdmin['roleId'] ?? 0;
  174. $role = AdminRoleClass::getById($roleId);
  175. $roleName = $role['roleName'] ?? '';
  176. if ($roleName == '员工') {
  177. util::fail('无法操作哦');
  178. }
  179. $shopId = $this->shopId;
  180. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  181. $get = Yii::$app->request->get();
  182. $printSn = $get['printSn'] ?? '';
  183. $printKey = $get['printKey'] ?? '';
  184. $printLabelSn = $get['printLabelSn'] ?? '';
  185. $printLabelKey = $get['printLabelKey'] ?? '';
  186. $shop = $this->shop;
  187. $default = $shop->default ?? 0;
  188. $shopName = $shop->shopName ?? '';
  189. $sj = $this->sj;
  190. $sjName = $sj->name ?? '';
  191. $name = $default == 1 && $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
  192. if (!empty($printSn) && !empty($printKey)) {
  193. $print = new printUtil($printSn);
  194. $return = $print->addPrint($printKey, $name);
  195. if ($return) {
  196. $ext->makePrintSn = $printSn;
  197. $ext->makePrintKey = $printKey;
  198. $ext->save();
  199. }
  200. } else {
  201. $ext->makePrintSn = '';
  202. $ext->makePrintKey = '';
  203. $ext->save();
  204. }
  205. if (!empty($printLabelSn) && !empty($printLabelKey)) {
  206. $labelPrint = new printUtil($printLabelSn);
  207. $return = $labelPrint->addPrint($printLabelKey, $name);
  208. if ($return) {
  209. $ext->makePrintLabelSn = $printLabelSn;
  210. $ext->makePrintLabelKey = $printLabelKey;
  211. $ext->save();
  212. //将打印纸张设置为50X70
  213. $labelPrint->times = 1;
  214. $content = '<SIZE>50,70</SIZE>';
  215. $labelPrint->printLabelMsg($content);
  216. }
  217. } else {
  218. $ext->makePrintLabelSn = '';
  219. $ext->makePrintLabelKey = '';
  220. $ext->save();
  221. }
  222. util::complete();
  223. }
  224. //添加美团制作单用的打印机 ssh 20210712
  225. public function actionAddMtPrint()
  226. {
  227. $shopAdmin = $this->shopAdmin;
  228. $roleId = $shopAdmin['roleId'] ?? 0;
  229. $role = AdminRoleClass::getById($roleId);
  230. $roleName = $role['roleName'] ?? '';
  231. if ($roleName == '员工') {
  232. util::fail('无法操作哦');
  233. }
  234. $shopId = $this->shopId;
  235. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  236. $get = Yii::$app->request->get();
  237. $printSn = $get['printSn'] ?? '';
  238. $printKey = $get['printKey'] ?? '';
  239. $printLabelSn = $get['printLabelSn'] ?? '';
  240. $printLabelKey = $get['printLabelKey'] ?? '';
  241. $shop = $this->shop;
  242. $default = $shop->default ?? 0;
  243. $shopName = $shop->shopName ?? '';
  244. $sj = $this->sj;
  245. $sjName = $sj->name ?? '';
  246. $name = $default == 1 && $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
  247. if (!empty($printSn) && !empty($printKey)) {
  248. $print = new printUtil($printSn);
  249. $return = $print->addPrint($printKey, $name);
  250. if ($return) {
  251. $ext->mtPrintSn = $printSn;
  252. $ext->mtPrintKey = $printKey;
  253. $ext->save();
  254. }
  255. } else {
  256. $ext->makePrintSn = '';
  257. $ext->makePrintKey = '';
  258. $ext->save();
  259. }
  260. if (!empty($printLabelSn) && !empty($printLabelKey)) {
  261. $labelPrint = new printUtil($printLabelSn);
  262. $return = $labelPrint->addPrint($printLabelKey, $name);
  263. if ($return) {
  264. $ext->mtPrintLabelSn = $printLabelSn;
  265. $ext->mtPrintLabelKey = $printLabelKey;
  266. $ext->save();
  267. //将打印纸张设置为50X70
  268. $labelPrint->times = 1;
  269. $content = '<SIZE>50,70</SIZE>';
  270. $labelPrint->printLabelMsg($content);
  271. }
  272. } else {
  273. $ext->mtPrintLabelSn = '';
  274. $ext->mtPrintLabelKey = '';
  275. $ext->save();
  276. }
  277. util::complete();
  278. }
  279. //获取打印机信息
  280. public function actionGetPrint()
  281. {
  282. $shopId = $this->shopId;
  283. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  284. util::success($ext);
  285. }
  286. //获取云喇叭信息 ssh 20220105
  287. public function actionGetLb()
  288. {
  289. $shopId = $this->shopId;
  290. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  291. util::success($ext);
  292. }
  293. //添加喇叭 ssh 20220105
  294. public function actionAddLb()
  295. {
  296. $shopAdmin = $this->shopAdmin;
  297. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  298. util::fail('超管才能修改');
  299. }
  300. $shopId = $this->shopId;
  301. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  302. $get = Yii::$app->request->get();
  303. if (isset($get['lbSn'])) {
  304. $lbSn = $get['lbSn'] ?? '';
  305. $lbVersion = $get['lbVersion'] ?? '';
  306. $ext->lbSn = $lbSn;
  307. $ext->lbVersion = $lbVersion;
  308. $ext->save();
  309. }
  310. if (isset($get['makeLbSn'])) {
  311. $makeLbSn = $get['makeLbSn'] ?? '';
  312. $makeLbVersion = $get['makeLbVersion'] ?? '';
  313. $ext->makeLbSn = $makeLbSn;
  314. $ext->makeLbVersion = $makeLbVersion;
  315. $ext->save();
  316. }
  317. if (isset($get['mtLbSn'])) {
  318. $mtLbSn = $get['mtLbSn'] ?? '';
  319. $mtLbVersion = $get['mtLbVersion'] ?? '';
  320. $ext->mtLbSn = $mtLbSn;
  321. $ext->mtLbVersion = $mtLbVersion;
  322. $ext->save();
  323. }
  324. util::complete('设置成功');
  325. }
  326. public function actionInfo()
  327. {
  328. $shopId = $this->shopId;
  329. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  330. util::success(['ext' => $ext]);
  331. }
  332. public function actionModifyGatherRepeat()
  333. {
  334. $staff = $this->shopAdmin;
  335. if ($staff->founder != 2) {
  336. util::fail('超超管才能修改');
  337. }
  338. $get = Yii::$app->request->get();
  339. $gatherRepeat = $get['gatherRepeat'] ?? 0;
  340. $shopId = $this->shopId;
  341. ShopExtClass::updateByCondition(['shopId' => $shopId], ['gatherRepeat' => $gatherRepeat]);
  342. util::complete('修改成功');
  343. }
  344. }