From 49c7ea314c2070a2090fee2c77acbd21435f0455 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期四, 20 六月 2024 16:51:09 +0800
Subject: [PATCH] 提交一把

---
 server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java |   74 +++++++++++++++---------------------
 1 files changed, 31 insertions(+), 43 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
index 29bb9de..3759e76 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/ApplyChangeServiceImpl.java
@@ -1088,30 +1088,10 @@
         applyChange.setIsdeleted(Constants.ZERO);
         //鏍规嵁鐢宠鏃ユ湡 澶勭悊鍔犲噺淇濈殑 瀹為檯鐢熸晥鏃ユ湡
         if(applyChange.getType().equals(Constants.ZERO)){
-            if(Objects.nonNull(solutions.getAddValidDays())){
-                applyChange.setApplyStartTime(
-                        DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getAddValidDays())
-                );
-            }else{
-                applyChange.setApplyStartTime(applyChange.getValidTime());
-            }
-            if(Objects.nonNull(solutions.getDelValidDays())){
-                applyChange.setDelValidTime(
-                        DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getDelValidDays())
-                );
-            }else{
-                applyChange.setDelValidTime(applyChange.getValidTime());
-            }
-            //浠呮敮鎸佹浛鎹�  淇濊瘉鍔犲噺淇濇棩鏈熶负鍚屼竴澶�
-            if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){
-                applyChange.setApplyStartTime(
-                        applyChange.getDelValidTime()
-                );
-            }
+            initJJBValidTime(applyChange,insuranceApply,solutions);
         }else{
             applyChange.setApplyStartTime(applyChange.getValidTime());
         }
-
         applyChange.setStatus(Constants.ZERO);
         applyChangeMapper.insert(applyChange);
 
@@ -1180,7 +1160,6 @@
             throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(), "淇濆崟宸茶繃淇濓紝鏃犳硶杩涜璇ユ搷浣�");
         }
         if (DateUtil.compareDate(applyChange.getValidTime(),insuranceApply.getStartTime()) > Constants.ZERO) {
-            //濡傛灉淇濆崟灏氭湭鐢熸晥锛岃缃湡鏈涚敓鏁堟棩鏈熶负淇濆崟鐢熸晥寮�濮嬫椂闂�
             applyChange.setValidTime(insuranceApply.getStartTime());
         }
         Solutions solutions = solutionsMapper.selectById(insuranceApply.getSolutionId());
@@ -1217,27 +1196,8 @@
         };
 
         if(applyChange.getType().equals(Constants.ZERO)){
-            if(Objects.nonNull(solutions.getAddValidDays())){
-                applyChange.setApplyStartTime(
-                        DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getAddValidDays())
-                );
-            }else{
-                applyChange.setApplyStartTime(applyChange.getValidTime());
-            }
-            if(Objects.nonNull(solutions.getDelValidDays())){
-                applyChange.setDelValidTime(
-                        DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getDelValidDays())
-                );
-            }else{
-                applyChange.setDelValidTime(applyChange.getValidTime());
-            }
-            //浠呮敮鎸佹浛鎹�  淇濊瘉鍔犲噺淇濇棩鏈熶负鍚屼竴澶�
-            if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){
-                applyChange.setApplyStartTime(
-                        applyChange.getDelValidTime()
-                );
-            }
-
+            //澶勭悊鏈熸湜鐢熸晥鏃ユ湡
+            initJJBValidTime(applyChange,insuranceApply,solutions);
         }else{
             applyChange.setApplyStartTime(applyChange.getValidTime());
         }
@@ -1267,6 +1227,34 @@
         return applyChange.getId();
     }
 
+    private void initJJBValidTime(ApplyChange applyChange, InsuranceApply insuranceApply, Solutions solutions) {
+        if( applyChange.getValidTime().getTime()>=insuranceApply.getStartTime().getTime()
+                && Objects.nonNull(solutions.getAddValidDays())){
+            //濡傛灉淇濆崟宸茬敓鏁堬紝鎸夌収t+n鐨勮鍒�
+            applyChange.setApplyStartTime(
+                    DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getAddValidDays())
+            );
+        }else{
+            //濡傛灉淇濆崟鏈敓鎴栬�呮病鏈夐厤缃敓鏁堝ぉ鏁帮紝璁剧疆鏈熸湜鐢熸晥鏃ユ湡涓轰繚鍗曠敓鏁堝紑濮嬫椂闂�
+            applyChange.setApplyStartTime(applyChange.getValidTime());
+        }
+        if(applyChange.getValidTime().getTime()>=insuranceApply.getStartTime().getTime()
+                &&Objects.nonNull(solutions.getDelValidDays())){
+            applyChange.setDelValidTime(
+                    DateUtil.afterDateByType(applyChange.getValidTime(),0,solutions.getDelValidDays())
+            );
+        }else{
+            applyChange.setDelValidTime(applyChange.getValidTime());
+        }
+        //浠呮敮鎸佹浛鎹�  淇濊瘉鍔犲噺淇濇棩鏈熶负鍚屼竴澶�
+        if(Constants.equalsInteger(solutions.getDelOnlyReplace(),Constants.ONE)){
+            applyChange.setApplyStartTime(
+                    applyChange.getDelValidTime()
+            );
+        }
+
+    }
+
 
     public BigDecimal dealApplyChangeData(ApplyChange applyChange,InsuranceApply insuranceApply
             ,CompanySolution companySolution,Solutions solutions,LoginUserInfo loginUserInfo,BigDecimal fee){

--
Gitblit v1.9.3