From c178011e0ae7618723d88dad21160d87447fd57c Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期二, 02 一月 2024 10:57:54 +0800
Subject: [PATCH] 小程序二维码

---
 guns-management/target/classes/com/stylefeng/guns/modular/system/dao/mapping/HouseResourceMapper.xml  |    3 -
 guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HouseResourceService.java     |   48 +++++++++++++-----------
 guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HousingDemandServiceImpl.java |   16 +++++--
 3 files changed, 38 insertions(+), 29 deletions(-)

diff --git a/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HouseResourceService.java b/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HouseResourceService.java
index 8bcf13e..e3b30b4 100644
--- a/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HouseResourceService.java
+++ b/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HouseResourceService.java
@@ -519,14 +519,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;
                     Map<String, Object> param = new HashMap<>();
-                    param.put("path", "pages/home/home");
-//            param.put("page", "pages/index/index"); // 路径 如果没有默认跳转到首页面微信小程序发布后才可以使用不能添加参数
+                    param.put("scene","id="+houseResource.getId());
+                    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); // 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 参数仅对小程序码生效
@@ -553,6 +576,7 @@
                     //获取文件的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 +597,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());
diff --git a/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HousingDemandServiceImpl.java b/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HousingDemandServiceImpl.java
index 8a649e7..882d1aa 100644
--- a/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HousingDemandServiceImpl.java
+++ b/guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HousingDemandServiceImpl.java
@@ -101,6 +101,12 @@
             housingDemand.setSaleAmount("0-500");
         }
         if (req.getType()==2){
+
+            this.insertOrUpdate(housingDemand);
+        }else{
+            this.insertOrUpdate(housingDemand);
+        }
+        if (req.getType()==2){
             if (StringUtils.hasLength(req.getWechatQRCode()))appUser.setWechatQrCode1(req.getWechatQRCode());
             if (StringUtils.hasLength(req.getWatchApp()))appUser.setWatchApp1(req.getWatchApp());
             if (StringUtils.hasLength(req.getPhone()))appUser.setPhone1(req.getPhone());
@@ -111,8 +117,10 @@
             try {
                 String url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?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="+housingDemand.getId());
+                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); // 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 参数仅对小程序码生效
@@ -139,6 +147,7 @@
                 //获取文件的URl地址
                 String imgUrl = ossService.getImgUrl(objectName);
                 housingDemand.setQrCode(imgUrl);
+                this.baseMapper.updateById(housingDemand);
                 System.err.println("看看文件路径" + imgUrl);
             } catch (Exception e) {
                 System.err.println("调用小程序生成微信永久小程序码URL接口异常" + e);
@@ -160,9 +169,6 @@
                     return null;
                 }
             }
-            this.insertOrUpdate(housingDemand);
-        }else{
-            this.insertOrUpdate(housingDemand);
         }
         List<HousingDemandDistrict> list = new ArrayList<>();
         if(ToolUtil.isNotEmpty(req.getDistrict())){
diff --git a/guns-management/target/classes/com/stylefeng/guns/modular/system/dao/mapping/HouseResourceMapper.xml b/guns-management/target/classes/com/stylefeng/guns/modular/system/dao/mapping/HouseResourceMapper.xml
index 9d2f36d..17d6f57 100644
--- a/guns-management/target/classes/com/stylefeng/guns/modular/system/dao/mapping/HouseResourceMapper.xml
+++ b/guns-management/target/classes/com/stylefeng/guns/modular/system/dao/mapping/HouseResourceMapper.xml
@@ -28,8 +28,7 @@
         left join t_app_user au on (hr.app_user_id = au.id)
         left join t_region rc on (hr.district_id = rc.id)
         left join t_region rp on (rp.id = rc.parent_id)
-        where hr.is_delete = 0 and hr.`status` = 1 and hr.auth_status = 2
-        and hr.type=2
+        where hr.is_delete = 0 and hr.`status` = 1 and hr.auth_status = 2  and hr.type=2
         <if test="null != req.type">
             and hr.data_type = #{req.type}
         </if>

--
Gitblit v1.7.1