ItemController.php 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187
  1. <?php
  2. namespace ghs\controllers;
  3. use biz\item\classes\PtItemClass;
  4. use biz\item\classes\UnitClass;
  5. use biz\shop\classes\ShopExtClass;
  6. use bizGhs\book\classes\BookItemClass;
  7. use bizGhs\custom\classes\CustomClass;
  8. use bizGhs\item\classes\ItemClass;
  9. use bizGhs\shop\classes\ShopAdminClass;
  10. use common\components\dict;
  11. use common\components\imgUtil;
  12. use common\components\miniUtil;
  13. use common\components\noticeUtil;
  14. use common\components\stringUtil;
  15. use common\components\util;
  16. use bizGhs\product\classes\ProductClass;
  17. use bizHd\wx\classes\WxOpenClass;
  18. use Yii;
  19. class ItemController extends BaseController
  20. {
  21. //花材已购客户列表 ssh 20250710
  22. public function actionHasLimitBuyCustomList()
  23. {
  24. $get = Yii::$app->request->get();
  25. $id = $get['id'] ?? '';
  26. $item = ItemClass::getById($id, true);
  27. if (empty($item)) {
  28. util::fail('没有找到花材');
  29. }
  30. if ($item->mainId != $this->mainId) {
  31. util::fail('不是你的花材');
  32. }
  33. $customList = ProductClass::getHasLimitBuyList($item);
  34. util::success(['customList' => $customList]);
  35. }
  36. //取消花材的限购,重新开始计算
  37. public function actionClearLimitBuy()
  38. {
  39. $get = Yii::$app->request->get();
  40. $id = $get['id'] ?? '';
  41. $item = ItemClass::getById($id, true);
  42. if (empty($item)) {
  43. util::fail('没有找到花材');
  44. }
  45. if ($item->mainId != $this->mainId) {
  46. util::fail('不是你的花材');
  47. }
  48. ProductClass::cancelLimitBuy($id);
  49. util::complete('清除成功');
  50. }
  51. public function actionModifyWeight()
  52. {
  53. $shop = $this->shop;
  54. if ($shop->default == 0) {
  55. util::fail('请在总店(首店)修改');
  56. }
  57. $get = Yii::$app->request->get();
  58. $id = $get['id'] ?? '';
  59. $weight = $get['weight'] ?? 1;
  60. if ($weight <= 0) {
  61. util::fail('重量不能小于0');
  62. }
  63. $item = ItemClass::getById($id, true);
  64. if (empty($item)) {
  65. util::fail('没有找到花材');
  66. }
  67. if ($item->mainId != $this->mainId) {
  68. util::fail('不是你的花材');
  69. }
  70. $adminId = $this->adminId;
  71. $ptItemId = $item->itemId ?? 0;
  72. $respond = ShopAdminClass::changeWeightRight($adminId, $ptItemId);
  73. $hasRightChange = $respond['hasRightChange'];
  74. if ($hasRightChange == 0) {
  75. util::fail('不能修改');
  76. }
  77. $ptItem = PtItemClass::getById($ptItemId, true);
  78. if (empty($ptItem)) {
  79. util::fail('花材信息缺失');
  80. }
  81. $connection = Yii::$app->db;
  82. $transaction = $connection->beginTransaction();
  83. try {
  84. $ptItem->weight = $weight;
  85. $ptItem->save();
  86. ItemClass::updateByCondition(['itemId' => $ptItemId], ['weight' => $weight]);
  87. $transaction->commit();
  88. util::complete('修改成功');
  89. } catch (\Exception $e) {
  90. $transaction->rollBack();
  91. Yii::info("修改失败原因:" . $e->getMessage());
  92. util::fail('修改失败');
  93. }
  94. }
  95. public function actionModifyRatio()
  96. {
  97. $shop = $this->shop;
  98. if ($shop->default == 0) {
  99. util::fail('请在总店(首店)修改');
  100. }
  101. $get = Yii::$app->request->get();
  102. $id = $get['id'] ?? '';
  103. $ratio = $get['ratio'] ?? 20;
  104. if ($ratio < 1) {
  105. util::fail('单位比不能小于1');
  106. }
  107. $item = ItemClass::getById($id, true);
  108. if (empty($item)) {
  109. util::fail('没有找到花材');
  110. }
  111. if ($item->mainId != $this->mainId) {
  112. util::fail('不是你的花材');
  113. }
  114. $adminId = $this->adminId;
  115. $ptItemId = $item->itemId ?? 0;
  116. $respond = ShopAdminClass::changeWeightRight($adminId, $ptItemId);
  117. $hasRightChange = $respond['hasRightChange'];
  118. if ($hasRightChange == 0) {
  119. util::fail('不能修改');
  120. }
  121. $ptItem = PtItemClass::getById($ptItemId, true);
  122. if (empty($ptItem)) {
  123. util::fail('花材信息缺失');
  124. }
  125. $connection = Yii::$app->db;
  126. $transaction = $connection->beginTransaction();
  127. try {
  128. $ptItem->ratio = $ratio;
  129. $ptItem->save();
  130. ItemClass::updateByCondition(['itemId' => $ptItemId], ['ratio' => $ratio]);
  131. $transaction->commit();
  132. util::complete('修改成功');
  133. } catch (\Exception $e) {
  134. $transaction->rollBack();
  135. Yii::info("修改失败原因:" . $e->getMessage());
  136. util::fail('修改失败');
  137. }
  138. }
  139. public function actionModifyUnit()
  140. {
  141. $shop = $this->shop;
  142. if ($shop->default == 0) {
  143. util::fail('请在总店(首店)修改');
  144. }
  145. $get = Yii::$app->request->get();
  146. $id = $get['id'] ?? '';
  147. $unitId = $get['unitId'] ?? 1;
  148. $unit = UnitClass::getById($unitId, true);
  149. $type = $get['type'] ?? 'big';
  150. if (empty($unit)) {
  151. util::fail('没有找到单位');
  152. }
  153. $unitName = $unit->name;
  154. $item = ItemClass::getById($id, true);
  155. if (empty($item)) {
  156. util::fail('没有找到花材');
  157. }
  158. if ($item->mainId != $this->mainId) {
  159. util::fail('不是你的花材');
  160. }
  161. $adminId = $this->adminId;
  162. $ptItemId = $item->itemId ?? 0;
  163. $respond = ShopAdminClass::changeWeightRight($adminId, $ptItemId);
  164. $hasRightChange = $respond['hasRightChange'];
  165. if ($hasRightChange == 0) {
  166. util::fail('不能修改');
  167. }
  168. $ptItem = PtItemClass::getById($ptItemId, true);
  169. if (empty($ptItem)) {
  170. util::fail('花材信息缺失');
  171. }
  172. $connection = Yii::$app->db;
  173. $transaction = $connection->beginTransaction();
  174. try {
  175. if ($type == 'big') {
  176. $ptItem->bigUnit = $unitName;
  177. $ptItem->bigUnitId = $unitId;
  178. $ptItem->save();
  179. ItemClass::updateByCondition(['itemId' => $ptItemId], ['bigUnit' => $unitName, 'bigUnitId' => $unitId]);
  180. } else {
  181. $ptItem->smallUnit = $unitName;
  182. $ptItem->smallUnitId = $unitId;
  183. $ptItem->save();
  184. ItemClass::updateByCondition(['itemId' => $ptItemId], ['smallUnit' => $unitName, 'smallUnitId' => $unitId]);
  185. }
  186. $transaction->commit();
  187. util::complete('修改成功');
  188. } catch (\Exception $e) {
  189. $transaction->rollBack();
  190. Yii::info("修改失败原因:" . $e->getMessage());
  191. util::fail('修改失败');
  192. }
  193. }
  194. //挪到处理区 ssh 20250418
  195. public function actionMoveToLosing()
  196. {
  197. //避免重复提交
  198. util::checkRepeatCommit($this->adminId, 4);
  199. $get = Yii::$app->request->get();
  200. $id = $get['id'] ?? '';
  201. $num = $get['num'] ?? 0;
  202. $item = ItemClass::getById($id, true);
  203. if (empty($item)) {
  204. util::fail('没有找到花材');
  205. }
  206. if ($item->mainId != $this->mainId) {
  207. util::fail('不是你的花材');
  208. }
  209. if ($num <= 0) {
  210. util::fail('请输入数量');
  211. }
  212. $remark = '挪到处理区';
  213. $staff = $this->shopAdmin;
  214. $staffName = $staff->name ?? '';
  215. $staffId = $staff->id;
  216. $adminId = $this->adminId;
  217. $params = [
  218. 'staffId' => $staffId,
  219. 'staffName' => $staffName,
  220. 'adminId' => $adminId,
  221. 'remark' => $remark,
  222. ];
  223. $connection = Yii::$app->db;
  224. $transaction = $connection->beginTransaction();
  225. try {
  226. $shop = $this->shop;
  227. ItemClass::moveLose($item, $num, $shop, $params);
  228. $transaction->commit();
  229. util::complete('挪动成功');
  230. } catch (\Exception $e) {
  231. $transaction->rollBack();
  232. Yii::info("挪动失败原因:" . $e->getMessage());
  233. util::fail('挪动失败');
  234. }
  235. }
  236. //设为处理区用的花材 ssh 20250418
  237. public function actionSetLosing()
  238. {
  239. $get = Yii::$app->request->get();
  240. $id = $get['id'] ?? '';
  241. $item = ItemClass::getById($id, true);
  242. if (empty($item)) {
  243. util::fail('没有找到花材');
  244. }
  245. if ($item->mainId != $this->mainId) {
  246. util::fail('不是你的花材');
  247. }
  248. $shopAdmin = $this->shopAdmin;
  249. if ($shopAdmin->founder == 1) {
  250. util::fail('请用超管手机操作');
  251. }
  252. $shopId = $this->shopId;
  253. $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
  254. if (empty($ext)) {
  255. util::fail('设置失败,没有找到门店信息');
  256. }
  257. $ext->losingItem = $id;
  258. $ext->save();
  259. util::complete('设置成功');
  260. }
  261. //增加和减少半扎 ssh 20250417
  262. public function actionChangeHalf()
  263. {
  264. util::fail('此功能已停用');
  265. $post = Yii::$app->request->post();
  266. $productId = $post['productId'] ?? '';
  267. $add = $post['add'] ?? 0;
  268. $remark = $post['remark'] ?? '';
  269. $product = ProductClass::getLockById($productId);
  270. if (empty($product)) {
  271. util::fail('没有找到花材');
  272. }
  273. if ($product->mainId != $this->mainId) {
  274. util::fail('不是你的花材');
  275. }
  276. if ($product->ratioType == 1) {
  277. util::fail('若干扎的花材不能减半份');
  278. }
  279. //避免重复提交
  280. util::checkRepeatCommit($this->adminId, 4);
  281. $connection = Yii::$app->db;
  282. $transaction = $connection->beginTransaction();
  283. try {
  284. $shop = $this->shop;
  285. $staff = $this->shopAdmin;
  286. $staffName = $staff->name ?? '';
  287. $staffId = $staff->id;
  288. $adminId = $this->adminId;
  289. $params = [
  290. 'staffId' => $staffId,
  291. 'staffName' => $staffName,
  292. 'adminId' => $adminId,
  293. 'remark' => $remark,
  294. ];
  295. ItemClass::modifyHalf($shop, $product, $params, $add);
  296. $product = ProductClass::getLockById($productId);
  297. $stock = $product->stock;
  298. $stock = floatval($stock);
  299. $transaction->commit();
  300. util::success(['stock' => $stock]);
  301. } catch (\Exception $e) {
  302. $transaction->rollBack();
  303. Yii::info("加减半份失败原因:" . $e->getMessage());
  304. util::fail('加减半份失败');
  305. }
  306. }
  307. //修改一个花材的采购人 ssh 20240719
  308. public function actionModifyCgStaff()
  309. {
  310. $get = Yii::$app->request->get();
  311. $id = $get['id'] ?? 0;
  312. $staffId = $get['staffId'] ?? 0;
  313. $item = ItemClass::getById($id, true);
  314. if (empty($item)) {
  315. util::fail('没有找到花材');
  316. }
  317. if ($item->mainId != $this->mainId) {
  318. util::fail('不是你的花材');
  319. }
  320. $staff = ShopAdminClass::getById($staffId, true);
  321. if (empty($staff) || $staff->mainId != $this->mainId) {
  322. util::fail('不是你的员工');
  323. }
  324. $staffName = $staff->name ?? '';
  325. $item->cgStaffId = $staffId;
  326. $item->cgStaffName = $staffName;
  327. $item->save();
  328. $shop = $this->shop;
  329. $bookSn = $shop->bookSn ?? 0;
  330. if (!empty($bookSn)) {
  331. BookItemClass::updateByCondition(['bookSn' => $bookSn, 'itemId' => $id], ['cgStaffId' => $staffId, 'cgStaffName' => $staffName]);
  332. }
  333. util::complete('修改成功');
  334. }
  335. //获取花材最新信息,库存 ssh 20240318
  336. public function actionGetNewInfo()
  337. {
  338. $post = Yii::$app->request->post();
  339. $str = $post['data'] ?? '';
  340. if (empty($str)) {
  341. util::fail('请传花材信息');
  342. }
  343. $arr = json_decode($str, true);
  344. if (empty($arr)) {
  345. util::fail('请传花材信息哈');
  346. }
  347. $ids = array_column($arr, 'productId');
  348. $list = ItemClass::getAllByCondition(['id' => ['in', $ids]], null, 'id,name,stock,mainId', 'id', true);
  349. if (!empty($list)) {
  350. foreach ($list as $item) {
  351. if ($item->mainId != $this->mainId) {
  352. util::fail('不是你的花材');
  353. }
  354. }
  355. }
  356. util::success(['list' => $list]);
  357. }
  358. //列出所有花材 ssh 20240222
  359. public function actionGetItemList()
  360. {
  361. $get = Yii::$app->request->get();
  362. $search = $get['search'] ?? '';
  363. $requestType = $get['requestType'] ?? 'kd';
  364. $classId = $get['classId'] ?? 0;
  365. $lookStock = $get['lookStock'] ?? 0;
  366. $where['mainId'] = $this->mainId;
  367. if ($requestType == 'kd') {
  368. $where['delStatus'] = 0;
  369. $where['status'] = 1;
  370. } elseif ($requestType == 'itemList') {
  371. $where['delStatus'] = 0;
  372. if ($lookStock == 1) {
  373. $where['stock>'] = 0;
  374. }
  375. if ($lookStock == 2) {
  376. $where['stock'] = 0;
  377. }
  378. unset($where['status']);
  379. } elseif ($requestType == 'changePrice') {
  380. $where['delStatus'] = 0;
  381. $where['stock>'] = 0;
  382. } elseif ($requestType == 'hasStockList') {
  383. $where['delStatus'] = 0;
  384. $where['stock>'] = 0;
  385. } elseif ($requestType == 'book') {
  386. $where['delStatus'] = 0;
  387. unset($where['status']);
  388. } elseif ($requestType == 'outList') {
  389. $where['delStatus'] = 0;
  390. $where['status'] = 2;
  391. $where['removeStatus'] = 0;
  392. } elseif ($requestType == 'stopList') {
  393. $where['delStatus'] = 1;
  394. unset($where['status']);
  395. $where['removeStatus'] = 0;
  396. } elseif ($requestType == 'removeList') {
  397. $where['delStatus'] = 1;
  398. unset($where['status']);
  399. $where['removeStatus'] = 1;
  400. } elseif ($requestType == 'cg') {
  401. $where['delStatus'] = 0;
  402. unset($where['status']);
  403. } elseif ($requestType == 'changeStock') {
  404. $where['delStatus'] = 0;
  405. unset($where['status']);
  406. } elseif ($requestType == 'check') {
  407. $where['delStatus'] = 0;
  408. unset($where['status']);
  409. } elseif ($requestType == 'stockOut') {
  410. $where['delStatus'] = 0;
  411. $where['status'] = 1;
  412. } elseif ($requestType == 'break') {
  413. $where['delStatus'] = 0;
  414. $where['status'] = 1;
  415. } elseif ($requestType == 'part') {
  416. $where['delStatus'] = 0;
  417. $where['status'] = 1;
  418. } else {
  419. util::fail('没有定义的请求方式');
  420. }
  421. if (!empty($search)) {
  422. if (stringUtil::isLetter($search)) {
  423. $search = strtolower($search);
  424. $where['py'] = ['like', $search];
  425. } else {
  426. $where['name'] = ['like', $search];
  427. }
  428. } else {
  429. if (!empty($classId)) {
  430. if ($classId == -1) {
  431. $where['discountPrice>'] = 0;
  432. } elseif ($classId == -2) {
  433. $where['reachNum>'] = 0;
  434. } elseif ($classId == -3) {
  435. $where['presell'] = 1;
  436. } else {
  437. $where['classId'] = $classId;
  438. }
  439. }
  440. }
  441. $customId = $get['customId'] ?? 0;
  442. $custom = CustomClass::getById($customId, true);
  443. if (!empty($custom)) {
  444. if ($custom->ownMainId != $this->mainId) {
  445. util::fail('不是你的客户');
  446. }
  447. }
  448. $level = $custom->level ?? 1;
  449. $field = '*';
  450. //只查我负责的花材
  451. $globalCgMyCharge = $get['globalCgMyCharge'] ?? 0;
  452. $needCgList = [];
  453. $shop = $this->shop;
  454. $bookSn = $shop->bookSn ?? 0;
  455. $staff = $this->shopAdmin;
  456. $staffId = $staff->id ?? 0;
  457. if (!empty($bookSn)) {
  458. $biList = BookItemClass::getAllByCondition(['bookSn' => $bookSn, 'cgStaffId' => $staffId], null, '*', null, true);
  459. if (!empty($biList)) {
  460. $myIds = [];
  461. foreach ($biList as $biInfo) {
  462. $biProductId = $biInfo->itemId ?? 0;
  463. if ($biInfo->needCgNum > 0) {
  464. $myIds[] = $biProductId;
  465. $needCgList[$biProductId] = $biInfo->needCgNum;
  466. }
  467. }
  468. if ($globalCgMyCharge == 1) {
  469. if (!empty($myIds)) {
  470. $where['id'] = ['in', $myIds];
  471. } else {
  472. $where['id'] = ['in', [0]];
  473. }
  474. }
  475. } else {
  476. if ($globalCgMyCharge == 1) {
  477. $where['id'] = ['in', [0]];
  478. }
  479. }
  480. }
  481. $result = ProductClass::getList($field, $where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC]);
  482. $list = $result['list'] ?? [];
  483. if ($requestType == 'hasStockList') {
  484. util::fail('无效方式');
  485. } elseif ($requestType == 'changePrice') {
  486. $list = ProductClass::changePriceGroup($list, $level);
  487. } elseif ($requestType == 'changeStock') {
  488. $list = ProductClass::changeStockGroup($list, $level);
  489. } elseif ($requestType == 'kd') {
  490. $list = ProductClass::kdItemGroup($list, $level);
  491. } elseif ($requestType == 'book') {
  492. $list = ProductClass::bookItemGroup($list, $level);
  493. } elseif ($requestType == 'itemList') {
  494. $list = ProductClass::itemListGroup($list, $level);
  495. } elseif ($requestType == 'outList') {
  496. $list = ProductClass::simpleGroup($list, $level);
  497. } elseif ($requestType == 'stopList') {
  498. $list = ProductClass::simpleGroup($list, $level);
  499. } elseif ($requestType == 'removeList') {
  500. $list = ProductClass::simpleGroup($list, $level);
  501. } elseif ($requestType == 'check') {
  502. $list = ProductClass::checkItemGroup($list, $level);
  503. } elseif ($requestType == 'break') {
  504. $list = ProductClass::breakItemGroup($list, $level);
  505. } elseif ($requestType == 'part') {
  506. $list = ProductClass::partItemGroup($list, $level);
  507. } elseif ($requestType == 'stockOut') {
  508. $list = ProductClass::stockOutGroup($list, $level);
  509. } elseif ($requestType == 'cg') {
  510. $list = ProductClass::cgItemGroup($list, $level);
  511. } elseif ($requestType == 'warning') {
  512. util::fail('无效方式');
  513. // $itemInfoData = Product::find()->where("mainId={$this->mainId}")
  514. // ->andWhere('`stock`+`onStock`<`stockWarning`')
  515. // ->andWhere("delStatus=0")
  516. // ->select($field)->asArray()->all();
  517. // $itemInfoData = ProductClass::warningGroup($itemInfoData, $level);
  518. } else {
  519. util::fail('没有数据');
  520. }
  521. if (!empty($needCgList)) {
  522. //采购人采自己花材需要知道要采多少
  523. if (!empty($list)) {
  524. foreach ($list as $key => $val) {
  525. $productId = $val['id'] ?? 0;
  526. if (isset($needCgList[$productId])) {
  527. $needCgNum = $needCgList[$productId];
  528. $list[$key]['needCgNum'] = $needCgNum;
  529. }
  530. }
  531. }
  532. }
  533. $result['list'] = $list;
  534. util::success($result);
  535. }
  536. //花材申请平台认证 ssh 20231125
  537. public function actionApplyAuth()
  538. {
  539. $get = Yii::$app->request->get();
  540. $id = $get['id'] ?? 0;
  541. $info = ItemClass::getById($id, true);
  542. if (empty($info)) {
  543. util::fail('没有找到花材');
  544. }
  545. if ($info->mainId != $this->mainId) {
  546. util::fail('不是你的花材哦');
  547. }
  548. $shop = $this->shop;
  549. $sjName = $shop->merchantName ?? '';
  550. $shopName = $shop->shopName ?? '';
  551. $name = $shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
  552. $ptItemId = $info->itemId ?? 0;
  553. $ptItem = PtItemClass::getById($ptItemId, true);
  554. if (empty($ptItem)) {
  555. util::fail('没有找到平台花材');
  556. }
  557. $ptItemName = $ptItem->name ?? '';
  558. noticeUtil::push($name . " 申请将【{$ptItemName}/{$ptItemId}】进行认证", '15280215347');
  559. util::complete();
  560. }
  561. //简单花材的列表
  562. public function actionSimpleList()
  563. {
  564. $get = Yii::$app->request->get();
  565. $name = $get['name'] ?? '';
  566. $num = $get['num'] ?? 0;
  567. $where = ['mainId' => $this->mainId, 'delStatus' => 0];
  568. if (!empty($name)) {
  569. if (stringUtil::isLetter($name)) {
  570. $where['py'] = ['like', $name];
  571. } else {
  572. $where['name'] = ['like', $name];
  573. }
  574. }
  575. $respond = ItemClass::getSimpleList($where, $num);
  576. util::success($respond);
  577. }
  578. //可借库存的花材列表 ssh 20240720
  579. public function actionGetLoanList()
  580. {
  581. $get = Yii::$app->request->get();
  582. $name = $get['name'] ?? '';
  583. $where = ['mainId' => $this->mainId, 'delStatus' => 0];
  584. if (!empty($name)) {
  585. if (stringUtil::isLetter($name)) {
  586. $where['py'] = ['like', $name];
  587. } else {
  588. $where['name'] = ['like', $name];
  589. }
  590. }
  591. $shop = $this->shop;
  592. $respond = ItemClass::getLoanList($where, $shop);
  593. util::success($respond);
  594. }
  595. public function actionChangeFrontHide()
  596. {
  597. $get = Yii::$app->request->get();
  598. $id = $get['id'] ?? 0;
  599. $status = $get['status'] ?? '';
  600. if (is_numeric($status) == false) {
  601. util::fail('请选择方式');
  602. }
  603. $info = ItemClass::getById($id, true);
  604. if (empty($info)) {
  605. util::fail('没有找到花材');
  606. }
  607. if ($info->mainId != $this->mainId) {
  608. util::fail('无法操作');
  609. }
  610. $info->frontHide = $status;
  611. $info->save();
  612. util::complete();
  613. }
  614. //检测是否要刷新
  615. public function actionCheckRefresh()
  616. {
  617. $mainId = $this->mainId;
  618. $staffId = $this->shopAdminId;
  619. $respond = Yii::$app->redis->executeCommand('GET', ['ghs_cashier_' . $mainId . '_' . $staffId . '_may_refresh']);
  620. if ($respond == 'yes') {
  621. util::success(['remind' => 1]);
  622. }
  623. util::complete();
  624. }
  625. //批量恢复花材 ssh 20230206
  626. public function actionBatchRecover()
  627. {
  628. $post = Yii::$app->request->post();
  629. $string = $post['ids'] ?? '';
  630. $ids = json_decode($string, true);
  631. $ids = array_unique(array_filter($ids));
  632. if (empty($ids)) {
  633. util::fail('请选择花材6');
  634. }
  635. $infoList = ItemClass::getAllByCondition(['id' => ['in', $ids]], null, 'id,name,mainId,status,delStatus,removeStatus', null, true);
  636. if (empty($infoList)) {
  637. util::fail('请选择花材哦8');
  638. }
  639. foreach ($infoList as $info) {
  640. if ($info->mainId != $this->mainId) {
  641. util::fail('请选择自己的花材');
  642. }
  643. $info->removeStatus = 0;
  644. $info->save();
  645. }
  646. util::complete('操作成功');
  647. }
  648. //批量删除花材 ssh 202302026
  649. public function actionBatchRemove()
  650. {
  651. $post = Yii::$app->request->post();
  652. $string = $post['ids'] ?? '';
  653. $ids = json_decode($string, true);
  654. $ids = array_unique(array_filter($ids));
  655. if (empty($ids)) {
  656. util::fail('请选择花材7');
  657. }
  658. $infoList = ItemClass::getAllByCondition(['id' => ['in', $ids]], null, 'id,name,mainId,status,delStatus,removeStatus', null, true);
  659. if (empty($infoList)) {
  660. util::fail('请选择花材哦10');
  661. }
  662. foreach ($infoList as $info) {
  663. if ($info->mainId != $this->mainId) {
  664. util::fail('请选择自己的花材');
  665. }
  666. $name = $info->name ?? '';
  667. if ($info->delStatus != 1) {
  668. util::fail($name . ' 停用了才能删除');
  669. }
  670. $info->removeStatus = 1;
  671. $info->save();
  672. }
  673. util::complete('操作成功');
  674. }
  675. //批量启用花材 ssh 20230206
  676. public function actionBatchEnable()
  677. {
  678. $post = Yii::$app->request->post();
  679. $string = $post['ids'] ?? '';
  680. $ids = json_decode($string, true);
  681. $ids = array_unique(array_filter($ids));
  682. if (empty($ids)) {
  683. util::fail('请选择花材11');
  684. }
  685. $infoList = ItemClass::getAllByCondition(['id' => ['in', $ids]], null, 'id,name,mainId,status,delStatus,removeStatus', null, true);
  686. if (empty($infoList)) {
  687. util::fail('请选择花材哦12');
  688. }
  689. foreach ($infoList as $info) {
  690. if ($info->mainId != $this->mainId) {
  691. util::fail('请选择自己的花材');
  692. }
  693. $info->delStatus = 0;
  694. $info->save();
  695. }
  696. util::complete('操作成功');
  697. }
  698. //批量停用花材 20230206
  699. public function actionBatchStop()
  700. {
  701. $post = Yii::$app->request->post();
  702. $string = $post['ids'] ?? '';
  703. $ids = json_decode($string, true);
  704. $ids = array_unique(array_filter($ids));
  705. if (empty($ids)) {
  706. util::fail('请选择花材13');
  707. }
  708. $infoList = ItemClass::getAllByCondition(['id' => ['in', $ids]], null, 'id,name,mainId,status,delStatus,removeStatus', null, true);
  709. if (empty($infoList)) {
  710. util::fail('请选择花材哦14');
  711. }
  712. foreach ($infoList as $info) {
  713. if ($info->mainId != $this->mainId) {
  714. util::fail('请选择自己的花材');
  715. }
  716. $name = $info->name ?? '';
  717. if ($info->status != 2) {
  718. util::fail($name . ' 下载了才能停用');
  719. }
  720. $info->delStatus = 1;
  721. $info->save();
  722. }
  723. util::complete('操作成功');
  724. }
  725. //获取给散客下单的花材海报 ssh 20220111
  726. public function actionGetSkPoster()
  727. {
  728. $get = Yii::$app->request->get();
  729. $id = $get['id'] ?? 0;
  730. $item = ItemClass::getById($id, true);
  731. if (empty($item) || $item->mainId != $this->mainId) {
  732. util::fail('获取失败');
  733. }
  734. $cover = $item->cover ?? '';
  735. if (empty($cover)) {
  736. util::fail('获取失败');
  737. }
  738. $merchant = WxOpenClass::getMallWxInfo();
  739. $page = 'pages/item/detail';
  740. $ptStyle = dict::getDict('ptStyle', 'mall');
  741. $shop = $this->shop;
  742. $lsShopId = $shop->lsShopId ?? 0;
  743. //scene不能超过32个字条
  744. $scene = "id=" . $id . '&a=' . $lsShopId;
  745. $miniCode = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $ptStyle);
  746. $miniCode = $miniCode . '?x-oss-process=image/resize,m_fill,h_200,w_200';
  747. $miniCodeBase64 = stringUtil::ossBase64($miniCode);
  748. Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'hd');
  749. $prefix = imgUtil::getPrefix();
  750. $price = $item->skPrice ?? 0;
  751. if ($item->discountPrice > 0) {
  752. $skMore = $item->skMore ?? 0;
  753. $price = bcadd($item->discountPrice, $skMore, 2);
  754. }
  755. $newPrice = '¥' . floatval($price);
  756. $priceBase64 = stringUtil::ossBase64($newPrice);
  757. $name = $item->name ?? '';
  758. $nameBase64 = stringUtil::ossBase64($name);
  759. $staff = $this->shopAdmin;
  760. $staffName = $staff->name ?? '';
  761. $newStaffName = $staffName . ' 为您推荐';
  762. $staffNameBase64 = stringUtil::ossBase64($newStaffName);
  763. //花材主图
  764. $itemCover = $cover . '?x-oss-process=image/resize,m_fill,h_750,w_750';
  765. $itemCoverBase64 = stringUtil::ossBase64($itemCover);
  766. $logoBase64 = '';
  767. if (in_array($this->mainId, [52, 1459, 13495])) {
  768. $logo = 'poster/hyxh_ncd_logo.png?x-oss-process=image/resize,m_fill,h_90,w_90';
  769. if ($this->mainId == 1459) {
  770. $logo = 'poster/hyxh_gcd_logo.png?x-oss-process=image/resize,m_fill,h_90,w_90';
  771. }
  772. if ($this->mainId == 13495) {
  773. $logo = 'poster/hyxh_hzd_logo.png?x-oss-process=image/resize,m_fill,h_90,w_90';
  774. }
  775. $logoBase64 = stringUtil::ossBase64($logo);
  776. }
  777. $url = $prefix . 'poster/1234.jpg?x-oss-process=image';
  778. //花材主图
  779. $url .= '/watermark,image_' . $itemCoverBase64 . ',g_nw,x_0,y_0';
  780. //小程序码
  781. $url .= '/watermark,image_' . $miniCodeBase64 . ',g_se';
  782. if (!empty($logoBase64)) {
  783. //logo
  784. $url .= '/watermark,image_' . $logoBase64 . ',g_se,x_65,y_65';
  785. }
  786. //为你推荐
  787. $url .= '/watermark,text_' . $staffNameBase64 . ',g_sw,x_18,y_235,color_8B8989,type_d3F5LW1pY3JvaGVp,size_30';
  788. //标题
  789. $url .= '/watermark,text_' . $nameBase64 . ',g_sw,x_18,y_145';
  790. //价格
  791. $url .= '/watermark,text_' . $priceBase64 . ',g_sw,x_18,y_50,color_EE2C2C,type_d3F5LW1pY3JvaGVp,size_50';
  792. $respond = ['imgUrl' => $url];
  793. util::success($respond);
  794. }
  795. //下载商品码,用于花市卖花 ssh 20240823
  796. public function actionDownMiniCode()
  797. {
  798. $get = Yii::$app->request->get();
  799. $id = $get['id'] ?? 0;
  800. $item = ItemClass::getById($id, true);
  801. if (empty($item)) {
  802. util::fail('没有找到花材');
  803. }
  804. if ($item->mainId != $this->mainId) {
  805. util::fail('不是你的花材');
  806. }
  807. $merchant = WxOpenClass::getWxInfo();
  808. $page = 'admin/ghsProduct/detail';
  809. $ptStyle = dict::getDict('ptStyle', 'hd');
  810. //小程序码,scene不能超过32个字条
  811. $scene = "id=" . $id . '&sId=' . $this->shopId;
  812. $miniCode = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $ptStyle);
  813. $miniCode = $miniCode . '?x-oss-process=image/resize,m_fill,h_450,w_450';
  814. $miniCodeBase64 = stringUtil::ossBase64($miniCode);
  815. $prefix = imgUtil::getPrefix();
  816. $url = $prefix . 'poster/mini_bg.jpg?x-oss-process=image';
  817. //小程序码
  818. $url .= '/watermark,image_' . $miniCodeBase64 . ',g_north,x_0,y_25';
  819. $name = $item->name ?? '';
  820. $nameBase64 = stringUtil::ossBase64($name);
  821. //标题
  822. $url .= '/watermark,text_' . $nameBase64 . ',g_south,x_0,y_35';
  823. $file = fopen($url, "rb");
  824. Header("Content-type: application/octet-stream ");
  825. Header("Accept-Ranges: bytes ");
  826. Header("Content-Disposition: attachment;filename={$name}.jpg");
  827. $contents = "";
  828. while (!feof($file)) {
  829. $contents .= fread($file, 8192);
  830. }
  831. echo $contents;
  832. fclose($file);
  833. }
  834. //获取给花店下单的花材海报 ssh 20220111
  835. public function actionGetHdPoster()
  836. {
  837. $get = Yii::$app->request->get();
  838. $id = $get['id'] ?? 0;
  839. $item = ItemClass::getById($id, true);
  840. if (empty($item) || $item->mainId != $this->mainId) {
  841. util::fail('获取失败');
  842. }
  843. $cover = $item->cover ?? '';
  844. if (empty($cover)) {
  845. util::fail('获取失败');
  846. }
  847. $merchant = WxOpenClass::getWxInfo();
  848. $page = 'admin/ghsProduct/detail';
  849. $ptStyle = dict::getDict('ptStyle', 'hd');
  850. //小程序码,scene不能超过32个字条
  851. $scene = "id=" . $id . '&sId=' . $this->shopId;
  852. $miniCode = miniUtil::generateUnlimitedMiniCode($merchant, $page, $scene, $ptStyle);
  853. $miniCode = $miniCode . '?x-oss-process=image/resize,m_fill,h_200,w_200';
  854. $miniCodeBase64 = stringUtil::ossBase64($miniCode);
  855. Yii::$app->params['ptStyle'] = dict::getDict('ptStyle', 'ghs');
  856. $prefix = imgUtil::getPrefix();
  857. $price = $item->price ?? 0;
  858. if ($item->discountPrice > 0) {
  859. $price = $item->discountPrice;
  860. }
  861. $newPrice = '¥' . floatval($price);
  862. $priceBase64 = stringUtil::ossBase64($newPrice);
  863. $name = $item->name ?? '';
  864. $nameBase64 = stringUtil::ossBase64($name);
  865. $staff = $this->shopAdmin;
  866. $staffName = $staff->name ?? '';
  867. $newStaffName = $staffName . ' 为您推荐';
  868. $staffNameBase64 = stringUtil::ossBase64($newStaffName);
  869. //花材主图
  870. $itemCover = $cover . '?x-oss-process=image/resize,m_fill,h_750,w_750';
  871. $itemCoverBase64 = stringUtil::ossBase64($itemCover);
  872. $logoBase64 = '';
  873. if (in_array($this->mainId, [52, 1459, 13495])) {
  874. $logo = 'poster/hyxh_ncd_logo.png?x-oss-process=image/resize,m_fill,h_90,w_90';
  875. if ($this->mainId == 1459) {
  876. $logo = 'poster/hyxh_gcd_logo.png?x-oss-process=image/resize,m_fill,h_90,w_90';
  877. }
  878. if ($this->mainId == 13495) {
  879. $logo = 'poster/hyxh_hzd_logo.png?x-oss-process=image/resize,m_fill,h_90,w_90';
  880. }
  881. $logoBase64 = stringUtil::ossBase64($logo);
  882. }
  883. $url = $prefix . 'poster/1234.jpg?x-oss-process=image';
  884. //花材主图
  885. $url .= '/watermark,image_' . $itemCoverBase64 . ',g_nw,x_0,y_0';
  886. //小程序码
  887. $url .= '/watermark,image_' . $miniCodeBase64 . ',g_se';
  888. if (!empty($logoBase64)) {
  889. //logo
  890. $url .= '/watermark,image_' . $logoBase64 . ',g_se,x_65,y_65';
  891. }
  892. //为你推荐
  893. $url .= '/watermark,text_' . $staffNameBase64 . ',g_sw,x_18,y_235,color_8B8989,type_d3F5LW1pY3JvaGVp,size_30';
  894. //标题
  895. $url .= '/watermark,text_' . $nameBase64 . ',g_sw,x_18,y_145';
  896. //价格
  897. $url .= '/watermark,text_' . $priceBase64 . ',g_sw,x_18,y_50,color_EE2C2C,type_d3F5LW1pY3JvaGVp,size_50';
  898. $respond = ['imgUrl' => $url];
  899. util::success($respond);
  900. }
  901. //是否有C级价格大于B级的 ssh 20221204
  902. public function actionGetErrorPrice()
  903. {
  904. $shop = $this->shop;
  905. $list = ItemClass::errorPrice($shop);
  906. util::success(['list' => $list]);
  907. }
  908. //列出所有花材,包括特价花材列表 ssh 20220315
  909. public function actionShowList()
  910. {
  911. $get = Yii::$app->request->get();
  912. $customId = $get['customId'] ?? 0;
  913. $custom = CustomClass::getById($customId, true);
  914. $where['mainId'] = $this->mainId;
  915. $where['delStatus'] = 0;
  916. $where['status'] = 1;
  917. $list = ItemClass::getShowList($where, $custom);
  918. $mainId = $this->mainId;
  919. $get = Yii::$app->request->get();
  920. $isCashier = $get['isCashier'] ?? 0;
  921. if ($isCashier == 1) {
  922. //去掉收银台提示价格更新
  923. $staffId = $this->shopAdminId;
  924. Yii::$app->redis->executeCommand('DEL', ['ghs_cashier_' . $mainId . '_' . $staffId . '_may_refresh']);
  925. }
  926. $productList = [];
  927. if (!empty($list)) {
  928. foreach ($list as $key => $item) {
  929. if (!empty($item)) {
  930. $productList = array_merge($productList, $item);
  931. }
  932. }
  933. }
  934. util::success(['list' => $list, 'productList' => $productList]);
  935. }
  936. public function actionAdd()
  937. {
  938. util::fail('开发中');
  939. }
  940. //批量添加花材
  941. public function actionBatchAdd()
  942. {
  943. $shopAdmin = $this->shopAdmin;
  944. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  945. util::fail('超管才能操作');
  946. }
  947. $post = Yii::$app->request->post();
  948. //[{"itemId":"1175","classId":"3548","price":"5","skPrice":"8","cost":"1","name":"卡娜百合"}]
  949. $data = $post['data'];
  950. if (empty($data)) {
  951. util::fail("请选花材");
  952. }
  953. $data = json_decode($data, true);
  954. if (is_array($data) == false || empty($data)) {
  955. util::fail("请选花材");
  956. }
  957. $shop = $this->shop;
  958. $shopId = $this->shopId;
  959. $mainId = $this->mainId;
  960. $sjId = $this->sjId;
  961. $adminId = $this->adminId;
  962. $ids = array_column($data, 'itemId');
  963. $ids = array_unique(array_filter($ids));
  964. $has = ProductClass::getByCondition(['mainId' => $mainId, 'itemId' => ['in', $ids]]);
  965. if (!empty($has)) {
  966. $hasName = $has->name ?? '';
  967. util::fail($hasName . " 已经添加过了");
  968. }
  969. $ptItemInfo = PtItemClass::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id');
  970. $connection = Yii::$app->db;
  971. $transaction = $connection->beginTransaction();
  972. try {
  973. foreach ($data as $v) {
  974. $ptItemId = $v['itemId'] ?? 0;
  975. $ratio = $ptItemInfo[$ptItemId]['ratio'] ?? 20;
  976. $shelfLife = $ptItemInfo[$ptItemId]['shelfLife'] ?? 7;
  977. $ratioType = $ptItemInfo[$ptItemId]['ratioType'] ?? 0;
  978. $variety = $ptItemInfo[$ptItemId]['variety'] ?? 0;
  979. $stockWarning = $ptItemInfo[$ptItemId]['stockWarning'] ?? 5;
  980. $weight = $ptItemInfo[$ptItemId]['weight'] ?? 1;
  981. $bigUnit = $ptItemInfo[$ptItemId]['bigUnit'] ?? '扎';
  982. $smallUnit = $ptItemInfo[$ptItemId]['smallUnit'] ?? '支';
  983. $bigUnitId = $ptItemInfo[$ptItemId]['bigUnitId'] ?? 1;
  984. $smallUnitId = $ptItemInfo[$ptItemId]['smallUnitId'] ?? 2;
  985. $cover = $ptItemInfo[$ptItemId]['cover'] ?? 'default-img.png';
  986. $v['ratio'] = $ratio;
  987. $v['cover'] = $cover;
  988. $v['shelfLife'] = $shelfLife;
  989. $v['ratioType'] = $ratioType;
  990. $v['variety'] = $variety;
  991. $v['stockWarning'] = $stockWarning;
  992. $v['weight'] = $weight;
  993. $v['bigUnit'] = $bigUnit;
  994. $v['smallUnit'] = $smallUnit;
  995. $v['bigUnitId'] = $bigUnitId;
  996. $v['smallUnitId'] = $smallUnitId;
  997. $v['adminId'] = $adminId;
  998. $v['sjId'] = $sjId;
  999. $v['shopId'] = $shopId;
  1000. $v['mainId'] = $mainId;
  1001. $v['staffName'] = $shopAdmin->name ?? '';
  1002. $name = $v['name'] ?? '';
  1003. $price = is_numeric($v['price']) ? $v['price'] : 0;
  1004. $skPrice = is_numeric($v['skPrice']) ? $v['skPrice'] : 0;
  1005. $cost = is_numeric($v['cost']) ? $v['cost'] : 0;
  1006. if ($price <= 0) {
  1007. util::fail("请填写{$name}的批发价");
  1008. }
  1009. if ($skPrice <= 0) {
  1010. util::fail("请填写{$name}的零售价");
  1011. }
  1012. if ($cost <= 0) {
  1013. util::fail("请填写{$name}的成本价");
  1014. }
  1015. if ($price > $skPrice) {
  1016. util::fail("{$name}的批发价比零售价还高");
  1017. }
  1018. if ($cost > $price) {
  1019. util::fail("{$name}的成本价比批发价还高");
  1020. }
  1021. $skMore = bcsub($skPrice, $price, 2);
  1022. $addPrice = bcsub($price, $cost, 2);
  1023. $v['skMore'] = $skMore;
  1024. $v['addPrice'] = $addPrice;
  1025. $v['hjAddPrice'] = $addPrice;
  1026. $v['hjPrice'] = $price;
  1027. ProductClass::addProduct($v, $shop);
  1028. }
  1029. $transaction->commit();
  1030. util::complete('添加成功');
  1031. } catch (Exception $e) {
  1032. $transaction->rollBack();
  1033. util::fail();
  1034. }
  1035. }
  1036. public function actionDelete()
  1037. {
  1038. util::fail('不能删除哦!');
  1039. }
  1040. //获取平台里的花材信息
  1041. public function actionPlatformItem()
  1042. {
  1043. $py = Yii::$app->request->get('py', '');
  1044. $where = [];
  1045. if ($py) {
  1046. $where = ['py' => $py];
  1047. }
  1048. $list = PtItemClass::getItemList($where);
  1049. util::success($list);
  1050. }
  1051. //列出需要进行颜色管理的花材 ssh 20220820
  1052. public function actionColorList()
  1053. {
  1054. $mainId = $this->mainId ?? 0;
  1055. $list = ItemClass::getAllByCondition(['mainId' => $mainId, 'variety' => 1], null, '*');
  1056. util::success(['list' => $list]);
  1057. }
  1058. //多颜色管理启用与停用 ssh 20221229
  1059. public function actionChangeVariety()
  1060. {
  1061. $get = Yii::$app->request->get();
  1062. $id = $get['id'] ?? 0;
  1063. $variety = $get['variety'] ?? 0;
  1064. $info = ItemClass::getById($id, true);
  1065. if (empty($info) || $info->mainId != $this->mainId) {
  1066. util::fail('操作失败');
  1067. }
  1068. $info->variety = $variety;
  1069. $info->save();
  1070. util::complete('操作成功');
  1071. }
  1072. //拆散花材 ssh 20221229
  1073. public function actionBreakItem()
  1074. {
  1075. util::fail('开发中');
  1076. util::complete();
  1077. }
  1078. //批量修改花材的负责人 ssh 20240718
  1079. public function actionChangeCgStaff()
  1080. {
  1081. $get = Yii::$app->request->get();
  1082. $beforeId = $get['beforeId'] ?? 0;
  1083. $newId = $get['newId'] ?? 0;
  1084. if (empty($beforeId) || empty($newId)) {
  1085. util::fail('员工信息有问题');
  1086. }
  1087. $new = ShopAdminClass::getById($newId, true);
  1088. if (empty($new) || $new->mainId != $this->mainId) {
  1089. util::fail('错误的员工信息');
  1090. }
  1091. $before = ShopAdminClass::getById($beforeId, true);
  1092. if (empty($before) || $before->mainId != $this->mainId) {
  1093. util::fail('错误的员工信息2');
  1094. }
  1095. $newName = $new->name ?? '';
  1096. ItemClass::updateByCondition(['mainId' => $this->mainId, 'cgStaffId' => $beforeId], ['cgStaffId' => $newId, 'cgStaffName' => $newName]);
  1097. $shop = $this->shop;
  1098. $bookSn = $shop->bookSn ?? 0;
  1099. if (!empty($bookSn)) {
  1100. BookItemClass::updateByCondition(['bookSn' => $bookSn, 'cgStaffId' => $beforeId], ['cgStaffId' => $newId, 'cgStaffName' => $newName]);
  1101. }
  1102. util::complete('修改成功');
  1103. }
  1104. }