ShopExtController.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\product\classes\XjClass;
  4. use biz\shop\classes\ShopExtClass;
  5. use bizGhs\order\classes\PurchaseOrderClass;
  6. use bizGhs\product\classes\ProductClass;
  7. use common\components\printUtil;
  8. use common\components\util;
  9. use Yii;
  10. class ShopExtController extends BaseController
  11. {
  12. public $guestAccess = [];
  13. //修改拓展信息表 ssh 20251005
  14. public function actionModifyExt()
  15. {
  16. $post = Yii::$app->request->post();
  17. $arr = [];
  18. if (isset($post['orderFlow'])) {
  19. $arr['orderFlow'] = $post['orderFlow'];
  20. }
  21. if (isset($post['thirdSend'])) {
  22. $arr['thirdSend'] = $post['thirdSend'];
  23. }
  24. if (isset($post['thirdSendFee'])) {
  25. $arr['thirdSendFee'] = $post['thirdSendFee'];
  26. }
  27. if (empty($arr)) {
  28. util::fail('没有需要修改');
  29. }
  30. $shopId = $this->shopId;
  31. \bizHd\shop\classes\ShopExtClass::updateByCondition(['shopId' => $shopId], $arr);
  32. util::complete('修改成功');
  33. }
  34. //设置处理花材、扫码收款和直接收款使用的花材 ssh 20250905
  35. public function actionSetItem()
  36. {
  37. $post = Yii::$app->request->post();
  38. $shopId = $this->shopId;
  39. $shop = $this->shop;
  40. $lsShopId = $shop->lsShopId ?? 0;
  41. $lsExt = null;
  42. //零售端需要同步修改
  43. if (!empty($lsShopId)) {
  44. $lsExt = \bizHd\shop\classes\ShopExtClass::getByCondition(['shopId' => $lsShopId], true);
  45. }
  46. $ext = \bizHd\shop\classes\ShopExtClass::getByCondition(['shopId' => $shopId], true);
  47. $losingItem = $post['losingItem'] ?? 0;
  48. if (!empty($losingItem)) {
  49. $info = ProductClass::getById($losingItem, true);
  50. if ($info->mainId != $this->mainId) {
  51. util::fail('不是你的花材呢,编号099323');
  52. }
  53. $ext->losingItem = $losingItem;
  54. $ext->save();
  55. if (!empty($lsExt)) {
  56. $lsExt->losingItem = $losingItem;
  57. $lsExt->save();
  58. }
  59. }
  60. $zjGatheringItem = $post['zjGatheringItem'] ?? 0;
  61. if (!empty($zjGatheringItem)) {
  62. $info = ProductClass::getById($losingItem, true);
  63. if ($info->mainId != $this->mainId) {
  64. util::fail('不是你的花材呢,编号099324');
  65. }
  66. $ext->zjGatheringItem = $zjGatheringItem;
  67. $ext->save();
  68. if (!empty($lsExt)) {
  69. $lsExt->zjGatheringItem = $zjGatheringItem;
  70. $lsExt->save();
  71. }
  72. }
  73. util::complete('修改成功');
  74. }
  75. public function actionInfo()
  76. {
  77. $ext = $this->shopExt;
  78. $losingItemId = $ext->losingItem ?? 0;
  79. $losingItem = ProductClass::getById($losingItemId, true);
  80. $losingItemName = $losingItem->name ?? '';
  81. $zjGatheringItemId = $ext->zjGatheringItem ?? 0;
  82. $zjGatheringItem = ProductClass::getById($zjGatheringItemId, true);
  83. $zjGatheringItemName = $zjGatheringItem->name ?? '';
  84. $arr = $ext->attributes ?? [];
  85. $arr['losingItemName'] = $losingItemName;
  86. $arr['zjGatheringItemName'] = $zjGatheringItemName;
  87. $arr['main'] = $this->main;
  88. util::success($arr);
  89. }
  90. //添加外采打印机 ssh 20230618
  91. public function actionAddWcPrint()
  92. {
  93. $shopAdmin = $this->shopAdmin;
  94. if (!isset($shopAdmin->super) || $shopAdmin->super != 1) {
  95. util::fail('超管才能修改');
  96. }
  97. $shopId = $this->shopId;
  98. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  99. $get = Yii::$app->request->get();
  100. $wcPrintSn = $get['wcPrintSn'] ?? '';
  101. $wcPrintKey = $get['wcPrintKey'] ?? '';
  102. $wcPrintSn2 = $get['wcPrintSn2'] ?? '';
  103. $wcPrintKey2 = $get['wcPrintKey2'] ?? '';
  104. $wcPrintSn3 = $get['wcPrintSn3'] ?? '';
  105. $wcPrintKey3 = $get['wcPrintKey3'] ?? '';
  106. $shop = $this->shop;
  107. $default = $shop->default ?? 0;
  108. $shopName = $shop->shopName ?? '';
  109. $sj = $this->sj;
  110. $sjName = $sj->name ?? '';
  111. $name = $default == 1 && $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
  112. if (empty($wcPrintSn) && !empty($wcPrintSn2)) {
  113. util::fail('请先填写小票机编号1');
  114. }
  115. if (empty($wcPrintSn2) && !empty($wcPrintSn3)) {
  116. util::fail('请先填写小票机编号2');
  117. }
  118. $hasFail = 0;
  119. if (!empty($wcPrintSn) && !empty($wcPrintKey)) {
  120. $print = new printUtil($wcPrintSn);
  121. $return = $print->addPrint($wcPrintKey, $name);
  122. if ($return) {
  123. $ext->wcPrintSn = $wcPrintSn;
  124. $ext->wcPrintKey = $wcPrintKey;
  125. $ext->save();
  126. } else {
  127. $hasFail = 1;
  128. }
  129. } else {
  130. $ext->wcPrintSn = '';
  131. $ext->wcPrintKey = '';
  132. $ext->save();
  133. }
  134. if (!empty($wcPrintSn2) && !empty($wcPrintKey2)) {
  135. $print = new printUtil($wcPrintSn2);
  136. $return = $print->addPrint($wcPrintKey2, $name);
  137. if ($return) {
  138. $ext->wcPrintSn2 = $wcPrintSn2;
  139. $ext->wcPrintKey2 = $wcPrintKey2;
  140. $ext->save();
  141. } else {
  142. $hasFail = 1;
  143. }
  144. } else {
  145. $ext->wcPrintSn2 = '';
  146. $ext->wcPrintKey2 = '';
  147. $ext->save();
  148. }
  149. if (!empty($wcPrintSn3) && !empty($wcPrintKey3)) {
  150. $print = new printUtil($wcPrintSn3);
  151. $return = $print->addPrint($wcPrintKey3, $name);
  152. if ($return) {
  153. $ext->wcPrintSn3 = $wcPrintSn3;
  154. $ext->wcPrintKey3 = $wcPrintKey3;
  155. $ext->save();
  156. } else {
  157. $hasFail = 1;
  158. }
  159. } else {
  160. $ext->wcPrintSn3 = '';
  161. $ext->wcPrintKey3 = '';
  162. $ext->save();
  163. }
  164. $wcPrintNum = 1;
  165. if (isset($ext->wcPrintSn2) && !empty($ext->wcPrintSn2)) {
  166. $wcPrintNum = 2;
  167. }
  168. if (isset($ext->wcPrintSn3) && !empty($ext->wcPrintSn3)) {
  169. $wcPrintNum = 3;
  170. }
  171. ShopExtClass::updateByCondition(['shopId' => $this->shopId], ['wcPrintNum' => $wcPrintNum]);
  172. if ($hasFail == 1) {
  173. util::success(['hasFail' => 1], '出现添加失败的情况');
  174. }
  175. util::complete();
  176. }
  177. //添加打印机 ssh 20210712
  178. public function actionAddPrint()
  179. {
  180. $shopAdmin = $this->shopAdmin;
  181. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  182. util::fail('超管才能修改');
  183. }
  184. $hasFail = 0;
  185. $shopId = $this->shopId;
  186. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  187. $get = Yii::$app->request->get();
  188. $printSn = $get['printSn'] ?? '';
  189. $printKey = $get['printKey'] ?? '';
  190. $printLabelSn = $get['printLabelSn'] ?? '';
  191. $printLabelKey = $get['printLabelKey'] ?? '';
  192. $wlLabelSn = $get['wlLabelSn'] ?? '';
  193. $wlLabelKey = $get['wlLabelKey'] ?? '';
  194. $shop = $this->shop;
  195. $default = $shop->default ?? 0;
  196. $shopName = $shop->shopName ?? '';
  197. $sj = $this->sj;
  198. $sjName = $sj->name ?? '';
  199. $name = $default == 1 && $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
  200. if (!empty($printSn) && !empty($printKey)) {
  201. $print = new printUtil($printSn);
  202. $return = $print->addPrint($printKey, $name);
  203. if ($return) {
  204. $ext->printSn = $printSn;
  205. $ext->printKey = $printKey;
  206. $ext->save();
  207. } else {
  208. $hasFail = 1;
  209. }
  210. } else {
  211. $ext->printSn = '';
  212. $ext->printKey = '';
  213. $ext->save();
  214. }
  215. if (!empty($printLabelSn) && !empty($printLabelKey)) {
  216. $labelPrint = new printUtil($printLabelSn);
  217. $return = $labelPrint->addPrint($printLabelKey, $name);
  218. if ($return) {
  219. $ext->printLabelSn = $printLabelSn;
  220. $ext->printLabelKey = $printLabelKey;
  221. $ext->save();
  222. //将打印纸张设置为50X40
  223. $labelPrint->times = 1;
  224. $content = '<SIZE>50,40</SIZE>';
  225. $labelPrint->printLabelMsg($content);
  226. } else {
  227. $hasFail = 1;
  228. }
  229. } else {
  230. $ext->printLabelSn = '';
  231. $ext->printLabelKey = '';
  232. $ext->save();
  233. }
  234. if (!empty($wlLabelSn) && !empty($wlLabelKey)) {
  235. $labelPrint = new printUtil($wlLabelSn);
  236. $return = $labelPrint->addPrint($wlLabelKey, $name);
  237. if ($return) {
  238. $ext->wlLabelSn = $wlLabelSn;
  239. $ext->wlLabelKey = $wlLabelKey;
  240. $ext->save();
  241. //将打印纸张设置为60X100
  242. $labelPrint->times = 1;
  243. $content = '<SIZE>60,100</SIZE>';
  244. $labelPrint->printLabelMsg($content);
  245. } else {
  246. $hasFail = 1;
  247. }
  248. } else {
  249. $ext->wlLabelSn = '';
  250. $ext->wlLabelKey = '';
  251. $ext->save();
  252. }
  253. if ($hasFail == 1) {
  254. util::success(['hasFail' => 1], '出现添加失败的情况');
  255. }
  256. util::complete();
  257. }
  258. //获取打印机信息
  259. public function actionGetPrint()
  260. {
  261. $shopId = $this->shopId;
  262. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  263. util::success($ext);
  264. }
  265. //获取云喇叭信息 ssh 20220105
  266. public function actionGetLb()
  267. {
  268. $shopId = $this->shopId;
  269. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  270. util::success($ext);
  271. }
  272. //添加喇叭 ssh 20220105
  273. public function actionAddLb()
  274. {
  275. $shopAdmin = $this->shopAdmin;
  276. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  277. util::fail('超管才能修改');
  278. }
  279. $shopId = $this->shopId;
  280. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  281. $get = Yii::$app->request->get();
  282. $lbSn = $get['lbSn'] ?? '';
  283. $lbVersion = $get['lbVersion'] ?? '';
  284. $ext->lbSn = $lbSn;
  285. $ext->lbVersion = $lbVersion;
  286. $ext->save();
  287. util::complete('设置成功');
  288. }
  289. //小菊启用和停用 ssh 20211210
  290. public function actionReplaceXj()
  291. {
  292. $act = Yii::$app->request->get('act', 'start');
  293. $id = Yii::$app->request->get('id', 0);
  294. $xj = XjClass::getById($id, true);
  295. if (empty($xj)) {
  296. util::fail('没有找到小菊');
  297. }
  298. $status = $act == 'start' ? 1 : 2;
  299. $xj->status = $status;
  300. $xj->save();
  301. util::complete();
  302. }
  303. }