ShopExtController.php 14 KB

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