|
|
@@ -2,11 +2,9 @@
|
|
|
|
|
|
namespace hd\controllers;
|
|
|
|
|
|
-
|
|
|
use biz\item\classes\PtItemClass;
|
|
|
-
|
|
|
-use bizGhs\item\classes\ItemClass;
|
|
|
-use bizGhs\item\services\ItemService;
|
|
|
+use bizHd\item\classes\ItemClass;
|
|
|
+use bizGhs\pictext\classes\PicTextGhsItemClass;
|
|
|
use bizHd\custom\classes\CustomClass;
|
|
|
use bizHd\product\classes\ProductClass;
|
|
|
use bizHd\wx\classes\WxOpenClass;
|
|
|
@@ -348,4 +346,65 @@ class ItemController extends BaseController
|
|
|
util::success($respond);
|
|
|
}
|
|
|
|
|
|
+ //获取花材描述
|
|
|
+ public function actionDesc()
|
|
|
+ {
|
|
|
+ $itemId = Yii::$app->request->get('itemId', 0);
|
|
|
+ $picText = PicTextGhsItemClass::getByCondition(['mainId'=> $this->mainId, 'ghsItemId' => $itemId, 'delStatus' => 0], true);
|
|
|
+ if (empty($picText)) {
|
|
|
+ // 适配前端的返回处理 -- 本来要使用 util::fail()
|
|
|
+ util::success('not_exist');
|
|
|
+ }
|
|
|
+ if ($picText->mainId != $this->mainId) {
|
|
|
+ util::fail('没有找到描述');
|
|
|
+ }
|
|
|
+ util::success($picText);
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建花材描述(花材介绍)
|
|
|
+ public function actionCreateDesc()
|
|
|
+ {
|
|
|
+ $form = new \ghs\models\item\CreateDescForm(); // 暂时使用同一份 ghs,项目独立时,再复制一份
|
|
|
+ $form->load(Yii::$app->request->post(), '');
|
|
|
+ if (!$form->validateForm()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ $data = $form->attributes;
|
|
|
+ $exists = PicTextGhsItemClass::exists(['mainId'=>$this->mainId, 'ghsItemId' => $data['itemId'], 'delStatus' => 0]);
|
|
|
+ if ($exists) {
|
|
|
+ util::fail('该商品已存在图文内容,请勿重复添加');
|
|
|
+ }
|
|
|
+
|
|
|
+ $data['mainId'] = $this->mainId;
|
|
|
+ $data['ghsItemId'] = $data['itemId'];
|
|
|
+ $result = PicTextGhsItemClass::add($data);
|
|
|
+ if ($result) {
|
|
|
+ util::success($result);
|
|
|
+ }
|
|
|
+
|
|
|
+ util::fail('创建失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新花材描述(花材介绍)
|
|
|
+ public function actionUpdateDesc()
|
|
|
+ {
|
|
|
+ $form = new \ghs\models\item\CreateDescForm();
|
|
|
+ $form->load(Yii::$app->request->post(), '');
|
|
|
+ if (!$form->validateForm()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ $data = $form->attributes;
|
|
|
+ $id = $data['id'];
|
|
|
+ $info = PicTextGhsItemClass::getById($id, false, 'id');
|
|
|
+ if (empty($info)) {
|
|
|
+ util::fail('描述不存在');
|
|
|
+ }
|
|
|
+ $data['mainId'] = $this->mainId;
|
|
|
+ $result = PicTextGhsItemClass::updateById($id, $data);
|
|
|
+ if ($result) {
|
|
|
+ util::success($result);
|
|
|
+ }
|
|
|
+ util::fail('更新失败');
|
|
|
+ }
|
|
|
}
|