shish vor 3 Jahren
Ursprung
Commit
0e04861556

+ 8 - 3
app-ghs/controllers/ProductController.php

@@ -279,7 +279,8 @@ class ProductController extends BaseController
         $shop = $this->shop;
         $default = $shop->default ?? 0;
 
-        $params = ['staffId' => $shopAdmin->id, 'staffName' => $shopAdmin->name];
+        $adminId = $this->adminId ?? 0;
+        $changeParams = ['staffId' => $shopAdmin->id, 'staffName' => $shopAdmin->name];
 
         $data = Yii::$app->request->post('data', '');
         if (empty($data)) {
@@ -334,14 +335,17 @@ class ProductController extends BaseController
                     continue;
                 }
                 $ptItemId = $productInfo->itemId;
-                ProductClass::changeSinglePrice($shop, $ptItemId, $price, $skPrice, $params);
+                ProductClass::changeSinglePrice($shop, $ptItemId, $price, $skPrice, $changeParams);
                 //在首店修改需要同步到所有直营店
                 if ($default == 1) {
                     foreach ($chainShopList as $chain) {
                         if ($chain->id == $shop->id) {
                             continue;
                         }
-                        ProductClass::changeSinglePrice($chain, $ptItemId, $price, $skPrice, $params);
+                        $chainMainId = $chain->mainId ?? 0;
+                        $staff = ShopAdminClass::getByCondition(['mainId' => $chainMainId, 'adminId' => $adminId], true);
+                        $changeParams2 = ['staffId' => $staff->id, 'staffName' => $staff->name];
+                        ProductClass::changeSinglePrice($chain, $ptItemId, $price, $skPrice, $changeParams2);
                     }
                 }
             }
@@ -571,6 +575,7 @@ class ProductController extends BaseController
 
         $post = Yii::$app->request->post();
         $post['adminId'] = $this->adminId;
+        $post['staffId'] = $this->shopAdmin->id;
         $post['staffName'] = $this->shopAdmin->name;
         ProductClass::updateProduct($post, $this->shop);
         util::complete();

+ 15 - 4
biz-ghs/product/classes/ProductClass.php

@@ -17,6 +17,7 @@ use bizGhs\merchant\classes\ShopClass;
 use bizGhs\order\classes\CheckOrderClass;
 use bizGhs\order\classes\CheckOrderItemClass;
 use bizGhs\order\traits\OrderTrait;
+use bizGhs\shop\classes\ShopAdminClass;
 use bizGhs\stock\classes\StockRecordClass;
 use bizGhs\stock\services\StockRecordService;
 use common\components\dict;
@@ -905,14 +906,19 @@ class ProductClass extends BaseClass
             $currentSkPrice = bcadd($price, $data['skMore'], 2);
         }
 
+        $staffId = $data['staffId'] ?? 0;
+        $staffName = $data['staffName'] ?? '';
+        $adminId = $data['adminId'] ?? 0;
+        $changeParams = ['staffId' => $staffId, 'staffName' => $staffName];
+
         if ($price != $product->price) {
             //花店价有变化
-            self::changeSinglePrice($shop, $ptItemId, $price, $currentSkPrice);
+            self::changeSinglePrice($shop, $ptItemId, $price, $currentSkPrice, $changeParams);
             unset($upData['price']);
         } else {
             //花店价没有变化,但散客价比花店价贵多少有修改时,也要改价
             if (isset($data['skMore']) && is_numeric($data['skMore']) && $data['skMore'] != $product->skMore) {
-                self::changeSinglePrice($shop, $ptItemId, $price, $currentSkPrice);
+                self::changeSinglePrice($shop, $ptItemId, $price, $currentSkPrice, $changeParams);
                 unset($upData['price']);
             }
         }
@@ -938,6 +944,11 @@ class ProductClass extends BaseClass
                 unset($params['status']);
                 unset($params['delStatus']);
 
+                $staff = ShopAdminClass::getByCondition(['mainId' => $chainMainId, 'adminId' => $adminId], true);
+                $staffId = $staff->id ?? 0;
+                $staffName = $staff->name ?? '';
+                $changeParams = ['staffId' => $staffId, 'staffName' => $staffName];
+
                 //如果有同步分类则移动,没有则不移动
                 if (isset($params['classId'])) {
                     $masterClassId = $params['classId'];
@@ -960,12 +971,12 @@ class ProductClass extends BaseClass
                 }
                 if ($price != $chainProduct->price) {
                     //花店价有变化
-                    self::changeSinglePrice($chainShop, $ptItemId, $price, $currentSkPrice);
+                    self::changeSinglePrice($chainShop, $ptItemId, $price, $currentSkPrice, $changeParams);
                     unset($params['price']);
                 } else {
                     //花店价没有变化,但散客价比花店价贵多少有修改时,也要改价
                     if (isset($data['skMore']) && is_numeric($data['skMore']) && $data['skMore'] != $chainProduct->skMore) {
-                        self::changeSinglePrice($chainShop, $ptItemId, $price, $currentSkPrice);
+                        self::changeSinglePrice($chainShop, $ptItemId, $price, $currentSkPrice, $changeParams);
                         unset($params['price']);
                     }
                 }