林琦海 5 лет назад
Родитель
Сommit
a412699c8a

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

@@ -91,8 +91,8 @@ class ProductClass extends BaseClass
                 $smallPrice = bcdiv($v['price'], $ratio, 2);
             }
             $list[$k]['smallPrice'] = $smallPrice;
-            $list[$k]['bigUnit'] = xhItemService::getUnitName($v['bigUnit']);
-            $list[$k]['smallUnit'] = xhItemService::getUnitName($v['smallUnit']);
+//            $list[$k]['bigUnitName'] = xhItemService::getUnitName($v['bigUnit']);
+//            $list[$k]['smallUnitName'] = xhItemService::getUnitName($v['smallUnit']);
         }
         return $list;
     }

+ 2 - 2
biz/item/classes/PtItemClass.php

@@ -27,8 +27,8 @@ class PtItemClass extends BaseClass
             $prefix = imgUtil::getPrefix();
             foreach ($list as $k => $v) {
                 $list[$k]['cover'] = $prefix . $v['cover'];
-                $list[$k]['bigUnitName'] = self::getUnitName($v['bigUnit']);
-                $list[$k]['smallUnitName'] = self::getUnitName($v['smallUnit']);
+//                $list[$k]['bigUnitName'] = self::getUnitName($v['bigUnit']);
+//                $list[$k]['smallUnitName'] = self::getUnitName($v['smallUnit']);
                 if ($showSelect) {
                     //1未选 2已选
                     if (in_array($v['id'], $sjItemIds)) {

+ 13 - 11
common/services/xhItemService.php

@@ -7,6 +7,7 @@
 namespace common\services;
 
 
+use biz\item\classes\UnitClass;
 use bizGhs\product\classes\ProductClass;
 use common\components\imgUtil;
 use common\models\xhItem;
@@ -19,19 +20,19 @@ class xhItemService
 	{
 		return (new xhItem())->getAllByCondition($condition, $order, $field);
 	}
-	
+
 	public static function getById($id)
 	{
 		return (new xhItem())->getById($id);
 	}
-	
+
 	public static function getItemUnitNum($id)
 	{
 		$itemData = self::getById($id);
 		$unitNum = $itemData['unitNum'];
 		return $unitNum;
 	}
-	
+
 	//批量获取item unitNum  [itemId=>unitNum]
 	public static function getItemUnitNums($ids)
 	{
@@ -44,13 +45,13 @@ class xhItemService
 		}
 		return $data;
 	}
-	
+
 	public static function getByIds($ids)
 	{
 		$list = (new xhItem())->getByIds($ids);
 		return self::groupBaseInfo($list);
 	}
-	
+
 	//组合常用信息 ssh 2021.3.4
 	public static function groupBaseInfo($list)
 	{
@@ -65,14 +66,15 @@ class xhItemService
 		return $list;
 	}
 
-	//先写死,之后查表
+	//查表
 	public static function getUnitName($unit)
 	{
-		$map = [
-			1 => '扎',
-			2 => '支',
-		];
+	    $data = UnitClass::getAllList("id,name",[]);
+	    $map =[];
+	    foreach ($data as $v){
+	        $map[$v['id']] = $v['name'];
+        }
 		return $map[$unit] ?? '支';
 	}
-	
+
 }

+ 9 - 0
sql.sql

@@ -2042,3 +2042,12 @@ CREATE TABLE `xhGoodsItem` (
   `updateTime` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '修改时间',
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='成品对应的花材';
+
+
+=====linqh 2021.4.11
+==
+ALTER TABLE `xhPtItem`
+MODIFY COLUMN `bigUnit`  varchar(20) NOT NULL DEFAULT '' COMMENT '大单位名称' AFTER `unit`,
+MODIFY COLUMN `smallUnit`  varchar(20) NOT NULL DEFAULT '' COMMENT '小单位' AFTER `bigUnit`,
+ADD COLUMN `bigUnitId`  smallint(6) NOT NULL DEFAULT 1 COMMENT '大单位ID' AFTER `smallUnit`,
+ADD COLUMN `smallUnitId`  smallint(6) NOT NULL DEFAULT 2 COMMENT '小单位ID' AFTER `bigUnitId`;