Просмотр исходного кода

传过来是单价不需要累加

shish 4 лет назад
Родитель
Сommit
8f6f227bc8
1 измененных файлов с 82 добавлено и 90 удалено
  1. 82 90
      biz-ghs/order/traits/OrderTrait.php

+ 82 - 90
biz-ghs/order/traits/OrderTrait.php

@@ -14,99 +14,91 @@ use common\components\imgUtil;
 trait OrderTrait
 {
 
-	//二维数组拼装admin信息
-	public static function groupAdminList($list)
-	{
-		if (empty($list)) {
-			return $list;
-		}
-		$adminIds = array_unique(array_filter(array_column($list, 'adminId')));
-		$adminInfo = AdminClass::getAdminByIds($adminIds, null, 'id');
-		foreach ($list as $k => $val) {
-			$adminId = $val['adminId'] ?? 0;
-			$list[$k]['adminName'] = $adminInfo[$adminId]['name']??'';
-			$list[$k]['nickName'] = $adminInfo[$adminId]['name']??'';
-			$list[$k]['avatar'] = $adminInfo[$adminId]['avatar'] ?? '';
-		}
-		return $list;
-	}
-
-	//2021.1.22 linqh 一维数组拼装admin信息
-	public static function groupAdmin($data)
-	{
-		$adminId = $data['adminId']??0;
-		$adminInfo = AdminClass::getAdminById($adminId);
-		$data['adminName'] = $adminInfo['name']??'';
-		$data['nickName'] = $adminInfo['name']??'';
-		$data['avatar'] = $adminInfo['avatar']??'';
-		return $data;
-
-	}
-
-	public static function groupSupplierList($list)
-	{
-		if (empty($list)) {
-			return $list;
-		}
-		$ghsIds = array_unique(array_filter(array_column($list, 'ghsId')));
-		$ghsInfo = GhsClass::getGhsByIds($ghsIds);
-
-
-		foreach ($list as $k => $val) {
-			$ghsId = $val['ghsId'] ?? 0;
-			$list[$k]['supplierName'] = $ghsInfo[$ghsId]['name'] ?? '';
-			$avatar = imgUtil::groupImg('');
-			$list[$k]['supplierAvatar'] = $avatar;
-			$list[$k]['supplierMobile'] = $ghsInfo[$ghsId]['mobile'] ?? '';
-			$list[$k]['supplierAddress'] = $ghsInfo[$ghsId]['address'] ?? '';
-		}
-		return $list;
-	}
-
-	//通过itemInfo 获取商品ID 对应数据(库存) linqh 2021.1.23
-	public static function getProductMapData($itemInfo,$key='productId')
-	{
-		$productIds = array_column($itemInfo, $key);
-		$productData = ProductClass::getProductByIds($productIds);
-		$productData = array_column($productData, NULL, 'id');
-		return $productData;
-	}
-
-	//通过itemInfo  求和大、小单位数  linqh 2021.1.25
-	public static function sumNumByItemInfo($itemInfo)
-	{
-		$bigNum = 0; //总共多少扎
-		$smallNum = 0; //总共多少支
-		if (!empty($itemInfo)) {
-			foreach ($itemInfo as $v) {
-				$bigNum += $v['bigNum']??0;
-				$smallNum += $v['smallNum']??0;
-			}
-		}
-		return [
-			'bigNum' => $bigNum,
-			'smallNum' => $smallNum
-		];
-	}
-
-	//itemInfo 相同product合并处理 [{"classId":5,"productId":3,"bigNum":1,"smallNum":2},{"classId":4,"productId":3,"bigNum":1,"smallNum":5}]
+    //二维数组拼装admin信息
+    public static function groupAdminList($list)
+    {
+        if (empty($list)) {
+            return $list;
+        }
+        $adminIds = array_unique(array_filter(array_column($list, 'adminId')));
+        $adminInfo = AdminClass::getAdminByIds($adminIds, null, 'id');
+        foreach ($list as $k => $val) {
+            $adminId = $val['adminId'] ?? 0;
+            $list[$k]['adminName'] = $adminInfo[$adminId]['name'] ?? '';
+            $list[$k]['nickName'] = $adminInfo[$adminId]['name'] ?? '';
+            $list[$k]['avatar'] = $adminInfo[$adminId]['avatar'] ?? '';
+        }
+        return $list;
+    }
+
+    //2021.1.22 linqh 一维数组拼装admin信息
+    public static function groupAdmin($data)
+    {
+        $adminId = $data['adminId'] ?? 0;
+        $adminInfo = AdminClass::getAdminById($adminId);
+        $data['adminName'] = $adminInfo['name'] ?? '';
+        $data['nickName'] = $adminInfo['name'] ?? '';
+        $data['avatar'] = $adminInfo['avatar'] ?? '';
+        return $data;
+
+    }
+
+    public static function groupSupplierList($list)
+    {
+        if (empty($list)) {
+            return $list;
+        }
+        $ghsIds = array_unique(array_filter(array_column($list, 'ghsId')));
+        $ghsInfo = GhsClass::getGhsByIds($ghsIds);
+
+
+        foreach ($list as $k => $val) {
+            $ghsId = $val['ghsId'] ?? 0;
+            $list[$k]['supplierName'] = $ghsInfo[$ghsId]['name'] ?? '';
+            $avatar = imgUtil::groupImg('');
+            $list[$k]['supplierAvatar'] = $avatar;
+            $list[$k]['supplierMobile'] = $ghsInfo[$ghsId]['mobile'] ?? '';
+            $list[$k]['supplierAddress'] = $ghsInfo[$ghsId]['address'] ?? '';
+        }
+        return $list;
+    }
+
+    //通过itemInfo 获取商品ID 对应数据(库存) linqh 2021.1.23
+    public static function getProductMapData($itemInfo, $key = 'productId')
+    {
+        $productIds = array_column($itemInfo, $key);
+        $productData = ProductClass::getProductByIds($productIds);
+        $productData = array_column($productData, NULL, 'id');
+        return $productData;
+    }
+
+    //通过itemInfo  求和大、小单位数  linqh 2021.1.25
+    public static function sumNumByItemInfo($itemInfo)
+    {
+        $bigNum = 0; //总共多少扎
+        $smallNum = 0; //总共多少支
+        if (!empty($itemInfo)) {
+            foreach ($itemInfo as $v) {
+                $bigNum += $v['bigNum'] ?? 0;
+                $smallNum += $v['smallNum'] ?? 0;
+            }
+        }
+        return [
+            'bigNum' => $bigNum,
+            'smallNum' => $smallNum
+        ];
+    }
+
+    //itemInfo 相同product合并处理 [{"classId":5,"productId":3,"bigNum":1,"smallNum":2},{"classId":4,"productId":3,"bigNum":1,"smallNum":5}]
     public static function mergeItemInfo($itemInfo)
     {
         $newItemInfo = [];
-        foreach ($itemInfo as $v){
+        foreach ($itemInfo as $v) {
             $productId = $v['productId'];
-            if(isset($newItemInfo[$productId])){
-                $newItemInfo[$productId]['bigNum'] = bcadd($v['bigNum'],$newItemInfo[$productId]['bigNum'],2);
-                $newItemInfo[$productId]['smallNum'] = bcadd($v['smallNum'],$newItemInfo[$productId]['smallNum'],2);
-                //价格累加
-                if(isset($v['price'])){
-                    $newItemInfo[$productId]['price'] =   bcadd($v['price'],$newItemInfo[$productId]['price'],2);
-                }
-                //供应商端自定义价格传导到零售也要累加(特价情况出现二个重复花材) shish 20210903
-                if(isset($v['userPrice'])){
-                    $newItemInfo[$productId]['userPrice'] =   bcadd($v['userPrice'],$newItemInfo[$productId]['userPrice'],2);
-                }
-            }else{
+            if (isset($newItemInfo[$productId])) {
+                $newItemInfo[$productId]['bigNum'] = bcadd($v['bigNum'], $newItemInfo[$productId]['bigNum'], 2);
+                $newItemInfo[$productId]['smallNum'] = bcadd($v['smallNum'], $newItemInfo[$productId]['smallNum'], 2);
+            } else {
                 $newItemInfo[$productId] = $v;
             }
         }
@@ -117,7 +109,7 @@ trait OrderTrait
     //出库时更新统计
     public static function updateStatByStockOut($order)
     {
-        //
+
     }
 
     //入库时更新统计