mainId; $where['delStatus'] = 0; $list = ItemClass::getShowList($where); util::success(['list' => $list]); } public function actionAdd() { $post = Yii::$app->request->post(); $post['adminId'] = $this->adminId; $post['sjId'] = $this->sjId; $connection = Yii::$app->db;//事务处理 $transaction = $connection->beginTransaction(); try { ItemService::addGhsItem($post); $transaction->commit(); util::complete('添加成功'); } catch (Exception $e) { $transaction->rollBack(); util::fail('添加失败'); } } //批量添加花材 public function actionBatchAdd() { $shopAdmin = $this->shopAdmin; if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) { util::fail('超管才能操作'); } $post = Yii::$app->request->post(); //[{itemId:1000,classId:2,price:1,stockWarning:1}] $data = $post['data']; if (empty($data)) { util::fail("请选花材"); } $data = json_decode($data, true); if (!is_array($data) || empty($data)) { util::fail("请选花材"); } $sjId = $this->sjId; $ids = array_column($data,'itemId'); $ids = array_unique(array_filter($ids)); $has = ProductClass::getByCondition(['sjId' => $sjId, 'itemId'=>['in',$ids]]); if(!empty($has)){ util::fail("有花材已经添加过了"); } $connection = Yii::$app->db;//事务处理 $transaction = $connection->beginTransaction(); try { foreach ($data as $v) { $v['adminId'] = $this->adminId; $v['sjId'] = $sjId; ItemService::addGhsItem($v); } $transaction->commit(); util::complete('添加成功'); } catch (Exception $e) { $transaction->rollBack(); util::fail(); } } public function actionDelete() { util::fail('不能删除哦!'); } //获取平台里的花材信息 public function actionPlatformItem() { $py = Yii::$app->request->get('py', ''); $where = []; if ($py) { $where = ['py' => $py]; } $list = PtItemClass::getItemList($where); util::success($list); } }