Ver Fonte

Merge remote-tracking branch 'origin/develop' into develop

FengChaoYu há 3 meses atrás
pai
commit
432c8631b4

+ 7 - 8
mall-miniapp-service/src/main/java/com/gree/mall/miniapp/logic/policy/WorkerLogic.java

@@ -100,6 +100,10 @@ public class WorkerLogic {
         List<WorkerRemind> workerReminds = new ArrayList<>();
 
         for (WebsitUser websitUser : websitUsers) {
+
+            AdminWebsit adminWebsit = adminWebsitService.getById(websitUser.getWebsitId());
+            if (!adminWebsit.getAttr().equals("SELF"))
+                continue;
             //保险购买状态,没有购买的意外险
             if (websitUser.getExamineStatus().equals(ExamineWorkerStatusEnum.WAIT_WORKER.getKey()) &&
                     workerPolicyService.lambdaQuery().eq(WorkerPolicy::getWebsitUserId,websitUser.getId())
@@ -118,8 +122,6 @@ public class WorkerLogic {
                     .eq(PolicyOrder::getWebsitUserId,websitUser.getId()).count() < 1
             ) {
 
-                AdminWebsit adminWebsit = adminWebsitService.getById(websitUser.getWebsitId());
-
                 WorkerRemind workerRemind = new WorkerRemind();
                 workerRemind.setWebsitId(websitUser.getWebsitId());
                 workerRemind.setWebsitName(adminWebsit.getName());
@@ -134,8 +136,6 @@ public class WorkerLogic {
                             .eq(WorkerPolicy::getPolicyType,"AC")
                             .count() > 0)) {
 
-                AdminWebsit adminWebsit = adminWebsitService.getById(websitUser.getWebsitId());
-
                 WorkerRemind workerRemind = new WorkerRemind();
                 workerRemind.setWebsitId(websitUser.getWebsitId());
                 workerRemind.setWebsitName(adminWebsit.getName());
@@ -176,8 +176,6 @@ public class WorkerLogic {
                         .eq(WorkerPolicy::getPolicyType,"AC")
                         .list();
 
-                AdminWebsit adminWebsit = adminWebsitService.getById(websitUser.getWebsitId());
-
                 for (WorkerPolicy workerPolicy : list) {
 
                     if (websitUserService.lambdaQuery().in(WebsitUser::getExamineStatus, ExamineWorkerStatusEnum.WAIT_WORKER.getKey())
@@ -236,8 +234,6 @@ public class WorkerLogic {
                         .eq(WorkerPolicy::getWebsitUserId,websitUser.getId())
                         .set(WorkerPolicy::getExTime,DateUtil.endOfDay(new Date())).update();
 
-                AdminWebsit adminWebsit = adminWebsitService.getById(websitUser.getWebsitId());
-
                 WorkerRemind workerRemind = new WorkerRemind();
                 workerRemind.setWebsitId(websitUser.getWebsitId());
                 workerRemind.setWebsitName(adminWebsit.getName());
@@ -592,6 +588,9 @@ public class WorkerLogic {
 
             ) {
                 AdminWebsit adminWebsit = adminWebsitService.getById(websitUser.getWebsitId());
+
+                if (!adminWebsit.getAttr().equals("SELF"))
+                    continue;
                 adminWebsits.add(adminWebsit);
             }
 

+ 14 - 7
mall-server-api/src/main/java/com/gree/mall/manager/logic/policy/AgreementLogic.java

@@ -1421,6 +1421,11 @@ public class AgreementLogic {
 
         for (WorkerPolicy workerPolicy : workerPolicies) {
 
+            AdminWebsit adminWebsit = adminWebsitService.getById(workerPolicy.getWebsitId());
+            if (!adminWebsit.getAttr().equals("SELF"))
+                continue;
+
+
             if (policyOrderService.lambdaQuery().eq(PolicyOrder::getPolicyOrderStatus, PolicyOrderInStutasEnum.DGM.getKey())
                     .eq(PolicyOrder::getWebsitUserId,workerPolicy.getWebsitUserId())
                     .eq(PolicyOrder::getType,"IN").count() > 0) {
@@ -1435,7 +1440,7 @@ public class AgreementLogic {
                 continue;
             }
 
-            AdminWebsit adminWebsit = adminWebsitService.getById(workerPolicy.getWebsitId());
+
             WebsitUser websitUser = websitUserService.getById(workerPolicy.getWebsitUserId());
             User user = userService.getById(websitUser.getUserId());
 
@@ -1485,6 +1490,14 @@ public class AgreementLogic {
 
         for (WorkerPolicy workerPolicy : workerPolicies) {
 
+            AdminWebsit adminWebsit = adminWebsitService.getById(workerPolicy.getWebsitId());
+
+            if (adminWebsit == null)
+                continue;
+
+            if (!adminWebsit.getAttr().equals("SELF"))
+                continue;
+
             if (policyOrderService.lambdaQuery().eq(PolicyOrder::getPolicyOrderStatus, PolicyOrderEmStutasEnum.XG.getKey())
                     .eq(PolicyOrder::getWebsitUserId,workerPolicy.getWebsitUserId())
                     .eq(PolicyOrder::getType,"EM").count() > 0) {
@@ -1503,12 +1516,6 @@ public class AgreementLogic {
                 continue;
             }
 
-
-            AdminWebsit adminWebsit = adminWebsitService.getById(workerPolicy.getWebsitId());
-
-            if (adminWebsit == null)
-                continue;
-
             WebsitUser websitUser = websitUserService.getById(workerPolicy.getWebsitUserId());
             User user = userService.getById(websitUser.getUserId());
 

+ 77 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/policy/PolicyOrderLogic.java

@@ -34,6 +34,7 @@ import java.time.Instant;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.ZoneId;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 
@@ -112,6 +113,7 @@ public class PolicyOrderLogic {
         return byId;
     }
 
+    @Transactional(rollbackFor = Exception.class)
     public void update(PolicyOrder policyOrder) {
 
         if (new Date().after(policyOrder.getStartTime()) && new Date().before(policyOrder.getEndTime()))
@@ -150,6 +152,19 @@ public class PolicyOrderLogic {
                 workerPolicy.setStatus("DSX");
             }
             workerPolicy.insert();
+
+            if (workerPolicy.getPolicyType().equals("EM")) {
+
+                List<WorkerPolicy> workerPolicyList = workerPolicyService.lambdaQuery().eq(WorkerPolicy::getWebsitUserId, policyOrder.getWebsitUserId())
+                        .eq(WorkerPolicy::getPolicyType, "EM").list();
+
+                Boolean wp = this.hasOverlap(workerPolicyList);
+
+                if (wp)
+                    throw new RemoteServiceException(policyOrder.getWorkerIdcard() + "雇主险有相同覆盖范围内的保险");
+            }
+
+
         }
     }
 
@@ -238,6 +253,11 @@ public class PolicyOrderLogic {
                 policyOrder.setBuyUnitId(sysDictCompany.getDictCode());
 
 
+                if (policyOrder.getStartTime().after(policyOrder.getEndTime()))
+                    throw new RemoteServiceException(policyOrder.getWorkerIdcard()+"开始时间不能大于结束时间");
+
+                if (!this.areInSameMonth(policyOrder.getStartTime(),policyOrder.getEndTime()))
+                    throw new RemoteServiceException(policyOrder.getWorkerIdcard()+"工伤险的有效时间必须在同一个月内");
 
 
                 if (new Date().after(policyOrder.getStartTime()) && new Date().before(policyOrder.getEndTime()))
@@ -293,6 +313,12 @@ public class PolicyOrderLogic {
                 policyOrderup.setClassWebsitName((String)row.get(12));
                 policyOrderup.setPayAmount(Convert.toBigDecimal(row.get(8)));
 
+                if (policyOrderup.getStartTime().after(policyOrderup.getEndTime()))
+                    throw new RemoteServiceException(policyOrderup.getWorkerIdcard()+"开始时间不能大于结束时间");
+
+                if (!this.areInSameMonth(policyOrderup.getStartTime(),policyOrderup.getEndTime()))
+                    throw new RemoteServiceException(policyOrderup.getWorkerIdcard()+"工伤险的有效时间必须在同一个月内");
+
 
                 if (new Date().after(policyOrderup.getStartTime()) && new Date().before(policyOrderup.getEndTime()))
                     policyOrderup.setPolicyOrderStatus("BZZ");
@@ -353,10 +379,30 @@ public class PolicyOrderLogic {
 
             }
 
+            List<WorkerPolicy> workerPolicyList = workerPolicyService.lambdaQuery().eq(WorkerPolicy::getWebsitUserId, websitUser.getId())
+                    .eq(WorkerPolicy::getPolicyType, "IN").list();
+
+            Boolean wp = this.hasOverlap(workerPolicyList);
+
+            if (wp)
+                throw new RemoteServiceException(user.getIdCard()+"工伤险有相同覆盖范围内的保险");
+
+
 
         }
     }
 
+    public boolean areInSameMonth(Date date1, Date date2) {
+        Calendar cal1 = Calendar.getInstance();
+        Calendar cal2 = Calendar.getInstance();
+
+        cal1.setTime(date1);
+        cal2.setTime(date2);
+
+        return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
+                cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH);
+    }
+
     @Transactional(rollbackFor = Exception.class)
     public void importEm(List<Object> objects) {
 
@@ -365,6 +411,9 @@ public class PolicyOrderLogic {
 
             AdminWebsit adminWebsit = adminWebsitService.lambdaQuery().eq(AdminWebsit::getWebsitNumber, (String) row.get(1)).one();
 
+            if (!adminWebsit.getAttr().equals("SELF"))
+                throw new RemoteServiceException(adminWebsit.getName()+"第三方网点请去师傅管理添加雇主险");
+
             User user = userService.lambdaQuery().eq(User::getIdCard, (String) row.get(4))
                     .one();
 
@@ -437,6 +486,9 @@ public class PolicyOrderLogic {
 
             policyOrder.setType("EM");
 
+            if (policyOrder.getStartTime().after(policyOrder.getEndTime()))
+                throw new RemoteServiceException((String) row.get(4)+"开始时间不能大于结束时间");
+
             if (new Date().after(policyOrder.getStartTime()) && new Date().before(policyOrder.getEndTime()))
                 policyOrder.setPolicyOrderStatus("BZZ");
             else if (new Date().after(policyOrder.getEndTime()))
@@ -448,6 +500,8 @@ public class PolicyOrderLogic {
             policyOrder.insert();
 
 
+
+
             WorkerPolicy workerPolicy = new WorkerPolicy();
             workerPolicy.setWorkerId(websitUser.getWorkerNumber());
             workerPolicy.setType("LINE");
@@ -472,11 +526,34 @@ public class PolicyOrderLogic {
             }
             workerPolicy.insert();
 
+            List<WorkerPolicy> workerPolicyList = workerPolicyService.lambdaQuery().eq(WorkerPolicy::getWebsitUserId, websitUser.getId())
+                    .eq(WorkerPolicy::getPolicyType, "EM").list();
+
+            Boolean wp = this.hasOverlap(workerPolicyList);
+
+            if (wp)
+                throw new RemoteServiceException(user.getIdCard()+"雇主险有相同覆盖范围内的保险");
 
 
 
+        }
+    }
+
+
+    public Boolean hasOverlap(List<WorkerPolicy> workerPolicies){
 
+        for (int i= 0; i<workerPolicies.size();i++){
+            WorkerPolicy workerPolicy = workerPolicies.get(i);
+            for (int j = i+1; j <workerPolicies.size() ; j++) {
+                WorkerPolicy workerPolicy2 = workerPolicies.get(j);
+                if (workerPolicy.getEndTime().after(workerPolicy2.getStartTime()) && workerPolicy2.getEndTime().after(workerPolicy.getStartTime())){
+                    return true;
+                }
+            }
         }
+
+        return false;
+
     }
 
     /**

+ 50 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/policy/WorkerManagerLogic.java

@@ -33,6 +33,7 @@ import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.ZoneId;
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 import java.util.stream.Collectors;
@@ -74,6 +75,9 @@ public class WorkerManagerLogic {
     @Autowired
     WorkerNumberCheckService workerNumberCheckService;
 
+    @Autowired
+    PolicyService policyService;
+
 
 
     public void stop(String id) {
@@ -883,6 +887,10 @@ public class WorkerManagerLogic {
             throw new RemoteServiceException("请填工程师意外险");
 
         for (WorkerPolicy workerPolicy : workerPolicies) {
+
+            if (workerPolicy.getStartTime().after(workerPolicy.getEndTime()))
+                throw new RemoteServiceException(workerPolicy.getWorkerName()+"意外开始时间不能大于结束时间");
+
             if (workerPolicy.getEndTime().after(new Date()) && workerPolicy.getStartTime().before(new Date())) {
                 workerPolicy.setStatus("BZZ");
             }else {
@@ -896,6 +904,24 @@ public class WorkerManagerLogic {
             throw new RemoteServiceException("意外险必须有生效的保险");
         }
 
+        PolicyOrder policyOrder = policyOrderService.lambdaQuery().eq(PolicyOrder::getWebsitUserId, websitUser.getId())
+                .eq(PolicyOrder::getType, "AC")
+                .isNull(PolicyOrder::getEndTime).last("limit 1").one();
+
+        if (policyOrder !=null){
+            Policy policy = policyService.getById(policyOrder.getPolicyId());
+            for (int i= 0; i<workerPolicies.size();i++){
+
+                WorkerPolicy workerPolicy2 = workerPolicies.get(i);
+                if (policy.getEndTime().after(workerPolicy2.getStartTime()) && workerPolicy2.getEndTime().after(policy.getStartTime())){
+                    throw new RemoteServiceException("意外险有已经购买相同覆盖范围内的保险");
+                }
+
+            }
+
+
+        }
+
 
         Boolean wp = this.hasOverlap(workerPolicies);
 
@@ -920,6 +946,14 @@ public class WorkerManagerLogic {
                 throw new RemoteServiceException("工伤险有相同覆盖范围内的保险");
 
             for (WorkerPolicy workerPolicy : workerPoliciesIn) {
+
+                if (workerPolicy.getStartTime().after(workerPolicy.getEndTime()))
+                    throw new RemoteServiceException(workerPolicy.getWorkerName()+"工伤开始时间不能大于结束时间");
+
+                if (!this.areInSameMonth(workerPolicy.getStartTime(),workerPolicy.getEndTime()))
+                    throw new RemoteServiceException(workerPolicy.getWorkerName()+"工伤险的有效时间必须在同一个月内");
+
+
                 if (workerPolicy.getEndTime().after(new Date()) && workerPolicy.getStartTime().before(new Date())) {
                     workerPolicy.setStatus("BZZ");
                 }else {
@@ -950,6 +984,11 @@ public class WorkerManagerLogic {
 
 
             for (WorkerPolicy workerPolicy : workerPoliciesEm) {
+
+                if (workerPolicy.getStartTime().after(workerPolicy.getEndTime()))
+                    throw new RemoteServiceException(workerPolicy.getWorkerName()+"雇主开始时间不能大于结束时间");
+
+
                 if (workerPolicy.getEndTime().after(new Date()) && workerPolicy.getStartTime().before(new Date())) {
                     workerPolicy.setStatus("BZZ");
                 }else {
@@ -970,6 +1009,17 @@ public class WorkerManagerLogic {
 
 }
 
+    public boolean areInSameMonth(Date date1, Date date2) {
+        Calendar cal1 = Calendar.getInstance();
+        Calendar cal2 = Calendar.getInstance();
+
+        cal1.setTime(date1);
+        cal2.setTime(date2);
+
+        return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
+                cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH);
+    }
+
     public WorkerUserCount countWorker( ) {
 
 

+ 19 - 0
mall-server-api/src/main/java/com/gree/mall/manager/logic/user/UserLogic.java

@@ -336,6 +336,13 @@ public class UserLogic {
                     userWaitPolicy.setStartTime(DateUtil.parse(in_policy_start_time, "yyyy-MM-dd"));
                     userWaitPolicy.setEndTime(this.getEndOfDay(DateUtil.parse(in_policy_end_time, "yyyy-MM-dd")));
 
+                    if (userWaitPolicy.getStartTime().after(userWaitPolicy.getEndTime()))
+                        throw new RemoteServiceException(userWait.getMobile()+"开始时间不能大于结束时间");
+
+                    if (!this.areInSameMonth(userWaitPolicy.getStartTime(),userWaitPolicy.getEndTime()))
+                        throw new RemoteServiceException(userWait.getMobile()+"工伤险的有效时间必须在同一个月内");
+
+
                     userWaitPolicies.add(userWaitPolicy);
                 }
 
@@ -478,6 +485,18 @@ public class UserLogic {
 
 
     }
+
+    public boolean areInSameMonth(Date date1, Date date2) {
+        Calendar cal1 = Calendar.getInstance();
+        Calendar cal2 = Calendar.getInstance();
+
+        cal1.setTime(date1);
+        cal2.setTime(date2);
+
+        return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) &&
+                cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH);
+    }
+
     /**
      * 获取某天最小时间
      * @param date 时间