objMReservoirArea = new MReservoirArea($this->onlineEnterpriseId, $this->onlineUserId); } /** * 获取参数 * @return array */ public function commonFieldFilter() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $data = [ "enterpriseId" => $this->onlineEnterpriseId, "warehouseId" => getArrayItem($params,'warehouseId'), // 仓库id "name" => getArrayItem($params,'name'), "code" => getArrayItem($params,'code'), "type" => getArrayItem($params,'type'), ]; foreach ($data as $key => $value) { if (empty($value) && $value !== 0) { $this->sendOutput($key . '参数错误', ErrorCode::$paramError); } } $data['length'] = getArrayItem($params,'length', 0); $data['width'] = getArrayItem($params,'width', 0); $data['height'] = getArrayItem($params,'height', 0); $data['weight'] = getArrayItem($params,'weight', 0); $data['enableStatus'] = getArrayItem($params,'enableStatus',5); return $data; } /** * 库区添加 */ public function addReservoir() { $data = $this->commonFieldFilter(); $result = $this->objMReservoirArea->addReservoir($data); if (!$result->isSuccess()) { parent::sendOutput($result->getData(), $result->getErrorCode()); } parent::sendOutput($result->getData()); } /** * 库区删除 */ public function deleteReservoir() { $id = $this->request->param('request_id'); if (empty($id)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $update = [ 'deleteStatus' => StatusCode::$delete ]; $result = $this->objMReservoirArea->updateReservoir($update, ['id' => $id,'enterpriseId' => $this->onlineEnterpriseId]); if (!$result->isSuccess()) { parent::sendOutput($result->getData(), $result->getErrorCode()); } parent::sendOutput($result->getData()); } /** * 库区修改 */ public function updateReservoir() { $id = $this->request->param('request_id'); if (empty($id)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $update = $this->commonFieldFilter(); $result = $this->objMReservoirArea->updateReservoir($update, ['id' => $id,'enterpriseId' => $this->onlineEnterpriseId]); if (!$result->isSuccess()) { parent::sendOutput($result->getData(), $result->getErrorCode()); } parent::sendOutput($result->getData()); } /** * 库区启用/禁用 */ public function enableReservoir() { $id = $this->request->param('request_id'); if (empty($id)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $params = $this->request->getRawJson(); $data = [ 'enableStatus' => getArrayItem($params,'enableStatus',5), ]; foreach ($data as $key => $value) { if (empty($value) && $value !== 0) { $this->sendOutput($key . '参数错误', ErrorCode::$paramError); } } $result = $this->objMReservoirArea->updateReservoir($data, ['id' => $id,'enterpriseId' => $this->onlineEnterpriseId]); if (!$result->isSuccess()) { parent::sendOutput($result->getData(), $result->getErrorCode()); } parent::sendOutput($result->getData()); } /** * 库区列表 */ public function getAllReservoir() { $params = $this->request->getRawJson(); $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; $selectParams['enterpriseId'] = $this->onlineEnterpriseId; $selectParams['deleteStatus'] = StatusCode::$standard; if(isset($params['warehouseId']) && !empty($params['warehouseId'])){ $selectParams['warehouseId'] = $params['warehouseId']; } if(isset($params['type']) && !empty($params['type'])){ $selectParams['type'] = $params['type']; } $result = $this->objMReservoirArea->getAllReservoir($selectParams); if (!$result->isSuccess()) { parent::sendOutput($result->getData(), ErrorCode::$dberror); } $returnData = $result->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } /** * 库区列表(不分页) */ public function getListReservoir() { $params = $this->request->getRawJson(); $selectParams = []; if(isset($params['warehouseId']) && !empty($params['warehouseId'])){ $selectParams['warehouseId'] = $params['warehouseId']; } if(isset($params['type']) && !empty($params['type'])){ $selectParams['type'] = $params['type']; } $selectParams['enterpriseId'] = $this->onlineEnterpriseId; $result = $this->objMReservoirArea->getListReservoir($selectParams); if (!$result->isSuccess()) { parent::sendOutput($result->getData(), ErrorCode::$dberror); } parent::sendOutput($result->getData()); } /** * 库区详情 */ public function getReservoirInfo() { $params = $this->request->param('request_id'); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $result = $this->objMReservoirArea->getReservoirInfo($params); if (!$result->isSuccess()) { parent::sendOutput($result->getData(), $result->getErrorCode()); } parent::sendOutput($result->getData()); } }