sn = $sn; $this->code = $code; } /** * 添加打印机设备 * @return ResultWrapper */ public function adddev() { $time = time(); $postData = [ 'user' => $this->user, 'stime' => $time, 'sig' => sha1($this->user.$this->ukey.$time), 'apiname' => 'Open_printerAddlist', 'printerContent' => $this->sn.'#'.$this->code,//打印机编号(必填) # 打印机识别码(必填) ]; $apiUrl = $this->apiUrl.$this->path; $reponse = request($apiUrl, $postData); if($reponse['httpcode'] != 200){ return ResultWrapper::fail('请求外部系统接口报错', ErrorCode::$apiNotResult); }else{ $reponseData = json_decode($reponse['content'], true); if( isset($reponseData['ret']) && $reponseData['ret'] != 0){ return ResultWrapper::fail($reponseData['msg'],$reponseData['ret']); } return ResultWrapper::success($reponseData['data']); } } /** * 发送打印机信息 * @param $params * @return ResultWrapper */ public function sendMsg($params) { $time = time(); $postData = [ 'user' => $this->user, 'stime' => $time, 'sig' => sha1($this->user.$this->ukey.$time), 'apiname' => 'Open_printMsg', ]; $postData['sn'] = $this->sn; $postData['content'] = $params; $apiUrl = $this->apiUrl.$this->path; $reponse = request($apiUrl, $postData); if($reponse['httpcode'] != 200){ return ResultWrapper::fail('请求外部系统接口报错', ErrorCode::$apiNotResult); }else{ $reponseData = json_decode($reponse['content'], true); if( isset($reponseData['ret']) && $reponseData['ret'] != 0){ return ResultWrapper::fail($reponseData['msg'],$reponseData['ret']); } return ResultWrapper::success($reponseData['data']); } } }