request->post(); $str = $post['ids'] ?? ''; $classId = $post['classId'] ?? 0; $class = PtItemCatClass::getById($classId, true); if (empty($class)) { util::fail('没有找到分类'); } $ids = json_decode($str, true); if (empty($ids)) { util::fail('请选择花材21'); } $list = PtItemClass::getByIds($ids); if (empty($list)) { util::fail('没有花材'); } foreach ($list as $item) { $id = $item['id'] ?? 0; $has = PtItemCatRelateClass::getByCondition(['catId' => $classId, 'itemId' => $id], true); if (empty($has)) { PtItemCatRelateClass::add(['catId' => $classId, 'itemId' => $id], true); } } util::complete(); } }