request->post(); $idsList = $post['ids'] ?? ''; $ids = json_decode($idsList, true); if (empty($ids)) { util::fail('请选择花材15'); } $motherId = $post['motherId'] ?? 0; $mother = ItemClass::getById($motherId, true); if (empty($mother) || $mother->mainId != $this->mainId) { util::fail('没有权限'); } $relate = ItemMsClass::getByCondition(['motherId' => $motherId], true); if (empty($relate)) { $relate = ItemMsClass::add(['motherId' => $motherId], true); } $hasIdString = $relate->idList ?? ''; $hasIds = []; if (!empty($hasIdString)) { $hasIds = explode(',', $hasIdString); } foreach ($ids as $current) { if (in_array($current, $hasIds) == false && $current != $motherId) { $hasIds[] = $current; } } $newString = implode(',', $hasIds); $relate->idList = $newString; $relate->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], 'delStatus' => 0,], 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]); } }