Procházet zdrojové kódy

管理后台异常问题分析处理

wangpenghui před 1 rokem
rodič
revize
6d3043a26e

+ 22 - 8
background-user/src/main/java/cn/kdan/compdf/service/impl/BackgroundUserBalanceServiceImpl.java

@@ -35,6 +35,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.assertj.core.util.Lists;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.data.redis.core.StringRedisTemplate;
 import org.springframework.stereotype.Service;
 
@@ -63,6 +64,8 @@ public class BackgroundUserBalanceServiceImpl extends ServiceImpl<BackgroundUser
 
     private final BackgroundUserService userService;
     private final BackgroundUserRemainService backgroundUserRemainService;
+    @Value("${free-100-tenantId}")
+    private Integer FREE_100_TENANT_ID;
 
     public BackgroundUserBalanceServiceImpl(StringRedisTemplate redisTemplate, BackgroundUserService userService, BackgroundUserRemainService backgroundUserRemainService) {
         this.redisTemplate = redisTemplate;
@@ -251,14 +254,25 @@ public class BackgroundUserBalanceServiceImpl extends ServiceImpl<BackgroundUser
             this.save(userBalance);
 
             newestPlanRemainingFiles = getNewestPlanRemainingFiles(asset.getTenantId());
-            userBalance.setId(null);
-            userBalance.setDate(userBalance.getDate().plusSeconds(1L));
-            userBalance.setDescriptionType(3);
-            userBalance.setDescription(UserBalanceConstant.DESCRIPTION_FREE); // TODO 枚举值
-            userBalance.setRemainingFiles(newestPlanRemainingFiles + freeAsset);
-            userBalance.setBalanceChange(freeAsset);
-            userBalance.setChangeType(1);
-            this.save(userBalance);
+            if (asset.getTenantId() >= FREE_100_TENANT_ID) {
+                userBalance.setId(null);
+                userBalance.setDate(userBalance.getDate().plusSeconds(1L));
+                userBalance.setDescriptionType(3);
+                userBalance.setDescription(UserBalanceConstant.DESCRIPTION_FREE); // TODO 枚举值
+                userBalance.setRemainingFiles(newestPlanRemainingFiles + 1000);
+                userBalance.setBalanceChange(1000);
+                userBalance.setChangeType(1);
+                this.save(userBalance);
+            }else {
+                userBalance.setId(null);
+                userBalance.setDate(userBalance.getDate().plusSeconds(1L));
+                userBalance.setDescriptionType(3);
+                userBalance.setDescription(UserBalanceConstant.DESCRIPTION_FREE); // TODO 枚举值
+                userBalance.setRemainingFiles(newestPlanRemainingFiles + freeAsset);
+                userBalance.setBalanceChange(freeAsset);
+                userBalance.setChangeType(1);
+                this.save(userBalance);
+            }
         }
         List<Asset> cleanFreeAssets = freePlanDTO.getCleanFreeAssets();
         for (Asset cleanFreeAsset : cleanFreeAssets) {

+ 4 - 1
background-user/src/main/resources/application.yml

@@ -135,4 +135,7 @@ compdf:
     endpoint: ${COMPDF_OSS_FILE_ENDPOINT:https://oss-cn-shanghai.aliyuncs.com}
     accessKeyId: ${COMPDF_OSS_FILE_ACCESSKEYID:LTAIBSxSrO3XuszA}
     accessKeySecret: ${COMPDF_OSS_FILE_ACCESSKEYSECRET:ylqpMGyA4qpsaobhZ34gJzNZzcnYmT}
-    file-prefix: ${COMPDF_OSS_FILE_PREFIX:saas}
+    file-prefix: ${COMPDF_OSS_FILE_PREFIX:saas}
+
+
+free-100-tenantId: ${FREE_100_TENANT_ID:135}