| | |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.http.entity.ContentType; |
| | | import org.dom4j.Document; |
| | | import org.dom4j.Element; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | |
| | | import org.springframework.data.geo.Point; |
| | | import org.springframework.data.mongodb.core.MongoTemplate; |
| | | import org.springframework.data.mongodb.core.geo.GeoJsonPoint; |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.CriteriaDefinition; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | |
| | | private RestTemplate restTemplate; |
| | | @Autowired |
| | | private IUserService userService; |
| | | |
| | | @Autowired |
| | | private OSSService ossService; |
| | | @Value("${wx.appletsAppid}") |
| | | private String wxAppletsAppid; |
| | | |
| | | @Value("${wx.appletsAppSecret}") |
| | | private String wxAppletsAppSecret; |
| | | /** |
| | | * 生成小程序码地址 |
| | | */ |
| | | public static final String CREATE_CODE_URL = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=ACCESS_TOKEN"; |
| | | // 生成小程序码 |
| | | |
| | | public String generateMiniProgramCode(String outputFilePath) throws IOException { |
| | | // 获取access_token |
| | | String accessToken = wxAppletTools.getAccessToken(); |
| | | // 替换CREATE_CODE_URL |
| | | String uri = CREATE_CODE_URL.replace("ACCESS_TOKEN", accessToken); |
| | | // 跳转到的小程序页面路径 |
| | | String pagePath = "pages/index/index"; |
| | | URL url = new URL(uri); |
| | | HttpURLConnection connection = (HttpURLConnection) url.openConnection(); |
| | | // 设置请求方法 |
| | | connection.setRequestMethod("POST"); |
| | | connection.setDoOutput(true); |
| | | // 构建请求参数 |
| | | String params = "path=" + URLEncoder.encode(pagePath, "UTF-8"); |
| | | // 获取输出流 |
| | | try (OutputStream outputStream = connection.getOutputStream()) { |
| | | outputStream.write(params.getBytes()); |
| | | } |
| | | // 获取输入流 |
| | | try (InputStream inputStream = connection.getInputStream(); |
| | | FileOutputStream outputStream = new FileOutputStream(outputFilePath)) { |
| | | // 将返回的图片数据写入文件 |
| | | byte[] buffer = new byte[1024]; |
| | | int bytesRead; |
| | | while ((bytesRead = inputStream.read(buffer)) != -1) { |
| | | outputStream.write(buffer, 0, bytesRead); |
| | | } |
| | | ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(buffer); |
| | | MultipartFile file = new MockMultipartFile(ContentType.APPLICATION_OCTET_STREAM.toString(), byteArrayInputStream); |
| | | return ossService.uploadFile(file); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取房源列表 |
| | | * @param req |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (req.getDistrict() != null &&(!req.getDistrict().equals("")) ){ |
| | | // 一级id |
| | | Integer integer = Integer.valueOf(req.getDistrict()); |
| | |
| | | houseResource.setDataType(req.getDataType()); |
| | | houseResource.setAuthStatus(1); |
| | | houseResource.setLeaseTime(req.getTime()); |
| | | houseResource.setAppUserId(appUserService.getAppUser().getId()); |
| | | houseResource.setAppUserId(appUserId); |
| | | houseResource.setFirmHouse(req.getFirmHouse()); |
| | | if (StringUtils.hasLength(req.getTime())){ |
| | | if (req.getTime().contains("年")){ |
| | |
| | | } |
| | | if (req.getType()==2){ |
| | | if (req.getId()==null){ |
| | | houseResource.setAuthStatus(2); |
| | | this.baseMapper.insert(houseResource); |
| | | }else{ |
| | | houseResource.setAuthStatus(2); |
| | | this.baseMapper.updateById(houseResource); |
| | | } |
| | | }else{ |
| | | if (req.getId()==null){ |
| | | houseResource.setAuthStatus(2); |
| | | this.baseMapper.insert(houseResource); |
| | | }else{ |
| | | houseResource.setAuthStatus(2); |
| | | this.baseMapper.updateById(houseResource); |
| | | } |
| | | } |
| | |
| | | pointLocation.setHouseId(houseResource.getId()); |
| | | mongoTemplate.insert(pointLocation); |
| | | houseResource.setCode(pointLocation.getId()); |
| | | houseResource.setAuthStatus(2); |
| | | this.baseMapper.updateById(houseResource); |
| | | |
| | | InputStream inputStream = null; |
| | | OutputStream outputStream = null; |
| | | String accessToken = wxAppletTools.getAccessToken(); |
| | | try { |
| | | String url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=" + accessToken; |
| | | String url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=" + accessToken; |
| | | Map<String, Object> param = new HashMap<>(); |
| | | param.put("scene","id="+houseResource.getId()); |
| | | //pageA/houseDetail |
| | | param.put("page", "pageA/houseDetail"); |
| | | param.put("check_path", false); |
| | | param.put("env_version", "trial"); |
| | |
| | | // oss中的文件夹名 |
| | | String objectName = sdf.format(new Date()) + "/" + finalFileName; |
| | | // 上传oss |
| | | ossService.uploadFile2OSS(inputStream, objectName); |
| | | String s = ossService.uploadFile2OSS(inputStream, objectName); |
| | | //获取文件的URl地址 |
| | | String imgUrl = ossService.getImgUrl(objectName); |
| | | houseResource.setQrCode(imgUrl); |
| | |
| | | pointLocation.setHouseId(req.getId()); |
| | | mongoTemplate.insert(pointLocation); |
| | | houseResource1.setCode(pointLocation.getId()); |
| | | houseResource1.setAuthStatus(2); |
| | | this.baseMapper.updateById(houseResource1); |
| | | } |
| | | Query query = Query.query(Criteria.where("_id").is(houseResource1.getCode())); |