|
|
@@ -1,4 +1,5 @@
|
|
|
<?php
|
|
|
+
|
|
|
namespace ghs\controllers;
|
|
|
|
|
|
use Yii;
|
|
|
@@ -23,7 +24,7 @@ class PicTextController extends BaseController
|
|
|
$where['mainId'] = $this->mainId;
|
|
|
$where['delStatus'] = 0;
|
|
|
// $where['type'] = $type; // 需求需要所有都展示,不分类别
|
|
|
-
|
|
|
+
|
|
|
$list = PicTextClass::getList('id, title, addTime', $where, 'addTime desc');
|
|
|
util::success($list);
|
|
|
}
|
|
|
@@ -35,7 +36,7 @@ class PicTextController extends BaseController
|
|
|
{
|
|
|
$post = Yii::$app->request->post();
|
|
|
$content = $post['content'];
|
|
|
-
|
|
|
+
|
|
|
$post['content'] = $content;
|
|
|
$post['mainId'] = $this->mainId;
|
|
|
// $post['staffId'] = intval($this->shopAdmin->id);
|
|
|
@@ -71,21 +72,22 @@ class PicTextController extends BaseController
|
|
|
public function actionSwitch()
|
|
|
{
|
|
|
$post = Yii::$app->request->post();
|
|
|
- $switch = intval($post['switch']);
|
|
|
- $shopId = intval($this->shopId);
|
|
|
- if ($shopId <= 0) {
|
|
|
- util::fail('门店出错');
|
|
|
+ $switch = $post['switch'] ?? 0;
|
|
|
+ $shopId = $this->shopId;
|
|
|
+ $picTextId = intval($post['picTextId']);
|
|
|
+ $shop = $this->shop;
|
|
|
+ $ext = ShopExtClass::getByCondition(['shopId' => $shopId], true);
|
|
|
+ if (empty($ext)) {
|
|
|
+ util::fail('门店信息缺失呢');
|
|
|
}
|
|
|
- if($switch == 1) {
|
|
|
- $picTextId = intval($post['picTextId']);
|
|
|
- $updateCount = ShopExtClass::updateByCondition(['shopId' => $shopId], ['purchaseGuide' => $picTextId]);
|
|
|
- }else{
|
|
|
- $updateCount = ShopExtClass::updateByCondition(['shopId' => $shopId], ['purchaseGuide' => 0]);
|
|
|
- }
|
|
|
- if ($updateCount <= 0) {
|
|
|
- util::fail('变更失败');
|
|
|
+ $ext->purchaseGuide = $picTextId;
|
|
|
+ $ext->save();
|
|
|
+ if ($switch == 1) {
|
|
|
+ if (isset($shop->buyNotice)) {
|
|
|
+ $shop->buyNotice = 1;
|
|
|
+ $shop->save();
|
|
|
+ }
|
|
|
}
|
|
|
- util::success('变更成功');
|
|
|
}
|
|
|
|
|
|
public function actionDel()
|