ShopExtController.php 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  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. util::success($arr);
  88. }
  89. //添加外采打印机 ssh 20230618
  90. public function actionAddWcPrint()
  91. {
  92. $shopAdmin = $this->shopAdmin;
  93. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  94. util::fail('超管才能修改');
  95. }
  96. $shopId = $this->shopId;
  97. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  98. $get = Yii::$app->request->get();
  99. $wcPrintSn = $get['wcPrintSn'] ?? '';
  100. $wcPrintKey = $get['wcPrintKey'] ?? '';
  101. $wcPrintSn2 = $get['wcPrintSn2'] ?? '';
  102. $wcPrintKey2 = $get['wcPrintKey2'] ?? '';
  103. $wcPrintSn3 = $get['wcPrintSn3'] ?? '';
  104. $wcPrintKey3 = $get['wcPrintKey3'] ?? '';
  105. $shop = $this->shop;
  106. $default = $shop->default ?? 0;
  107. $shopName = $shop->shopName ?? '';
  108. $sj = $this->sj;
  109. $sjName = $sj->name ?? '';
  110. $name = $default == 1 && $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
  111. if (empty($wcPrintSn) && !empty($wcPrintSn2)) {
  112. util::fail('请先填写小票机编号1');
  113. }
  114. if (empty($wcPrintSn2) && !empty($wcPrintSn3)) {
  115. util::fail('请先填写小票机编号2');
  116. }
  117. $hasFail = 0;
  118. if (!empty($wcPrintSn) && !empty($wcPrintKey)) {
  119. $print = new printUtil($wcPrintSn);
  120. $return = $print->addPrint($wcPrintKey, $name);
  121. if ($return) {
  122. $ext->wcPrintSn = $wcPrintSn;
  123. $ext->wcPrintKey = $wcPrintKey;
  124. $ext->save();
  125. } else {
  126. $hasFail = 1;
  127. }
  128. } else {
  129. $ext->wcPrintSn = '';
  130. $ext->wcPrintKey = '';
  131. $ext->save();
  132. }
  133. if (!empty($wcPrintSn2) && !empty($wcPrintKey2)) {
  134. $print = new printUtil($wcPrintSn2);
  135. $return = $print->addPrint($wcPrintKey2, $name);
  136. if ($return) {
  137. $ext->wcPrintSn2 = $wcPrintSn2;
  138. $ext->wcPrintKey2 = $wcPrintKey2;
  139. $ext->save();
  140. } else {
  141. $hasFail = 1;
  142. }
  143. } else {
  144. $ext->wcPrintSn2 = '';
  145. $ext->wcPrintKey2 = '';
  146. $ext->save();
  147. }
  148. if (!empty($wcPrintSn3) && !empty($wcPrintKey3)) {
  149. $print = new printUtil($wcPrintSn3);
  150. $return = $print->addPrint($wcPrintKey3, $name);
  151. if ($return) {
  152. $ext->wcPrintSn3 = $wcPrintSn3;
  153. $ext->wcPrintKey3 = $wcPrintKey3;
  154. $ext->save();
  155. } else {
  156. $hasFail = 1;
  157. }
  158. } else {
  159. $ext->wcPrintSn3 = '';
  160. $ext->wcPrintKey3 = '';
  161. $ext->save();
  162. }
  163. $wcPrintNum = 1;
  164. if (isset($ext->wcPrintSn2) && !empty($ext->wcPrintSn2)) {
  165. $wcPrintNum = 2;
  166. }
  167. if (isset($ext->wcPrintSn3) && !empty($ext->wcPrintSn3)) {
  168. $wcPrintNum = 3;
  169. }
  170. ShopExtClass::updateByCondition(['shopId' => $this->shopId], ['wcPrintNum' => $wcPrintNum]);
  171. if ($hasFail == 1) {
  172. util::success(['hasFail' => 1], '出现添加失败的情况');
  173. }
  174. util::complete();
  175. }
  176. //添加打印机 ssh 20210712
  177. public function actionAddPrint()
  178. {
  179. $shopAdmin = $this->shopAdmin;
  180. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  181. util::fail('超管才能修改');
  182. }
  183. $hasFail = 0;
  184. $shopId = $this->shopId;
  185. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  186. $get = Yii::$app->request->get();
  187. $printSn = $get['printSn'] ?? '';
  188. $printKey = $get['printKey'] ?? '';
  189. $printLabelSn = $get['printLabelSn'] ?? '';
  190. $printLabelKey = $get['printLabelKey'] ?? '';
  191. $wlLabelSn = $get['wlLabelSn'] ?? '';
  192. $wlLabelKey = $get['wlLabelKey'] ?? '';
  193. $shop = $this->shop;
  194. $default = $shop->default ?? 0;
  195. $shopName = $shop->shopName ?? '';
  196. $sj = $this->sj;
  197. $sjName = $sj->name ?? '';
  198. $name = $default == 1 && $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
  199. if (!empty($printSn) && !empty($printKey)) {
  200. $print = new printUtil($printSn);
  201. $return = $print->addPrint($printKey, $name);
  202. if ($return) {
  203. $ext->printSn = $printSn;
  204. $ext->printKey = $printKey;
  205. $ext->save();
  206. } else {
  207. $hasFail = 1;
  208. }
  209. } else {
  210. $ext->printSn = '';
  211. $ext->printKey = '';
  212. $ext->save();
  213. }
  214. if (!empty($printLabelSn) && !empty($printLabelKey)) {
  215. $labelPrint = new printUtil($printLabelSn);
  216. $return = $labelPrint->addPrint($printLabelKey, $name);
  217. if ($return) {
  218. $ext->printLabelSn = $printLabelSn;
  219. $ext->printLabelKey = $printLabelKey;
  220. $ext->save();
  221. //将打印纸张设置为50X40
  222. $labelPrint->times = 1;
  223. $content = '<SIZE>50,40</SIZE>';
  224. $labelPrint->printLabelMsg($content);
  225. } else {
  226. $hasFail = 1;
  227. }
  228. } else {
  229. $ext->printLabelSn = '';
  230. $ext->printLabelKey = '';
  231. $ext->save();
  232. }
  233. if (!empty($wlLabelSn) && !empty($wlLabelKey)) {
  234. $labelPrint = new printUtil($wlLabelSn);
  235. $return = $labelPrint->addPrint($wlLabelKey, $name);
  236. if ($return) {
  237. $ext->wlLabelSn = $wlLabelSn;
  238. $ext->wlLabelKey = $wlLabelKey;
  239. $ext->save();
  240. //将打印纸张设置为60X100
  241. $labelPrint->times = 1;
  242. $content = '<SIZE>60,100</SIZE>';
  243. $labelPrint->printLabelMsg($content);
  244. } else {
  245. $hasFail = 1;
  246. }
  247. } else {
  248. $ext->wlLabelSn = '';
  249. $ext->wlLabelKey = '';
  250. $ext->save();
  251. }
  252. if ($hasFail == 1) {
  253. util::success(['hasFail' => 1], '出现添加失败的情况');
  254. }
  255. util::complete();
  256. }
  257. //获取打印机信息
  258. public function actionGetPrint()
  259. {
  260. $shopId = $this->shopId;
  261. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  262. util::success($ext);
  263. }
  264. //获取云喇叭信息 ssh 20220105
  265. public function actionGetLb()
  266. {
  267. $shopId = $this->shopId;
  268. $ext = ShopExtClass::getByCondition(['shopId' => $shopId]);
  269. util::success($ext);
  270. }
  271. //添加喇叭 ssh 20220105
  272. public function actionAddLb()
  273. {
  274. $shopAdmin = $this->shopAdmin;
  275. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  276. util::fail('超管才能修改');
  277. }
  278. $shopId = $this->shopId;
  279. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  280. $get = Yii::$app->request->get();
  281. $lbSn = $get['lbSn'] ?? '';
  282. $lbVersion = $get['lbVersion'] ?? '';
  283. $ext->lbSn = $lbSn;
  284. $ext->lbVersion = $lbVersion;
  285. $ext->save();
  286. util::complete('设置成功');
  287. }
  288. //小菊启用和停用 ssh 20211210
  289. public function actionReplaceXj()
  290. {
  291. $act = Yii::$app->request->get('act', 'start');
  292. $id = Yii::$app->request->get('id', 0);
  293. $xj = XjClass::getById($id, true);
  294. if (empty($xj)) {
  295. util::fail('没有找到小菊');
  296. }
  297. $status = $act == 'start' ? 1 : 2;
  298. $xj->status = $status;
  299. $xj->save();
  300. util::complete();
  301. }
  302. }