ShopExtController.php 14 KB

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