objMReceive = new MReceive($this->onlineEnterpriseId, $this->onlineUserId); } /** * 添加和编辑应收单管理公共字段处理方法 * * @return array */ public function commonFieldFilter() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $receiveData = [ 'customerId' => isset($params['customerId']) ? $params['customerId'] : '',//int(11) DEFAULT NULL COMMENT '客户Id', 'customerName' => isset($params['customerName']) ? $params['customerName'] : '',//varchar(50) DEFAULT NULL COMMENT '客户名称', 'orderId' => isset($params['orderId']) ? $params['orderId'] : '',//varchar(50) DEFAULT NULL COMMENT '单据编号', 'sourceNo' => isset($params['sourceNo']) ? $params['sourceNo'] : '',//varchar(50) DEFAULT NULL COMMENT '订单号', 'financeTypeId' => isset($params['financeTypeId']) ? $params['financeTypeId'] : '',//int(10) DEFAULT NULL COMMENT '财务类型id', 'financeType' => isset($params['financeType']) ? $params['financeType'] : '', 'discountMoney' => isset($params['discountMoney']) ? $params['discountMoney'] : '',//float(10,2) DEFAULT NULL COMMENT '优惠金额', 'receiveMoney' => isset($params['receiveMoney']) ? $params['receiveMoney'] : '',//float(10,2) DEFAULT NULL COMMENT '实际应收金额', 'shopId' => isset($params['shopId']) ? $params['shopId'] : '',//int(11) DEFAULT NULL COMMENT '商铺Id', 'shopName' => isset($params['shopName']) ? $params['shopName'] : '',//varchar(50) DEFAULT NULL COMMENT '商铺名称', 'receiptTypeId' => isset($params['receiptTypeId']) ? $params['receiptTypeId'] : '',//tinyint(2) DEFAULT NULL COMMENT '单据状态', 'auditStatus' => isset($params['auditStatus']) ? $params['auditStatus'] : '',//tinyint(2) DEFAULT NULL COMMENT '单据状态', 'offsetStatus' => getArrayItem($params, 'offsetStatus',4), ]; foreach ($receiveData as $key => $value) { if (empty($value) && $value !== 0) { $this->sendOutput($key . '参数错误', ErrorCode::$paramError); } } $receiveData['deleteStatus'] = StatusCode::$standard; $receiveData['createTime'] = time(); $receiveData['updateTime'] = time(); return $receiveData; } /** * 添加应收单 */ public function addReceive() { $receiveData = $this->commonFieldFilter(); $result = $this->objMReceive->addReceive($receiveData); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 获取指定应收单信息 */ public function getReceiveInfo() { $params = $this->request->getRawJson(); if (empty($params['id']) || empty($params['createTime'])) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $result = $this->objMReceive->getReceiveInfo($params); if ($result->isSuccess()) { $this->sendOutput($result->getData()); } else { $this->sendOutput($result->getData(), $result->getErrorCode()); } } /** * 应收单审核 */ public function updateReceiveStatus() { $params = $this->request->getRawJson(); if (empty($params['id']) || empty($params['createTime'])) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $result = $this->objMReceive->updateReceiveStatus($params); if ($result->isSuccess()) { parent::sendOutput($result->getData()); } else { parent::sendOutput($result->getData(), $result->getErrorCode()); } } /** * 后台所有应收单列表 */ public function getAllReceive() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $selectParams = [ 'customerId' => getArrayItem($params, 'customerId', 0), 'auditStatus' => getArrayItem($params, 'auditStatus', 0), 'offsetStatus' => getArrayItem($params, 'offsetStatus', []), 'shopId' => getArrayItem($params, 'shopId', 0), 'receiveReceiptIds' => getArrayItem($params, 'receiveReceiptIds', []), 'start' => getArrayItem($params, 'start', 0), 'end' => getArrayItem($params, 'end', 0), ]; $isExport = false; if(isset($params['isExport'])) { $isExport = $params['isExport']; } $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; $result = $this->objMReceive->getAllReceive($selectParams, $isExport); 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(), $result->getErrorCode()); } } /** * 搜索 */ public function search() { $params = $this->request->getRawJson(); if (empty($params)) { $this->sendOutput('参数为空', ErrorCode::$paramError); } $selectParams = [ 'keyword' => isset($params['keyword']) ? $params['keyword'] : '', 'shopId' => isset($params['shopId']) ? $params['shopId'] : '', 'start' => isset($params['start']) ? $params['start'] : '', 'end' => isset($params['end']) ? $params['end'] : '', 'receiptTypeId' => isset($params['receiptTypeId']) ? $params['receiptTypeId'] : '', 'auditStatus' => isset($params['auditStatus']) ? $params['auditStatus'] : '', 'isExport' => isset($params['isExport']) ? $params['isExport'] : 0, ]; $pageParams = pageToOffset($params['page'] ?: 1, $params['pageSize'] ?: 10); $selectParams['limit'] = $pageParams['limit']; $selectParams['offset'] = $pageParams['offset']; $result = $this->objMReceive->search($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(), $result->getErrorCode()); } } }