shish пре 3 година
родитељ
комит
889368ce83
1 измењених фајлова са 9 додато и 6 уклоњено
  1. 9 6
      biz-hd/purchase/classes/PurchaseClass.php

+ 9 - 6
biz-hd/purchase/classes/PurchaseClass.php

@@ -482,10 +482,6 @@ class PurchaseClass extends BaseClass
                 'smallUnit' => $hdProductData[$hdProductId]['smallUnit'],//小单位名称 支
             ];
 
-            if ($currentBigNum > 0 && $currentSmallNum > 0) {
-                util::fail($itemName . ' 扎和支只能选一种');
-            }
-
             $productList[$key]['itemInfo'] = json_encode($itemInfo);
             $productList[$key]['variety'] = $variety;
             $productList[$key]['itemId'] = $itemId;
@@ -503,18 +499,25 @@ class PurchaseClass extends BaseClass
             $productList[$key]['smallPrice'] = $price;
             $productList[$key]['mainId'] = $mainId;
 
+            $currentBigUnit = $hdProductData[$hdProductId]['bigUnit'] ?? '';
+            $currentSmallUnit = $hdProductData[$hdProductId]['smallUnit'] ?? '';
             if ($currentBigNum > 0) {
                 $xhNum = $currentBigNum;
-                $xhUnitName = $hdProductData[$hdProductId]['bigUnit'] ?? '';
+                $xhUnitName = $currentBigUnit;
                 $xhUnitType = dict::getDict('unitType', 'big');
             } else {
                 $xhNum = $currentSmallNum;
-                $xhUnitName = $hdProductData[$hdProductId]['smallUnit'] ?? '';
+                $xhUnitName = $currentSmallUnit;
                 $xhUnitType = dict::getDict('unitType', 'small');
             }
             $itemPrice = $price;
             $price = bcmul($itemPrice, $xhNum, 2);
 
+			//客户下单时会出现同时选了扎和支,很奇怪,前端没有找到原因,后端限制
+            if ($currentBigNum > 0 && $currentSmallNum > 0) {
+                util::fail($itemName . " {$currentBigUnit}和{$currentSmallUnit}每单只能选一种");
+            }
+
             $productList[$key]['xhNum'] = $xhNum;
             $productList[$key]['xhUnitName'] = $xhUnitName;
             $productList[$key]['xhUnitType'] = $xhUnitType;