ShopExtController.php 13 KB

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