Kaynağa Gözat

fix: 名称同步调度器跳过租户过滤查询待重试记录

alphaH 1 gün önce
ebeveyn
işleme
7b98fd3cd7

+ 7 - 0
java/src/main/java/com/payment/platform/module/payment/enterprise/mapper/EnterpriseMapper.java

@@ -8,6 +8,8 @@ import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 import org.apache.ibatis.annotations.Update;
 
+import java.util.List;
+
 @Mapper
 public interface EnterpriseMapper extends BaseMapper<EnterpriseEntity> {
 
@@ -25,4 +27,9 @@ public interface EnterpriseMapper extends BaseMapper<EnterpriseEntity> {
     @InterceptorIgnore(tenantLine = "true")
     @Update("UPDATE pay_enterprise SET enterprise_id=#{enterpriseId},out_biz_no=#{outBizNo},account_id=#{accountId},status=#{status},remark=#{remark},name=#{name},short_name=#{shortName},name_sync_status=#{nameSyncStatus},name_sync_retry_count=#{nameSyncRetryCount},name_sync_next_time=#{nameSyncNextTime},updated_time=NOW() WHERE id=#{id}")
     int updateIgnoreTenant(EnterpriseEntity entity);
+
+    /** 名称同步调度器用 — 查待重试记录,跳过租户过滤 */
+    @InterceptorIgnore(tenantLine = "true")
+    @Select("SELECT * FROM pay_enterprise WHERE name_sync_status = '0' AND name_sync_retry_count < #{maxRetry} AND name_sync_next_time <= NOW() LIMIT #{limit}")
+    List<EnterpriseEntity> selectPendingNameSync(@Param("maxRetry") int maxRetry, @Param("limit") int limit);
 }

+ 1 - 7
java/src/main/java/com/payment/platform/module/payment/enterprise/scheduler/EnterpriseNameSyncScheduler.java

@@ -1,6 +1,5 @@
 package com.payment.platform.module.payment.enterprise.scheduler;
 
-import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.payment.platform.module.payment.enterprise.entity.EnterpriseEntity;
 import com.payment.platform.module.payment.enterprise.mapper.EnterpriseMapper;
 import com.payment.platform.module.payment.enterprise.service.AlipayEnterpriseService;
@@ -36,12 +35,7 @@ public class EnterpriseNameSyncScheduler {
     @Scheduled(fixedDelay = 60 * 1000)
     public void retryNameSync() {
         log.info("[企业名称同步] 开始执行");
-        List<EnterpriseEntity> list = enterpriseMapper.selectList(
-                new LambdaQueryWrapper<EnterpriseEntity>()
-                        .eq(EnterpriseEntity::getNameSyncStatus, "0")
-                        .lt(EnterpriseEntity::getNameSyncRetryCount, MAX_RETRY)
-                        .le(EnterpriseEntity::getNameSyncNextTime, OffsetDateTime.now())
-                        .last("LIMIT 50"));
+        List<EnterpriseEntity> list = enterpriseMapper.selectPendingNameSync(MAX_RETRY, 50);
         if (list.isEmpty()) return;
 
         log.info("[企业名称同步] 待重试: {} 条", list.size());