Jelajahi Sumber

清除特价

shish 8 bulan lalu
induk
melakukan
0f0e7968e7
1 mengubah file dengan 12 tambahan dan 5 penghapusan
  1. 12 5
      app-ghs/controllers/ProductController.php

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

@@ -701,22 +701,29 @@ class ProductController extends BaseController
                     util::fail('没有找到花材');
                 }
                 $productName = $productInfo->name ?? '';
-                if (isset($product['id']) == false) {
+
+                //这里清掉花材已经在做的特价活动
+                $productInfo->discountPrice = 0;
+                $productInfo->skDiscountPrice = 0;
+                $productInfo->hjDiscountPrice = 0;
+                $productInfo->save();
+
+                if (!isset($product['id'])) {
                     util::fail('没有花材');
                 }
-                if (isset($product['price']) == false || is_numeric($product['price']) == false || $product['price'] < 0) {
+                if (!isset($product['price']) || !is_numeric($product['price']) || $product['price'] < 0) {
                     util::fail('请填写' . $productName . '的批发价');
                 }
                 $price = $product['price'];
-                if (isset($product['skPrice']) == false || is_numeric($product['skPrice']) == false || $product['skPrice'] < 0) {
+                if (!isset($product['skPrice']) || !is_numeric($product['skPrice']) || $product['skPrice'] < 0) {
                     util::fail('请填写' . $productName . '的零售价');
                 }
                 $skPrice = $product['skPrice'];
-                if (isset($product['hjPrice']) == false || is_numeric($product['hjPrice']) == false || $product['hjPrice'] < 0) {
+                if (!isset($product['hjPrice']) || !is_numeric($product['hjPrice']) || $product['hjPrice'] < 0) {
                     util::fail('请填写' . $productName . '的会员价');
                 }
                 $hjPrice = $product['hjPrice'] ?? 0;
-                if (isset($productInfo->mainId) == false || $productInfo->mainId != $this->mainId) {
+                if (!isset($productInfo->mainId) || $productInfo->mainId != $this->mainId) {
                     util::fail('无法访问');
                 }
                 if ($hjPrice > $price) {