@@ -30,38 +30,38 @@ public class AdMobRewardServiceImpl implements AdMobRewardService {
3030 @ Override
3131 @ Transactional
3232 public String processReward (AdMobRewardRequest request ) {
33- // 2. 서명 검증
34- if (!verifyAdMobSignature (request )) {
35- log .warn ("AdMob 서명 검증 실패: transaction_id={}" , request .transaction_id ());
36- throw new CustomException (ErrorCode .REWARD_INVALID_SIGNATURE );
37- }
38-
39- // 3. 중복 처리 방지
33+ // // 1. 서명 검증
34+ // if (!verifyAdMobSignature(request)) {
35+ // log.warn("AdMob 서명 검증 실패: transaction_id={}", request.transaction_id());
36+ // throw new CustomException(ErrorCode.REWARD_INVALID_SIGNATURE);
37+ // }
38+ //
39+ // 2. 중복 처리 방지
40+ // 만약 여기서 true가 안 나온다면, DB에 transaction_id가 아직 안 쌓인 상태입니다.
4041 if (adRewardHistoryRepository .existsByTransactionId (request .transaction_id ())) {
4142 log .info ("이미 처리된 광고 요청입니다: transaction_id={}" , request .transaction_id ());
4243 return "Already Processed" ;
4344 }
44-
45- // 4. 유저 존재 여부 확인
46- User user = userRepository .findById (request .getUserId ())
47- .orElseThrow (() -> new CustomException (ErrorCode .REWARD_INVALID_USER ));
48-
49- // 5. 실질적인 크레딧 적립 로직 추가
50- // transaction_id를 Long으로 변환하여 referenceId로 사용
51- Long refId = parseTransactionId (request .transaction_id ());
52- creditService .addCredit (user .getId (), CreditType .AD_REWARD , refId );
53-
54- // 6. 보상 이력 저장
55- AdRewardHistory history = AdRewardHistory .builder ()
56- .transactionId (request .transaction_id ())
57- .user (user )
58- .rewardAmount (request .reward_amount ())
59- .rewardItem (request .getRewardType ())
60- .build ();
61-
62- adRewardHistoryRepository .save (history );
63-
64- log .info ("보상 지급 완료: user={}, amount={}" , user .getId (), request .reward_amount ());
45+ //
46+ // // 3. 유저 확인
47+ // User user = userRepository.findById(request.getUserId())
48+ // .orElseThrow(() -> new CustomException(ErrorCode.REWARD_INVALID_USER));
49+ //
50+ // // 4. 보상 이력(AdRewardHistory)을 먼저 저장
51+ // // 이력을 먼저 남겨야 다음 요청이 들어왔을 때 위 2번 로직에서 걸러집니다.
52+ // AdRewardHistory history = AdRewardHistory.builder()
53+ // .transactionId(request.transaction_id())
54+ // .user(user)
55+ // .rewardAmount(request.reward_amount())
56+ // .rewardItem(request.getRewardType())
57+ // .build();
58+ // adRewardHistoryRepository.save(history);
59+ //
60+ // // 5. 크레딧 적립
61+ // Long refId = parseTransactionId(request.transaction_id());
62+ // creditService.addCredit(user.getId(), CreditType.AD_REWARD, refId);
63+ //
64+ // log.info("보상 지급 완료: user={}, amount={}", user.getId(), request.reward_amount());
6565 return "OK" ;
6666 }
6767
0 commit comments