ProductController.php 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573
  1. <?php
  2. /**
  3. * User: admin
  4. * Date Time: 2021/1/15 20:36
  5. */
  6. namespace ghs\controllers;
  7. use biz\admin\classes\AdminRoleClass;
  8. use biz\item\classes\PtItemClass;
  9. use biz\wx\classes\WxMessageClass;
  10. use bizGhs\cp\classes\CpClass;
  11. use bizGhs\cp\classes\CpItemClass;
  12. use bizGhs\custom\classes\CustomClass;
  13. use bizGhs\item\classes\ItemClass;
  14. use bizGhs\item\classes\ItemClassClass;
  15. use bizGhs\merchant\classes\ShopClass;
  16. use bizGhs\notify\classes\NotifyClass;
  17. use bizGhs\order\classes\PurchaseOrderClass;
  18. use bizGhs\product\classes\ProductClass;
  19. use bizGhs\product\models\Product;
  20. use bizGhs\product\services\ProductService;
  21. use bizGhs\shop\classes\ShopAdminClass;
  22. use bizGhs\stock\classes\StockInDayClass;
  23. use common\components\imgUtil;
  24. use common\components\noticeUtil;
  25. use common\components\printUtil;
  26. use common\components\stringUtil;
  27. use common\components\util;
  28. use bizGhs\stock\classes\OnStockRecordClass;
  29. use Yii;
  30. class ProductController extends BaseController
  31. {
  32. public $guestAccess = ['index'];
  33. //修改路上库存 ssh 20231219
  34. public function actionModifyOnStock()
  35. {
  36. $get = Yii::$app->request->get();
  37. $id = $get['id'] ?? 0;
  38. $onStock = $get['onStock'] ?? 0;
  39. $info = ProductClass::getLockById($id);
  40. ProductClass::check($info, $this->mainId);
  41. $oldOnStock = $info->onStock ?? 0;
  42. $newOnStock = $onStock;
  43. $num = bcsub($newOnStock, $oldOnStock);
  44. $num = abs($num);
  45. $staff = $this->shopAdmin;
  46. $staffName = $staff->name ?? '';
  47. $onRecord = [];
  48. $onRecord['sjId'] = $this->sjId;
  49. $onRecord['shopId'] = $this->shopId;
  50. $onRecord['mainId'] = $this->mainId;
  51. $onRecord['orderSn'] = '';
  52. $onRecord['productId'] = $id;
  53. $onRecord['itemId'] = $info->itemId ?? 0;
  54. $onRecord['relateName'] = $staffName;
  55. $onRecord['itemNum'] = $num;
  56. $onRecord['oldStock'] = $oldOnStock;
  57. $onRecord['newStock'] = $newOnStock;
  58. $onRecord['ptStyle'] = 2;
  59. OnStockRecordClass::modify($onRecord);
  60. $info->onStock = $newOnStock;
  61. $info->save();
  62. util::complete('修改成功');
  63. }
  64. //停止预售 ssh 20230224
  65. public function actionCancelPreSell()
  66. {
  67. $get = Yii::$app->request->get();
  68. $id = $get['id'] ?? 0;
  69. $info = ProductClass::getById($id, true);
  70. ProductClass::check($info, $this->mainId);
  71. if ($info->stock > 0) {
  72. util::fail('没有库存才能停止预售');
  73. }
  74. $info->presell = 0;
  75. $info->presellDate = '';
  76. $info->save();
  77. util::complete();
  78. }
  79. //修改预售 ssh 20221214
  80. public function actionChangePresell()
  81. {
  82. $post = Yii::$app->request->post();
  83. $id = $post['id'] ?? 0;
  84. $info = ProductClass::getById($id, true);
  85. ProductClass::check($info, $this->mainId);
  86. $str = $post['date'] ?? '';
  87. $presell = $post['presell'] ?? 0;
  88. $newStr = '';
  89. if ($presell == 1) {
  90. if (empty($str)) {
  91. util::fail('请填写预售日期');
  92. }
  93. $arr = json_decode($str, true);
  94. if (empty($arr)) {
  95. util::fail('请填写预售日期');
  96. }
  97. $new = [];
  98. foreach ($arr as $date) {
  99. $new[] = strtotime($date);
  100. }
  101. $new = array_unique(array_filter($new));
  102. asort($new);
  103. $newStr = implode(',', $new);
  104. }
  105. $info->presell = $presell;
  106. $info->presellDate = $newStr;
  107. $info->discountPrice = 0;
  108. $info->save();
  109. util::complete();
  110. }
  111. //取消满减 ssh 20231216
  112. public function actionCancelFullOff()
  113. {
  114. $get = Yii::$app->request->get();
  115. $id = $get['id'] ?? 0;
  116. $info = ProductClass::getById($id, true);
  117. ProductClass::check($info, $this->mainId);
  118. $info->reachNum = 0;
  119. $info->reachNumDiscount = 0;
  120. $info->save();
  121. util::complete('取消成功');
  122. }
  123. //取消特价 ssh 20220901
  124. public function actionCancelDiscount()
  125. {
  126. $get = Yii::$app->request->get();
  127. $id = $get['id'] ?? 0;
  128. $info = ProductClass::getById($id, true);
  129. ProductClass::check($info, $this->mainId);
  130. $info->discountPrice = 0;
  131. $info->skDiscountPrice = 0;
  132. $info->hjDiscountPrice = 0;
  133. $info->save();
  134. util::complete('取消成功');
  135. }
  136. //打印花材的标签 ssh 20220602
  137. public function actionPrint()
  138. {
  139. $get = Yii::$app->request->get();
  140. $id = $get['id'] ?? 0;
  141. $num = $get['num'] ?? 1;
  142. $num = floatval($num);
  143. $num = (int)$num;
  144. $type = $get['type'] ?? 0;
  145. $info = ProductClass::getById($id, true);
  146. if (empty($info)) {
  147. util::fail('没有找到花材');
  148. }
  149. $name = $info->name ?? '';
  150. $ptItemId = $info->itemId ?? 0;
  151. $mainId = $info->mainId ?? 0;
  152. $ext = $this->shopExt;
  153. $printLabelSn = $ext->printLabelSn ?? '';
  154. if (empty($printLabelSn)) {
  155. util::fail('请设置标签打印机');
  156. }
  157. $p = new printUtil($printLabelSn);
  158. $unit = $info->ratio . $info->smallUnit . '/' . $info->bigUnit;
  159. if (isset($info->ratioType) && $info->ratioType == 1) {
  160. $unit = '若干' . $info->smallUnit . '/' . $info->bigUnit;
  161. }
  162. $p->times = $num;
  163. if (stringUtil::getWordNum($name) > 7) {
  164. $content = '<TEXT x="30" y="30" font="12" w="1" h="1" r="0">' . $name . '</TEXT>';
  165. } else {
  166. $content = '<TEXT x="30" y="30" font="12" w="2" h="2" r="0">' . $name . '</TEXT>';
  167. }
  168. //杭州斗南批发店
  169. if (isset($get['type']) == false && $this->shopId == 4608) {
  170. $content .= '<QR x="35" y="100" e="L" w="5">' . Yii::$app->params['mallHost'] . "/item/show-info?id=" . $id . '</QR>';
  171. $content .= '<TEXT x="40" y="270" font="12" w="1" h="1" r="0">扫码看价格</TEXT>';
  172. } else {
  173. if ($type == 0) {
  174. //打标签
  175. $content .= '<BC128 x="30" y="115" h="75" s="1" r="0" n="3" w="10">' . $ptItemId . '</BC128>';
  176. if (in_array($mainId, [52, 1459])) {
  177. $content .= '<TEXT x="30" y="250" font="12" w="2" h="2" r="0">惠雅鲜花</TEXT>';
  178. } else {
  179. $content .= '<TEXT x="30" y="250" font="12" w="1" h="1" r="0">' . $unit . '</TEXT>';
  180. }
  181. } else {
  182. //打价码
  183. $content .= '<QR x="35" y="100" e="L" w="5">' . Yii::$app->params['mallHost'] . "/item/show-info?id=" . $id . '</QR>';
  184. $content .= '<TEXT x="40" y="270" font="12" w="1" h="1" r="0">扫码看价格</TEXT>';
  185. }
  186. }
  187. $p->printLabelMsg($content);
  188. util::complete();
  189. }
  190. //取出今天有入库的花材 ssh 20221024
  191. public function actionStockIn()
  192. {
  193. $py = Yii::$app->request->get('py', '');
  194. $version = Yii::$app->request->get('version', 0);
  195. if ($version == 0) {
  196. util::fail('请先升级版本到1.0.70以上');
  197. }
  198. $classInfo = ItemClassClass::getGhsItemClassAll($this->mainId);
  199. $mainId = $this->mainId ?? 0;
  200. $where['mainId'] = $mainId;
  201. if ($py) {
  202. $pyName = strtolower($py);
  203. $where['py'] = $pyName;
  204. }
  205. $arr = StockInDayClass::getAllByCondition(['mainId' => $mainId], null, '*');
  206. if (empty($arr)) {
  207. util::fail('没有花材需要盘点');
  208. }
  209. $ids = array_column($arr, 'itemId');
  210. $ids = array_unique($ids);
  211. $where['id'] = ['in', $ids];
  212. $level = 1;
  213. $field = 'id,py,cover,name,ratio,cost,addPrice,classId,skMore,skPrice,itemId,smallUnit,smallRatio,presellDate,bigUnit,smallUnit,ratioType,variety,price,stock,stockWarning,discountPrice,presell,presellDate';
  214. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  215. $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
  216. $data = ProductService::assembleData($classInfo, $itemInfoData, true);
  217. util::success($data);
  218. }
  219. //按分类列出所有花材
  220. public function actionShow()
  221. {
  222. $py = Yii::$app->request->get('py', '');
  223. $name = Yii::$app->request->get('name', '');
  224. $requestType = Yii::$app->request->get('requestType', 'common');
  225. //默认显示上架商品
  226. $status = Yii::$app->request->get('status', 1);
  227. //默认显示未删除商品
  228. $delStatus = Yii::$app->request->get('delStatus', 0);
  229. $classId = Yii::$app->request->get('classId', 0);
  230. //获取所有当前供货商的分类 (全部、常用)
  231. //根据分类组装分类下的花材信息
  232. //中央ID
  233. $classInfo = ItemClassClass::getGhsItemClassAll($this->mainId);
  234. $where['mainId'] = $this->mainId;
  235. if ($py) {
  236. $pyName = strtolower($py);
  237. $where['py'] = $pyName;
  238. }
  239. //改价和全部有库存花材列表
  240. if ($requestType == 'changePrice' || $requestType == 'hasStockList') {
  241. $where['stock>'] = 0;
  242. }
  243. if (!empty($status)) {
  244. $where['status'] = $status;
  245. if ($requestType == 'itemList') {
  246. unset($where['status']);
  247. }
  248. }
  249. if ($requestType == 'book') {
  250. unset($where['status']);
  251. }
  252. $where['delStatus'] = $delStatus;
  253. if (!empty($classId)) {
  254. $where['classId'] = $classId;
  255. }
  256. if (!empty($name)) {
  257. if (stringUtil::isLetter($name)) {
  258. $name = strtolower($name);
  259. $where['py'] = ['like', $name];
  260. } else {
  261. $where['name'] = ['like', $name];
  262. }
  263. }
  264. //客户等级
  265. $customId = Yii::$app->request->get('customId', 0);
  266. $level = 1;
  267. if (!empty($customId)) {
  268. $custom = CustomClass::getById($customId, true);
  269. $level = $custom->level ?? 1;
  270. }
  271. $itemInfoData = [];
  272. if ($requestType == 'hasStockList') {
  273. //有库存的花材列表
  274. $field = 'id,py,cover,name,classId,itemId,price,skPrice,hjPrice,stock,cost';
  275. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  276. if (!empty($itemInfoData)) {
  277. foreach ($itemInfoData as $key => $val) {
  278. //以下参数主要是网页批量改价要用到
  279. $shortCover = $val['cover'] ?? '';
  280. $itemInfoData[$key]['cover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_100,w_100";
  281. $itemInfoData[$key]['shortCover'] = $shortCover;
  282. }
  283. }
  284. } elseif ($requestType == 'changePrice') {
  285. $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,hjPrice,discountPrice,hjDiscountPrice,skDiscountPrice,skMore,hjAddPrice,addPrice,variety,price,hjPrice,stock,onStock,presell,frontHide,reachNum,reachNumDiscount';
  286. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  287. $itemInfoData = ProductClass::changePriceGroup($itemInfoData, $level);
  288. } elseif ($requestType == 'changeStock') {
  289. //修改库存列表
  290. $field = 'id,py,cover,name,cost,itemId,status,classId,addPrice,skPrice,discountPrice,skMore,variety,price,stock,frontHide';
  291. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  292. $itemInfoData = ProductClass::changeStockGroup($itemInfoData, $level);
  293. } elseif ($requestType == 'kd') {
  294. //开单的花材列表
  295. $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,hjDiscountPrice,skDiscountPrice,discountPrice,stock,weight,stockWarning,presell,ratioType,smallUnit,smallRatio,bigUnit,ratio,frontHide,reachNum,reachNumDiscount';
  296. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  297. $itemInfoData = ProductClass::kdItemGroup($itemInfoData, $level);
  298. } elseif ($requestType == 'book') {
  299. //预订花材列表
  300. $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,hjDiscountPrice,skDiscountPrice,discountPrice,stock,weight,stockWarning,presell,ratioType,smallUnit,smallRatio,bigUnit,ratio,frontHide';
  301. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  302. $itemInfoData = ProductClass::bookItemGroup($itemInfoData, $level);
  303. } elseif ($requestType == 'itemList') {
  304. //花材列表
  305. $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,discountPrice,hjDiscountPrice,skDiscountPrice,stock,onStock,actualSold,status,ratio,ratioType,presell,frontHide,auth,reachNum,reachNumDiscount';
  306. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  307. $itemInfoData = ProductClass::itemListGroup($itemInfoData, $level);
  308. } elseif ($requestType == 'cgStaffList') {
  309. unset($where['status']);
  310. $where['delStatus'] = 0;
  311. $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,hjPrice,discountPrice,hjDiscountPrice,skDiscountPrice,stock,onStock,actualSold,status,ratio,ratioType,presell,frontHide,auth,reachNum,reachNumDiscount,cgStaffId,cgStaffName';
  312. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  313. $itemInfoData = ProductClass::cgStaffListGroup($itemInfoData, $level);
  314. } elseif ($requestType == 'outList') {
  315. //下架花材列表
  316. $where['status'] = 2;
  317. $where['delStatus'] = 0;
  318. $where['removeStatus'] = 0;
  319. $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,bigUnit,smallUnit,ratio,ratioType,discountPrice,skMore,variety,price,stock,presell,status';
  320. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  321. $itemInfoData = ProductClass::simpleGroup($itemInfoData, $level);
  322. } elseif ($requestType == 'stopList') {
  323. //停用花材列表
  324. unset($where['status']);
  325. $where['delStatus'] = 1;
  326. $where['removeStatus'] = 0;
  327. $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,bigUnit,smallUnit,ratio,ratioType,discountPrice,skMore,variety,price,stock,presell,status,delStatus';
  328. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  329. $itemInfoData = ProductClass::simpleGroup($itemInfoData, $level);
  330. } elseif ($requestType == 'removeList') {
  331. //删除花材列表
  332. unset($where['status']);
  333. $where['delStatus'] = 1;
  334. $where['removeStatus'] = 1;
  335. $field = 'id,py,cover,name,cost,itemId,classId,addPrice,skPrice,bigUnit,smallUnit,ratio,ratioType,discountPrice,skMore,variety,price,stock,presell,status';
  336. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  337. $itemInfoData = ProductClass::simpleGroup($itemInfoData, $level);
  338. } elseif ($requestType == 'check') {
  339. $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio,frontHide';
  340. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  341. $itemInfoData = ProductClass::checkItemGroup($itemInfoData, $level);
  342. } elseif ($requestType == 'break') {
  343. $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio,frontHide';
  344. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  345. $itemInfoData = ProductClass::breakItemGroup($itemInfoData, $level);
  346. } elseif ($requestType == 'part') {
  347. //拆散花材
  348. $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio';
  349. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  350. $itemInfoData = ProductClass::partItemGroup($itemInfoData, $level);
  351. } elseif ($requestType == 'stockOut') {
  352. $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio,smallRatio,frontHide';
  353. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  354. $itemInfoData = ProductClass::stockOutGroup($itemInfoData, $level);
  355. } elseif ($requestType == 'cg') {
  356. $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,presell,ratioType,smallUnit,bigUnit,ratio,weight,frontHide';
  357. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  358. $itemInfoData = ProductClass::cgItemGroup($itemInfoData, $level);
  359. } elseif ($requestType == 'warning') {
  360. $field = 'id,py,cover,name,cost,itemId,classId,skPrice,variety,price,discountPrice,stock,onStock,actualSold,presell,bigUnit,stockWarning,status,frontHide';
  361. $itemInfoData = Product::find()->where("mainId={$this->mainId}")
  362. ->andWhere('`stock`+`onStock`<`stockWarning`')
  363. ->andWhere("delStatus=0")
  364. ->select($field)->asArray()->all();
  365. $itemInfoData = ProductClass::warningGroup($itemInfoData, $level);
  366. } else {
  367. util::fail('没有数据');
  368. }
  369. $data = ProductService::assembleItemData($classInfo, $itemInfoData);
  370. util::success($data);
  371. }
  372. //取出今天有入库的花材 ssh 20221224
  373. public function actionGetStockIn()
  374. {
  375. $py = Yii::$app->request->get('py', '');
  376. $version = Yii::$app->request->get('version', 0);
  377. if ($version == 0) {
  378. util::fail('请先升级版本到1.0.70以上');
  379. }
  380. $classInfo = ItemClassClass::getGhsItemClassAll($this->mainId);
  381. $mainId = $this->mainId ?? 0;
  382. $where['mainId'] = $mainId;
  383. if ($py) {
  384. $pyName = strtolower($py);
  385. $where['py'] = $pyName;
  386. }
  387. $arr = StockInDayClass::getAllByCondition(['mainId' => $mainId], null, '*');
  388. if (empty($arr)) {
  389. util::fail('没有花材需要盘点');
  390. }
  391. $ids = array_column($arr, 'itemId');
  392. $ids = array_unique($ids);
  393. $where['id'] = ['in', $ids];
  394. $level = 1;
  395. $field = 'id,py,cover,name,itemId,classId,variety,price,discountPrice,stock,stockWarning,presell,ratioType,smallUnit,bigUnit,ratio';
  396. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  397. $itemInfoData = ProductClass::checkItemGroup($itemInfoData, $level);
  398. $data = ProductService::assembleItemData($classInfo, $itemInfoData);
  399. util::success($data);
  400. }
  401. //按分类列出所有花材
  402. public function actionIndex()
  403. {
  404. $py = Yii::$app->request->get('py', '');
  405. $requestType = Yii::$app->request->get('requestType', 'common');
  406. //默认显示上架商品
  407. $status = Yii::$app->request->get('status', 1);
  408. //默认显示未删除商品
  409. $delStatus = Yii::$app->request->get('delStatus', 0);
  410. $warning = Yii::$app->request->get('warning', 0);
  411. //获取所有当前供货商的分类 (全部、常用)
  412. //根据分类组装分类下的花材信息
  413. //中央ID
  414. $classInfo = ItemClassClass::getGhsItemClassAll($this->mainId);
  415. $where['mainId'] = $this->mainId;
  416. if ($py) {
  417. $pyName = strtolower($py);
  418. $where['py'] = $pyName;
  419. }
  420. if ($requestType == 'hasStock') {
  421. //改价只显示库存大于0的
  422. $where['stock>'] = 0;
  423. }
  424. if (!empty($status)) {
  425. $where['status'] = $status;
  426. }
  427. $where['delStatus'] = $delStatus;
  428. //客户等级
  429. $customId = Yii::$app->request->get('customId', 0);
  430. $level = 1;
  431. if (!empty($customId)) {
  432. $custom = CustomClass::getById($customId, true);
  433. $level = $custom->level ?? 1;
  434. }
  435. if ($warning == 1) {
  436. //库存预警
  437. $field = 'id,py,cover,name,ratio,cost,addPrice,classId,skMore,skPrice,itemId,smallUnit,smallRatio,presellDate,bigUnit,smallUnit,ratioType,variety,price,stock,stockWarning,discountPrice,presell';
  438. $itemInfoData = Product::find()->where("mainId={$this->mainId}")
  439. ->andWhere('`stock`<`stockWarning`')
  440. ->andWhere("delStatus=0")
  441. ->select($field)->asArray()->all();
  442. } else {
  443. $field = 'id,py,cover,name,ratio,cost,addPrice,classId,skMore,skPrice,itemId,smallUnit,smallRatio,presellDate,bigUnit,smallUnit,ratioType,variety,price,stock,stockWarning,discountPrice,presell';
  444. $itemInfoData = ProductClass::getAllByCondition($where, ['inTurn' => SORT_DESC, 'actualSold' => SORT_DESC], $field);
  445. }
  446. $itemInfoData = ProductClass::groupProductInfo($itemInfoData, $level);
  447. $data = ProductService::assembleData($classInfo, $itemInfoData, true);
  448. util::success($data);
  449. }
  450. //所有花材分页和不分页
  451. public function actionList()
  452. {
  453. $where = [];
  454. $classId = Yii::$app->request->get('classId', 0);
  455. if (!empty($classId)) {
  456. $where['classId'] = $classId;
  457. }
  458. $name = Yii::$app->request->get('name', '');
  459. if (empty($name)) {
  460. $py = Yii::$app->request->get('py', '');
  461. $name = !empty($py) ? $py : '';
  462. }
  463. if (!empty($name)) {
  464. if (stringUtil::isLetter($name)) {
  465. $where['py'] = ['like', $name];
  466. } else {
  467. $where['name'] = ['like', $name];
  468. }
  469. }
  470. $status = Yii::$app->request->get('status', 0);
  471. if (!empty($status)) {
  472. $where['status'] = $status;
  473. }
  474. $delStatus = Yii::$app->request->get('delStatus', 0);
  475. if ($delStatus != 2) {
  476. $where['delStatus'] = $delStatus;
  477. }
  478. $where['mainId'] = $this->mainId;
  479. $productIds = Yii::$app->request->get('ids', '');
  480. if (!empty($productIds)) {
  481. $productIdArr = explode(',', $productIds);
  482. if (!empty($productIdArr)) {
  483. $where['id'] = ['in', $productIdArr];
  484. }
  485. }
  486. //输出标准会员价,即批发价,默认显示的是批发价
  487. $level = 1;
  488. $type = Yii::$app->request->get('type', '');
  489. $showPage = Yii::$app->request->get('showPage', 0);
  490. if ($showPage) {
  491. if ($type == 'waring') {
  492. $pro = Product::find()->where("mainId={$this->mainId}")->andWhere('`stock`<`stockWarning`')->select('id')->asArray()->all();
  493. $lackIds = array_column($pro, 'id');
  494. if (empty($lackIds)) {
  495. util::success([]);
  496. }
  497. $lackIds = array_filter(array_unique($lackIds));
  498. $where['id'] = ['in', $lackIds];
  499. $respond = ProductClass::getList("*", $where, "actualSold desc");
  500. } else {
  501. $respond = ProductClass::getList("*", $where, "inTurn desc");
  502. }
  503. $respond['list'] = ProductClass::groupProductInfo($respond['list'], $level);
  504. $respond['list'] = ProductClass::groupClassName($this->sjId, $respond['list']);
  505. util::success($respond);
  506. } else {
  507. if ($type == 'waring') {
  508. //库存预警 按库存从小到大排序
  509. $data = ProductClass::getAllByCondition($where, ['stock' => SORT_ASC, 'inTurn' => SORT_DESC], "*");
  510. } else {
  511. if (!empty($productIds)) {
  512. //优先按 $productIds 排序 "FIELD(`id`,4,5,6)"=>true
  513. $data = ProductClass::getAllByCondition($where, ["FIELD(`id`,$productIds)" => true, 'inTurn' => SORT_DESC], "*");
  514. } else {
  515. $data = ProductClass::getAllByCondition($where, ['actualSold' => SORT_DESC, 'inTurn' => SORT_DESC], "*");
  516. }
  517. }
  518. $data = ProductClass::groupProductInfo($data, $level);
  519. $data = ProductClass::groupClassName($this->sjId, $data);
  520. if ($type == 'waring') {
  521. //库存预警
  522. $newData = [];
  523. foreach ($data as $v) {
  524. if ($v['stock'] <= $v['stockWarning']) {
  525. $newData[] = $v;
  526. }
  527. }
  528. util::success(['list' => $newData]);
  529. }
  530. util::success(['list' => $data]);
  531. }
  532. }
  533. //所有花材
  534. public function actionAll()
  535. {
  536. $where = [];
  537. $where['mainId'] = $this->mainId;
  538. $classId = Yii::$app->request->get('classId', 0);
  539. if (!empty($classId)) {
  540. $where['classId'] = $classId;
  541. }
  542. $status = Yii::$app->request->get('status', 0);
  543. if (!empty($status)) {
  544. $where['status'] = $status;
  545. }
  546. $delStatus = Yii::$app->request->get('delStatus', 0);
  547. if ($delStatus != 2) {
  548. $where['delStatus'] = $delStatus;
  549. }
  550. //输出标准会员价,即批发价,默认显示的是批发价
  551. $level = 1;
  552. $data = ProductClass::getAllByCondition($where, ['actualSold' => SORT_DESC, 'inTurn' => SORT_DESC], "*");
  553. $data = ProductClass::groupProductInfo($data, $level);
  554. util::success(['list' => $data]);
  555. }
  556. //批量改价
  557. public function actionBatchChangePrice()
  558. {
  559. $shop = $this->shop;
  560. $join = $shop->join ?? 0;
  561. $default = $shop->default ?? 0;
  562. if ($join == 0 && $default == 0) {
  563. util::fail('当前直营分店,只能回总店修改价格');
  564. }
  565. $shopAdmin = $this->shopAdmin;
  566. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  567. util::fail('超管才能修改');
  568. }
  569. $shop = $this->shop;
  570. $default = $shop->default ?? 0;
  571. $adminId = $this->adminId ?? 0;
  572. //normal常规改价,cg采购改价
  573. $changeType = Yii::$app->request->post('changeType', 'normal');
  574. $targetId = Yii::$app->request->post('targetId', 0);
  575. $changeParams = ['staffId' => $shopAdmin->id, 'staffName' => $shopAdmin->name, 'changeType' => $changeType, 'targetId' => $targetId];
  576. $post = Yii::$app->request->post();
  577. $data = $post['data'] ?? '';
  578. if (empty($data)) {
  579. util::fail('没有修改');
  580. }
  581. $arr = json_decode($data, true);
  582. if (empty($arr)) {
  583. util::fail('没有修改哦');
  584. }
  585. $appVersion = $post['appVersion'] ?? 0;
  586. if ($appVersion != 1) {
  587. util::fail('请先升级应用');
  588. }
  589. //解决重复请求问题
  590. $cacheKey = 'batch_change_price_' . $targetId;
  591. $has = Yii::$app->redis->executeCommand('GET', [$cacheKey]);
  592. if (!empty($has)) {
  593. util::fail('请5秒后操作');
  594. }
  595. Yii::$app->redis->executeCommand('SETEX', [$cacheKey, 5, 'has']);
  596. $connection = Yii::$app->db;
  597. $transaction = $connection->beginTransaction();
  598. try {
  599. $needNotice = false;
  600. $cg = PurchaseOrderClass::getLockById($targetId);
  601. if (!empty($cg)) {
  602. if (isset($cg->mainId) == false || $cg->mainId != $this->mainId) {
  603. util::fail('不是您的采购单');
  604. }
  605. //批量改价同时入库
  606. if ($cg->status == PurchaseOrderClass::PURCHASE_ORDER_STATUS_SENDING) {
  607. $staff = $this->shopAdmin;
  608. $data = [];
  609. $data['staffId'] = $staff->id ?? 0;
  610. $data['staffName'] = $staff->name ?? '';
  611. $data['adminId'] = $this->adminId ?? 0;
  612. PurchaseOrderClass::putIn($cg, $data);
  613. $needNotice = true;
  614. }
  615. }
  616. $ids = array_column($arr, 'id');
  617. $ids = array_unique(array_filter($ids));
  618. if (empty($ids)) {
  619. util::fail('请选择花材');
  620. }
  621. $sjId = $shop->sjId ?? 0;
  622. $chainShopList = [];
  623. if ($default == 1) {
  624. $chainShopList = ShopClass::getAllByCondition(['sjId' => $sjId, 'join' => 0], null, '*', null, true);
  625. }
  626. $productList = ProductClass::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id', true);
  627. foreach ($arr as $product) {
  628. $productId = $product['id'];
  629. $productInfo = $productList[$productId] ?? [];
  630. if (empty($productInfo)) {
  631. util::fail('没有找到花材');
  632. }
  633. $productName = $productInfo->name ?? '';
  634. if (isset($product['id']) == false) {
  635. util::fail('没有花材');
  636. }
  637. if (isset($product['price']) == false || is_numeric($product['price']) == false || $product['price'] < 0) {
  638. util::fail('请填写' . $productName . '的批发价');
  639. }
  640. $price = $product['price'];
  641. if (isset($product['skPrice']) == false || is_numeric($product['skPrice']) == false || $product['skPrice'] < 0) {
  642. util::fail('请填写' . $productName . '的零售价');
  643. }
  644. $skPrice = $product['skPrice'];
  645. if (isset($product['hjPrice']) == false || is_numeric($product['hjPrice']) == false || $product['hjPrice'] < 0) {
  646. util::fail('请填写' . $productName . '的会员价');
  647. }
  648. $hjPrice = $product['hjPrice'] ?? 0;
  649. if (isset($productInfo->mainId) == false || $productInfo->mainId != $this->mainId) {
  650. util::fail('无法访问');
  651. }
  652. if ($hjPrice > $price) {
  653. util::fail($productName . ' 批发价要大于会员价');
  654. }
  655. if ($price > $skPrice) {
  656. util::fail($productName . ' 零售价要大于批发价');
  657. }
  658. $ptItemId = $productInfo->itemId;
  659. ProductClass::changeSinglePrice($shop, $ptItemId, $price, $skPrice, $hjPrice, $changeParams);
  660. //在首店修改需要同步到所有直营店
  661. if ($default == 1 && isset($shop->dataSync) && $shop->dataSync == 1) {
  662. foreach ($chainShopList as $chain) {
  663. if ($chain->id == $shop->id) {
  664. continue;
  665. }
  666. $chainMainId = $chain->mainId ?? 0;
  667. $staff = ShopAdminClass::getByCondition(['mainId' => $chainMainId, 'adminId' => $adminId], true);
  668. $staffId = $staff->id ?? 0;
  669. $staffName = $staff->name ?? '';
  670. $changeParams2 = ['staffId' => $staffId, 'staffName' => $staffName, 'changeType' => $changeType, 'targetId' => $targetId];
  671. ProductClass::changeSinglePrice($chain, $ptItemId, $price, $skPrice, $hjPrice, $changeParams2);
  672. }
  673. }
  674. }
  675. $mainId = $shop->mainId ?? 0;
  676. if (!empty($mainId)) {
  677. //提醒零售收银台界面要刷新
  678. $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
  679. if (!empty($staffList)) {
  680. foreach ($staffList as $staff) {
  681. $staffId = $staff->id ?? 0;
  682. Yii::$app->redis->executeCommand('SET', ['cashier_' . $mainId . '_' . $staffId . '_may_refresh', 'yes']);
  683. Yii::$app->redis->executeCommand('SET', ['ghs_cashier_' . $mainId . '_' . $staffId . '_may_refresh', 'yes']);
  684. }
  685. }
  686. }
  687. $transaction->commit();
  688. //入库成功通知相关人员,关键词 put_in_notice
  689. if ($needNotice) {
  690. $cg = PurchaseOrderClass::getLockById($targetId);
  691. WxMessageClass::ghsCgEntryInform($shop, $cg);
  692. }
  693. util::complete('操作成功');
  694. } catch (\Exception $e) {
  695. $transaction->rollBack();
  696. $msg = $e->getMessage();
  697. Yii::info("修改失败原因:" . $msg);
  698. noticeUtil::push("修改价格出现失败情况,原因:" . $msg, '15280215347');
  699. util::fail('修改失败');
  700. }
  701. }
  702. //多个花材同时改成一个价 ssh 20231003
  703. public function actionManyItemChangeOnePrice()
  704. {
  705. $shop = $this->shop;
  706. $join = $shop->join ?? 0;
  707. $default = $shop->default ?? 0;
  708. if ($join == 0 && $default == 0) {
  709. util::fail('当前直营分店,只能回总店修改价格');
  710. }
  711. $shopAdmin = $this->shopAdmin;
  712. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  713. util::fail('超管才能修改');
  714. }
  715. $post = Yii::$app->request->post();
  716. $idsList = $post['ids'] ?? '';
  717. $ids = json_decode($idsList, true);
  718. if (empty($ids)) {
  719. util::fail('请选择花材');
  720. }
  721. $list = ProductClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
  722. if (empty($list)) {
  723. util::fail('请选择花材哦');
  724. }
  725. $mainId = $this->mainId;
  726. $adminId = $this->adminId ?? 0;
  727. $shop = $this->shop;
  728. $default = $shop->default ?? 0;
  729. $shopAdmin = $this->shopAdmin;
  730. $price = $post['price'] ?? 0;
  731. if (is_numeric($price) == false) {
  732. util::fail('批发价填写错误');
  733. }
  734. $skPrice = $post['skPrice'] ?? 0;
  735. if (is_numeric($skPrice) == false) {
  736. util::fail('散客价填写错误');
  737. }
  738. $hjPrice = $post['hjPrice'] ?? 0;
  739. if (is_numeric($hjPrice) == false) {
  740. util::fail('会员价填写错误');
  741. }
  742. if ($hjPrice > $price) {
  743. util::fail('会员价不能大于批发价');
  744. }
  745. if ($price > $skPrice) {
  746. util::fail('批发价不能大于零售价');
  747. }
  748. $sjId = $shop->sjId ?? 0;
  749. $chainShopList = [];
  750. if ($default == 1) {
  751. $chainShopList = ShopClass::getAllByCondition(['sjId' => $sjId, 'join' => 0], null, '*', null, true);
  752. }
  753. //normal常规改价,cg采购改价
  754. $changeType = Yii::$app->request->post('changeType', 'normal');
  755. $targetId = 0;
  756. $changeParams = ['staffId' => $shopAdmin->id, 'staffName' => $shopAdmin->name, 'changeType' => $changeType, 'targetId' => $targetId];
  757. $connection = Yii::$app->db;
  758. $transaction = $connection->beginTransaction();
  759. try {
  760. foreach ($list as $product) {
  761. if ($product->mainId != $mainId) {
  762. util::fail('修改失败,不是你的花材');
  763. }
  764. $ptItemId = $product->itemId;
  765. ProductClass::changeSinglePrice($shop, $ptItemId, $price, $skPrice, $hjPrice, $changeParams);
  766. //在首店修改需要同步到所有直营店
  767. if ($default == 1 && isset($shop->dataSync) && $shop->dataSync == 1) {
  768. if (!empty($chainShopList)) {
  769. foreach ($chainShopList as $chain) {
  770. if ($chain->id == $shop->id) {
  771. continue;
  772. }
  773. $chainMainId = $chain->mainId ?? 0;
  774. $staff = ShopAdminClass::getByCondition(['mainId' => $chainMainId, 'adminId' => $adminId], true);
  775. $changeParams2 = ['staffId' => $staff->id, 'staffName' => $staff->name, 'changeType' => $changeType, 'targetId' => $targetId];
  776. ProductClass::changeSinglePrice($chain, $ptItemId, $price, $skPrice, $hjPrice, $changeParams2);
  777. }
  778. }
  779. }
  780. }
  781. if (!empty($mainId)) {
  782. //提醒零售收银台界面要刷新
  783. $staffList = ShopAdminClass::getAllByCondition(['mainId' => $mainId], null, '*', null, true);
  784. if (!empty($staffList)) {
  785. foreach ($staffList as $staff) {
  786. $staffId = $staff->id ?? 0;
  787. Yii::$app->redis->executeCommand('SET', ['cashier_' . $mainId . '_' . $staffId . '_may_refresh', 'yes']);
  788. Yii::$app->redis->executeCommand('SET', ['ghs_cashier_' . $mainId . '_' . $staffId . '_may_refresh', 'yes']);
  789. }
  790. }
  791. }
  792. $transaction->commit();
  793. util::complete('修改成功');
  794. } catch (\Exception $e) {
  795. $transaction->rollBack();
  796. Yii::info("修改失败原因:" . $e->getMessage());
  797. util::fail('修改失败');
  798. }
  799. }
  800. //改价
  801. public function actionChangePrice()
  802. {
  803. $shopAdmin = $this->shopAdmin;
  804. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  805. util::fail('超管才能修改');
  806. }
  807. $productId = Yii::$app->request->post('productId', 0);
  808. $productInfo = ProductClass::getById($productId, true);
  809. if (empty($productInfo)) {
  810. util::fail("花材不存在");
  811. }
  812. if ($productInfo->mainId != $this->mainId) {
  813. util::fail('没有权限');
  814. }
  815. $price = Yii::$app->request->post('price', '');
  816. if (is_numeric($price) && $price > 0) {
  817. ProductClass::changeSinglePrice($productInfo, $price, ProductClass::PRICE_LABEL_CHANGE);
  818. } else {
  819. $price = bcadd($productInfo->cost, $productInfo->addPrice, 2);
  820. ProductClass::changeSinglePrice($productInfo, $price, ProductClass::PRICE_LABEL_AUTO);
  821. }
  822. util::success(['price' => $price]);
  823. }
  824. //恢复自动调价
  825. public function actionAutoPrice()
  826. {
  827. $productId = Yii::$app->request->post('productId', 0);
  828. $productData = ProductClass::getById($productId);
  829. if (!$productData) {
  830. util::fail("花材不存在");
  831. }
  832. //2021.04.06改为用product中的成本价+加价
  833. $price = bcadd($productData['cost'], $productData['addPrice'], 2);
  834. ProductClass::changeSinglePrice($productId, $this->shopId, $price, ProductClass::PRICE_LABEL_AUTO);
  835. util::complete("操作成功");
  836. }
  837. //修改加价
  838. public function actionChangeAddPrice()
  839. {
  840. $productId = Yii::$app->request->post('productId', 0);
  841. $addPrice = Yii::$app->request->post('addPrice', '');
  842. if ($addPrice < 0) {
  843. util::fail("加价不能小于0");
  844. }
  845. $productData = ProductClass::getProductData($productId, $this->mainId);
  846. if (!$productData) {
  847. util::fail("花材不存在");
  848. }
  849. ProductClass::changeAddPrice($productId, $addPrice);
  850. util::complete();
  851. }
  852. //批量修改更多,包括排序、重量和保质期 ssh 20211211
  853. public function actionBatchChangeMore()
  854. {
  855. $shop = $this->shop;
  856. $default = $shop->default ?? 0;
  857. if ($default == 0) {
  858. util::fail('当前直营分店,请返回总店修改');
  859. }
  860. $shopAdmin = $this->shopAdmin;
  861. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  862. util::fail('超管才能操作');
  863. }
  864. $addData = Yii::$app->request->post('addData', '');
  865. if (empty($addData)) {
  866. util::fail('没有花材');
  867. }
  868. $itemData = json_decode($addData, true);
  869. if (is_array($itemData) == false) {
  870. util::fail('没有花材...');
  871. }
  872. $ids = array_column($itemData, 'id');
  873. $infoList = ProductClass::getByIds($ids, null, 'id');
  874. if (empty($infoList)) {
  875. util::fail('没有花材');
  876. }
  877. foreach ($infoList as $info) {
  878. if (isset($info['mainId']) == false || $info['mainId'] != $this->mainId) {
  879. util::fail('不是你的花材不能修改');
  880. }
  881. }
  882. //总店修改同步到所有门店
  883. $sjId = $shop->sjId ?? 0;
  884. $chainShopList = ShopClass::getAllByCondition(['sjId' => $sjId], null, '*', null, true);
  885. foreach ($itemData as $key => $data) {
  886. $id = $data['id'] ?? 0;
  887. unset($data['id']);
  888. ProductClass::updateById($id, $data);
  889. $ptItemId = $infoList[$id]['itemId'] ?? 0;
  890. if (empty($ptItemId)) {
  891. continue;
  892. }
  893. if (isset($shop->default) && $shop->default == 1 && isset($shop->dataSync) && $shop->dataSync == 1) {
  894. foreach ($chainShopList as $chainShop) {
  895. $currentMainId = $chainShop->mainId ?? 0;
  896. if ($currentMainId == $shop->mainId) {
  897. //前面已经修改过了,不需要重复修改
  898. continue;
  899. }
  900. ProductClass::updateByCondition(['mainId' => $currentMainId, 'itemId' => $ptItemId], $data);
  901. }
  902. }
  903. }
  904. util::complete('修改成功');
  905. }
  906. //批量修改加价 ssh 20211211
  907. public function actionBatchChangeAddPrice()
  908. {
  909. $shop = $this->shop;
  910. $join = $shop->join ?? 0;
  911. $default = $shop->default ?? 0;
  912. if ($join == 0 && $default == 0) {
  913. util::fail('当前直营分店,请切回总店操作');
  914. }
  915. $shopAdmin = $this->shopAdmin;
  916. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  917. util::fail('超管才能操作');
  918. }
  919. $post = Yii::$app->request->post();
  920. $addData = $post['addData'] ?? '';
  921. if (empty($addData)) {
  922. util::fail('没有花材');
  923. }
  924. $itemData = json_decode($addData, true);
  925. if (is_array($itemData) == false) {
  926. util::fail('没有花材...');
  927. }
  928. $ids = array_column($itemData, 'id');
  929. $infoList = ProductClass::getByIds($ids, null, 'id');
  930. if (empty($infoList)) {
  931. util::fail('没有花材');
  932. }
  933. foreach ($infoList as $info) {
  934. if (isset($info['mainId']) == false || $info['mainId'] != $this->mainId) {
  935. util::fail('不能修改别人的花材');
  936. }
  937. }
  938. $appVersion = $post['appVersion'] ?? 0;
  939. if ($appVersion != 1) {
  940. util::fail('请先升级应用');
  941. }
  942. //总店修改同步到所有门店
  943. $sjId = $shop->sjId ?? 0;
  944. $chainShopList = ShopClass::getAllByCondition(['sjId' => $sjId], null, '*', null, true);
  945. foreach ($itemData as $key => $data) {
  946. $id = $data['id'] ?? 0;
  947. unset($data['id']);
  948. ProductClass::updateById($id, $data);
  949. $ptItemId = $infoList[$id]['itemId'] ?? 0;
  950. if (empty($ptItemId)) {
  951. continue;
  952. }
  953. if (isset($shop->default) && $shop->default == 1 && isset($shop->dataSync) && $shop->dataSync == 1) {
  954. foreach ($chainShopList as $chainShop) {
  955. if (isset($chainShop->join) && $chainShop->join == 1) {
  956. continue;
  957. }
  958. $currentMainId = $chainShop->mainId ?? 0;
  959. if ($currentMainId == $shop->mainId) {
  960. //前面已经修改过了,不需要重复修改
  961. continue;
  962. }
  963. ProductClass::updateByCondition(['mainId' => $currentMainId, 'itemId' => $ptItemId], $data);
  964. }
  965. }
  966. }
  967. util::complete('修改成功');
  968. }
  969. public function actionUpdate()
  970. {
  971. $shopAdmin = $this->shopAdmin;
  972. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  973. util::fail('超管才能操作');
  974. }
  975. $shop = $this->shop;
  976. $join = $shop->join ?? 0;
  977. $default = $shop->default ?? 0;
  978. if ($join == 0 && $default == 0) {
  979. //因为盘点不能将花材盘成0,所以这边放出入口允许创始人在分店修改分店的花材库存
  980. if ($shopAdmin->super != 1) {
  981. util::fail('请先开通超管权限');
  982. }
  983. }
  984. $post = Yii::$app->request->post();
  985. $discountPrice = $post['discountPrice'] ?? 0;
  986. if ($discountPrice > 0) {
  987. if (isset($post['hjDiscountPrice']) == false || empty($post['hjDiscountPrice'])) {
  988. $addPrice = $post['addPrice'] ?? 0;
  989. $hjAddPrice = $post['hjAddPrice'] ?? 0;
  990. $skMore = $post['skMore'] ?? 0;
  991. $diff = bcsub($addPrice, $hjAddPrice, 2);
  992. if ($diff > 0 && $discountPrice > $diff) {
  993. $hjDiscountPrice = bcsub($discountPrice, $diff, 2);
  994. } else {
  995. $hjDiscountPrice = $discountPrice;
  996. }
  997. $diff = bcsub($skMore, $addPrice, 2);
  998. if ($diff > 0) {
  999. $skDiscountPrice = bcadd($diff, $discountPrice, 2);
  1000. } else {
  1001. $skDiscountPrice = $discountPrice;
  1002. }
  1003. $post['skDiscountPrice'] = $skDiscountPrice;
  1004. $post['hjDiscountPrice'] = $hjDiscountPrice;
  1005. }
  1006. $reachNum = $post['reachNum'] ?? 0;
  1007. $reachNumDiscount = $post['reachNumDiscount'] ?? 0;
  1008. if ($reachNum > 0 && $reachNumDiscount > 0) {
  1009. util::fail('特价和满减不能同时进行');
  1010. }
  1011. }
  1012. $post['adminId'] = $this->adminId;
  1013. $post['staffId'] = $this->shopAdmin->id;
  1014. $post['staffName'] = $this->shopAdmin->name;
  1015. ProductClass::updateProduct($post, $this->shop);
  1016. util::complete();
  1017. }
  1018. //上下架状态控制 ssh 20210713
  1019. public function actionStatusUpdate()
  1020. {
  1021. $post = Yii::$app->request->post();
  1022. $shopAdmin = $this->shopAdmin;
  1023. $roleId = $shopAdmin['roleId'] ?? 0;
  1024. $role = AdminRoleClass::getById($roleId);
  1025. $roleName = $role['roleName'] ?? '';
  1026. if ($roleName == '员工') {
  1027. util::fail('无法操作哦');
  1028. }
  1029. $id = $post['id'] ?? 0;
  1030. $status = $post['status'] ?? 1;
  1031. $product = ProductClass::getById($id, true);
  1032. if ($product->mainId != $this->mainId) {
  1033. util::fail('无法操作');
  1034. }
  1035. $product->status = $status;
  1036. if ($status == 2) {
  1037. $product->discountPrice = 0;
  1038. }
  1039. $product->save();
  1040. util::complete();
  1041. }
  1042. //花材展示状态控制 ssh 20231113
  1043. public function actionDelStatusUpdate()
  1044. {
  1045. $post = Yii::$app->request->post();
  1046. $shop = $this->shop;
  1047. $join = $shop->join ?? 0;
  1048. $default = $shop->default ?? 0;
  1049. if ($join == 0 && $default == 0) {
  1050. util::fail('请在首店操作');
  1051. }
  1052. $id = $post['id'] ?? 0;
  1053. $delStatus = $post['delStatus'] ?? 0;
  1054. $product = ProductClass::getById($id, true);
  1055. if ($product->mainId != $this->mainId) {
  1056. util::fail('不是你的花材哦!!');
  1057. }
  1058. $product->delStatus = $delStatus;
  1059. if ($delStatus == 1) {
  1060. $product->stock = 0;
  1061. $product->status = 2;
  1062. }
  1063. $product->save();
  1064. $ptItemId = $product->itemId ?? 0;
  1065. if (isset($shop->default) && $shop->default == 1 && isset($shop->dataSync) && $shop->dataSync == 1) {
  1066. //总店修改同步到所有门店
  1067. $sjId = $shop->sjId ?? 0;
  1068. $chainShopList = ShopClass::getAllByCondition(['sjId' => $sjId], null, '*', null, true);
  1069. foreach ($chainShopList as $chainShop) {
  1070. $chainShopId = $chainShop->id ?? 0;
  1071. if (isset($chainShop->join) && $chainShop->join == 1) {
  1072. continue;
  1073. }
  1074. if ($chainShopId == $shop->id) {
  1075. continue;
  1076. }
  1077. $chainMainId = $chainShop->mainId ?? 0;
  1078. $chainProduct = ProductClass::getByCondition(['mainId' => $chainMainId, 'itemId' => $ptItemId], true);
  1079. if (!empty($chainProduct)) {
  1080. $chainProduct->delStatus = $delStatus;
  1081. if ($delStatus == 1) {
  1082. $chainProduct->stock = 0;
  1083. $chainProduct->status = 2;
  1084. }
  1085. $chainProduct->save();
  1086. }
  1087. }
  1088. }
  1089. util::complete();
  1090. }
  1091. //详情 shish 20240115
  1092. public function actionDetail()
  1093. {
  1094. $id = Yii::$app->request->get('id', 0);
  1095. $source = Yii::$app->request->get('source', '');
  1096. $respond = ProductClass::getItemInfo($id);
  1097. $ptItemId = $respond['itemId'] ?? 0;
  1098. $ptItemInfo = PtItemClass::getById($ptItemId);
  1099. $respond['ptItemInfo'] = $ptItemInfo;
  1100. //通知提醒抹除
  1101. if ($source == 'notify' && $respond['mainId'] == $this->mainId) {
  1102. $staff = $this->shopAdmin;
  1103. $staffId = $this->shopAdminId;
  1104. $notify = NotifyClass::getByCondition(['staffId' => $staffId, 'type' => 1, 'targetId' => $id], true);
  1105. if (!empty($notify)) {
  1106. if ($notify->read == 0) {
  1107. $notify->read = 1;
  1108. $notify->save();
  1109. $notifyNum = $staff->notifyNum;
  1110. if ($notifyNum > 0) {
  1111. $notifyNum--;
  1112. $staff->notifyNum = $notifyNum;
  1113. $staff->save();
  1114. }
  1115. }
  1116. }
  1117. }
  1118. //重复花材
  1119. $repeatList = ProductClass::getAllByCondition(['mainId' => $this->mainId, 'itemId' => $ptItemId, 'delStatus' => 0], null, '*', null, true);
  1120. $repeatId = 0;
  1121. if (!empty($repeatList)) {
  1122. foreach ($repeatList as $repeat) {
  1123. if ($repeat->id != $id) {
  1124. $repeatId = $repeat->id;
  1125. }
  1126. }
  1127. }
  1128. $respond['repeatId'] = $repeatId;
  1129. $cpItemList = CpItemClass::getAllByCondition(['productId' => $id], null, '*', 'cpId');
  1130. $cpInfo = [];
  1131. if (!empty($cpItemList)) {
  1132. $cpIds = array_column($cpItemList, 'cpId');
  1133. $cpList = CpClass::getByIds($cpIds);
  1134. if (!empty($cpList)) {
  1135. foreach ($cpList as $key => $val) {
  1136. $id = $val['id'] ?? 0;
  1137. $name = $val['name'] ?? '';
  1138. $cpInfo[] = ['cpId' => $id, 'cpName' => $name];
  1139. }
  1140. }
  1141. }
  1142. $respond['cpInfo'] = $cpInfo;
  1143. util::success($respond);
  1144. }
  1145. //新增花材 2021.6.21
  1146. public function actionAdd()
  1147. {
  1148. $post = Yii::$app->request->post();
  1149. //临时兼容,2023.7.1后可以删除
  1150. $appVersion = $post['appVersion'] ?? 0;
  1151. if ($appVersion != 1) {
  1152. util::fail('请先升级应用');
  1153. }
  1154. $discountPrice = $post['discountPrice'] ?? 0;
  1155. if ($discountPrice > 0) {
  1156. if (isset($post['hjDiscountPrice']) == false || empty($post['hjDiscountPrice'])) {
  1157. $addPrice = $post['addPrice'] ?? 0;
  1158. $hjAddPrice = $post['hjAddPrice'] ?? 0;
  1159. $skMore = $post['skMore'] ?? 0;
  1160. $diff = bcsub($addPrice, $hjAddPrice, 2);
  1161. if ($diff > 0 && $discountPrice > $diff) {
  1162. $hjDiscountPrice = bcsub($discountPrice, $diff, 2);
  1163. } else {
  1164. $hjDiscountPrice = $discountPrice;
  1165. }
  1166. $diff = bcsub($skMore, $addPrice, 2);
  1167. if ($diff > 0) {
  1168. $skDiscountPrice = bcadd($diff, $discountPrice, 2);
  1169. } else {
  1170. $skDiscountPrice = $discountPrice;
  1171. }
  1172. $post['skDiscountPrice'] = $skDiscountPrice;
  1173. $post['hjDiscountPrice'] = $hjDiscountPrice;
  1174. }
  1175. }
  1176. $shop = $this->shop;
  1177. $join = $shop->join ?? 0;
  1178. $default = $shop->default ?? 0;
  1179. if ($join == 0 && $default == 0) {
  1180. util::fail('当前直营分店,请切回总店添加花材');
  1181. }
  1182. $shopAdmin = $this->shopAdmin;
  1183. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  1184. util::fail('管理员才能添加花材');
  1185. }
  1186. $post['sjId'] = $this->sjId;
  1187. $post['adminId'] = $this->adminId;
  1188. $post['mainId'] = $this->mainId;
  1189. $price = $post['price'] ?? 0;
  1190. $addPrice = $post['addPrice'] ?? 0;
  1191. if ($addPrice > $price) {
  1192. util::fail('加价不能大于售价');
  1193. }
  1194. $weight = isset($post['weight']) && is_numeric($post['weight']) ? $post['weight'] : 0;
  1195. if ($weight <= 0) {
  1196. util::fail('请填写重量,最小0.1');
  1197. }
  1198. $post['staffName'] = $shopAdmin->name ?? '';
  1199. ProductClass::addProduct($post, $this->shop);
  1200. util::complete('添加成功');
  1201. }
  1202. //获取拼音缩写 ssh 20210707
  1203. public function actionPy()
  1204. {
  1205. $name = Yii::$app->request->get('name');
  1206. $py = stringUtil::py($name);
  1207. util::success(['py' => $py]);
  1208. }
  1209. //(客户端-批发商)复制花材
  1210. public function actionClone()
  1211. {
  1212. $post = Yii::$app->request->post();
  1213. $appVersion = $post['appVersion'] ?? 0;
  1214. if ($appVersion != 1) {
  1215. util::fail('请先升级应用');
  1216. }
  1217. $discountPrice = $post['discountPrice'] ?? 0;
  1218. if ($discountPrice > 0) {
  1219. if (isset($post['hjDiscountPrice']) == false || empty($post['hjDiscountPrice'])) {
  1220. $addPrice = $post['addPrice'] ?? 0;
  1221. $hjAddPrice = $post['hjAddPrice'] ?? 0;
  1222. $skMore = $post['skMore'] ?? 0;
  1223. $diff = bcsub($addPrice, $hjAddPrice, 2);
  1224. if ($diff > 0 && $discountPrice > $diff) {
  1225. $hjDiscountPrice = bcsub($discountPrice, $diff, 2);
  1226. } else {
  1227. $hjDiscountPrice = $discountPrice;
  1228. }
  1229. $diff = bcsub($skMore, $addPrice, 2);
  1230. if ($diff > 0) {
  1231. $skDiscountPrice = bcadd($diff, $discountPrice, 2);
  1232. } else {
  1233. $skDiscountPrice = $discountPrice;
  1234. }
  1235. $post['skDiscountPrice'] = $skDiscountPrice;
  1236. $post['hjDiscountPrice'] = $hjDiscountPrice;
  1237. }
  1238. }
  1239. $shop = $this->shop;
  1240. $join = $shop->join ?? 0;
  1241. $default = $shop->default ?? 0;
  1242. if ($join == 0 && $default == 0) {
  1243. util::fail('请在首店操作');
  1244. }
  1245. $shopAdmin = $this->shopAdmin;
  1246. if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
  1247. util::fail('管理员才能添加花材');
  1248. }
  1249. $post['sjId'] = $this->sjId;
  1250. $post['adminId'] = $this->adminId;
  1251. $post['mainId'] = $this->mainId;
  1252. $post['staffName'] = $shopAdmin->name ?? '';
  1253. $price = $post['price'] ?? 0;
  1254. if (empty($price) || $price <= 0) {
  1255. util::fail('请填写批发价');
  1256. }
  1257. $skPrice = $post['skPrice'] ?? 0;
  1258. if (empty($skPrice) || $skPrice <= 0) {
  1259. util::fail('请填写零售价');
  1260. }
  1261. $hjPrice = $post['hjPrice'] ?? 0;
  1262. if (empty($hjPrice) || $hjPrice <= 0) {
  1263. util::fail('请填写会员价');
  1264. }
  1265. $addPrice = $post['addPrice'] ?? 0;
  1266. if ($addPrice > $price) {
  1267. util::fail('批发价的加价不能大于售价');
  1268. }
  1269. //复制标识
  1270. $post['copy'] = 1;
  1271. //去除无用的字段
  1272. unset($post['viewNum']);
  1273. unset($post['actualSold']);
  1274. unset($post['itemId']);
  1275. unset($post['id']);
  1276. unset($post['delStatus']);
  1277. ProductClass::addProduct($post, $this->shop);
  1278. util::complete('复制成功');
  1279. }
  1280. //下载价格表 ssh 20210922
  1281. public function actionGeneratePriceTable()
  1282. {
  1283. $level = Yii::$app->request->get('level', 0);
  1284. $respond = ProductService::generatePriceTable($this->sjId, $level, $this->mainId);
  1285. $file = $respond['file'] ?? '';
  1286. $shortFile = $respond['shortFile'] ?? '';
  1287. $fileUrl = Yii::$app->params['ghsHost'] . $file;
  1288. util::success(['file' => $fileUrl, 'shortFile' => $shortFile]);
  1289. }
  1290. public function actionGenerateItemTable()
  1291. {
  1292. $level = Yii::$app->request->get('level', 0);
  1293. $respond = ProductService::generateItemTable($this->sjId, $level, $this->mainId);
  1294. $file = $respond['file'] ?? '';
  1295. $shortFile = $respond['shortFile'] ?? '';
  1296. $fileUrl = Yii::$app->params['ghsHost'] . $file;
  1297. util::success(['file' => $fileUrl, 'shortFile' => $shortFile]);
  1298. }
  1299. //下载条形码 lqh 20211227
  1300. public function actionGenerateBarcodeTable()
  1301. {
  1302. $respond = ProductService::generateBarcodeTable($this->sjId, $this->shopId, $this->mainId);
  1303. $file = $respond['file'] ?? '';
  1304. $shortFile = $respond['shortFile'] ?? '';
  1305. $fileUrl = Yii::$app->params['ghsHost'] . $file;
  1306. util::success(['file' => $fileUrl, 'shortFile' => $shortFile]);
  1307. }
  1308. //批量修改花材的分类 ssh 20230405
  1309. public function actionBatchModifyClass()
  1310. {
  1311. $post = Yii::$app->request->post();
  1312. $shop = $this->shop;
  1313. $sjName = $shop->merchantName ?? '';
  1314. $shopName = $shop->shopName ?? '';
  1315. $sjShopName = $shop->shopName == '首店' ? $sjName : $sjName . ' ' . $shopName;
  1316. noticeUtil::push($sjShopName . ' 批量移动花材分类', '15280215347');
  1317. $join = $shop->join ?? 0;
  1318. $default = $shop->default ?? 0;
  1319. if ($join == 0 && $default == 0) {
  1320. util::fail('当前直营分店,请切回总店操作');
  1321. }
  1322. $classId = $post['classId'] ?? 0;
  1323. $class = ItemClassClass::getById($classId, true);
  1324. if (empty($class) || $class->mainId != $this->mainId) {
  1325. util::fail('请选择您自己的分类');
  1326. }
  1327. $connection = Yii::$app->db;
  1328. $transaction = $connection->beginTransaction();
  1329. try {
  1330. $className = $class->name ?? '';
  1331. $idsList = $post['ids'] ?? '';
  1332. $ids = json_decode($idsList, true);
  1333. if (empty($ids)) {
  1334. util::fail('请选择花材');
  1335. }
  1336. $list = ProductClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
  1337. if (empty($list)) {
  1338. util::fail('请选择花材');
  1339. }
  1340. $ptItemList = [];
  1341. foreach ($list as $item) {
  1342. $name = $item->name ?? '';
  1343. if ($item->mainId != $this->mainId) {
  1344. util::fail($name . '不是您的花材');
  1345. }
  1346. $item->classId = $classId;
  1347. $item->save();
  1348. $ptItemId = $item->itemId ?? 0;
  1349. $ptItemList[] = $ptItemId;
  1350. //如果有修改分类,则在多个订单表中同步修改,如需修改,多个地方要同步修改,请搜索关键词item_class_modify_sync
  1351. $itemClassKey = 'item_class_modify_sync';
  1352. Yii::$app->redis->executeCommand('LPUSH', [$itemClassKey, $item->id]);
  1353. }
  1354. $shop = $this->shop;
  1355. if (isset($shop->default) && $shop->default == 1 && isset($shop->dataSync) && $shop->dataSync == 1) {
  1356. //总店修改同步到所有门店
  1357. $sjId = $shop->sjId ?? 0;
  1358. $chainShopList = ShopClass::getAllByCondition(['sjId' => $sjId], null, '*', null, true);
  1359. foreach ($chainShopList as $chainShop) {
  1360. $chainShopId = $chainShop->id ?? 0;
  1361. if ($chainShopId == $shop->id) {
  1362. continue;
  1363. }
  1364. $chainManId = $chainShop->mainId ?? 0;
  1365. $chainAllClassList = ItemClassClass::getAllByCondition(['mainId' => $chainManId], null, '*', null, true);
  1366. if (!empty($chainAllClassList)) {
  1367. foreach ($chainAllClassList as $chainClass) {
  1368. $chainName = $chainClass->name ?? '';
  1369. $chainClassId = $chainClass->id ?? 0;
  1370. if ($chainName == $className) {
  1371. $chainProductList = Productclass::getAllByCondition(['mainId' => $chainManId, 'itemId' => ['in', $ptItemList]], null, '*', null, true);
  1372. if (!empty($chainProductList)) {
  1373. foreach ($chainProductList as $currentProduct) {
  1374. $currentProduct->classId = $chainClassId;
  1375. $currentProduct->save();
  1376. //如果有修改分类,则在多个订单表中同步修改,如需修改,多个地方要同步修改,请搜索关键词item_class_modify_sync
  1377. $itemClassKey = 'item_class_modify_sync';
  1378. Yii::$app->redis->executeCommand('LPUSH', [$itemClassKey, $currentProduct->id]);
  1379. }
  1380. }
  1381. }
  1382. }
  1383. }
  1384. }
  1385. }
  1386. $transaction->commit();
  1387. util::complete('修改成功');
  1388. } catch (\Exception $e) {
  1389. $transaction->rollBack();
  1390. Yii::info("修改失败原因:" . $e->getMessage());
  1391. util::fail('修改失败');
  1392. }
  1393. }
  1394. //批量修改采购人 ssh 20240609
  1395. public function actionBatchModifyCgStaff()
  1396. {
  1397. $post = Yii::$app->request->post();
  1398. $staffId = $post['staffId'] ?? 0;
  1399. $staff = ShopAdminClass::getById($staffId, true);
  1400. if (empty($staff)) {
  1401. util::fail('没有找到这个员工');
  1402. }
  1403. if ($staff->mainId != $this->mainId) {
  1404. util::fail('不是你的员工');
  1405. }
  1406. $staffName = $staff->name ?? '';
  1407. $connection = Yii::$app->db;
  1408. $transaction = $connection->beginTransaction();
  1409. try {
  1410. $idsList = $post['ids'] ?? '';
  1411. $ids = json_decode($idsList, true);
  1412. if (empty($ids)) {
  1413. util::fail('请选择花材');
  1414. }
  1415. $list = ProductClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true);
  1416. if (empty($list)) {
  1417. util::fail('请选择花材');
  1418. }
  1419. foreach ($list as $item) {
  1420. $name = $item->name ?? '';
  1421. if ($item->mainId != $this->mainId) {
  1422. util::fail($name . '不是您的花材');
  1423. }
  1424. $item->cgStaffId = $staffId;
  1425. $item->cgStaffName = $staffName;
  1426. $item->save();
  1427. }
  1428. $transaction->commit();
  1429. util::complete('修改成功');
  1430. } catch (\Exception $e) {
  1431. $transaction->rollBack();
  1432. Yii::info("修改失败原因:" . $e->getMessage());
  1433. util::fail('修改失败');
  1434. }
  1435. }
  1436. //修改属于成本还是收入选项 ssh 20240514
  1437. public function actionChangeBelongCost()
  1438. {
  1439. $get = Yii::$app->request->get();
  1440. $id = $get['id'] ?? 0;
  1441. $belongCost = $get['belongCost'] ?? 0;
  1442. $info = ProductClass::getById($id, true);
  1443. if (empty($info)) {
  1444. util::fail('没有找到花材');
  1445. }
  1446. if ($info->mainId != $this->mainId) {
  1447. util::fail('不是你的花材哦');
  1448. }
  1449. $info->belongCost = $belongCost;
  1450. $info->save();
  1451. //队列方式去处理
  1452. $redisKey = 'change_belong_cost_item_list';
  1453. $value = $id . '_' . $belongCost;
  1454. Yii::$app->redis->executeCommand('LPUSH', [$redisKey, $value]);
  1455. util::complete('修改成功');
  1456. }
  1457. }