shish %!s(int64=4) %!d(string=hai) anos
pai
achega
1c8322a5c6
Modificáronse 1 ficheiros con 16 adicións e 11 borrados
  1. 16 11
      app-ghs/controllers/ProductController.php

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

@@ -255,27 +255,32 @@ class ProductController extends BaseController
 
             $productList = ProductClass::getAllByCondition(['id' => ['in', $ids]], null, '*', 'id', true);
             foreach ($arr as $product) {
-                if (isset($product['price']) == false) {
-                    util::fail('没有价格');
+
+                $productId = $product['id'];
+                $productInfo = $productList[$productId] ?? [];
+                if (empty($productInfo)) {
+                    util::fail('没有找到花材');
                 }
+                $productName = $productInfo->name ?? '';
                 if (isset($product['id']) == false) {
                     util::fail('没有花材');
                 }
-                $price = $product['price'] ?? 0;
-                $skPrice = $product['skPrice'] ?? 0;
-                $productId = $product['id'];
-
-                $product = $productList[$productId] ?? [];
-                if (empty($product)) {
-                    util::fail('没有找到花材');
+                if (isset($product['price']) == false || is_numeric($product['price']) == false || $product['price'] < 0) {
+                    util::fail('请填写' . $productName . '的花店价');
                 }
-                if (isset($product->mainId) == false || $product->mainId != $this->mainId) {
+                $price = $product['price'];
+                if (isset($product['skPrice']) == false || is_numeric($product['skPrice']) == false || $product['skPrice'] < 0) {
+                    util::fail('请填写' . $productName . '的散客价');
+                }
+                $skPrice = $product['skPrice'];
+
+                if (isset($productInfo->mainId) == false || $productInfo->mainId != $this->mainId) {
                     util::fail('没有权限访问');
                 }
                 if (empty($price)) {
                     continue;
                 }
-                $ptItemId = $product->itemId;
+                $ptItemId = $productInfo->itemId;
                 ProductClass::changeSinglePrice($shop, $ptItemId, $price, $skPrice);
                 //在首店修改需要同步到所有直营店
                 if ($default == 1) {