浏览代码

合同过期状态修改

zhangchen 1 月之前
父节点
当前提交
0d7c95cdf9

+ 9 - 4
alien-store/src/main/java/shop/alien/store/service/LifeStoreService.java

@@ -313,14 +313,19 @@ public class LifeStoreService {
 
     /**
      * 根据过期时间修改状态
+     * 将已过期的门店状态从0(正常)更新为99(已过期)
      */
     public void checkAndUpdateExpiredRecords() {
-        LambdaUpdateWrapper<StoreInfo> queryWrapper = new LambdaUpdateWrapper<>();
-        queryWrapper.isNotNull(StoreInfo::getExpirationTime)
+        LambdaUpdateWrapper<StoreInfo> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.isNotNull(StoreInfo::getExpirationTime)
                 .lt(StoreInfo::getExpirationTime, LocalDateTime.now())
                 .eq(StoreInfo::getBusinessStatus, 0)
-                .set(StoreInfo::getBusinessStatus, 99);
-        storeInfoService.update(queryWrapper);
+                .set(StoreInfo::getStoreStatus, 0);
+        
+        boolean success = storeInfoService.update(updateWrapper);
+        if (success) {
+            log.debug("过期门店状态更新完成");
+        }
     }
 
     public boolean modifyPassword(String phone, String passWord) {

+ 11 - 5
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -1831,12 +1831,18 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
     }
 
     /**
-     * 根据过期时间修改状态
+     * 检查并更新过期记录
+     * 将过期时间已到且业务状态为0的店铺状态更新为99(过期状态)
+     *
+     * @return 更新的记录数
      */
-    public void checkAndUpdateExpiredRecords() {
-        LambdaUpdateWrapper<StoreInfo> queryWrapper = new LambdaUpdateWrapper<>();
-        queryWrapper.isNotNull(StoreInfo::getExpirationTime).lt(StoreInfo::getExpirationTime, LocalDateTime.now()).eq(StoreInfo::getBusinessStatus, 0).set(StoreInfo::getBusinessStatus, 99);
-        this.update(queryWrapper);
+    public int checkAndUpdateExpiredRecords() {
+        LambdaUpdateWrapper<StoreInfo> updateWrapper = new LambdaUpdateWrapper<>();
+        updateWrapper.isNotNull(StoreInfo::getExpirationTime)
+                .lt(StoreInfo::getExpirationTime, LocalDateTime.now())
+                .eq(StoreInfo::getBusinessStatus, 0)
+                .set(StoreInfo::getStoreStatus, 0);
+        return storeInfoMapper.update(null, updateWrapper);
     }
 
     @Override