|
@@ -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) {
|
|
|
//取前一天入库的一周内的动态
|