objMInventory = new MInventory($this->onlineEnterpriseId, $this->onlineUserId); } /** * 库存列表 * @throws Exception */ public function getInventoryAll() { $params = $this->request->getRawJson(); if(empty($params)){ $this->sendOutput('参数为空', ErrorCode::$paramError); } $selectParams = [ 'haveInventoryNum' => getArrayItem($params, 'haveInventoryNum', 0), 'materielName' => getArrayItem($params, 'materielName', ''), 'materielCode' => getArrayItem($params, 'materielCode', ''), 'merchantId' => getArrayItem($params, 'merchantId', 0), 'categoryId' => getArrayItem($params, 'categoryId', 0), 'export' => getArrayItem($params, 'export', 0), 'sortType' => getArrayItem($params,'sortType',0) ]; $pageParams = pageToOffset(isset($params['page']) ? $params['page'] : 1, isset($params['pageSize']) ? $params['pageSize'] : 10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; $export = isset($params['export']) ? $params['export'] : 0; $result = $this->objMInventory->getInventoryAll($selectParams, $export); if ($result->isSuccess()) { $returnData = $result->getData(); $pageData = [ 'amount' => $returnData['amount'], 'count' => $returnData['count'], 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } else { parent::sendOutput($result->getData(), ErrorCode::$dberror); } } /** * 仓库库存 * @throws Exception */ public function getWarehouseInventory() { $skuId = $this->request->param('request_id'); if(empty($skuId)){ $this->sendOutput('参数为空', ErrorCode::$paramError); } $result = $this->objMInventory->getWarehouseInventory(['skuId' => $skuId]); if (!$result->isSuccess()) { parent::sendOutput($result->getData(), ErrorCode::$dberror); } parent::sendOutput($result->getData()); } /** * 库存流水列表 * @throws Exception */ public function getInventoryDetailsAll() { $params = $this->request->getRawJson(); if(empty($params)){ $this->sendOutput('参数为空', ErrorCode::$paramError); } $selectParams = []; $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; if(isset($params['warehouseId']) && !empty($params['warehouseId'])){ $selectParams['warehouseId'] = $params['warehouseId']; }else{ $this->sendOutput('warehouseId,参数错误', ErrorCode::$paramError); } if(isset($params['operatorId']) && !empty($params['operatorId'])){ $selectParams['operatorId'] = $params['operatorId']; } if(isset($params['skuId']) && !empty($params['skuId'])){ $selectParams['skuId'] = $params['skuId']; } if(isset($params['merchantId']) && !empty($params['merchantId'])){ $selectParams['merchantId'] = $params['merchantId']; } $export = isset($params['export']) ? $params['export'] : 0; $result = $this->objMInventory->getInventoryDetailsAll($selectParams, $export); if ($result->isSuccess()) { $returnData = $result->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } else { parent::sendOutput($result->getData(), ErrorCode::$dberror); } } /** * 库存流水搜索 * @throws Exception */ public function searchAllInventoryDetails() { $params = $this->request->getRawJson(); if(empty($params)){ $this->sendOutput('参数为空', ErrorCode::$paramError); } $selectParams = []; $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; if(isset($params['warehouseId']) && !empty($params['warehouseId'])){ $selectParams['warehouseId'] = $params['warehouseId']; }else{ $this->sendOutput('warehouseId,参数错误', ErrorCode::$paramError); } $selectParams['operatorId'] = isset($params['operatorId']) ? $params['operatorId'] : ''; $selectParams['skuId'] = isset($params['skuId']) ? $params['skuId'] : ''; $selectParams['start'] = isset($params['start']) ? $params['start'] : ''; $selectParams['end'] = isset($params['end']) ? $params['end'] : ''; $selectParams['search'] = isset($params['search']) ? $params['search'] : ''; $selectParams['merchantId'] = isset($params['merchantId']) ? $params['merchantId'] : ''; $selectParams['source'] = isset($params['source']) ? $params['source'] : ''; $export = isset($params['export']) ? $params['export'] : 0; $result = $this->objMInventory->getAllInventoryDetailsList($selectParams, $export, 0); if ($result->isSuccess()) { $returnData = $result->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } else { parent::sendOutput($result->getData(), ErrorCode::$dberror); } } /** * 批次列表 * @throws Exception */ public function getAllBatch() { $params = $this->request->getRawJson(); if(empty($params)){ $this->sendOutput('参数为空', ErrorCode::$paramError); } $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $selectParams = [ 'limit' => $pageParams['limit'], 'offset' => $pageParams['offset'], 'warehouseId' => getArrayItem($params, 'warehouseId', 0), 'materielId' => getArrayItem($params, 'materielId', 0), 'skuId' => getArrayItem($params, 'skuId', 0), 'startTime' => getArrayItem($params, 'start', 0), 'endTime' => getArrayItem($params, 'end', 0), 'keyword' => getArrayItem($params, 'keyword', 0), 'batchNo' => getArrayItem($params, 'batchNo', 0), ]; if( empty($selectParams['warehouseId']) ){ $this->sendOutput('warehouseId参数错误', ErrorCode::$paramError); } $result = $this->objMInventory->getAllBatch($selectParams); if ($result->isSuccess()) { $returnData = $result->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } else { parent::sendOutput($result->getData(), ErrorCode::$dberror); } } /** * 批次搜索 */ public function searchAllInventoryBatch() { $params = $this->request->getRawJson(); if(empty($params)){ $this->sendOutput('参数为空', ErrorCode::$paramError); } $selectParams = []; $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; if(isset($params['warehouseId']) && !empty($params['warehouseId'])){ $selectParams['warehouseId'] = $params['warehouseId']; }else{ $this->sendOutput('warehouseId,参数错误', ErrorCode::$paramError); } $selectParams['start'] = isset($params['start']) ? $params['start'] : ''; $selectParams['end'] = isset($params['end']) ? $params['end'] : ''; $selectParams['search'] = isset($params['search']) ? $params['search'] : ''; $result = $this->objMInventory->searchAllInventoryBatch($selectParams); if ($result->isSuccess()) { $returnData = $result->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } else { parent::sendOutput($result->getData(), ErrorCode::$dberror); } } /** * 批次详情 */ public function getBatchInfo() { $params = $this->request->getRawJson(); if(empty($params)) parent::sendOutput('参数为空', ErrorCode::$paramError); $selectParams = [ 'id' => isset($params['id']) ? $params['id'] : '', 'warehouseId' => isset($params['warehouseId']) ? $params['warehouseId'] : '', ]; foreach($selectParams as $key => $value){ if(empty($value)){ parent::sendOutput($key.'参数为空', ErrorCode::$paramError); } } $modelResult = $this->objMInventory->getBatchInfo($selectParams); if(!$modelResult->getData()){ parent::sendOutput($modelResult->getData(), $modelResult->getErrorCode()); } parent::sendOutput($modelResult->getData()); } /** * 库存汇总 * @throws Exception */ public function inventoryStatistics() { $params = $this->request->getRawJson(); if(empty($params)) parent::sendOutput('参数为空', ErrorCode::$paramError); $selectParams = [ 'warehouseId' => isset($params['warehouseId']) ? $params['warehouseId'] : '', ]; foreach($selectParams as $key => $value){ if(empty($value)){ parent::sendOutput($key.'参数错误', ErrorCode::$paramError); } } $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; $selectParams['start'] = isset($params['start']) ? $params['start'] : ''; $selectParams['end'] = isset($params['end']) ? $params['end'] : ''; $selectParams['search'] = isset($params['search']) ? $params['search'] : ''; $selectParams['merchantId'] = isset($params['merchantId']) ? $params['merchantId'] : ''; $selectParams['materielCode'] = isset($params['materielCode']) ? $params['materielCode'] : ''; $export = isset($params['export']) ? $params['export'] : 0; $hideAmount = isset($params['hideAmount']) ? $params['hideAmount'] : 0; $reconciliation = isset($params['reconciliation']) ? $params['reconciliation'] : 0;//库存日对账 $result = $this->objMInventory->inventoryStatistics($selectParams, $export, $hideAmount,$reconciliation); if ($result->isSuccess()) { $returnData = $result->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } else { parent::sendOutput($result->getData(), ErrorCode::$dberror); } } /** * 库存汇总搜索 * @throws Exception */ public function searchInventoryStatistics() { $params = $this->request->getRawJson(); if(empty($params)){ $this->sendOutput('参数为空', ErrorCode::$paramError); } $selectParams = []; $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; if(isset($params['warehouseId']) && !empty($params['warehouseId'])){ $selectParams['warehouseId'] = $params['warehouseId']; }else{ $this->sendOutput('warehouseId,参数错误', ErrorCode::$paramError); } $selectParams['start'] = isset($params['start']) ? $params['start'] : ''; $selectParams['end'] = isset($params['end']) ? $params['end'] : ''; $selectParams['search'] = isset($params['search']) ? $params['search'] : ''; $export = isset($params['export']) ? $params['export'] : 0; $hideAmount = isset($params['hideAmount']) ? $params['hideAmount'] : 0; $result = $this->objMInventory->searchInventoryStatistics($selectParams, $export, $hideAmount); if ($result->isSuccess()) { $returnData = $result->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } else { parent::sendOutput($result->getData(), ErrorCode::$dberror); } } /** * 根据仓库id查询物料库存信息 * @throws Exception */ public function getInventoryByWarehouseId() { $params = $this->request->getRawJson(); if(empty($params)){ $this->sendOutput('参数为空', ErrorCode::$paramError); } $selectParams = []; $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; if(isset($params['warehouseId']) && !empty($params['warehouseId'])){ $selectParams['warehouseId'] = $params['warehouseId']; } if(isset($params['search']) && !empty($params['search'])){ $selectParams['search'] = $params['search']; } if (isset($params['categoryId']) && !empty($params['categoryId'])){ $selectParams['categoryId'] = $params['categoryId']; } if (isset($params['merchantId']) && !empty($params['merchantId'])){ $selectParams['merchantId'] = $params['merchantId']; } $export = isset($params['export']) ? $params['export'] : 0; $result = $this->objMInventory->getInventoryByWarehouseId($selectParams,$export); if ($result->isSuccess()) { $returnData = $result->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } else { parent::sendOutput($result->getData(), ErrorCode::$dberror); } } /** * * @throws Exception */ public function getBatchByIds() { $params = $this->request->getRawJson(); if(empty($params)){ parent::sendOutput('参数为空', ErrorCode::$paramError); } $data = [ 'warehouseId' => isset($params['warehouseId']) ? $params['warehouseId'] : '', 'materielId' => isset($params['materielId']) ? $params['materielId'] : '', ]; foreach($data as $key => $value){ if(empty($value)){ parent::sendOutput($key.'参数错误', ErrorCode::$paramError); } } $result = $this->objMInventory->getBatchByIds([$data], 'batchNo,num'); if(!$result->isSuccess()){ parent::sendOutput($result->getData(),$result->getErrorCode()); } $returnData = $result->getData(); parent::sendOutput($returnData[0]['batch']); } /** * 格式化库存流水es */ public function formatInventoryDetailsEsData() { $params = $this->request->getRawJson(); if (!isset($params['key']) || md5('123456123456') != $params['key']) { $this->sendOutput('参数校验失败', ErrorCode::$paramError); } $result = $this->objMInventory->formatInventoryDetailsEsData(); if (!$result->isSuccess()) { parent::sendOutput($result->getData(),$result->getErrorCode()); } parent::sendOutput($result->getData()); } /** * 换算sku数量 * @throws Exception */ public function getSkuNum() { $params = $this->request->getRawJson(); $result = $this->objMInventory->getSkuNum($params); if (!$result->isSuccess()) { parent::sendOutput($result->getData(),$result->getErrorCode()); } parent::sendOutput($result->getData()); } /** * 换算主单位sku数量 * @throws Exception */ public function getMasterSkuNum() { $params = $this->request->getRawJson(); if(empty($params)){ parent::sendOutput('参数为空', ErrorCode::$paramError); } $result = $this->objMInventory->getMasterSkuNum($params); if (!$result->isSuccess()) { parent::sendOutput($result->getData(),$result->getErrorCode()); } parent::sendOutput($result->getData()); } public function getInventoryByShopIdAndSkuIds() { $params = $this->request->getRawJson(); $result = $this->objMInventory->getInventoryByShopIdAndSkuIds($params['shopId'], $params['skuId']); if (!$result->isSuccess()) { parent::sendOutput($result->getData(),$result->getErrorCode()); } parent::sendOutput($result->getData()); } public function getInventoryByShopIdAndMaterielIds() { $params = $this->request->getRawJson(); $result = $this->objMInventory->getInventoryByShopIdAndMaterielIds($params['shopId'], $params['materielIds']); if (!$result->isSuccess()) { parent::sendOutput($result->getData(),$result->getErrorCode()); } parent::sendOutput($result->getData()); } /** * 根据skuId获取库区数量 */ public function getAreaDateBySkuId() { $objMInventoryArea = new MInventoryArea($this->onlineEnterpriseId,$this->onlineUserId); $params = $this->request->getRawJson(); if( !isset($params['skuId']) && empty($params['skuId'])){ parent::sendOutput('skuId参数为空', ErrorCode::$paramError); } $result = $objMInventoryArea->getAreaDateBySkuId($params); if (!$result->isSuccess()) { parent::sendOutput($result->getData(),$result->getErrorCode()); } parent::sendOutput($result->getData()); } }