|
|
@@ -432,6 +432,66 @@ class ProductController extends BaseController
|
|
|
|
|
|
}
|
|
|
|
|
|
+ //批量修改更多,包括排序、重量和保质期 ssh 20211211
|
|
|
+ public function actionBatchChangeMore()
|
|
|
+ {
|
|
|
+ $shop = $this->shop;
|
|
|
+ $default = $shop->default ?? 0;
|
|
|
+ $join = $shop->join ?? 0;
|
|
|
+ if ($default == 0 && $join == 0) {
|
|
|
+ util::fail('当前是直营店,请返回总店修改');
|
|
|
+ }
|
|
|
+
|
|
|
+ $shopAdmin = $this->shopAdmin;
|
|
|
+ if (isset($shopAdmin->super) == false || $shopAdmin->super != 1) {
|
|
|
+ util::fail('超管才能操作');
|
|
|
+ }
|
|
|
+
|
|
|
+ $addData = Yii::$app->request->post('addData', '');
|
|
|
+ if (empty($addData)) {
|
|
|
+ util::fail('没有花材');
|
|
|
+ }
|
|
|
+ $itemData = json_decode($addData, true);
|
|
|
+ if (is_array($itemData) == false) {
|
|
|
+ util::fail('没有花材...');
|
|
|
+ }
|
|
|
+ $ids = array_column($itemData, 'id');
|
|
|
+ $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('不是你的花材不能修改');
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //总店修改同步到所有门店
|
|
|
+ $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 && isset($shop->dataSync) && $shop->dataSync == 1) {
|
|
|
+ foreach ($chainShopList as $chainShop) {
|
|
|
+ $currentMainId = $chainShop->mainId ?? 0;
|
|
|
+ if ($currentMainId == $shop->mainId) {
|
|
|
+ //前面已经修改过了,不需要重复修改
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ ProductClass::updateByCondition(['mainId' => $currentMainId, 'itemId' => $ptItemId], $data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ util::complete('修改成功');
|
|
|
+ }
|
|
|
+
|
|
|
//批量改价
|
|
|
public function actionBatchChangePrice()
|
|
|
{
|