BUGFIX:普通生成积分扣除有误
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package com.ai.da.common.RabbitMQ;
|
||||
|
||||
import com.ai.da.common.config.exception.BusinessException;
|
||||
import com.ai.da.common.constant.CommonConstant;
|
||||
import com.ai.da.common.utils.RedisUtil;
|
||||
import com.ai.da.model.dto.GenerateThroughImageTextDTO;
|
||||
@@ -149,6 +150,13 @@ public class GenerateConsumer {
|
||||
// 存redis
|
||||
redisUtil.addToMap(exceptionMapKey, exceptionInfo);
|
||||
}
|
||||
} catch (BusinessException e){
|
||||
log.error(e.getMsg());
|
||||
try {
|
||||
channel.basicAck(msg.getMessageProperties().getDeliveryTag(), false);
|
||||
} catch (IOException exception) {
|
||||
log.error("手动确认,取消返回队列,不再重新消费");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
try {
|
||||
|
||||
@@ -1162,7 +1162,8 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
||||
}
|
||||
}
|
||||
account.setUpdateDate(new Date());
|
||||
accountMapper.updateById(account);
|
||||
int i = accountMapper.updateById(account);
|
||||
log.info("更新用户信息,影响条数:{},用户信息:{}", i, JSON.toJSON(account));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -239,7 +239,7 @@ public class CreditsServiceImpl extends ServiceImpl<CreditsDetailMapper, Credits
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean taskCreditsDeduction(Long accountId, String taskId) {
|
||||
log.info("指定任务的积分扣除 : {}", taskId);
|
||||
log.info("指定 accountId: {} 任务的积分扣除 : {}", accountId, taskId);
|
||||
String key = creditsDeduction + ":" + accountId + ":" + taskId;
|
||||
// 1、获取当前任务id对应的积分
|
||||
String value = redisUtil.getFromString(key);
|
||||
|
||||
@@ -311,9 +311,10 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
generateDetail.setCreateDate(LocalDateTime.now());
|
||||
generateDetail.setMd5(md5);
|
||||
// 将相应的url保存到数据库
|
||||
generateDetailMapper.insert(generateDetail);
|
||||
int insert = generateDetailMapper.insert(generateDetail);
|
||||
log.info("添加 {} 条数据到t_generate_detail", insert);
|
||||
|
||||
String uuid = taskId.substring(0, taskId.substring(0, taskId.lastIndexOf("-")).lastIndexOf("-"));
|
||||
// String uuid = taskId.substring(0, taskId.substring(0, taskId.lastIndexOf("-")).lastIndexOf("-"));
|
||||
String key = generateResultKey + ":" + taskId;
|
||||
String imageName = url.substring(url.lastIndexOf("/") + 1);
|
||||
String status = imageName.equals("white_image.jpg") ? "Invalid" : "Success";
|
||||
@@ -328,6 +329,7 @@ public class GenerateServiceImpl extends ServiceImpl<GenerateMapper, Generate> i
|
||||
// 执行积分扣除
|
||||
// ** 注:如果生成的图片都是空白 则不扣积分
|
||||
if (!status.equals("Invalid")) {
|
||||
String uuid = taskId.substring(0, taskId.lastIndexOf("-", taskId.lastIndexOf("-") - 1));
|
||||
String accountId = taskId.substring(taskId.lastIndexOf("-") + 1);
|
||||
Boolean flag = creditsService.taskCreditsDeduction(Long.parseLong(accountId), uuid);
|
||||
if (flag) creditsService.updateChangedCredits(accountId, uuid);
|
||||
|
||||
Reference in New Issue
Block a user