Browse Source

feat:动态调度

zhangwei 3 years ago
parent
commit
138d034079

+ 1 - 1
src/main/java/com/winhc/repal/cloud/InCaseService.java

@@ -18,7 +18,7 @@ import org.springframework.web.bind.annotation.RequestBody;
  * @description
  */
 @FeignClient("inCaseService")
-//@FeignClient(value = "inCaseService",url = "106.14.81.247:58554")
+//@FeignClient(value = "inCaseService",url = "106.14.81.247:8554")
 public interface InCaseService {
 
     /**

+ 19 - 0
src/main/java/com/winhc/repal/enums/RepalVipSignEnum.java

@@ -0,0 +1,19 @@
+package com.winhc.repal.enums;
+
+/**
+ * @author Aaron
+ * @date 2022/5/7 13:22
+ * @description
+ */
+public enum RepalVipSignEnum {
+    有特权("0"),无特权("1");
+    private String code;
+
+    RepalVipSignEnum(String code) {
+        this.code = code;
+    }
+
+    public String getCode() {
+        return code;
+    }
+}

+ 6 - 3
src/main/java/com/winhc/repal/service/impl/RepalCustomerServiceImpl.java

@@ -128,9 +128,12 @@ public class RepalCustomerServiceImpl extends ServiceImpl<RepalCustomerMapper, R
          List<RepalCustChargeRel> rels = repalCustChargeRelService.list(Wrappers.lambdaQuery(RepalCustChargeRel.class)
                  .in(RepalCustChargeRel::getCustId,custIds));
          Map<Long, List<RepalCustChargeRel>> relMap = rels.stream().collect(Collectors.groupingBy(RepalCustChargeRel::getCustId));
-         Map<Long, RepalGroupMember> memberMap = repalGroupMemberService.list(Wrappers.lambdaQuery(RepalGroupMember.class)
-                 .in(RepalGroupMember::getUserId,rels.stream().map(RepalCustChargeRel::getMemberUserId).collect(Collectors.toList())))
-                 .stream().collect(Collectors.toMap(RepalGroupMember::getUserId,Function.identity()));
+         Map<Long, RepalGroupMember> memberMap = new HashMap<>();
+         if(CollUtil.isNotEmpty(rels)) {
+             memberMap = repalGroupMemberService.list(Wrappers.lambdaQuery(RepalGroupMember.class)
+                             .in(RepalGroupMember::getUserId, rels.stream().map(RepalCustChargeRel::getMemberUserId).collect(Collectors.toList())))
+                     .stream().collect(Collectors.toMap(RepalGroupMember::getUserId, Function.identity()));
+         }
          List<RepalCustomerInfoVO> voList = new ArrayList<>();
          for(RepalCustomerInfoBO customerInfo:page.getRecords()){
              RepalCustomerInfoVO vo = new RepalCustomerInfoVO();

+ 28 - 15
src/main/java/com/winhc/repal/task/SmartRemindTask.java

@@ -14,16 +14,15 @@ import com.winhc.repal.cloud.dto.QueryESFinanceDynamicDTO;
 import com.winhc.repal.cloud.dto.QueryV8DynamicDTO;
 import com.winhc.repal.cloud.vo.FinanceDynamicVO;
 import com.winhc.repal.cloud.vo.V8DynamicVO;
-import com.winhc.repal.entity.RepalBill;
-import com.winhc.repal.entity.RepalRemindDefinition;
-import com.winhc.repal.entity.RepalRemindHistory;
-import com.winhc.repal.entity.ThirdPartyAccount;
+import com.winhc.repal.entity.*;
 import com.winhc.repal.enums.*;
 import com.winhc.repal.service.*;
 import com.winhc.repal.util.RedisUtil;
 import com.xxl.job.core.handler.annotation.XxlJob;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.EnableScheduling;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.PostConstruct;
@@ -44,6 +43,7 @@ import java.util.stream.Collectors;
  */
 @Component
 @Slf4j
+//@EnableScheduling
 public class SmartRemindTask {
     private static final int PAGE_SIZE = 100;
     private static final String MESSAGE_PRIFIX = "winhc:repal:key_";
@@ -63,6 +63,10 @@ public class SmartRemindTask {
     private RedisUtil redisUtil;
     @Autowired
     private ThirdPartyAccountService thirdPartyAccountService;
+    @Autowired
+    private RepalVipService repalVipService;
+    @Autowired
+    private RepalGroupMemberService repalGroupMemberService;
 
     private static final HashMap<String,String> RISK_MAP = new HashMap<>(32);
 
@@ -105,27 +109,36 @@ public class SmartRemindTask {
      */
     //@Scheduled(cron = "0 0 10 * * ?")
     @XxlJob("checkTrend")
+//    @Scheduled(cron = "0 56 13 * * ?")
     public void checkTrend(){
         LocalDate now = LocalDate.now();
         LambdaQueryWrapper<RepalBill> qw = Wrappers.lambdaQuery(RepalBill.class);
-        qw.ne(RepalBill::getRepalBillStatus,RepalBillStatusEnum.SUCCESS.getCode());
+        qw.notIn(RepalBill::getRepalBillStatus,Arrays.asList(RepalBillStatusEnum.SUCCESS.getCode(),RepalBillStatusEnum.END.getCode()));
         qw.ne(RepalBill::getUserId,0);
         qw.eq(RepalBill::getDeleted,Dict.DeletedStatusEnunm.否.getCode());
-        IPage<RepalBill> countAccountBill =accountBillService.page(new Page<>(1,1),qw);
-        long pageNum = (countAccountBill.getTotal()+PAGE_SIZE-1) / PAGE_SIZE;
+        int totalCount = accountBillService.count(qw);
+        long pageNum = (totalCount+PAGE_SIZE-1) / PAGE_SIZE;
         for(long i = 1;i<= pageNum ; i++){
             IPage<RepalBill> result = accountBillService.page(new Page<>(i,PAGE_SIZE),qw);
             List<RepalBill> billList = result.getRecords();
             //更新逾期状态
             billList.forEach(e->{
-                //todo 过滤没开通标准版和高级版的账款
-
+                RepalVip repalVip = repalVipService.getOne(Wrappers.lambdaQuery(RepalVip.class).eq(RepalVip::getRepalGroupId,e.getRepalGroupId()),false);
+                if(ObjectUtil.isNull(repalVip) ||
+                        RepalVipSignEnum.无特权.getCode().equals(repalVip.getRepalVipSign()) ||
+                        repalVip.getRepalVipEndTime() != null && repalVip.getRepalVipEndTime().isBefore(LocalDateTime.now())){
+                    return;
+                }
                 //查出组织下所有已经授权的成员
-                List<ThirdPartyAccount> accounts = thirdPartyAccountService.list(Wrappers.lambdaQuery(ThirdPartyAccount.class)
-                        .eq(ThirdPartyAccount::getGroupId,e.getRepalGroupId())
-                        .eq(ThirdPartyAccount::getDeleted,Dict.DeletedStatusEnunm.否.getCode())
-                        .eq(ThirdPartyAccount::getAppId,0)
-                        .isNotNull(ThirdPartyAccount::getMobileNo));
+                List<RepalGroupMember> repalGroupMembers = repalGroupMemberService.list(Wrappers.lambdaQuery(RepalGroupMember.class).eq(RepalGroupMember::getRepalGroupId,e.getRepalGroupId()).eq(RepalGroupMember::getDeleted,Dict.DeletedStatusEnunm.否.getCode()));
+                List<ThirdPartyAccount> accounts = new ArrayList<>();
+                if(CollUtil.isNotEmpty(repalGroupMembers)) {
+                    accounts = thirdPartyAccountService.list(Wrappers.lambdaQuery(ThirdPartyAccount.class)
+                            .in(ThirdPartyAccount::getUserId, repalGroupMembers.stream().map(RepalGroupMember::getUserId).collect(Collectors.toList()))
+                            .eq(ThirdPartyAccount::getDeleted, Dict.DeletedStatusEnunm.否.getCode())
+                            .eq(ThirdPartyAccount::getAppId, "0")
+                            .isNotNull(ThirdPartyAccount::getMobileNo));
+                }
                 List<String> mobiles = accounts.stream().map(ThirdPartyAccount::getMobileNo).collect(Collectors.toList());
 
                 AtomicReference<Boolean> needRefreshGrade = new AtomicReference<>(Boolean.FALSE);
@@ -191,7 +204,7 @@ public class SmartRemindTask {
                         financeQw.eq(RepalRemindDefinition::getRemindType, RemindEnum.财产线索.name());
                         financeQw.eq(RepalRemindDefinition::getOpportunity, financeDynamicTypeEnum.getCode());
                         financeQw.eq(RepalRemindDefinition::getRepalBillStatus, e.getRepalBillStatus());
-                        financeQw.eq(RepalRemindDefinition::getRepalBillStatus, e.getRepalBillStage() == null ? 1 :e.getRepalBillStage());
+                        financeQw.eq(RepalRemindDefinition::getRepalBillStage, e.getRepalBillStage() == null ? 1 :e.getRepalBillStage());
                         RepalRemindDefinition accountRemindDefinition = accountRemindDefinitionService.getOne(financeQw, false);
                         if (accountRemindDefinition != null) {
                             //取前一天入库的一周内的动态