objMExpenseSingle = new MExpenseSingle($this->onlineEnterpriseId, $this->onlineUserId); } /** * 添加和编辑收款申请单公共字段处理方法 * * @return array */ public function commonFieldFilter() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $ExpenseSingleData = [ 'currentUnitId' => getArrayItem($params, 'currentUnitId'), 'currentUnit' => getArrayItem($params, 'currentUnit',''), 'type' => getArrayItem($params, 'type',''), 'billTime' => getArrayItem($params, 'billTime'), 'manager' => getArrayItem($params, 'manager',''), 'shopId' => getArrayItem($params, 'shopId',''), 'shopName' => getArrayItem($params, 'shopName',''), 'consumeTypeId' => getArrayItem($params, 'consumeTypeId',''), 'consumeTypeName' => getArrayItem($params, 'consumeTypeName',''), 'totalCollectionAmount' => getArrayItem($params,'totalCollectionAmount',0), 'totalPreferentialAmount' => getArrayItem($params,'totalPreferentialAmount',0), 'totalActualAmount' => getArrayItem($params,'totalActualAmount',0), 'payType' =>getArrayItem($params,'payType',''), 'auditStatus' =>getArrayItem($params,'auditStatus', StatusCode::$auditStatus['auditing']), 'deleteStatus' =>getArrayItem($params,'deleteStatus', 5), 'expenseSingleAccountDate' => getArrayItem($params,'expenseSingleAccountDate', []) ]; foreach ($ExpenseSingleData as $key => $value) { if (empty($value) && $value !== 0) { $this->sendOutput($key . '参数错误', ErrorCode::$paramError); } } //判断expenseSingleAccountDate里面的数据是否为空 foreach ($ExpenseSingleData['expenseSingleAccountDate'] as $expenseSingle) { if(!empty($expenseSingle)) { foreach ($expenseSingle as $k =>$v) { if(in_array($k, ['accountId','amount','settlementMethodId','settlementAccount']) && empty($v)) { $this->sendOutput('请输入账户'.$k, ErrorCode::$paramError); } } } } $ExpenseSingleData['createTime'] = time(); $ExpenseSingleData['updateTime'] = time(); return $ExpenseSingleData; } /** * 新增费用单 */ public function addExpenseSingle() { $expenseSingleData = $this->commonFieldFilter(); $result = $this->objMExpenseSingle->addExpenseSingle($expenseSingleData); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 获取指定的费用单 */ public function getExpenseSingleInfo() { $expenseSingleId = $this->request->param('request_id'); if (!$expenseSingleId) { $this->sendOutput('参数错误', ErrorCode::$paramError); } $result = $this->objMExpenseSingle->getExpenseSingleInfo($expenseSingleId); if ($result->isSuccess()) { $this->sendOutput($result->getData()); } else { $this->sendOutput($result->getData(), $result->getErrorCode()); } } /** * 编辑指定的收款单 */ public function editExpenseSingle() { $expenseSingletId = $this->request->param('request_id'); if(empty($expenseSingletId)){ $this->sendOutput('参数错误', ErrorCode::$paramError); } $expenseSingletData = $this->commonFieldFilter(); $expenseSingletData['id'] = $expenseSingletId; $result = $this->objMExpenseSingle->editExpenseSingle($expenseSingletData); if($result->isSuccess()){ parent::sendOutput($result->getData()); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 删除指定的费用单 */ public function delExpenseSingle() { $expenseSingleId = $this->request->param('request_id'); if(!$expenseSingleId){ $this->sendOutput('参数错误', ErrorCode::$paramError); } $result = $this->objMExpenseSingle->delExpenseSingle($expenseSingleId); if($result->isSuccess()){ parent::sendOutput($result->getData()); }else{ parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 获取所有的费用单 */ public function getAllExpenseSingle() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $params['limit'] = $pageParams['limit']; $params['offset'] = $pageParams['offset']; $params['currentUnitId'] = getArrayItem($params,'currentUnitId',""); $params['consumeTypeId'] = getArrayItem($params,'consumeTypeId',""); $params['auditStatus'] = getArrayItem($params,'auditStatus',""); $params['start'] = getArrayItem($params,'start',""); $params['end'] = getArrayItem($params,'end',""); $returnData = $this->objMExpenseSingle->getAllExpenseSingle($params); if ($returnData->isSuccess()) { $returnData = $returnData->getData(); $pageData = [ 'pageIndex' => $params['page'], 'pageSize' => $params['pageSize'], 'pageTotal' => $returnData['total'], ]; parent::sendOutput($returnData['data'], 0, $pageData); } else { parent::sendOutput($returnData->getData(), ErrorCode::$dberror); } } /** * 审核费用单 */ public function updateExpenseStatus() { $params = $this->request->getRawJson(); if (empty($params['id']) || empty($params['createTime'])) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $result = $this->objMExpenseSingle->updateExpenseStatus($params); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } }