Bladeren bron

加价控制

shish 4 jaren geleden
bovenliggende
commit
468b72de67
1 gewijzigde bestanden met toevoegingen van 8 en 11 verwijderingen
  1. 8 11
      app-ghs/controllers/ProductController.php

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

@@ -388,28 +388,25 @@ class ProductController extends BaseController
             }
             $currentProduct->$type = $val;
             if ($type == 'addPrice') {
-
-                $anotherAddPrice = $val > 2 ? $val - 1 : 1;
-
                 $qtAddPrice = $currentProduct->qtAddPrice;
                 if ($qtAddPrice <= 0) {
-                    $currentProduct->qtAddPrice = $anotherAddPrice;
-                    $data['qtAddPrice'] = $anotherAddPrice;
+                    $currentProduct->qtAddPrice = $val - 1 > 0 ? $val - 1 : 1;
+                    $data['qtAddPrice'] = $currentProduct->qtAddPrice;
                 }
                 $byAddPrice = $currentProduct->byAddPrice;
                 if ($byAddPrice <= 0) {
-                    $currentProduct->byAddPrice = $anotherAddPrice;
-                    $data['byAddPrice'] = $anotherAddPrice;
+                    $currentProduct->byAddPrice = $val - 2 > 0 ? $val - 2 : 1;
+                    $data['byAddPrice'] = $currentProduct->byAddPrice;
                 }
                 $hjAddPrice = $currentProduct->hjAddPrice;
                 if ($hjAddPrice <= 0) {
-                    $currentProduct->hjAddPrice = $anotherAddPrice;
-                    $data['hjAddPrice'] = $anotherAddPrice;
+                    $currentProduct->hjAddPrice = $val - 3 > 0 ? $val - 3 : 1;
+                    $data['hjAddPrice'] = $currentProduct->hjAddPrice;
                 }
                 $zsAddPrice = $currentProduct->zsAddPrice;
                 if ($zsAddPrice <= 0) {
-                    $currentProduct->zsAddPrice = $anotherAddPrice;
-                    $data['zsAddPrice'] = $anotherAddPrice;
+                    $currentProduct->zsAddPrice = $val - 4 > 0 ? $val - 4 : 1;
+                    $data['zsAddPrice'] = $currentProduct->zsAddPrice;
                 }
             }
             $currentProduct->save();