objMMerchantDetail = new MMerchantDetail($this->onlineEnterpriseId, $this->onlineUserId); } /** * 添加和编辑收支记录公共字段处理方法 * * @return array */ public function commonFieldFilter() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $ReceiptRequisitionData = [ 'merchantId' => getArrayItem($params,'merchantId',''), 'merchantName' => getArrayItem($params, 'merchantName',''), 'money' => isset($params['money']) ? $params['money'] : 0.00, 'type' => isset($params['type']) ? $params['type'] : '', 'settlementId' => getArrayItem($params,'settlementId',''), ]; foreach ($ReceiptRequisitionData as $key => $value) { if (empty($value) && $value !== 0) { $this->sendOutput($key . '参数错误', ErrorCode::$paramError); } } $ReceiptRequisitionData['createTime'] = time(); $ReceiptRequisitionData['updateTime'] = time(); return $ReceiptRequisitionData; } /* * 新增收支记录 * */ public function addMerchantDetail() { $merchantDetailData = $this->commonFieldFilter(); $result = $this->objMMerchantDetail->addMerchantDetail($merchantDetailData); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } /* * 所有收支记录 * */ public function getAllMerchantDetail() { $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['merchantId'] = getArrayItem($params,'merchantId',''); $params['type'] = getArrayItem($params,'type',''); $params['start'] = getArrayItem($params,'start',''); $params['end'] = getArrayItem($params,'end',''); $returnData = $this->objMMerchantDetail->getAllMerchantDetail($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); } } }