|
@@ -2,6 +2,7 @@ package com.citu.module.menduner.system.service.user;
|
|
|
|
|
|
|
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
+import com.baomidou.lock.annotation.Lock4j;
|
|
|
import com.citu.framework.common.pojo.PageResult;
|
|
|
import com.citu.module.menduner.common.util.LoginUserContext;
|
|
|
import com.citu.module.menduner.system.controller.admin.user.vo.UserAccountPageRespVO;
|
|
@@ -12,7 +13,6 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.validation.annotation.Validated;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.math.BigDecimal;
|
|
|
|
|
|
/**
|
|
|
* 用户账户 Service 实现类
|
|
@@ -49,19 +49,19 @@ public class UserAccountServiceImpl implements UserAccountService {
|
|
|
|
|
|
@Override
|
|
|
@DSTransactional
|
|
|
+ @Lock4j(keys = {"#userId"}, expire = 60000, acquireTimeout = 1000)
|
|
|
public UserAccountDO createUserAccountIfAbsent(Long userId) {
|
|
|
- synchronized (userId) {
|
|
|
- UserAccountDO accountDO = userAccountMapper.selectByUserId(userId);
|
|
|
- if (null != accountDO) {
|
|
|
- return accountDO;
|
|
|
- }
|
|
|
- UserAccountDO entity = UserAccountDO.builder()
|
|
|
- .userId(userId)
|
|
|
- .point(0)
|
|
|
- .build();
|
|
|
- userAccountMapper.insert(entity);
|
|
|
- return entity;
|
|
|
+ UserAccountDO accountDO = userAccountMapper.selectByUserId(userId);
|
|
|
+ if (null != accountDO) {
|
|
|
+ return accountDO;
|
|
|
}
|
|
|
+ UserAccountDO entity = UserAccountDO.builder()
|
|
|
+ .userId(userId)
|
|
|
+ .point(0)
|
|
|
+ .build();
|
|
|
+ userAccountMapper.insert(entity);
|
|
|
+ return entity;
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|