|
@@ -2,6 +2,7 @@ package cn.kdan.compdf.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import cn.kdan.compdf.dto.AddFreePlanDTO;
|
|
|
import cn.kdan.compdf.dto.Asset;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
@@ -126,7 +127,8 @@ public class BackgroundUserBalanceServiceImpl extends ServiceImpl<BackgroundUser
|
|
|
|
|
|
/**
|
|
|
* 账户消费充值记录导出
|
|
|
- * @param userId 用户id
|
|
|
+ *
|
|
|
+ * @param userId 用户id
|
|
|
* @param response response
|
|
|
*/
|
|
|
@Override
|
|
@@ -193,7 +195,7 @@ public class BackgroundUserBalanceServiceImpl extends ServiceImpl<BackgroundUser
|
|
|
list.forEach(item -> {
|
|
|
Long userId = userService.getUserId(item.getTenantId());
|
|
|
// 最新的plan剩余额度
|
|
|
- Integer newestPlanRemainingFiles = this.baseMapper.selectNewestPlanRemainingFiles(item.getTenantId());
|
|
|
+ Integer newestPlanRemainingFiles = getNewestPlanRemainingFiles(item.getTenantId());
|
|
|
BackgroundUserBalance backgroundUserBalance = new BackgroundUserBalance();
|
|
|
backgroundUserBalance.setUserId(userId);
|
|
|
backgroundUserBalance.setTenantId(item.getTenantId());
|
|
@@ -206,7 +208,7 @@ public class BackgroundUserBalanceServiceImpl extends ServiceImpl<BackgroundUser
|
|
|
userBalanceList.add(backgroundUserBalance);
|
|
|
});
|
|
|
this.saveBatch(userBalanceList);
|
|
|
- }catch (Exception e){
|
|
|
+ } catch (Exception e) {
|
|
|
redisTemplate.delete(PLAN_SYNC_KEY);
|
|
|
throw e;
|
|
|
}
|
|
@@ -221,7 +223,7 @@ public class BackgroundUserBalanceServiceImpl extends ServiceImpl<BackgroundUser
|
|
|
List<Asset> assets = freePlanDTO.getAssets();
|
|
|
for (Asset asset : assets) {
|
|
|
// 最新的plan剩余额度
|
|
|
- Integer newestPlanRemainingFiles = this.baseMapper.selectNewestPlanRemainingFiles(asset.getTenantId());
|
|
|
+ Integer newestPlanRemainingFiles = getNewestPlanRemainingFiles(asset.getTenantId());
|
|
|
BackgroundUserBalance userBalance = new BackgroundUserBalance();
|
|
|
userBalance.setTenantId(asset.getTenantId());
|
|
|
userBalance.setUserId(userService.getUserId(asset.getTenantId()));
|
|
@@ -234,7 +236,8 @@ public class BackgroundUserBalanceServiceImpl extends ServiceImpl<BackgroundUser
|
|
|
|
|
|
this.save(userBalance);
|
|
|
|
|
|
- newestPlanRemainingFiles = this.baseMapper.selectNewestPlanRemainingFiles(asset.getTenantId());
|
|
|
+ newestPlanRemainingFiles = getNewestPlanRemainingFiles(asset.getTenantId());
|
|
|
+ userBalance.setId(null);
|
|
|
userBalance.setDate(new Date());
|
|
|
userBalance.setDescriptionType(3);
|
|
|
userBalance.setDescription("Free增加资产");
|
|
@@ -245,5 +248,18 @@ public class BackgroundUserBalanceServiceImpl extends ServiceImpl<BackgroundUser
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获取最新的plan资产余额
|
|
|
+ *
|
|
|
+ * @param tenantId tenantId
|
|
|
+ * @return 最新的plan资产余额
|
|
|
+ */
|
|
|
+ private Integer getNewestPlanRemainingFiles(Long tenantId) {
|
|
|
+ Integer newestPlanRemainingFiles = this.baseMapper.selectNewestPlanRemainingFiles(tenantId);
|
|
|
+ if (ObjectUtil.isEmpty(newestPlanRemainingFiles)) {
|
|
|
+ newestPlanRemainingFiles = 0;
|
|
|
+ }
|
|
|
+ return newestPlanRemainingFiles;
|
|
|
+ }
|
|
|
|
|
|
}
|