AccountService.create() 호출 시 PointService.awardAccountEntry() 적립. ACCOUNT_ENTRY reason, 일 5회(50p) 초과 시 미지급.
This commit is contained in:
@@ -22,6 +22,7 @@ import com.sb.web.account.mapper.AccountEntryMapper;
|
||||
import com.sb.web.account.mapper.AccountTagMapper;
|
||||
import com.sb.web.account.mapper.WalletMapper;
|
||||
import com.sb.web.common.exception.ApiException;
|
||||
import com.sb.web.point.PointService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -48,6 +49,7 @@ public class AccountService {
|
||||
private final WalletMapper walletMapper;
|
||||
private final InvestService investService;
|
||||
private final CardNotificationParser notificationParser;
|
||||
private final PointService pointService;
|
||||
|
||||
/* ===================== 항목 ===================== */
|
||||
|
||||
@@ -252,6 +254,7 @@ public class AccountService {
|
||||
.build();
|
||||
mapper.insert(entry);
|
||||
applyTags(entry.getId(), req.getTagIds(), memberId);
|
||||
pointService.awardAccountEntry(memberId);
|
||||
return toResponse(mapper.findByIdAndMember(entry.getId(), memberId));
|
||||
}
|
||||
|
||||
@@ -542,7 +545,7 @@ public class AccountService {
|
||||
wallet.setType(req.getType());
|
||||
wallet.setName(req.getName().trim());
|
||||
wallet.setIssuer(blankToNull(req.getIssuer()));
|
||||
wallet.setAccountNumber("BANK".equals(req.getType()) ? blankToNull(req.getAccountNumber()) : null);
|
||||
wallet.setAccountNumber(("BANK".equals(req.getType()) || "MINUS".equals(req.getType())) ? blankToNull(req.getAccountNumber()) : null);
|
||||
wallet.setCardType("CARD".equals(req.getType()) ? blankToNull(req.getCardType()) : null);
|
||||
wallet.setOpeningBalance(req.getOpeningBalance() != null ? req.getOpeningBalance() : 0L);
|
||||
wallet.setOpeningDate(req.getOpeningDate());
|
||||
@@ -587,7 +590,7 @@ public class AccountService {
|
||||
.type(req.getType())
|
||||
.name(req.getName().trim())
|
||||
.issuer(blankToNull(req.getIssuer()))
|
||||
.accountNumber("BANK".equals(req.getType()) ? blankToNull(req.getAccountNumber()) : null)
|
||||
.accountNumber(("BANK".equals(req.getType()) || "MINUS".equals(req.getType())) ? blankToNull(req.getAccountNumber()) : null)
|
||||
.cardType("CARD".equals(req.getType()) ? blankToNull(req.getCardType()) : null)
|
||||
.openingBalance(req.getOpeningBalance() != null ? req.getOpeningBalance() : 0L)
|
||||
.openingDate(req.getOpeningDate())
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
/**
|
||||
* 활동 포인트 적립/조회.
|
||||
* 게시판 글/댓글 작성 시 10점, 하루 3회까지만 지급(글+댓글 합산).
|
||||
* 게시판 글/댓글 작성 시 10점(하루 3회), 가계부 내역 작성 시 10점(하루 50점 한도).
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@@ -19,6 +19,10 @@ public class PointService {
|
||||
public static final int BOARD_WRITE_DAILY_LIMIT = 3;
|
||||
public static final String REASON_BOARD_WRITE = "BOARD_WRITE";
|
||||
|
||||
public static final int ACCOUNT_ENTRY_POINT = 10;
|
||||
public static final int ACCOUNT_ENTRY_DAILY_LIMIT = 5; // 10pt × 5 = 일 50pt 한도
|
||||
public static final String REASON_ACCOUNT_ENTRY = "ACCOUNT_ENTRY";
|
||||
|
||||
/**
|
||||
* 게시판 글/댓글 작성 보상. 오늘 지급 횟수가 한도 미만일 때만 지급한다.
|
||||
* @return 지급되면 지급 포인트, 한도 초과로 미지급이면 0
|
||||
@@ -34,6 +38,21 @@ public class PointService {
|
||||
return BOARD_WRITE_POINT;
|
||||
}
|
||||
|
||||
/**
|
||||
* 가계부 내역 작성 보상. 건당 10점, 하루 5건(50점)까지만 지급한다.
|
||||
* @return 지급되면 지급 포인트, 한도 초과로 미지급이면 0
|
||||
*/
|
||||
@Transactional
|
||||
public int awardAccountEntry(Long memberId) {
|
||||
int today = pointMapper.countTodayGrants(memberId, REASON_ACCOUNT_ENTRY);
|
||||
if (today >= ACCOUNT_ENTRY_DAILY_LIMIT) {
|
||||
return 0;
|
||||
}
|
||||
pointMapper.insertHistory(memberId, ACCOUNT_ENTRY_POINT, REASON_ACCOUNT_ENTRY);
|
||||
pointMapper.addPoints(memberId, ACCOUNT_ENTRY_POINT);
|
||||
return ACCOUNT_ENTRY_POINT;
|
||||
}
|
||||
|
||||
public long getPoints(Long memberId) {
|
||||
Long p = pointMapper.getPoints(memberId);
|
||||
return p == null ? 0L : p;
|
||||
|
||||
Reference in New Issue
Block a user