ShopExtController.php 14 KB

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