|
|
@@ -195,7 +195,8 @@ class ProductController extends BaseController
|
|
|
//花材价格只能在首店修改,并同步到分店
|
|
|
$shop = $this->shop;
|
|
|
$default = $shop->default ?? 0;
|
|
|
- if ($default != 1) {
|
|
|
+ $join = $shop->join ?? 0;
|
|
|
+ if ($join == 1 && $default != 1) {
|
|
|
util::fail('请在首店修改');
|
|
|
}
|
|
|
|
|
|
@@ -218,8 +219,16 @@ class ProductController extends BaseController
|
|
|
util::fail('请选择花材');
|
|
|
}
|
|
|
|
|
|
- $productList = ProductClass::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id', true);
|
|
|
+ $sjId = $shop->sjId ?? 0;
|
|
|
+ $chainShopList = [];
|
|
|
+ if ($default == 1) {
|
|
|
+ $chainShopList = ShopClass::getAllByCondition(['sjId' => $sjId, 'join' => 0], null, '*', null, true);
|
|
|
+ if (empty($chainShopList)) {
|
|
|
+ util::fail('没有找到直营店');
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ $productList = ProductClass::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id', true);
|
|
|
foreach ($arr as $product) {
|
|
|
if (isset($product['price']) == false) {
|
|
|
util::fail('没有价格');
|
|
|
@@ -240,7 +249,14 @@ class ProductController extends BaseController
|
|
|
if (empty($price)) {
|
|
|
continue;
|
|
|
}
|
|
|
- ProductClass::changePrice($product, $price, ProductClass::PRICE_LABEL_CHANGE);
|
|
|
+ //在首店修改需要同步到直营店
|
|
|
+ if ($default == 1) {
|
|
|
+ foreach ($chainShopList as $chain) {
|
|
|
+ $ptItemId = $product->itemId;
|
|
|
+ ProductClass::changePrice($chain, $ptItemId, $price);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
$transaction->commit();
|
|
|
util::complete('修改成功');
|
|
|
@@ -535,11 +551,9 @@ class ProductController extends BaseController
|
|
|
|
|
|
public function actionUpdate()
|
|
|
{
|
|
|
- $post = Yii::$app->request->post();
|
|
|
-
|
|
|
$shopAdmin = $this->shopAdmin;
|
|
|
if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
|
|
|
- util::fail('超管才能修改');
|
|
|
+ util::fail('超管才能操作');
|
|
|
}
|
|
|
|
|
|
$shop = $this->shop;
|
|
|
@@ -551,8 +565,9 @@ class ProductController extends BaseController
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ $post = Yii::$app->request->post();
|
|
|
$post['adminId'] = $this->adminId;
|
|
|
- ProductClass::updateProduct($post);
|
|
|
+ ProductClass::updateProduct($post, $this->shop);
|
|
|
util::complete();
|
|
|
}
|
|
|
|