靓号审核功能处理
This commit is contained in:
parent
fc60be306b
commit
ef7fe36a42
@ -52,7 +52,7 @@ public class UserBeautifulNumberApplyCmdExe {
|
||||
Boolean.TRUE.equals(hasPendingApply)
|
||||
);
|
||||
|
||||
// (4) 用户在当前财富等级已经申请过ID(申请失败)- 通过数据库判断
|
||||
// (4) 用户在当前财富等级已经申请过ID(申请成功)- 通过数据库判断
|
||||
Boolean hasAppliedFailed = userBeautifulNumberApplyService.hasAppliedAtLevelWithFailure(userId, wealthLevel);
|
||||
ResponseAssert.isFalse(
|
||||
UserSpecialErrorCode.ALREADY_APPLIED_AT_LEVEL,
|
||||
|
||||
@ -50,9 +50,6 @@ public class UserBeautifulNumberApplyServiceImpl extends
|
||||
|
||||
@Override
|
||||
public void handleApply(Long id, Integer state) {
|
||||
|
||||
ResponseAssert.isTrue(CommonErrorCode.TYPE_IS_NOT_IN_SCOPE, checkState(state));
|
||||
|
||||
UserBeautifulNumberApply apply = query().eq(UserBeautifulNumberApply::getId, id).getOne();
|
||||
ResponseAssert.notNull(CommonErrorCode.DATA_ERROR, apply);
|
||||
|
||||
@ -62,17 +59,12 @@ public class UserBeautifulNumberApplyServiceImpl extends
|
||||
|
||||
}
|
||||
|
||||
|
||||
private boolean checkState(Integer state) {
|
||||
return Objects.equals(state, 1) || Objects.equals(state, 2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean hasAppliedAtLevelWithFailure(Long userId, Integer wealthLevel) {
|
||||
return Optional.ofNullable(query()
|
||||
.eq(UserBeautifulNumberApply::getApplyUser, userId)
|
||||
.eq(UserBeautifulNumberApply::getWealthLevel, wealthLevel)
|
||||
.eq(UserBeautifulNumberApply::getState, 2)
|
||||
.eq(UserBeautifulNumberApply::getState, 1)
|
||||
.list()).map(CollectionUtil::isNotEmpty).orElse(Boolean.FALSE);
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
package com.red.circle.other.app.inner.service.user.user.impl;
|
||||
|
||||
import com.red.circle.framework.core.asserts.ResponseAssert;
|
||||
import com.red.circle.framework.core.response.CommonErrorCode;
|
||||
import com.red.circle.framework.dto.PageResult;
|
||||
import com.red.circle.other.infra.database.mongo.entity.user.profile.UserSpecialId;
|
||||
import com.red.circle.other.infra.database.mongo.service.user.profile.UserSpecialIdService;
|
||||
import com.red.circle.other.infra.database.rds.entity.user.user.UserBeautifulNumberApply;
|
||||
import com.red.circle.other.infra.database.rds.service.user.user.UserBeautifulNumberApplyService;
|
||||
import com.red.circle.other.infra.database.rds.service.user.user.UserBeautifulNumberService;
|
||||
import com.red.circle.other.app.inner.convertor.user.UserProfileInnerConvertor;
|
||||
@ -10,9 +15,12 @@ import com.red.circle.other.inner.model.cmd.user.UserBeautifulNumberCmd;
|
||||
import com.red.circle.other.inner.model.dto.user.BeautifulNumberDTO;
|
||||
import com.red.circle.other.inner.model.dto.user.UserBeautifulNumberApplyDTO;
|
||||
import com.red.circle.other.app.inner.service.user.user.UserBeautifulNumberClientService;
|
||||
import com.red.circle.tool.core.date.TimestampUtils;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 用户申请靓号记录 服务类.
|
||||
@ -29,6 +37,7 @@ public class UserBeautifulNumberClientServiceImpl implements
|
||||
private final UserProfileInnerConvertor userProfileInnerConvertor;
|
||||
private final UserBeautifulNumberService userBeautifulNumberService;
|
||||
private final UserBeautifulNumberApplyService userBeautifulNumberApplyService;
|
||||
private final UserSpecialIdService userSpecialIdService;
|
||||
|
||||
@Override
|
||||
public PageResult<UserBeautifulNumberApplyDTO> pageBeautifulNumberApply(
|
||||
@ -39,7 +48,31 @@ public class UserBeautifulNumberClientServiceImpl implements
|
||||
|
||||
@Override
|
||||
public void handleApply(Long id, Integer state) {
|
||||
ResponseAssert.isTrue(CommonErrorCode.TYPE_IS_NOT_IN_SCOPE, checkState(state));
|
||||
userBeautifulNumberApplyService.handleApply(id, state);
|
||||
|
||||
if (state == 1) {
|
||||
UserBeautifulNumberApply beautifulNumberApply = userBeautifulNumberApplyService.getById(id);
|
||||
|
||||
UserSpecialId userSpecialId = userSpecialIdService.getByUserId(beautifulNumberApply.getApplyUser());
|
||||
if (Objects.nonNull(userSpecialId)) {
|
||||
userSpecialIdService.remove(userSpecialId.getId());
|
||||
}
|
||||
|
||||
// 创建新靓号
|
||||
UserSpecialId specialIdCmd = new UserSpecialId();
|
||||
specialIdCmd.setSysOrigin(beautifulNumberApply.getSysOrigin());
|
||||
specialIdCmd.setAccount(beautifulNumberApply.getApplyAccount());
|
||||
specialIdCmd.setUserId(beautifulNumberApply.getApplyUser());
|
||||
// 设置365 * 3天后过期
|
||||
specialIdCmd.setExpiredTime(TimestampUtils.dateTimePlusDays(TimestampUtils.now(),365 * 3));
|
||||
userSpecialIdService.add(specialIdCmd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean checkState(Integer state) {
|
||||
return Objects.equals(state, 1) || Objects.equals(state, 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user