From c178011e0ae7618723d88dad21160d87447fd57c Mon Sep 17 00:00:00 2001
From: 44323 <443237572@qq.com>
Date: 星期二, 02 一月 2024 10:57:54 +0800
Subject: [PATCH] 小程序二维码
---
guns-admin/src/main/java/com/stylefeng/guns/modular/system/service/impl/HousingDemandServiceImpl.java | 264 +++++++++++++++++++++++++++++++++++++++++-----------
1 files changed, 206 insertions(+), 58 deletions(-)
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 4403e5d..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
@@ -93,15 +93,34 @@
housingDemand.setInsertUserId(appUser.getId());
housingDemand.setAppUserId(appUser.getId());
housingDemand.setStatus(1);
+ housingDemand.setUpdateTime(new Date());
+ if (StringUtils.hasLength(req.getSaleAmount())&&req.getSaleAmount().equals("2000")){
+ housingDemand.setSaleAmount("2000-99999999");
+ }
+ if (StringUtils.hasLength(req.getSaleAmount())&&req.getSaleAmount().equals("500")){
+ 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());
+ appUserService.updateById(appUser);
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="+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); // 自动配置线条颜色,如果颜色依然是黑色,则说明不建议配置主色调 参数仅对小程序码生效
@@ -128,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);
@@ -149,9 +169,6 @@
return null;
}
}
- this.insert(housingDemand);
- }else{
- this.updateById(housingDemand);
}
List<HousingDemandDistrict> list = new ArrayList<>();
if(ToolUtil.isNotEmpty(req.getDistrict())){
@@ -206,7 +223,7 @@
Double saleAmountEnd = null;
if(StringUtils.hasLength(req.getSaleAmount())){
if (req.getSaleAmount().contains("以上")){
- saleAmountEnd =1000000.0;
+ saleAmountEnd =2001.0;
saleAmountStart = 2000.0;
}else if (req.getSaleAmount().contains("以下")){
saleAmountEnd =500.0;
@@ -231,53 +248,85 @@
for (String s : split) {
houseTypeIds.add(Integer.valueOf(s));
}
+ houseTypeIds.add(0);
}
-
-
-
SearchHousingDemandRes searchHouseResource = new SearchHousingDemandRes();
List<SearchHousingDemandListRes> searchHouseResourceListRes = this.baseMapper.searchHousingDemand
(req, districtIds,areaIds, saleAmountStart, saleAmountEnd, houseModels, houseTypeIds);
-
for (SearchHousingDemandListRes searchHouseResourceListRe : searchHouseResourceListRes) {
- List<HousingDemandDistrict> list = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
- .eq("housing_demand_id", searchHouseResourceListRe.getId()));
+ // 获取到房源区域id集合
+ List<HousingDemandDistrict> list1 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
+ .eq("housing_demand_id", searchHouseResourceListRe.getId())
+ ).stream().filter(t -> t.getCityId() == 1).collect(Collectors.toList());
+ List<HousingDemandDistrict> list2 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
+ .eq("housing_demand_id", searchHouseResourceListRe.getId())
+ ).stream().filter(t -> t.getCityId() == 2).collect(Collectors.toList());
+ List<HousingDemandDistrict> list3 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
+ .eq("housing_demand_id", searchHouseResourceListRe.getId())
+ ).stream().filter(t -> t.getCityId() == 3).collect(Collectors.toList());
List<String> dis = new ArrayList<>();
- for (HousingDemandDistrict housingDemandDistrict : list) {
- Region region = regionService.selectById(housingDemandDistrict.getCityId());
+ StringBuilder s1 = new StringBuilder("香港岛>");
+ StringBuilder s2 = new StringBuilder("九龙>");
+ StringBuilder s3 = new StringBuilder("新界>");
+ for (HousingDemandDistrict housingDemandDistrict : list1) {
Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
- dis.add(region.getName() + ">" + (null == region1 ? "不限" : region1.getName()));
+ s1.append((null == region1 ? "不限" : region1.getName())+"/");
+ }
+ for (HousingDemandDistrict housingDemandDistrict : list2) {
+ Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
+ s2.append((null == region1 ? "不限" : region1.getName())+"/");
+ }
+ for (HousingDemandDistrict housingDemandDistrict : list3) {
+ Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
+ s3.append((null == region1 ? "不限" : region1.getName())+"/");
+ }
+ String string1 = s1.toString();
+ String string2 = s2.toString();
+ String string3 = s3.toString();
+ String substring1=string1;
+ String substring2=string2;
+ String substring3=string3;
+ if (string1.endsWith("/")){
+ substring1 = string1.substring(0, string1.length() - 1);
+ }
+ if (string2.endsWith("/")){
+ substring2 = string2.substring(0, string2.length() - 1);
+ }
+ if (string3.endsWith("/")){
+ substring3 = string3.substring(0, string3.length() - 1);
+ }
+ if (!substring1.equals("香港岛>")){
+ dis.add(substring1);
+ }
+ if (!substring2.equals("九龙>")){
+ dis.add(substring2);
+ }
+ if (!substring3.equals("新界>")){
+ dis.add(substring3);
}
//城市不限用空判断
searchHouseResourceListRe.setAddress(dis.size() == 0 ? null : dis);
}
List<SearchHousingDemandListRes> collect = new ArrayList<>();
- if (req.getRentalDuration()!=null){
- if (req.getRentalDuration().equals("一年以上")){
- collect = searchHouseResourceListRes.stream().filter(t -> t.getRentalDuration() >= 12)
+ if (StringUtils.hasLength(req.getRentalDuration())){
+ if (req.getRentalDuration().equals("2")){
+ collect = searchHouseResourceListRes.stream().filter(t -> t.getRentalDuration()!=null && t.getRentalDuration()>= 12)
.collect(Collectors.toList());
- }else if (req.getRentalDuration().equals("一年以下")){
- collect = searchHouseResourceListRes.stream().filter(t -> t.getRentalDuration() < 12)
+ }else if (req.getRentalDuration().equals("1")){
+ collect = searchHouseResourceListRes.stream().filter(t ->t.getRentalDuration()!=null && t.getRentalDuration() < 12)
.collect(Collectors.toList());
}
-
searchHouseResource.setList(collect);
searchHouseResource.setTotal(collect.size());
}else{
searchHouseResource.setList(searchHouseResourceListRes);
searchHouseResource.setTotal(searchHouseResourceListRes.size());
}
-
-
- Integer integer = this.baseMapper.searchHousingDemandCount(req, districtIds,areaIds, saleAmountStart, saleAmountEnd, houseModels, houseTypeIds);
-
return searchHouseResource;
}
-
/**
* 搜索求房源列表数据
-
* @return
*/
@Override
@@ -285,16 +334,56 @@
SearchHousingDemandRes searchHouseResource = new SearchHousingDemandRes();
List<SearchHousingDemandListRes> searchHouseResourceListRes = this.baseMapper.searchHousingDemand1(id);
-
for (SearchHousingDemandListRes searchHouseResourceListRe : searchHouseResourceListRes) {
- List<HousingDemandDistrict> list = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
- .eq("housing_demand_id", searchHouseResourceListRe.getId()));
+ // 获取到房源区域id集合
+ List<HousingDemandDistrict> list1 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
+ .eq("housing_demand_id", searchHouseResourceListRe.getId())
+ ).stream().filter(t -> t.getCityId() == 1).collect(Collectors.toList());
+ List<HousingDemandDistrict> list2 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
+ .eq("housing_demand_id", searchHouseResourceListRe.getId())
+ ).stream().filter(t -> t.getCityId() == 2).collect(Collectors.toList());
+ List<HousingDemandDistrict> list3 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
+ .eq("housing_demand_id", searchHouseResourceListRe.getId())
+ ).stream().filter(t -> t.getCityId() == 3).collect(Collectors.toList());
List<String> dis = new ArrayList<>();
- for (HousingDemandDistrict housingDemandDistrict : list) {
- Region region = regionService.selectById(housingDemandDistrict.getCityId());
+ StringBuilder s1 = new StringBuilder("香港岛>");
+ StringBuilder s2 = new StringBuilder("九龙>");
+ StringBuilder s3 = new StringBuilder("新界>");
+ for (HousingDemandDistrict housingDemandDistrict : list1) {
Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
- dis.add(region.getName() + ">" + (null == region1 ? "不限" : region1.getName()));
-
+ s1.append((null == region1 ? "不限" : region1.getName())+"/");
+ }
+ for (HousingDemandDistrict housingDemandDistrict : list2) {
+ Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
+ s2.append((null == region1 ? "不限" : region1.getName())+"/");
+ }
+ for (HousingDemandDistrict housingDemandDistrict : list3) {
+ Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
+ s3.append((null == region1 ? "不限" : region1.getName())+"/");
+ }
+ String string1 = s1.toString();
+ String string2 = s2.toString();
+ String string3 = s3.toString();
+ String substring1=string1;
+ String substring2=string2;
+ String substring3=string3;
+ if (string1.endsWith("/")){
+ substring1 = string1.substring(0, string1.length() - 1);
+ }
+ if (string2.endsWith("/")){
+ substring2 = string2.substring(0, string2.length() - 1);
+ }
+ if (string3.endsWith("/")){
+ substring3 = string3.substring(0, string3.length() - 1);
+ }
+ if (!substring1.equals("香港岛>")){
+ dis.add(substring1);
+ }
+ if (!substring2.equals("九龙>")){
+ dis.add(substring2);
+ }
+ if (!substring3.equals("新界>")){
+ dis.add(substring3);
}
//城市不限用空判断
searchHouseResourceListRe.setAddress(dis.size() == 0 ? null : dis);
@@ -308,7 +397,6 @@
public SearchHousingDemandRes searchHousingDemand2(List<Integer> id) {
SearchHousingDemandRes searchHouseResource = new SearchHousingDemandRes();
List<SearchHousingDemandListRes> searchHouseResourceListRes = this.baseMapper.searchHousingDemand2(id);
-
for (SearchHousingDemandListRes searchHouseResourceListRe : searchHouseResourceListRes) {
List<HousingDemandDistrict> list = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
.eq("housing_demand_id", searchHouseResourceListRe.getId()));
@@ -317,7 +405,6 @@
Region region = regionService.selectById(housingDemandDistrict.getCityId());
Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
dis.add(region.getName() + ">" + (null == region1 ? "不限" : region1.getName()));
-
}
//城市不限用空判断
searchHouseResourceListRe.setAddress(dis.size() == 0 ? null : dis);
@@ -326,9 +413,8 @@
searchHouseResource.setTotal(searchHouseResourceListRes.size());
return searchHouseResource;
}
-
/**
- * 不带分页的求房源列表
+ * 求房源详情
* @param id
* @return
*/
@@ -347,27 +433,86 @@
housingDemandInfoRes.setRentalDuration(housingDemand.getRentalDuration());
housingDemandInfoRes.setSaleDate(housingDemand.getSaleDate());
if (StringUtils.hasLength(housingDemand.getHouseTypeId())){
- String[] split = housingDemand.getHouseTypeId().split(",");
- String houseType = "";
- for (String s : split) {
- HouseType htype = houseTypeService.selectById(s);
- houseType += htype.getName() + " / ";
+ if (housingDemand.getHouseTypeId().equals("0")){
+ housingDemandInfoRes.setHouseType("不限");
+ }else{
+ String[] split = housingDemand.getHouseTypeId().split(",");
+ String houseType = "";
+ for (String s : split) {
+ HouseType htype = houseTypeService.selectById(s);
+ if (htype!=null)houseType += htype.getName() + " / ";
+ }
+ if (StringUtils.hasLength(houseType))housingDemandInfoRes.setHouseType(houseType.substring(0, houseType.lastIndexOf("/")));
}
- housingDemandInfoRes.setHouseType(houseType.substring(0, houseType.lastIndexOf("/")));
}
housingDemandInfoRes.setFloor(housingDemand.getFloor());
housingDemandInfoRes.setElevator(housingDemand.getElevator());
- housingDemandInfoRes.setDryingArea(housingDemand.getDryingArea());
+ StringBuilder stringBuilder = new StringBuilder("");
+ if (housingDemand.getBalcony()==1 && housingDemand.getAir()==1 && housingDemand.getDryingArea()==1){
+ stringBuilder.append("不限");
+ }else{
+ if (housingDemand.getBalcony()!=null && housingDemand.getBalcony() == 1){
+ stringBuilder.append("阳台");
+ }
+ if (housingDemand.getDryingArea()!=null && housingDemand.getDryingArea() == 1){
+ stringBuilder.append("| 天台");
+ }
+ if (housingDemand.getAir()!=null && housingDemand.getAir() == 1){
+ stringBuilder.append("| 无");
+ }
+ }
+ housingDemandInfoRes.setDryingArea(stringBuilder.toString());
housingDemandInfoRes.setHouseArea(housingDemand.getHouseArea());
housingDemandInfoRes.setKeepPet(housingDemand.getKeepPet());
- List<HousingDemandDistrict> list = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
- .eq("housing_demand_id", id));
+ // 获取到房源区域id集合
+ List<HousingDemandDistrict> list1 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
+ .eq("housing_demand_id", id)
+ ).stream().filter(t -> t.getCityId() == 1).collect(Collectors.toList());
+ List<HousingDemandDistrict> list2 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
+ .eq("housing_demand_id", id)
+ ).stream().filter(t -> t.getCityId() == 2).collect(Collectors.toList());
+ List<HousingDemandDistrict> list3 = housingDemandDistrictService.selectList(new EntityWrapper<HousingDemandDistrict>()
+ .eq("housing_demand_id", id)
+ ).stream().filter(t -> t.getCityId() == 3).collect(Collectors.toList());
List<String> dis = new ArrayList<>();
- for (HousingDemandDistrict housingDemandDistrict : list) {
- Region region = regionService.selectById(housingDemandDistrict.getCityId());
+ StringBuilder s1 = new StringBuilder("香港岛>");
+ StringBuilder s2 = new StringBuilder("九龙>");
+ StringBuilder s3 = new StringBuilder("新界>");
+ for (HousingDemandDistrict housingDemandDistrict : list1) {
Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
- dis.add(region.getName() + ">" + (null == region1 ? "不限" : region1.getName()));
-
+ s1.append((null == region1 ? "不限" : region1.getName())+"/");
+ }
+ for (HousingDemandDistrict housingDemandDistrict : list2) {
+ Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
+ s2.append((null == region1 ? "不限" : region1.getName())+"/");
+ }
+ for (HousingDemandDistrict housingDemandDistrict : list3) {
+ Region region1 = regionService.selectById(housingDemandDistrict.getDistrictId());
+ s3.append((null == region1 ? "不限" : region1.getName())+"/");
+ }
+ String string1 = s1.toString();
+ String string2 = s2.toString();
+ String string3 = s3.toString();
+ String substring1=string1;
+ String substring2=string2;
+ String substring3=string3;
+ if (string1.endsWith("/")){
+ substring1 = string1.substring(0, string1.length() - 1);
+ }
+ if (string2.endsWith("/")){
+ substring2 = string2.substring(0, string2.length() - 1);
+ }
+ if (string3.endsWith("/")){
+ substring3 = string3.substring(0, string3.length() - 1);
+ }
+ if (!substring1.equals("香港岛>")){
+ dis.add(substring1);
+ }
+ if (!substring2.equals("九龙>")){
+ dis.add(substring2);
+ }
+ if (!substring3.equals("新界>")){
+ dis.add(substring3);
}
//城市不限用空判断
housingDemandInfoRes.setAddress(dis.size() == 0 ? null : dis);
@@ -378,7 +523,7 @@
housingDemandInfoRes.setNickname(appUser1.getNickname());
housingDemandInfoRes.setInsertTime(sdf.format(housingDemand.getInsertTime()));
if (housingDemand.getUpdateTime()==null){
- housingDemandInfoRes.setUpdateTime(sdf.format(housingDemand.getInsertTime()));
+ housingDemandInfoRes.setUpdateTime(null);
}else{
housingDemandInfoRes.setUpdateTime(sdf.format(housingDemand.getUpdateTime()));
}
@@ -417,11 +562,10 @@
@Override
public ContactInformationRes getContactInformation(Integer id) {
HousingDemand houseResource = this.selectById(id);
- AppUser appUser = appUserService.selectById(houseResource.getAppUserId());
ContactInformationRes contactInformationRes = new ContactInformationRes();
- contactInformationRes.setWhatsApp(appUser.getWatchApp());
- contactInformationRes.setPhone(appUser.getPhone());
- contactInformationRes.setWechatQrCode(appUser.getWechatQRCode());
+ contactInformationRes.setWatchApp(houseResource.getWatchApp());
+ contactInformationRes.setPhone(houseResource.getPhone());
+ contactInformationRes.setWechatQrCode(houseResource.getWechatQRCode());
return contactInformationRes;
}
@@ -435,10 +579,14 @@
if(null == appUser){
return ResultUtil.tokenErr();
}
- int num = this.selectCount(new EntityWrapper<HousingDemand>().eq("is_delete", 0)
+ int num = this.selectCount(new EntityWrapper<HousingDemand>()
+ .eq("is_delete", 0)
.eq("app_user_id", appUser.getId())
- .eq("status", 1)
+ .eq("type", 2)
);
+ if (appUser.getAuth()==2){
+ return ResultUtil.success(99999);
+ }
return ResultUtil.success(appUser.getUserType() != 3 ? (3 - num) : -1);
}
}
--
Gitblit v1.7.1