|
|
@@ -401,10 +401,9 @@ class ProductController extends BaseController
|
|
|
public function actionBatchChangeMore()
|
|
|
{
|
|
|
$shop = $this->shop;
|
|
|
- $join = $shop->join ?? 0;
|
|
|
$default = $shop->default ?? 0;
|
|
|
- if ($join == 0 && $default == 0) {
|
|
|
- util::fail('请在首店操作');
|
|
|
+ if ($default == 0) {
|
|
|
+ util::fail('请在首店修改');
|
|
|
}
|
|
|
|
|
|
$shopAdmin = $this->shopAdmin;
|
|
|
@@ -421,18 +420,40 @@ class ProductController extends BaseController
|
|
|
util::fail('没有花材...');
|
|
|
}
|
|
|
$ids = array_column($itemData, 'id');
|
|
|
- $infoList = ProductClass::getByIds($ids);
|
|
|
+ $infoList = ProductClass::getByIds($ids,null,'id');
|
|
|
if (empty($infoList)) {
|
|
|
util::fail('没有花材');
|
|
|
}
|
|
|
foreach ($infoList as $info) {
|
|
|
if (isset($info['mainId']) == false || $info['mainId'] != $this->mainId) {
|
|
|
- util::fail('非常访问,不是你的花材不能修改');
|
|
|
+ util::fail('不是你的花材不能修改');
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ //首店修改同步到所有直营店
|
|
|
+ $sjId = $shop->sjId ?? 0;
|
|
|
+ $chainShopList = ShopClass::getAllByCondition(['sjId' => $sjId], null, '*', null, true);
|
|
|
+
|
|
|
foreach ($itemData as $key => $data) {
|
|
|
$id = $data['id'] ?? 0;
|
|
|
+ unset($data['id']);
|
|
|
ProductClass::updateById($id, $data);
|
|
|
+
|
|
|
+ $ptItemId = $infoList[$id]['itemId'] ?? 0;
|
|
|
+ if (empty($ptItemId)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (isset($shop->default) && $shop->default == 1) {
|
|
|
+ foreach ($chainShopList as $chainShop) {
|
|
|
+ $currentMainId = $chainShop->mainId ?? 0;
|
|
|
+ if ($currentMainId == $shop->mainId) {
|
|
|
+ //前面已经修改过了,不需要重复修改
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ProductClass::updateByCondition(['mainId' => $currentMainId, 'itemId' => $ptItemId], $data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
util::complete('修改成功');
|
|
|
}
|