From 68ca7bdcebed980fcab33d9bff3d720f30371eb6 Mon Sep 17 00:00:00 2001
From: 无关风月 <443237572@qq.com>
Date: 星期五, 07 三月 2025 22:04:10 +0800
Subject: [PATCH] 账单

---
 ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java |  188 ++++++++++++++++++++++++----------------------
 1 files changed, 98 insertions(+), 90 deletions(-)

diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java
index 1df47bd..1b8b4e9 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/task/TaskUtil.java
@@ -1,93 +1,101 @@
-package com.ruoyi.web.controller.task;
-
-
-import com.ruoyi.system.model.TBill;
-import com.ruoyi.system.model.TContract;
-import com.ruoyi.system.model.TContractRentType;
-import com.ruoyi.system.service.TBillService;
-import com.ruoyi.system.service.TContractRentTypeService;
-import com.ruoyi.system.service.TContractService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.scheduling.annotation.Scheduled;
-import org.springframework.stereotype.Component;
-
-import javax.annotation.Resource;
-import java.math.BigDecimal;
-import java.time.LocalDate;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.temporal.ChronoUnit;
-import java.time.temporal.TemporalAdjusters;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Random;
-import java.util.stream.Collectors;
-
-/**
- * @author zhibing.pu
- * @date 2023/7/11 8:39
- */
-@Component
-public class TaskUtil {
-    @Autowired
-    private TContractService contractService;
-    @Autowired
-    private TBillService billService;
-    // 用于更新违约金账单
-    @Scheduled(cron = "0 0 0 * * ?")
-    public void dayOfProportionBill() {
-        try {
-            // 查询所有未缴费账单
-            List<TBill> list = billService.lambdaQuery().eq(TBill::getPayFeesStatus, 1).list();
-            for (TBill tBill : list) {
-                if (tBill.getPayableFeesTime().isAfter(LocalDate.now())){
-                    tBill.setPayFeesStatus("4");
-                }
-                TContract contract = contractService.getById(tBill.getContractId());
-                LocalDate payableFeesTime = tBill.getPayableFeesTime();
-                LocalDateTime now = LocalDateTime.now();
-                // 计算两个时间相差多少个小时
-                long hours = ChronoUnit.HOURS.between(payableFeesTime, now);
-                long l = hours / 24;
-                if (l>3){
-                    // 违约金比例
-                    BigDecimal proportion = contract.getProportion();
-                    // 按每天 待缴费金额 * XX% 增加违约金费用
-                    if (tBill.getOutstandingMoney().compareTo(new BigDecimal("0"))==0){
-                        tBill.setPayFeesStatus("3");
-                        billService.updateById(tBill);
-                        continue;
-                    }
-                    BigDecimal money = tBill.getOutstandingMoney().multiply(proportion).setScale(2, BigDecimal.ROUND_DOWN);
-                    tBill.setOverDays((int) l);
-                    tBill.setPayableFeesPenalty((tBill.getPayableFeesPenalty()!=null?tBill.getPayableFeesPenalty():BigDecimal.ZERO).add(money));
-                }
-                billService.updateById(tBill);
-            }
-
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-    public static void main(String[] args) {
-
-//        LocalDateTime now = LocalDateTime.now().minusMonths(1).withDayOfMonth(31);
-//        System.err.println(now);
-//        LocalDateTime now2 = now.plusMonths(1);
-//        System.err.println(now2);
+//package com.ruoyi.web.controller.task;
 //
-//        LocalDateTime now1 = LocalDateTime.now();
-//        long days = ChronoUnit.DAYS.between(now, now1);
-//        long days2 = ChronoUnit.DAYS.between(now.plusDays(1), now1);
 //
-//        System.err.println(days);
-//        System.err.println(days2);
-//        LocalDateTime endTime = now.with(TemporalAdjusters.lastDayOfMonth()).withSecond(59).withHour(23).withMinute(59);
+//import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+//import com.ruoyi.system.mapper.TBillMapper;
+//import com.ruoyi.system.model.TBill;
+//import com.ruoyi.system.model.TContract;
+//import com.ruoyi.system.model.TContractRentType;
+//import com.ruoyi.system.service.TBillService;
+//import com.ruoyi.system.service.TContractRentTypeService;
+//import com.ruoyi.system.service.TContractService;
+//import org.springframework.beans.factory.annotation.Autowired;
+//import org.springframework.scheduling.annotation.Scheduled;
+//import org.springframework.stereotype.Component;
 //
-//        System.err.println(endTime);
-
-    }
-
-}
+//import javax.annotation.Resource;
+//import java.math.BigDecimal;
+//import java.time.LocalDate;
+//import java.time.LocalDateTime;
+//import java.time.LocalTime;
+//import java.time.ZoneId;
+//import java.time.temporal.ChronoUnit;
+//import java.time.temporal.TemporalAdjusters;
+//import java.util.ArrayList;
+//import java.util.Date;
+//import java.util.List;
+//import java.util.Random;
+//import java.util.stream.Collectors;
+//
+///**
+// * @author zhibing.pu
+// * @date 2023/7/11 8:39
+// */
+//@Component
+//public class TaskUtil {
+//    @Autowired
+//    private TContractService contractService;
+//    @Autowired
+//    private TBillMapper billMapper;
+//    // 用于更新违约金账单
+//    // 每分钟执行一次的定时任务
+//
+////    @Scheduled(cron = "0 0 0 * * ?")
+//    @Scheduled(cron = "0 * * * * ?")
+//    public void dayOfProportionBill() {
+//        try {
+//            // 查询所有未缴费账单
+//            List<TBill> list = billMapper.selectList(new LambdaQueryWrapper<TBill>().eq(TBill::getPayFeesStatus, 1)
+//                    .le(TBill::getPayableFeesTime,LocalDate.now()));
+//            for (TBill tBill : list) {
+//                tBill.setPayFeesStatus("4");
+//                TContract contract = contractService.getById(tBill.getContractId());
+//                LocalDate payableFeesTime = tBill.getPayableFeesTime();
+//                // 将LocalDate转化为LocalDateTime
+//                LocalDateTime payableFeesTime1 = LocalDateTime.of(payableFeesTime, LocalTime.of(0, 0, 0));
+//                LocalDateTime now = LocalDateTime.now();
+//                // 计算两个时间相差多少个小时
+//                long hours = ChronoUnit.HOURS.between(payableFeesTime1, now);
+//                long l = hours / 24;
+//                if (l>=3){
+//                    // 违约金比例
+//                    BigDecimal proportion = contract.getProportion();
+//                    // 按每天 待缴费金额 * XX% 增加违约金费用
+//                    if (tBill.getOutstandingMoney().compareTo(new BigDecimal("0"))==0){
+//                        tBill.setPayFeesStatus("3");
+//                        billMapper.updateById(tBill);
+//                        continue;
+//                    }
+//                    BigDecimal money = tBill.getOutstandingMoney().multiply(new BigDecimal(100).add(proportion)).divide(new BigDecimal(100),2, BigDecimal.ROUND_DOWN);
+//                    tBill.setOverDays((int) l);
+//                    tBill.setPayableFeesPenalty((tBill.getPayableFeesPenalty()!=null?tBill.getPayableFeesPenalty():BigDecimal.ZERO).add(money));
+//                    tBill.setOutstandingMoney(money);
+//                    billMapper.updateById(tBill);
+//
+//                }
+//            }
+//        } catch (Exception e) {
+//            e.printStackTrace();
+//        }
+//    }
+//
+//    public static void main(String[] args) {
+//
+////        LocalDateTime now = LocalDateTime.now().minusMonths(1).withDayOfMonth(31);
+////        System.err.println(now);
+////        LocalDateTime now2 = now.plusMonths(1);
+////        System.err.println(now2);
+////
+////        LocalDateTime now1 = LocalDateTime.now();
+////        long days = ChronoUnit.DAYS.between(now, now1);
+////        long days2 = ChronoUnit.DAYS.between(now.plusDays(1), now1);
+////
+////        System.err.println(days);
+////        System.err.println(days2);
+////        LocalDateTime endTime = now.with(TemporalAdjusters.lastDayOfMonth()).withSecond(59).withHour(23).withMinute(59);
+////
+////        System.err.println(endTime);
+//
+//    }
+//
+//}

--
Gitblit v1.7.1