onlineEnterpriseId = $enterpriseId; $this->objDAppVersion = new DAppVersion(); } /** * @param string $oldVersion * @return ResultWrapper */ public function getVersion(string $oldVersion) { $map = [ 'isUpdate' => true, 'oldVersion' => $oldVersion, ]; if (empty($oldVersion)){ $map['isUpdate'] = false; return ResultWrapper::success($map); } $dbResult = $this->objDAppVersion->get(['enterpriseId'=> $this->onlineEnterpriseId],'appVersion,downloadUrl'); if ($dbResult === false){ return ResultWrapper::fail($this->objDAppVersion->error(),ErrorCode::$dberror); } if (empty($dbResult)){ $map['isUpdate'] = false; return ResultWrapper::success($map); } switch (version_compare($oldVersion,$dbResult['appVersion'])){ case 0: //旧版本等与新版本 $map['isUpdate'] = false; break; case 1: //旧版本>新版本 $map['isUpdate'] = false; break; case -1: //旧版本<新版本 $map['isUpdate'] = true; $map['appVersion'] = $dbResult['appVersion']; $map['downloadUrl'] = $dbResult['downloadUrl']; break; } return ResultWrapper::success($map); } }