$val) { $adminId = $val['adminId'] ?? 0; //不能取admin里的nam $list[$k]['adminName'] = $val['shopAdminName'] ?? ''; $list[$k]['nickName'] = $adminInfo[$adminId]['name'] ?? ''; $list[$k]['avatar'] = $adminInfo[$adminId]['avatar'] ?? ''; } return $list; } //2021.1.22 lqh 一维数组拼装admin信息 public static function groupAdmin($data) { $adminId = $data['adminId'] ?? 0; $adminInfo = AdminClass::getAdminById($adminId); //不能取admin里的nam $data['adminName'] = $data['shopAdminName'] ?? ''; $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 对应数据(库存) lqh 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 求和大、小单位数 lqh 2021.1.25 public static function sumNumByItemInfo($itemInfo) { $bigNum = 0; //总共多少扎 $smallNum = 0; //总共多少支 if (!empty($itemInfo)) { foreach ($itemInfo as $v) { $currentBigNum = isset($v['bigNum']) && is_numeric($v['bigNum']) ? $v['bigNum'] : 0; $bigNum += $currentBigNum; $currentSmallNum = isset($v['smallNum']) && is_numeric($v['smallNum']) ? $v['smallNum'] : 0; $smallNum += $currentSmallNum; } } 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) { $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); } else { $newItemInfo[$productId] = $v; } } $newItemInfo = array_merge($newItemInfo); return $newItemInfo; } //出库时更新统计 public static function updateStatByStockOut($order) { } //入库时更新统计 public static function updateStatByStockIn($order) { } //盘点时更新统计 public static function updateStatCheck($order) { } }