From be0301e67768fb183df7e29f411a7e54dbf15c40 Mon Sep 17 00:00:00 2001
From: jiangping <jp@doumee.com>
Date: 星期三, 08 五月 2024 10:37:58 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/1.0.1' into 1.0.1

---
 server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java |   71 +++++++++++++++++++++++++++--------
 1 files changed, 55 insertions(+), 16 deletions(-)

diff --git a/server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java b/server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java
index a05336f..1efb65a 100644
--- a/server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java
+++ b/server/service/src/main/java/com/doumee/service/business/impl/UnionChangeServiceImpl.java
@@ -36,6 +36,7 @@
 import org.springframework.transaction.annotation.Transactional;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
@@ -187,7 +188,7 @@
                     fee = fee.subtract(new BigDecimal(maxDays).multiply(applyChagneDetail.getPrice())).add(applyChagneDetail.getFee());
                 }
             }
-            unionChange.setFee(fee);
+            unionChange.setFee(fee.setScale(2, RoundingMode.HALF_UP));
             //鏌ヨ鎿嶄綔璁板綍
             List<ApplyLog> applyLogList = applyLogJoinMapper.selectJoinList(ApplyLog.class,
                     new MPJLambdaWrapper<ApplyLog>()
@@ -351,7 +352,8 @@
         }
         if(Objects.isNull(saveUnionChangeDTO)
                 || Objects.isNull(saveUnionChangeDTO.getApplyIds())
-                || Objects.isNull(saveUnionChangeDTO.getApplyDate())
+                || Objects.isNull(saveUnionChangeDTO.getAddValidDate())
+                || Objects.isNull(saveUnionChangeDTO.getDelValidDate())
                 || Objects.isNull(saveUnionChangeDTO.getUnionApplyId())
                 || Objects.isNull(saveUnionChangeDTO.getBusinessType())
         ){
@@ -364,9 +366,13 @@
         }
         //鍒ゆ柇鎵瑰崟鏃ユ湡 鍚堝苟鍗曠殑鎵瑰崟鐢熸晥鏈熷湪涓� 淇濆崟璧锋湡鐨勬鏃� 鍒颁繚鍗曟鏈�
         //鑾峰彇寮�濮嬫棩鏈熸鏃�
-        if(saveUnionChangeDTO.getApplyDate().getTime()<=DateUtil.afterDateByType(unionApply.getStartTime(),0,1).getTime()
-        || saveUnionChangeDTO.getApplyDate().getTime()> unionApply.getEndTime().getTime()){
-            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍚堝苟鍗曠殑鎵瑰崟鐢熸晥鏈熼敊璇�");
+        if(saveUnionChangeDTO.getAddValidDate().getTime()<DateUtil.afterDateByType(unionApply.getStartTime(),0,1).getTime()
+        || saveUnionChangeDTO.getAddValidDate().getTime()> unionApply.getEndTime().getTime()){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍚堝苟鍗曠殑鎵瑰崟鍔犱繚鐢熸晥鏈熼敊璇�");
+        }
+        if(saveUnionChangeDTO.getDelValidDate().getTime()<DateUtil.afterDateByType(unionApply.getStartTime(),0,1).getTime()
+                || saveUnionChangeDTO.getDelValidDate().getTime()> unionApply.getEndTime().getTime()){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍚堝苟鍗曠殑鎵瑰崟鍔犱繚鐢熸晥鏈熼敊璇�");
         }
 
         List<ApplyChange> applyChangeList = applyChangeJoinMapper.selectJoinList(ApplyChange.class,
@@ -389,10 +395,13 @@
         UnionChange unionChange = new UnionChange();
         unionChange.setCreateDate(new Date());
         unionChange.setCreator(user.getId());
+        unionChange.setEditDate(new Date());
+        unionChange.setEditor(user.getId());
         unionChange.setShopId(user.getCompanyId());
         unionChange.setIsdeleted(Constants.ZERO);
         unionChange.setUnionApplyId(saveUnionChangeDTO.getUnionApplyId());
-        unionChange.setApplyStartTime(DateUtil.getMontageDate(saveUnionChangeDTO.getApplyDate(),1));
+        unionChange.setApplyStartTime(DateUtil.getMontageDate(saveUnionChangeDTO.getAddValidDate(),1));
+        unionChange.setDelValidTime(DateUtil.getMontageDate(saveUnionChangeDTO.getDelValidDate(),1));
         unionChange.setType(saveUnionChangeDTO.getBusinessType());
         unionChange.setStatus(Constants.UnionChangeStatus.MERGE.getKey());
         unionChangeMapper.insert(unionChange);
@@ -408,7 +417,6 @@
         applyChagneDetailJoinMapper.update(null,new UpdateWrapper<ApplyChagneDetail>().lambda()
                 .set(ApplyChagneDetail::getUnionChangeId,unionChange.getId())
                 .in(ApplyChagneDetail::getApplyChangeId,saveUnionChangeDTO.getApplyIds()));
-
 
         Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_HBD_UPLOAD;
         ApplyLog log = new ApplyLog(unionChange,applyLogType.getName(), null
@@ -549,14 +557,14 @@
     public  String getSignLink(SmsCheckDTO smsCheckDTO) {
         if(Objects.isNull(smsCheckDTO)
                 || Objects.isNull(smsCheckDTO.getBusinessId())
-                || StringUtils.isBlank(smsCheckDTO.getCode())
+//                || StringUtils.isBlank(smsCheckDTO.getCode())
         ){
             throw  new BusinessException(ResponseStatus.BAD_REQUEST);
         }
         //楠岃瘉 楠岃瘉鐮�
-        if(!debugModel){
-            smsEmailService.validateCode(smsCheckDTO.getCode());
-        }
+//        if(!debugModel){
+//            smsEmailService.validateCode(smsCheckDTO.getCode());
+//        }
         LoginUserInfo user = (LoginUserInfo) SecurityUtils.getSubject().getPrincipal();
         UnionChange unionChange = this.unionChangeDetail(smsCheckDTO.getBusinessId());
         unionChange.setStatus(Constants.formatIntegerNum(unionChange.getStatus()));
@@ -625,6 +633,10 @@
         if(Objects.isNull(unionChange)||!Constants.equalsInteger(unionChange.getIsdeleted(),Constants.ZERO)){
             throw new BusinessException(ResponseStatus.DATA_EMPTY);
         }
+        if(!Constants.equalsInteger(unionChange.getType(),Constants.ONE)&&
+                unionChangeBXDDTO.getDelValidTime() == null ){
+            throw  new BusinessException(ResponseStatus.BAD_REQUEST);
+        }
         unionChange.setStatus(Constants.formatIntegerNum(unionChange.getStatus()));
         unionChange.setShopId(Constants.formatIntegerNum(unionChange.getShopId()));
         if(!unionChange.getShopId().equals(user.getCompanyId())){
@@ -645,10 +657,15 @@
         }
         //鍒ゆ柇鎵瑰崟鏃ユ湡 鍚堝苟鍗曠殑鎵瑰崟鐢熸晥鏈熷湪涓� 淇濆崟璧锋湡鐨勬鏃� 鍒颁繚鍗曟鏈�
         //鑾峰彇寮�濮嬫棩鏈熸鏃�
-        if(unionChangeBXDDTO.getApplyDate().getTime()<=DateUtil.afterDateByType(unionApply.getStartTime(),0,1).getTime()
+        if(unionChangeBXDDTO.getApplyDate().getTime()<DateUtil.afterDateByType(unionApply.getStartTime(),0,1).getTime()
                 || unionChangeBXDDTO.getApplyDate().getTime()> unionApply.getEndTime().getTime()){
-            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍚堝苟鍗曠殑鎵瑰崟鐢熸晥鏈熼敊璇�");
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍚堝苟鍗曠殑鎵瑰崟鍔犱繚鐢熸晥鏈熼敊璇�");
         }
+        if(unionChangeBXDDTO.getDelValidTime().getTime()<DateUtil.afterDateByType(unionApply.getStartTime(),0,1).getTime()
+                || unionChangeBXDDTO.getDelValidTime().getTime()> unionApply.getEndTime().getTime()){
+            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鍚堝苟鍗曠殑鎵瑰崟鍑忎繚鐢熸晥鏈熼敊璇�");
+        }
+
 
         List<ApplyChange> applyChangeList = applyChangeJoinMapper.selectJoinList(ApplyChange.class,
                 new MPJLambdaWrapper<ApplyChange>()
@@ -682,6 +699,10 @@
                 throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"鎵瑰崟鏄庣粏璁板綍瀛樺湪闈炴湰鍚堝苟鍗曟暟鎹�");
             };
             for (Multifile m:unionChangeBXDDTO.getApplyChangeBXDList()) {
+                if(StringUtils.isBlank(m.getName())
+                        || StringUtils.isBlank(m.getFileurl()) ){
+                    continue;
+                }
                 if(Objects.isNull(m.getObjId())
                         ||StringUtils.isBlank(m.getFileurl())
                         ||StringUtils.isBlank(m.getName())
@@ -699,8 +720,10 @@
         }
         if(CollectionUtils.isNotEmpty(applyChangeList)){
             for (ApplyChange applyChange:applyChangeList) {
+                ApplyChange oldModel = applyChange;
                 applyChange.setApplyStartTime(unionChangeBXDDTO.getApplyDate());
-                applyChange.setValidTime(unionChangeBXDDTO.getApplyDate());
+                applyChange.setDelValidTime(unionChangeBXDDTO.getDelValidTime());
+//                applyChange.setValidTime(unionChangeBXDDTO.getApplyDate());
                 applyChange.setEditDate(new Date());
                 applyChange.setEditor(user.getId());
                 applyChange.setStatus(Constants.ApplyChangeStatus.APPROVE.getKey());
@@ -727,6 +750,18 @@
                                 .eq(ApplyChagneDetail::getApplyChangeId,applyChange.getId()));
                 this.dealApplyChangeDetail(applyChange,allList);
                 applyChangeJoinMapper.updateById(applyChange);
+
+                //瀛樺偍鎵瑰崟瀹屾垚淇℃伅
+                Constants.ApplyLogType applyLogType = Constants.ApplyLogType.CA_PLATFORM_APPROVE;
+                String info = "";
+                if(applyChange.getValidTime()!=null && applyChange.getValidTime().getTime()/1000!= applyChange.getApplyStartTime().getTime()/1000){
+                    info =applyLogType.getInfo();
+                    info = info.replace("${param1}",DateUtil.getPlusTime2(applyChange.getValidTime()));
+                    info = info.replace("${param2}",DateUtil.getPlusTime2(applyChange.getApplyStartTime()));
+                }
+                ApplyLog log = new ApplyLog(applyChange,applyLogType.getName(), info,applyChange.getId(),applyLogType.getKey(),JSONObject.toJSONString(oldModel), JSONObject.toJSONString(applyChange));
+                applyLogMapper.insert(log);
+
             }
         }
         unionChangeMapper.update(null,new UpdateWrapper<UnionChange>().lambda()
@@ -734,6 +769,7 @@
                 .set(UnionChange::getEditDate,new Date())
                 .set(UnionChange::getEditor,user.getId())
                 .set(UnionChange::getValidTime,unionChangeBXDDTO.getApplyDate())
+                .set(UnionChange::getDelValidTime,unionChangeBXDDTO.getDelValidTime())
                 .set(UnionChange::getApplyStartTime,unionChangeBXDDTO.getApplyDate())
                 .set(UnionChange::getCode,unionChangeBXDDTO.getCode())
                 .eq(UnionChange::getId,unionChangeBXDDTO.getId())
@@ -811,6 +847,9 @@
         ApplyDetail add = new ApplyDetail();
         if(new Date().compareTo(DateUtil.getMontageDate(applyChange.getApplyStartTime(), 2))>=0){
             Integer days =  DateUtil.calculateBetween(applyChange.getApplyStartTime(),DateUtil.getMontageDate(new Date(), 2),0);
+
+
+
             //濡傛灉宸插凡浜х敓璐圭敤锛岃绠楀凡宸蹭骇鐢熻垂鐢�
             add.setCurrentFee(new BigDecimal(days).multiply(detail.getPrice()));
         }else{
@@ -982,7 +1021,7 @@
 
             //淇敼 鍛樺伐鎶曚繚鏄庣粏璁板綍 鍘嗗彶鏁版嵁
             memberInsuranceJoinMapper.update(null,new UpdateWrapper<MemberInsurance>().lambda()
-                    .set(MemberInsurance::getEndTime,applyStartTime)
+                    .set(MemberInsurance::getEndTime,DateUtil.getMontageDate(applyStartTime,3))
                     .set(MemberInsurance::getFee,oldFee)
                     .eq(MemberInsurance::getRelationId,oldModel.getId())
             );
@@ -1012,7 +1051,7 @@
             add.setFromId(detail.getId());
             applyDetailJoinMapper.insert(add);
 
-            MemberInsurance memberInsurance = new MemberInsurance(oldModel,applyChange.getId());
+            MemberInsurance memberInsurance = new MemberInsurance(add,applyChange.getId());
             memberInsurance.setSolutionId(detail.getSolutionId());
             memberInsurance.setWorktypeName(detail.getWorkTypeName());
             memberInsurance.setDuName(detail.getDuName());

--
Gitblit v1.9.3