|
|
@@ -2,6 +2,7 @@
|
|
|
|
|
|
namespace business\controllers;
|
|
|
|
|
|
+use biz\goods\services\CategoryService;
|
|
|
use biz\goods\services\PicCategoryService;
|
|
|
use biz\goods\services\PicService;
|
|
|
use Yii;
|
|
|
@@ -37,12 +38,38 @@ class PicController extends BaseController
|
|
|
$pic = PicService::add($data);
|
|
|
util::success(['id' => $pic['id'], 'url' => $url, 'shortUrl' => $img]);
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
//备注图片 shish 2019.12.8
|
|
|
public function actionRemark()
|
|
|
{
|
|
|
$post = Yii::$app->request->post();
|
|
|
- dd($post);
|
|
|
+ $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']);
|
|
|
+ $merchantHas = CategoryService::getCategoryIdList($this->merchantId);
|
|
|
+ $diff = array_diff($categoryIdList, $merchantHas);
|
|
|
+ if (!empty($diff)) {
|
|
|
+ util::fail('只能设置自己的分类');
|
|
|
+ }
|
|
|
+ $picList = PicService::getByIds($picIdList);
|
|
|
+ $add = [];
|
|
|
+ foreach ($picList as $picKey => $picVal) {
|
|
|
+ if ($picVal['merchantId'] != $this->merchantId) {
|
|
|
+ util::fail('只能设置自己的图片');
|
|
|
+ }
|
|
|
+ $currentId = $picVal['id'];
|
|
|
+ PicService::updateById($currentId, $post);
|
|
|
+ foreach ($categoryIdList as $categoryId) {
|
|
|
+ $add[] = ['categoryId' => $categoryId, 'picId' => $currentId, 'merchantId' => $this->merchantId];
|
|
|
+ }
|
|
|
+ PicCategoryService::deleteByCondition(['picId' => $currentId]);
|
|
|
+ }
|
|
|
+ PicCategoryService::batchAdd($add);
|
|
|
+ util::ok('备注成功');
|
|
|
}
|
|
|
|
|
|
}
|