金豆操作添加事务

This commit is contained in:
2025-09-08 17:21:25 +08:00
parent 57ad350ca7
commit 54f2fe4f7d

View File

@@ -16,6 +16,7 @@ import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.Date;
@@ -50,6 +51,7 @@ public class UserGoldBeanServiceImpl extends ServiceImpl<UserGoldBeanMapper, Use
return userGoldBean;
}
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
@Override
public UserGoldBean addGoldBean(Long uid, BigDecimal goldBean, GoldBeanBillType goldBeanBillType,
String objId, Integer num, String taskType, Long reachNum, Long standardValue, String todayDate) {
@@ -72,6 +74,7 @@ public class UserGoldBeanServiceImpl extends ServiceImpl<UserGoldBeanMapper, Use
return after;
}
@Transactional(rollbackFor = Exception.class, transactionManager = "mybatisplusTransactionManager")
@Override
public UserGoldBean subGoldBean(Long uid, BigDecimal goldBean, GoldBeanBillType goldBeanBillType, String objId, Integer num) {
if (goldBean.doubleValue() <= 0d) {
@@ -110,7 +113,7 @@ public class UserGoldBeanServiceImpl extends ServiceImpl<UserGoldBeanMapper, Use
}
private <R> R withLock(Long uid, DailyTaskConstant.RedisKey redisKey, Function<UserGoldBean, R> function) {
public <R> R withLock(Long uid, DailyTaskConstant.RedisKey redisKey, Function<UserGoldBean, R> function) {
String lockKey = redisKey.getKey(String.valueOf(uid));
RLock lock = redissonClient.getLock(lockKey);
long startTime = System.currentTimeMillis();