request->post(); if (empty($post)) { util::fail('请排序'); } foreach ($post as $cp) { $cpId = $cp['cpId']; $inTurn = $cp['inTurn'] ?? 0; PtCpClass::updateById($cpId, ['inTurn' => $inTurn]); } util::complete('修改成功'); } //根据花材建产品 ssh 20240305 public function actionCopyCreateCp() { $get = Yii::$app->request->get(); $itemId = $get['id'] ?? 0; $cpClassId = $get['cpClassId'] ?? 0; $needLevelItem = $get['needLevelItem'] ?? 0; PtCpClass::copyCreateCp($itemId, $cpClassId, $needLevelItem); util::complete(); } //批量修改产品分类 ssh 20240215 public function actionBatchModifyClass() { $post = Yii::$app->request->post(); $classId = $post['classId'] ?? 0; $str = $post['ids'] ?? ''; $ids = json_decode($str, true); if (empty($ids)) { util::fail('没有产品'); } $class = PtCpClassClass::getById($classId, true); if (empty($class)) { util::fail('没有找到分类'); } $cpList = PtCpClass::getAllByCondition(['id' => ['in', $ids]], null, "*", null, true); if (empty($cpList)) { util::fail('没有找到产品'); } foreach ($cpList as $cp) { $cp->classId = $classId; $cp->save(); } util::complete('修改成功'); } public function actionList() { $get = Yii::$app->request->get(); $classId = $get['classId'] ?? 0; $search = $get['search'] ?? ''; $delStatus = $get['delStatus'] ?? ''; $classStyle = $get['classStyle'] ?? -1; $where = []; if ($classStyle == 0) { $where['classId'] = 0; } else { if (!empty($classId) && is_numeric($classId)) { $where['classId'] = $classId; } } if (!empty($search)) { if (stringUtil::isLetter($search)) { $where['py'] = ['like', $search]; } else { $where['name'] = ['like', $search]; } } if (is_numeric($delStatus)) { $where['delStatus'] = $delStatus; } $respond = PtCpClass::getCpList($where); util::success($respond); } //添加产品 ssh 20240119 public function actionAddCp() { $post = Yii::$app->request->post(); PtCpClass::addCp($post); util::complete('添加成功'); } //修改产品 ssh 20240119 public function actionUpdateCp() { $post = Yii::$app->request->post(); PtCpClass::updateCp($post); util::complete('修改成功'); } //删除产品 ssh 20240119 public function actionDelCp() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $cp = PtCpClass::getById($id, true); if (empty($cp)) { util::fail('没有找到产品'); } $cp->delStatus = 1; $cp->save(); util::complete('删除成功'); } //获取详情 ssh 20240119 public function actionGetDetail() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $cp = PtCpClass::getById($id); if (empty($cp)) { util::fail('没有找到产品'); } $classId = $cp['classId'] ?? 0; $class = PtCpClassClass::getById($classId, true); $className = $class->name ?? ''; $cp['className'] = $className; util::success(['info' => $cp]); } //认证和取消认证 ssh 20240119 public function actionAuth() { $get = Yii::$app->request->get(); $id = $get['id'] ?? 0; $cp = PtCpClass::getById($id, true); if (empty($cp)) { util::fail('没有找到产品'); } if ($cp->delStatus == 1) { util::fail('已删除不能认证'); } $auth = $cp->auth == 0 ? 1 : 0; $cp->auth = $auth; $cp->save(); } }