ShopExtController.php 11 KB

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