From 4151c136e9f4a8022c52c49e8718a54d35dd36fc Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期三, 19 二月 2025 10:14:07 +0800
Subject: [PATCH] 小程序登录

---
 ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/IndexController.java |  135 +++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 118 insertions(+), 17 deletions(-)

diff --git a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/IndexController.java b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/IndexController.java
index f3b2a4f..76b035f 100644
--- a/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/IndexController.java
+++ b/ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/IndexController.java
@@ -15,11 +15,10 @@
 import com.ruoyi.system.model.*;
 import com.ruoyi.system.query.TBannerQuery;
 import com.ruoyi.system.query.TBillQuery;
+import com.ruoyi.system.query.TCheckAcceptRecordAppletQuery;
+import com.ruoyi.system.query.TCheckAcceptRecordQuery;
 import com.ruoyi.system.service.*;
-import com.ruoyi.system.vo.MyHouseVO;
-import com.ruoyi.system.vo.MyToDoVO;
-import com.ruoyi.system.vo.PayListVO;
-import com.ruoyi.system.vo.TBillVO;
+import com.ruoyi.system.vo.*;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import jdk.nashorn.internal.parser.Token;
@@ -27,8 +26,11 @@
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.util.CollectionUtils;
+import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
+import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -57,6 +59,8 @@
     @Autowired
     private THouseService houseService;
 
+    @Autowired
+    private TCheckAcceptRecordService checkAcceptRecordService;
 
     /**
      * 获取轮播图管理列表
@@ -65,7 +69,9 @@
     @PostMapping(value = "/list")
     public R<List<TBanner>> list(@RequestBody TBannerQuery query) {
         return R.ok(bannerService.list(query));
-    }    /**
+    }
+
+    /**
      * 获取轮播图管理列表
      */
     @ApiOperation(value = "租户-我的待办")
@@ -73,45 +79,50 @@
     public R<MyToDoVO> tenantMyToDo() {
         MyToDoVO myToDoVO = new MyToDoVO();
         LoginUserApplet loginUserApplet = tokenService.getLoginUserApplet();
-        if (loginUserApplet!=null){
+        if (loginUserApplet != null) {
             long contractCount = contractService.count(new LambdaQueryWrapper<TContract>()
                     .eq(TContract::getStatus, 3).eq(TContract::getTenantId, loginUserApplet.getUserId()));
             myToDoVO.setContractCount((int) contractCount);
             List<String> contractIds = contractService.lambdaQuery().eq(TContract::getTenantId, loginUserApplet.getUserId()).list()
                     .stream().map(TContract::getId).collect(Collectors.toList());
-            if (CollectionUtils.isEmpty(contractIds)){
+            if (CollectionUtils.isEmpty(contractIds)) {
                 myToDoVO.setBillCount(0);
                 myToDoVO.setContractCount(0);
                 return R.ok(myToDoVO);
             }
             int billCount = billService.lambdaQuery().in(TBill::getContractId, contractIds).eq(TBill::getPayFeesStatus, 1).list().size();
             myToDoVO.setBillCount(billCount);
-        }else {
+        } else {
             myToDoVO.setBillCount(0);
             myToDoVO.setContractCount(0);
         }
         return R.ok(myToDoVO);
     }
+
     @ApiOperation(value = "租户-当前在租房源")
     @PostMapping(value = "/tenant/myHouse")
     public R<List<MyHouseVO>> myHouse() {
         List<MyHouseVO> myHouseVOS = new ArrayList<>();
         LoginUserApplet loginUserApplet = tokenService.getLoginUserApplet();
 
-        if (loginUserApplet!=null){
+        if (loginUserApplet != null) {
             List<TContract> contractList = contractService.lambdaQuery().eq(TContract::getTenantId, loginUserApplet.getUserId())
                     .eq(TContract::getStatus, 4).list();
             List<THouse> houseList = houseService.list();
             List<TBill> bills = billService.lambdaQuery().orderByDesc(TBill::getPayableFeesTime).list();
             for (TContract contract : contractList) {
                 THouse tHouse = houseList.stream().filter(e -> e.getId().equals(contract.getHouseId())).findFirst().orElse(null);
-                TBill bill = bills.stream().filter(e -> e.getContractId().equals(contract.getId())).findFirst().orElse(null);
-                if (tHouse!=null&& bill!=null){
+                TBill bill = bills.stream().filter(e -> e.getContractId().equals(contract.getId()) && e.getPayFeesStatus().equals("3")).findFirst().orElse(null);
+                if (bill == null) {
+                    bill = bills.stream().filter(e -> e.getContractId().equals(contract.getId())).findFirst().orElse(null);
+                }
+                if (tHouse != null && bill != null) {
                     MyHouseVO myToDoVO = new MyHouseVO();
+                    myToDoVO.setId(contract.getId());
                     myToDoVO.setHouseAddress(tHouse.getHouseAddress());
                     myToDoVO.setMonthRent(contract.getMonthRent());
-                    myToDoVO.setPayType(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CONTRACT_PAY_TYPE,contract.getPayType()));
-                    myToDoVO.setMonth(bill.getPayFeesTime().getMonth()+"");
+                    myToDoVO.setPayType(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CONTRACT_PAY_TYPE, contract.getPayType()));
+                    myToDoVO.setMonth(bill.getPayFeesTime() == null ? bill.getPayableFeesTime().getMonth() + "月" : bill.getPayFeesTime().getMonth() + "月");
                     myToDoVO.setHouseArea(tHouse.getHouseArea());
                     myToDoVO.setHouseType(tHouse.getHouseType());
                     myToDoVO.setEndTime(DateUtils.localDateTimeToStringYear(contract.getEndTime()));
@@ -121,9 +132,12 @@
                     List<TBill> billList = bills.stream().filter(e -> e.getContractId().equals(contract.getId())).collect(Collectors.toList());
                     List<PayListVO> payList = new ArrayList<>();
                     for (TBill tBill : billList) {
+                        if (tBill.getPayFeesTime()==null){
+                            continue;
+                        }
                         PayListVO payListVO = new PayListVO();
                         payListVO.setPayFeesTime(DateUtils.localDateTimeToStringYear(tBill.getPayFeesTime()));
-                        payListVO.setPayFeesMoney("-"+tBill.getPayFeesMoney()+"元");
+                        payListVO.setPayFeesMoney("-" + tBill.getPayFeesMoney() + "元");
                         payList.add(payListVO);
                     }
                     myToDoVO.setPayList(payList);
@@ -132,16 +146,60 @@
 
             }
             return R.ok(myHouseVOS);
-        }else {
+        } else {
             return R.ok(myHouseVOS);
         }
     }
+
+    @ApiOperation(value = "租户-当前在租房源-租赁详情")
+    @GetMapping(value = "/tenant/myHouseDetail")
+    public R<MyHouseVO> myHouseDetail(String id) {
+        LoginUserApplet loginUserApplet = tokenService.getLoginUserApplet();
+
+        if (loginUserApplet != null) {
+            MyHouseVO myToDoVO = new MyHouseVO();
+            TContract contract = contractService.getById(id);
+            List<TBill> bills = billService.lambdaQuery().orderByDesc(TBill::getPayableFeesTime).list();
+            THouse tHouse = houseService.getById(contract.getHouseId());
+            TBill bill = bills.stream().filter(e -> e.getContractId().equals(contract.getId()) && e.getPayFeesStatus().equals("3")).findFirst().orElse(null);
+            if (bill == null) {
+                bill = bills.stream().filter(e -> e.getContractId().equals(contract.getId())).findFirst().orElse(null);
+            }
+            if (tHouse != null && bill != null) {
+                myToDoVO.setId(contract.getId());
+                myToDoVO.setHouseAddress(tHouse.getHouseAddress());
+                myToDoVO.setMonthRent(contract.getMonthRent());
+                myToDoVO.setPayType(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CONTRACT_PAY_TYPE, contract.getPayType()));
+                myToDoVO.setMonth(bill.getPayFeesTime() == null ? bill.getPayableFeesTime().getMonth() + "月" : bill.getPayFeesTime().getMonth() + "月");
+                myToDoVO.setHouseArea(tHouse.getHouseArea());
+                myToDoVO.setHouseType(tHouse.getHouseType());
+                myToDoVO.setEndTime(DateUtils.localDateTimeToStringYear(contract.getEndTime()));
+                myToDoVO.setStartTime(DateUtils.localDateTimeToStringYear(contract.getStartTime()));
+                myToDoVO.setPropertyRightPerson(tHouse.getPropertyRightPerson());
+                myToDoVO.setPhone(tHouse.getPhone());
+                List<TBill> billList = bills.stream().filter(e -> e.getContractId().equals(contract.getId())).collect(Collectors.toList());
+                List<PayListVO> payList = new ArrayList<>();
+                for (TBill tBill : billList) {
+                    PayListVO payListVO = new PayListVO();
+                    payListVO.setPayFeesTime(DateUtils.localDateTimeToStringYear(tBill.getPayFeesTime()));
+                    payListVO.setPayFeesMoney("-" + tBill.getPayFeesMoney() + "元");
+                    payList.add(payListVO);
+                }
+                myToDoVO.setPayList(payList);
+            }
+
+            return R.ok(myToDoVO);
+        } else {
+            return R.ok(new MyHouseVO());
+        }
+    }
+
     @ApiOperation(value = "管理员-我的待办")
     @PostMapping(value = "/admin/myToDo")
     public R<MyToDoVO> adminMyToDo() {
         MyToDoVO myToDoVO = new MyToDoVO();
         LoginUserApplet loginUserApplet = tokenService.getLoginUserApplet();
-        if (loginUserApplet!=null){
+        if (loginUserApplet != null) {
             long examineCount = contractService.count(new LambdaQueryWrapper<TContract>()
                     .eq(TContract::getStatus, 2));
             myToDoVO.setExamineCount((int) examineCount);
@@ -150,13 +208,56 @@
             int overdueCount = contractService.lambdaQuery().in(TContract::getId, contractIds).list()
                     .stream().map(TContract::getTenantId).distinct().collect(Collectors.toList()).size();
             myToDoVO.setOverdueCount(overdueCount);
-        }else {
+        } else {
             myToDoVO.setExamineCount(0);
             myToDoVO.setOverdueCount(0);
         }
         return R.ok(myToDoVO);
     }
 
+    /**
+     * 获取验收记录管理列表
+     */
+    @ApiOperation(value = "管理员-房屋验收单列表")
+    @PostMapping(value = "/admin/houseCheck")
+    public R<PageInfo<TCheckAcceptRecordVO>> houseCheck(@RequestBody TCheckAcceptRecordAppletQuery query) {
+        return R.ok(checkAcceptRecordService.pageListApplet(query));
+    }
+
+    /**
+     * 查看验收记录详情
+     */
+    @ApiOperation(value = "管理员-查看验收记录详情")
+    @GetMapping(value = "/getDetailById")
+    public R<TCheckAcceptRecordVO> getDetailById(@RequestParam String id) {
+        TCheckAcceptRecord checkAcceptRecord = checkAcceptRecordService.getById(id);
+        checkAcceptRecord.setCleanSituation(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION, checkAcceptRecord.getCleanSituation()));
+        checkAcceptRecord.setOverallSituation(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION, checkAcceptRecord.getOverallSituation()));
+        checkAcceptRecord.setDeviceSituation(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION, checkAcceptRecord.getDeviceSituation()));
+        checkAcceptRecord.setFurnitureSituation(DictUtils.getDictLabel(DictConstants.DICT_TYPE_CHECK_SITUATION, checkAcceptRecord.getFurnitureSituation()));
+        TCheckAcceptRecordVO checkAcceptRecordVO = new TCheckAcceptRecordVO();
+        BeanUtils.copyProperties(checkAcceptRecord, checkAcceptRecordVO);
+        // 查询合同信息
+        checkAcceptRecordVO.setContract(contractService.getById(checkAcceptRecord.getContractId()));
+        // 查询房屋信息
+        checkAcceptRecordVO.setHouse(houseService.getById(checkAcceptRecord.getHouseId()));
+        return R.ok(checkAcceptRecordVO);
+    }
+
+    @ApiOperation(value = "管理员-新增验收")
+    @GetMapping(value = "/addRecord")
+    public R<TCheckAcceptRecordVO> getDetailById(@Validated @RequestBody TCheckAcceptRecord dto) {
+        dto.setAcceptanceTime(LocalDateTime.now());
+        dto.setCheckTime(LocalDateTime.now());
+        LocalDate now = LocalDate.now();
+        String replace = (now + "").replace("-", "");
+        int size = checkAcceptRecordService.list(new LambdaQueryWrapper<TCheckAcceptRecord>()
+                .likeRight(TCheckAcceptRecord::getAcceptanceTime, LocalDate.now())).size();
+        dto.setCode(replace.substring(2)+String.format("%03d", size+1));
+        // 添加验收记录
+        checkAcceptRecordService.save(dto);
+        return R.ok();
+    }
 }
 
 

--
Gitblit v1.7.1