ShopExtController.php 14 KB

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