1
zj
2025-10-12 84d42b6997ae87fa64b75ae085fce11d05a6ca5a
ruoyi-admin/src/main/java/com/ruoyi/im/task/MedicalInsuranceTask.java
@@ -1,5 +1,6 @@
package com.ruoyi.im.task;
import cn.hutool.core.stream.CollectorUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.im.service.MedicalInsuranceAccountService;
import com.ruoyi.im.service.UserPolicyService;
@@ -13,6 +14,7 @@
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import java.time.LocalDate;
import java.util.ArrayList;
@@ -122,12 +124,14 @@
        List<Integer> ids = list.stream()
                .map(UserPolicy::getId) // 提取orderId字段
                .collect(Collectors.toList());
        List<PaymentRecord> records = paymentRecordService.list(new LambdaQueryWrapper<PaymentRecord>()
                .in(PaymentRecord::getOrderId, ids)
        );
        userPolicyService.removeByIds(list);
        userPolicyService.removeByIds(records);
        if(!CollectionUtils.isEmpty(ids)){
            List<PaymentRecord> records = paymentRecordService.list(new LambdaQueryWrapper<PaymentRecord>()
                    .in(PaymentRecord::getOrderId, ids)
            );
            userPolicyService.removeByIds(records);
        }
        if(!CollectionUtils.isEmpty(list)){
            paymentRecordService.removeByIds(list);
        }
    }
}