|
|
@@ -1,6 +1,7 @@
|
|
|
<?php
|
|
|
namespace hd\controllers;
|
|
|
|
|
|
+use bizHd\goods\classes\CategoryClass;
|
|
|
use Yii;
|
|
|
use bizHd\pictext\classes\PicTextClass;
|
|
|
use common\components\util;
|
|
|
@@ -12,6 +13,7 @@ class PicTextController extends BaseController
|
|
|
$where = [];
|
|
|
$where['mainId'] = $this->mainId;
|
|
|
$where['delStatus'] = 0;
|
|
|
+ $where['type'] = 1;
|
|
|
|
|
|
$list = PicTextClass::getList('id, title, addTime', $where, 'addTime desc');
|
|
|
util::success($list);
|
|
|
@@ -20,12 +22,14 @@ class PicTextController extends BaseController
|
|
|
public function actionAdd()
|
|
|
{
|
|
|
$post = Yii::$app->request->post();
|
|
|
- $content = $post['imageTextVos'];
|
|
|
+ $content = $post['content'];
|
|
|
|
|
|
- $post['content'] = json_encode($content);
|
|
|
+ $post['content'] = $content;
|
|
|
$post['mainId'] = $this->mainId;
|
|
|
// $post['staffId'] = intval($this->shopAdmin->id);
|
|
|
|
|
|
+ // 类别 1. 花束分类说明(运用于分类的商品) 2. 商品特有说明(非商品简介,优先级可高于分类说明) 3. 售前与售后说明
|
|
|
+ $post['type'] = PicTextClass::TYPE_CATEGORY; // type 默认为 1
|
|
|
$id = PicTextClass::add($post);
|
|
|
util::success($id);
|
|
|
}
|
|
|
@@ -37,36 +41,67 @@ class PicTextController extends BaseController
|
|
|
|
|
|
$picText = PicTextClass::getById($id, true);
|
|
|
if (empty($picText)) {
|
|
|
- util::fail('没有找到图片');
|
|
|
+ util::fail('没有找到图文');
|
|
|
}
|
|
|
if ($picText->mainId != $this->mainId) {
|
|
|
util::fail('没有权限修改');
|
|
|
}
|
|
|
|
|
|
- $post['mainId'] = $this->mainId;
|
|
|
$post['staffId'] = intval($this->shopAdmin->id);
|
|
|
$id = PicTextClass::updateById($id, $post);
|
|
|
util::success('修改成功');
|
|
|
}
|
|
|
|
|
|
+ public function actionUpdateCategoryId()
|
|
|
+ {
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
+ $id = $post['id'];
|
|
|
+ $categoryId = intval($post['categoryId']);
|
|
|
+ if ($categoryId <= 0) {
|
|
|
+ util::fail('分类id出错');
|
|
|
+ }
|
|
|
+ $picText = PicTextClass::getById($id, true, 'id, mainId, type');
|
|
|
+ if (empty($picText)) {
|
|
|
+ util::fail('没有找到图文');
|
|
|
+ }
|
|
|
+ if ($picText->type != PicTextClass::TYPE_CATEGORY) {
|
|
|
+ util::fail('图文类型不支持设置分类');
|
|
|
+ }
|
|
|
+ if ($picText->mainId != $this->mainId) {
|
|
|
+ util::fail('没有权限修改');
|
|
|
+ }
|
|
|
+
|
|
|
+ $updateCount = CategoryClass::updateByCondition(['id' => $categoryId, 'mainId' => $this->mainId], ['picTextId' => $id]);
|
|
|
+ //CategoryClass::updateById($id, ['picTextId' => $id]);
|
|
|
+ if ($updateCount <= 0) {
|
|
|
+ util::fail('变更失败');
|
|
|
+ }
|
|
|
+ util::success('变更成功');
|
|
|
+ }
|
|
|
+
|
|
|
public function actionDel()
|
|
|
{
|
|
|
- $id = Yii::$app->request->post('id');
|
|
|
- $picText = PicTextClass::getById($id);
|
|
|
+ $id = intval(Yii::$app->request->post('id'));
|
|
|
+ $picText = PicTextClass::getById($id, true);
|
|
|
if (empty($picText)) {
|
|
|
- util::fail('没有找到图片');
|
|
|
+ util::fail('图文id不对');
|
|
|
+ }
|
|
|
+ if ($picText->mainId != $this->mainId) {
|
|
|
+ util::fail('没有权限');
|
|
|
}
|
|
|
+ PicTextClass::updateById($id, ['delStatus'=>1]);
|
|
|
+ util::complete('成功删除');
|
|
|
}
|
|
|
|
|
|
public function actionDetail()
|
|
|
{
|
|
|
- $id = Yii::$app->request->get('id');
|
|
|
+ $id = intval(Yii::$app->request->get('id'));
|
|
|
$picText = PicTextClass::getById($id, true);
|
|
|
if (empty($picText)) {
|
|
|
util::fail('没有找到图片');
|
|
|
}
|
|
|
if ($picText->mainId != $this->mainId) {
|
|
|
- util::fail('没有权限查看');
|
|
|
+ util::fail('没有权限');
|
|
|
}
|
|
|
|
|
|
util::success($picText);
|