false]; private function __clone() { } private function __construct($userid) { $config = \Yii::$app->params['jac_erp']; // ... 在应用配置之前初始化 if(!$config['secret']){ throw new \Exception('江奥川ERP参数配置错误'); } if($userid){ $config['userid'] = $userid; } $this->config = $config; } public static function getInstance($userid) { if(empty(self::$instance)){ self::$instance = new self($userid); } return self::$instance; } public function syncOrder($params){ throw new Exception('暂时关闭老接口的同步功能'); ds($params); $response = (new Client(['http_errors' => false]))->post( 'http://127.0.0.1/open-api/test-api/send-china-prescription?keys=kB0sE7tZ3yT0jI1sD4wL2lI0kN6jO8cV4tO1zQ8zA5pgG5iW6zV0oB8vD6qV5cS7wQ5tN4cO8bG9gY6yL3lA6g', [ 'headers' => ['Content-Type' => 'application/json', 'userid' => $this->config['userid'], 'secret' => $this->config['secret']], \GuzzleHttp\RequestOptions::JSON =>$params ] ); $result = json_decode($response->getBody(),true); ds($result); if ($result['code']) { throw new Exception($result['message']); } return true; \Yii::info(__METHOD__."——同步订单至江奥川erp接口地址: ".$this->config['url'].'/tis-server/api/addTisApplyMaster'); $url = $this->config['url'].'/tis-server/api/addTisApplyMaster'; $params['hospital_code'] = $this->config['userid']; $params['apply_no'] = time().rand(100,999); $response = (new Client(['http_errors' => false]))->post( $url, [ 'headers' => ['Content-Type' => 'application/json', 'userid' => $this->config['userid'], 'secret' => $this->config['secret']], \GuzzleHttp\RequestOptions::JSON =>$params ] ); $result = json_decode($response->getBody(),true); if ($result['code']) { throw new Exception($result['message']); } return true; } }