shish před 4 roky
rodič
revize
5149f0c2d9

+ 5 - 4
app-ghs/controllers/ProductController.php

@@ -47,7 +47,7 @@ class ProductController extends BaseController
 
         $p->times = $num;
         $content = '<TEXT x="360" y="30" font="12" w="2" h="2" r="90">' . $name . '</TEXT>';
-        $content .= '<BC128 x="260" y="30" h="80" s="1" r="90" n="5" w="12">'.$ptItemId.'</BC128>';
+        $content .= '<BC128 x="260" y="30" h="80" s="1" r="90" n="5" w="12">' . $ptItemId . '</BC128>';
         $p->printLabelMsg($content);
         util::complete();
     }
@@ -261,7 +261,8 @@ class ProductController extends BaseController
                 if (isset($product['id']) == false) {
                     util::fail('没有花材');
                 }
-                $price = $product['price'];
+                $price = $product['price'] ?? 0;
+                $skPrice = $product['skPrice'] ?? 0;
                 $productId = $product['id'];
 
                 $product = $productList[$productId] ?? [];
@@ -275,14 +276,14 @@ class ProductController extends BaseController
                     continue;
                 }
                 $ptItemId = $product->itemId;
-                ProductClass::changeSinglePrice($shop, $ptItemId, $price);
+                ProductClass::changeSinglePrice($shop, $ptItemId, $price, $skPrice);
                 //在首店修改需要同步到所有直营店
                 if ($default == 1) {
                     foreach ($chainShopList as $chain) {
                         if ($chain->id == $shop->id) {
                             continue;
                         }
-                        ProductClass::changeSinglePrice($chain, $ptItemId, $price);
+                        ProductClass::changeSinglePrice($chain, $ptItemId, $price, $skPrice);
                     }
                 }
             }

+ 7 - 17
biz-ghs/product/classes/ProductClass.php

@@ -586,30 +586,20 @@ class ProductClass extends BaseClass
     }
 
     //单个修改价格 lqh 2021.1.28
-    public static function changeSinglePrice($shop, $ptItemId, $price)
+    public static function changeSinglePrice($shop, $ptItemId, $price, $skPrice = null)
     {
         $mainId = $shop->mainId ?? 0;
         $productInfo = ProductClass::getByCondition(['itemId' => $ptItemId, 'mainId' => $mainId], true);
         if (empty($productInfo)) {
             return false;
         }
-
         $productInfo->price = $price;
-
-        $addPrice = $productInfo->addPrice ?? 0;
-
-        $skAddPrice = $productInfo->skAddPrice ?? 0;
-        $sk = bcsub($addPrice, $skAddPrice, 2);
-        $productInfo->skPrice = bcsub($price, $sk, 2);
-
-        $hjAddPrice = $productInfo->hjAddPrice ?? 0;
-        $hj = bcsub($addPrice, $hjAddPrice, 2);
-        $productInfo->hjPrice = bcsub($price, $hj, 2);
-
-        $zsAddPrice = $productInfo->zsAddPrice ?? 0;
-        $zs = bcsub($addPrice, $zsAddPrice, 2);
-        $productInfo->zsPrice = bcsub($price, $zs, 2);
-
+        if (empty($skPrice)) {
+            $skMore = $productInfo->skMore ?? 0;
+            $productInfo->skPrice = bcadd($price, $skMore, 2);
+        } else {
+            $productInfo->skPrice = $skPrice;
+        }
         $productInfo->save();
     }