|
|
@@ -0,0 +1,114 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace ghs\controllers;
|
|
|
+
|
|
|
+use bizGhs\item\classes\ItemClass;
|
|
|
+use bizGhs\item\classes\ItemMsClass;
|
|
|
+use common\components\imgUtil;
|
|
|
+use common\components\util;
|
|
|
+use Yii;
|
|
|
+
|
|
|
+class ItemMsController extends BaseController
|
|
|
+{
|
|
|
+
|
|
|
+ //分配库存和改价 ssh 20230719
|
|
|
+ public function actionSendStock()
|
|
|
+ {
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
+
|
|
|
+ //批量添加子花材 ssh 20230719
|
|
|
+ public function actionBatchAddItem()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $idsList = $post['ids'] ?? '';
|
|
|
+ $ids = json_decode($idsList, true);
|
|
|
+ if (empty($ids)) {
|
|
|
+ util::fail('请选择花材');
|
|
|
+ }
|
|
|
+ $motherId = $post['motherId'] ?? 0;
|
|
|
+ $mother = ItemClass::getById($motherId, true);
|
|
|
+ if (empty($mother) || $mother->mainId != $this->mainId) {
|
|
|
+ util::fail('没有权限');
|
|
|
+ }
|
|
|
+ $hasIdString = $mother->idList ?? '';
|
|
|
+ $hasIds = [];
|
|
|
+ if (!empty($hasIdString)) {
|
|
|
+ $hasIds = explode(',', $hasIdString);
|
|
|
+ }
|
|
|
+ foreach ($ids as $current) {
|
|
|
+ if (in_array($current, $hasIds) == false) {
|
|
|
+ $hasIds[] = $current;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $newString = implode(',', $hasIds);
|
|
|
+ $mother->idList = $newString;
|
|
|
+ $mother->save();
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除花材 ssh 20230718
|
|
|
+ public function actionDelItem()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $motherId = $get['motherId'] ?? 0;
|
|
|
+ $delId = $get['id'] ?? 0;
|
|
|
+ $mother = ItemClass::getById($motherId, true);
|
|
|
+ if (empty($mother) || $mother->mainId != $this->mainId) {
|
|
|
+ util::fail('没有权限');
|
|
|
+ }
|
|
|
+ $relate = ItemMsClass::getByCondition(['motherId' => $motherId], true);
|
|
|
+ if (empty($relate)) {
|
|
|
+ util::fail('没有找到花材');
|
|
|
+ }
|
|
|
+ $idList = $relate->idList ?? '';
|
|
|
+ if (!empty($idList)) {
|
|
|
+ $ids = explode(',', $idList);
|
|
|
+ $new = [];
|
|
|
+ foreach ($ids as $current) {
|
|
|
+ if ($current != $delId) {
|
|
|
+ $new[] = $current;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $idString = implode(',', $new);
|
|
|
+ $relate->idList = $idString;
|
|
|
+ $relate->save();
|
|
|
+ }
|
|
|
+ util::complete();
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取子花材 ssh 20230718
|
|
|
+ public function actionGetSonList()
|
|
|
+ {
|
|
|
+ $get = Yii::$app->request->get();
|
|
|
+ $motherId = $get['motherId'] ?? 0;
|
|
|
+ $item = ItemClass::getById($motherId, true);
|
|
|
+ if (empty($item) || $item->mainId != $this->mainId) {
|
|
|
+ util::fail('没有找到花材');
|
|
|
+ }
|
|
|
+ $ms = ItemMsClass::getByCondition(['motherId' => $motherId], true);
|
|
|
+ $list = [];
|
|
|
+ $idList = $ms->idList ?? '';
|
|
|
+ if (!empty($idList)) {
|
|
|
+ $ids = explode(',', $idList);
|
|
|
+ $list = ItemClass::getAllByCondition(['id' => ['in', $ids]], null, '*');
|
|
|
+ if (!empty($list)) {
|
|
|
+ foreach ($list as $key => $val) {
|
|
|
+ $shortCover = $val['cover'] ?? '';
|
|
|
+ $bigCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
|
|
|
+ $smallCover = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
|
|
|
+ $list[$key]['bigCover'] = $bigCover;
|
|
|
+ $list[$key]['smallCover'] = $smallCover;
|
|
|
+ $list[$key]['shortCover'] = $shortCover;
|
|
|
+ $list[$key]['cover'] = $bigCover;
|
|
|
+ $list[$key]['sendHyPrice'] = '';
|
|
|
+ $list[$key]['sendSonStock'] = '';
|
|
|
+ $list[$key]['sendLsPrice'] = '';
|
|
|
+ $list[$key]['sendPfPrice'] = '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ util::success(['list' => $list]);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|