objMReceipt = new MReceipt($this->onlineEnterpriseId,$this->onlineUserId); } /** * 公共参数 */ public function commonFieldFilter() { $params = $this->request->getRawJson(); if(empty($params)){ $this->sendOutput('参数为空', ErrorCode::$paramError ); } $data = [ 'objectId' => isset($params['objectId']) ? $params['objectId'] : null, 'objectType' => isset($params['objectType']) ? $params['objectType'] : null ]; foreach($data as $key => $value){ if(empty($value)){ parent::sendOutput($key.'参数错误', ErrorCode::$paramError ); } } return $data; } /** * 打印小票 * @throws \Exception */ public function toPrint() { $data = self::commonFieldFilter(); $result = $this->objMReceipt->toPrint($data['objectId'],$data['objectType']); if($result->isSuccess()){ parent::sendOutput('操作成功'); } parent::sendOutput($result->getData(), $result->getErrorCode()); } }