apps创建唯一性调整
This commit is contained in:
1 parent
221b7c4f96
commit
410d777c0b
3 files changed
+23
-1
No files matched your search
@@ -286,15 +286,23 @@ public class AppsServiceImpl extends ServiceImpl<AppsMapper, AppsPlus> implement
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int insertApps(Apps apps, boolean isUser) {
|
||||
validateAppForCreate(apps, isUser);
|
||||
Long ownerUserId = isUser ? SecurityUtils.getUserId() : apps.getUserId();
|
||||
if (ownerUserId == null || appsMapper.lockUserById(ownerUserId) == null) {
|
||||
throw new CustomException("所属用户不存在");
|
||||
}
|
||||
if (appsMapper.countActiveAppsByUserId(ownerUserId) > 0) {
|
||||
throw new CustomException("该用户已经创建商户应用,每个用户只能创建一个应用");
|
||||
}
|
||||
apps.setUserId(ownerUserId);
|
||||
// 每个新应用统一使用全局配置主钱包地址,忽略请求中可能伪造的归集地址。
|
||||
apps.setDistTokenAddress(getGlobalAggregationAddress());
|
||||
apps.setCreatedAt(DateUtils.getNowDate());
|
||||
apps.setUpdatedAt(DateUtils.getNowDate());
|
||||
apps.setDeletedAt(null);
|
||||
if (isUser) {
|
||||
apps.setUserId(SecurityUtils.getUserId());
|
||||
apps.setTrxBalance(BigDecimal.ZERO);
|
||||
apps.setUsdtBalance(BigDecimal.ZERO);
|
||||
apps.setCreditLimit(BigDecimal.ZERO);
|
||||
|
||||
Reference in new issue
Block a user