From 43f0578e80af82ecae6c61b51bd0539c6b960603 Mon Sep 17 00:00:00 2001
From: puhanshu <a9236326>
Date: 星期二, 16 八月 2022 19:08:32 +0800
Subject: [PATCH] 服务范围优化

---
 springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/RentingHourseRegisterServiceImpl.java |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)

diff --git a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/RentingHourseRegisterServiceImpl.java b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/RentingHourseRegisterServiceImpl.java
index b3b54d7..d26abf0 100644
--- a/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/RentingHourseRegisterServiceImpl.java
+++ b/springcloud_k8s_panzhihuazhihuishequ/service_community/src/main/java/com/panzhihua/service_community/service/impl/RentingHourseRegisterServiceImpl.java
@@ -4,6 +4,7 @@
 import static java.util.Objects.nonNull;
 import static org.apache.commons.lang3.StringUtils.isNotBlank;
 
+import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Comparator;
 import java.util.Date;
@@ -12,7 +13,9 @@
 import java.util.stream.Collectors;
 
 import javax.annotation.Resource;
+import javax.validation.constraints.NotNull;
 
+import com.panzhihua.common.exceptions.ServiceException;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Value;
@@ -77,6 +80,7 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public R registerRentingHouse(RentingHouseRegisterDTO registerDTO) {
+        checkDepositMoney(registerDTO);
         Long communityId = registerDTO.getCommunityId();
         Long userId = registerDTO.getUserId();
         RentingHourseRegister houseRegister = new RentingHourseRegister();
@@ -176,6 +180,14 @@
         return R.fail("新增房源失败");
     }
 
+    private void checkDepositMoney(RentingHouseRegisterDTO registerDTO) {
+        BigDecimal dingMoney = registerDTO.getDingMoney();
+        BigDecimal monthlyRentMoney = registerDTO.getMonthlyRentMoney();
+        if (nonNull(dingMoney) && nonNull(monthlyRentMoney) && dingMoney.compareTo(monthlyRentMoney) == 1) {
+            throw new ServiceException("500", "定金不能超过月租金");
+        }
+    }
+
     /**
      * 编辑房源信息
      * @param registerDTO
@@ -184,6 +196,7 @@
     @Override
     @Transactional(rollbackFor = Exception.class)
     public R updateRentingHouse(RentingHouseRegisterDTO registerDTO) {
+        checkDepositMoney(registerDTO);
         Long id = registerDTO.getId();
         Long userId = registerDTO.getUserId();
         RentingHourseRegister houseRegister = this.baseMapper.selectById(id);
@@ -356,6 +369,8 @@
         if (status.intValue() != RentingHourseRegister.Status.dfb) {
             return R.fail("已发布房源不支持删除");
         }
+        rentingHourseFileService.remove(new QueryWrapper<RentingHourseFile>().lambda()
+                .eq(RentingHourseFile::getRefId, registerId));
         int result = this.baseMapper.deleteById(registerId);
         if (result > 0) {
             return R.ok();
@@ -412,7 +427,7 @@
     public R nearby(NearbyDTO nearbyDTO) {
         Rectangle rectangle =new NearbyUtil().getRectangle(nearbyDTO.getDistance(), Double.parseDouble(nearbyDTO.getLongitude()), Double.parseDouble(nearbyDTO.getLatitude()));
         return R.ok(this.baseMapper.nearby(rectangle.getMinX(),rectangle.getMaxX(),
-                rectangle.getMinY(),rectangle.getMaxY(),nearbyDTO.getKeyword(), nearbyDTO.getCommunityId()));
+                rectangle.getMinY(),rectangle.getMaxY(), nearbyDTO));
     }
 
     @Override
@@ -424,7 +439,7 @@
     }
 
     @Override
-    public void updateAllHouseUnionAppCode() {
+    public void updateAllHouseUnionAppCode(String areaCode) {
         List<RentingHourseRegister> list = this.baseMapper.selectList(null);
         if (!list.isEmpty()) {
             list.stream().forEach(houseRegister -> {

--
Gitblit v1.7.1