44323
2024-01-03 87ea11cb159443aa70f02b4a83914d8d5ab16c6a
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HouseResourceService.java
@@ -158,7 +158,6 @@
                }
            }
        }
        if (req.getDistrict() != null &&(!req.getDistrict().equals("")) ){
            // 一级id
            Integer integer = Integer.valueOf(req.getDistrict());
@@ -470,9 +469,9 @@
    }
    @Override
    public ResultUtil addHouse(AddHouseReq req) {
        Integer appUserId = appUserService.getAppUser().getId();
//        Integer appUserId = appUserService.getAppUser().getId();
        AppUser appUser = appUserService.selectOne(new EntityWrapper<AppUser>()
                .eq("id", appUserId)
                .eq("id", 40)
                .eq("status", 1));
        if (appUser!=null){
            if (req.getId()==null){
@@ -484,7 +483,7 @@
                if (appUser.getAuth()!=2){
                    // 未认证 只能能发布三条房源信息
                    List<HouseResource> houseResources = this.selectList(new EntityWrapper<HouseResource>()
                            .eq("app_user_id", appUserId)
                            .eq("app_user_id", 40)
                            .eq("is_delete", 0)
                            .eq("type", 2)
                    );
@@ -501,7 +500,7 @@
            houseResource.setInsertTime(new Date());
            houseResource.setGoodHouse(0);
            houseResource.setIsDelete(0);
            houseResource.setInsertUserId(appUserId);
            houseResource.setInsertUserId(40);
            houseResource.setViewsNumber(0);
            houseResource.setUpdateTime(new Date());
            // todo 修改回审核和上下架状态
@@ -509,7 +508,7 @@
            houseResource.setDataType(req.getDataType());
            houseResource.setAuthStatus(1);
            houseResource.setLeaseTime(req.getTime());
            houseResource.setAppUserId(appUserService.getAppUser().getId());
            houseResource.setAppUserId(40);
            houseResource.setFirmHouse(req.getFirmHouse());
            if (StringUtils.hasLength(req.getTime())){
                if (req.getTime().contains("年")){
@@ -519,14 +518,37 @@
                }
            }
            if (req.getType()==2){
                if (req.getId()==null){
                    this.baseMapper.insert(houseResource);
                }else{
                    this.baseMapper.updateById(houseResource);
                }
            }else{
                if (req.getId()==null){
                    this.baseMapper.insert(houseResource);
                }else{
                    this.baseMapper.updateById(houseResource);
                }
            }
            if (req.getType()==2 && req.getId()==null){
                PointLocation pointLocation = new PointLocation();
                GeoJsonPoint geoJsonPoint = new GeoJsonPoint(Double.valueOf(req.getLongitude()),Double.valueOf(req.getLatitude()));
                pointLocation.setGeoJsonPoint(geoJsonPoint);
                pointLocation.setHouseId(houseResource.getId());
                mongoTemplate.insert(pointLocation);
                houseResource.setCode(pointLocation.getId());
                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("path", "pages/home/home");
//            param.put("page", "pages/index/index"); // 路径 如果没有默认跳转到首页面微信小程序发布后才可以使用不能添加参数
                    param.put("scene","id="+houseResource.getId());
                    //pageA/houseDetail
                    param.put("page", "pageA/houseDetail");
                    param.put("check_path", false);
                    param.put("env_version", "trial");
                    param.put("width", 200); //二维码尺寸
                    param.put("is_hyaline", true); // 是否需要透明底色, is_hyaline 为true时,生成透明底色的小程序码 参数仅对小程序码生效
                    param.put("auto_color", true); // 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 参数仅对小程序码生效
@@ -549,10 +571,11 @@
                    // 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);
                    this.baseMapper.updateById(houseResource);
                    System.err.println("看看文件路径" + imgUrl);
                } catch (Exception e) {
                    System.err.println("调用小程序生成微信永久小程序码URL接口异常" + e);
@@ -573,26 +596,6 @@
                        return null;
                    }
                }
                if (req.getId()==null){
                    this.baseMapper.insert(houseResource);
                }else{
                    this.baseMapper.updateById(houseResource);
                }
            }else{
                if (req.getId()==null){
                    this.baseMapper.insert(houseResource);
                }else{
                    this.baseMapper.updateById(houseResource);
                }
            }
            if (req.getType()==2 && req.getId()==null){
                PointLocation pointLocation = new PointLocation();
                GeoJsonPoint geoJsonPoint = new GeoJsonPoint(Double.valueOf(req.getLongitude()),Double.valueOf(req.getLatitude()));
                pointLocation.setGeoJsonPoint(geoJsonPoint);
                pointLocation.setHouseId(houseResource.getId());
                mongoTemplate.insert(pointLocation);
                houseResource.setCode(pointLocation.getId());
                this.baseMapper.updateById(houseResource);
            }
            if (req.getType()==2 && req.getId()!=null){
                HouseResource houseResource1 = this.baseMapper.selectById(req.getId());