request->get(); $where = []; $where['sjId'] = $this->sjId; $categoryId = isset($get['categoryId']) && is_numeric($get['categoryId']) ? $get['categoryId'] : -1; if ($categoryId != -1) { $where['categoryId'] = $get['categoryId']; $list = PicCategoryService::getPicList($where, true); } else { $list = PicService::getPicList($where, true); } util::success($list); } //上传图片 ssh 2019.12.7 public function actionAdd() { $return = fileUtil::imgUpload($this->sjId); $sjId = $this->sjId; $time = time(); $name = '未命名'; $img = isset($return['shortUrl']) ? $return['shortUrl'] : ''; $data = ['img' => $img, 'sjId' => $sjId, 'name' => $name, 'addTime' => $time]; $pic = PicService::add($data); $return['id'] = $pic['id']; util::success($return); } //备注图片 ssh 2019.12.8 public function actionRemark() { $post = Yii::$app->request->post(); $post['price'] = isset($post['price']) && !empty($post['price']) ? $post['price'] : 0; $post['name'] = isset($post['name']) && !empty($post['name']) ? $post['name'] : '未命名'; $picIdList = isset($post['picIdList']) && !empty($post['picIdList']) ? $post['picIdList'] : []; unset($post['picIdList']); if (empty($picIdList)) { util::fail('没有图片需要备注'); } $categoryIdList = isset($post['categoryIdList']) && !empty($post['categoryIdList']) ? $post['categoryIdList'] : []; unset($post['categoryIdList']); if (empty($categoryIdList)) { util::fail('请选择分类'); } $merchantHas = CategoryClass::getCategoryIds($this->mainId); $diff = array_diff($categoryIdList, $merchantHas); if (!empty($diff)) { util::fail('只能选择自己的分类'); } $picList = PicService::getByIds($picIdList); $add = []; foreach ($picList as $picKey => $picVal) { if ($picVal['sjId'] != $this->sjId) { util::fail('只能设置自己的图片'); } $currentId = $picVal['id']; PicService::updateById($currentId, $post); foreach ($categoryIdList as $categoryId) { $add[] = ['categoryId' => $categoryId, 'picId' => $currentId, 'sjId' => $this->sjId]; } PicCategoryService::deleteByCondition(['picId' => $currentId]); } PicCategoryService::batchAdd($add); util::complete('备注成功'); } //查看图片详情 ssh 2019.12.8 public function actionDetail() { $id = Yii::$app->request->get('id', 0); $info = PicService::getById($id); PicService::valid($info, $this->sjId); $pic = PicService::getPic($info); util::success($pic); } //删除图片 ssh 2019.12.8 public function actionDelete() { $id = Yii::$app->request->post('id', 0); $info = PicService::getById($id); PicService::valid($info, $this->sjId); PicService::delPic($id); util::complete('删除成功'); } //置顶 ssh 2019.12.8 public function actionTop() { $id = Yii::$app->request->post('id', 0); $info = PicService::getById($id); PicService::valid($info, $this->sjId); PicService::top($info); util::complete(); } //发送到微信 ssh 2019.12.8 public function actionSendToWx() { $id = Yii::$app->request->get('id', 0); util::complete(); } //分享 ssh 2020.5.8 public function actionShare() { util::fail('即将开通'); } }