shish преди 6 години
родител
ревизия
988f5a2ce4
променени са 1 файла, в които са добавени 108 реда и са изтрити 107 реда
  1. 108 107
      app/shop/controllers/PicController.php

+ 108 - 107
app/shop/controllers/PicController.php

@@ -12,113 +12,114 @@ use common\components\util;
 class PicController extends BaseController
 {
 
-	//图库列表 shish 2019.12.7
-	public function actionList()
-	{
-		$get = Yii::$app->request->get();
-		$where = [];
-		$where['merchantId'] = $this->merchantId;
-		$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);
-	}
+    //图库列表 shish 2019.12.7
+    public function actionList()
+    {
+        $get = Yii::$app->request->get();
+        $where = [];
+        $where['merchantId'] = $this->merchantId;
+        $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);
+    }
 
-	//上传图片 shish 2019.12.7
-	public function actionAdd()
-	{
-		$return = fileUtil::imgUpload($this->merchantId);
-		$merchantId = $this->merchantId;
-		$time = time();
-		$name = '未命名';
-		$img = isset($return['shortUrl']) ? $return['shortUrl'] : '';
-		$data = ['img' => $img, 'merchantId' => $merchantId, 'name' => $name, 'addTime' => $time];
-		$pic = PicService::add($data);
-		$return['id'] = $pic['id'];
-		util::success($return);
-	}
-	
-	//备注图片 shish 2019.12.8
-	public function actionRemark()
-	{
-		$post = Yii::$app->request->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']);
-		if (empty($categoryIdList)) {
-			util::fail('请选择分类');
-		}
-		$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::complete('备注成功');
-	}
+    //上传图片 shish 2019.12.7
+    public function actionAdd()
+    {
+        $return = fileUtil::imgUpload($this->merchantId);
+        $merchantId = $this->merchantId;
+        $time = time();
+        $name = '未命名';
+        $img = isset($return['shortUrl']) ? $return['shortUrl'] : '';
+        $data = ['img' => $img, 'merchantId' => $merchantId, 'name' => $name, 'addTime' => $time];
+        $pic = PicService::add($data);
+        $return['id'] = $pic['id'];
+        util::success($return);
+    }
+
+    //备注图片 shish 2019.12.8
+    public function actionRemark()
+    {
+        $post = Yii::$app->request->post();
+        $post['price'] = isset($post['price']) && !empty($post['price']) ? $post['price'] : 0;
+        $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 = 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::complete('备注成功');
+    }
+
+    //查看图片详情 shish 2019.12.8
+    public function actionDetail()
+    {
+        $id = Yii::$app->request->get('id', 0);
+        $info = PicService::getById($id);
+        PicService::valid($info, $this->merchantId);
+        $pic = PicService::getPic($info);
+        util::success($pic);
+    }
+
+    //删除图片 shish 2019.12.8
+    public function actionDelete()
+    {
+        $id = Yii::$app->request->post('id', 0);
+        $info = PicService::getById($id);
+        PicService::valid($info, $this->merchantId);
+        PicService::delPic($id);
+        util::complete('删除成功');
+    }
+
+    //置顶 shish 2019.12.8
+    public function actionTop()
+    {
+        $id = Yii::$app->request->post('id', 0);
+        $info = PicService::getById($id);
+        PicService::valid($info, $this->merchantId);
+        PicService::top($info);
+        util::complete();
+    }
+
+    //发送到微信 shish 2019.12.8
+    public function actionSendToWx()
+    {
+        $id = Yii::$app->request->get('id', 0);
+        util::complete();
+    }
+
+    //分享 shish 2020.5.8
+    public function actionShare()
+    {
+        util::fail('即将开通');
+    }
 
-	//查看图片详情 shish 2019.12.8
-	public function actionDetail()
-	{
-		$id = Yii::$app->request->get('id', 0);
-		$info = PicService::getById($id);
-		PicService::valid($info, $this->merchantId);
-		$pic = PicService::getPic($info);
-		util::success($pic);
-	}
-	
-	//删除图片 shish 2019.12.8
-	public function actionDelete()
-	{
-		$id = Yii::$app->request->post('id', 0);
-		$info = PicService::getById($id);
-		PicService::valid($info, $this->merchantId);
-		PicService::delPic($id);
-		util::complete('删除成功');
-	}
-	
-	//置顶 shish 2019.12.8
-	public function actionTop()
-	{
-		$id = Yii::$app->request->post('id', 0);
-		$info = PicService::getById($id);
-		PicService::valid($info, $this->merchantId);
-		PicService::top($info);
-		util::complete();
-	}
-	
-	//发送到微信 shish 2019.12.8
-	public function actionSendToWx()
-	{
-		$id = Yii::$app->request->get('id', 0);
-		util::complete();
-	}
-	
-	//分享 shish 2020.5.8
-	public function actionShare()
-	{
-		util::fail('即将开通');
-	}
-	
 }