Selaa lähdekoodia

大小单位管理

shish 3 vuotta sitten
vanhempi
commit
cc175c3b25
1 muutettua tiedostoa jossa 12 lisäystä ja 2 poistoa
  1. 12 2
      biz-ghs/product/classes/ProductClass.php

+ 12 - 2
biz-ghs/product/classes/ProductClass.php

@@ -1092,8 +1092,18 @@ class ProductClass extends BaseClass
         $data['cover'] = isset($data['cover']) && !empty($data['cover']) ? $data['cover'] : '';
         $ratio = $data['ratio'] ?? false;
         $weight = $data['weight'] ?? false;
-        $data['bigUnit'] = $data['bigUnit'] ?? '扎';
-        $data['smallUnit'] = $data['smallUnit'] ?? '支';
+
+        $bigUnitId = $data['bigUnitId'] ?? 0;
+        $smallUnitId = $data['smallUnitId'] ?? 0;
+        if (empty($bigUnitId) || empty($smallUnitId)) {
+            util::fail('请选择单位');
+        }
+        $unitList = UnitClass::getByIds([$bigUnitId, $smallUnitId], null, 'id');
+        $bigUnit = $unitList[$bigUnitId]['name'] ?? '扎';
+        $smallUnit = $unitList[$smallUnitId]['name'] ?? '支';
+        $data['bigUnit'] = $bigUnit;
+        $data['smallUnit'] = $smallUnit;
+
         $data['shopId'] = $data['shopId'] ?? 0;
         $currentShopId = $data['shopId'];
         $data['sjId'] = $data['sjId'] ?? 0;