Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat : 쿠폰 복구 로직 구현 #201

Merged
merged 5 commits into from
Jan 26, 2023
Merged

Conversation

cofls6581
Copy link
Member

@cofls6581 cofls6581 commented Jan 26, 2023

개요

작업사항

  • 주문 취소시 쿠폰 복구 로직 구현
    분산락 걸긴했는데 복구 쪽이라 꼭 걸어야 될 필요는 없어보여요. 일단 돈 관련된 곳이라 걸어두긴 했습니다ㅎㅎ
    WithDrawOrderEvent에 쿠폰 관련 값들이 필요해 CreateOrderEvent에서 관련 값들 보고 맞춰서 구현했습니다.
 private final Boolean isUsingCoupon;  
 @Nullable private final Long issuedCouponId;
  • 쿠폰 할인 금액 검증 시 에러 처리 추가
    public Money checkSupplyIsGreaterThenDiscount(Money supply, Long discount) {
        if (supply.isLessThan(Money.wons(discount))) {
            throw NotApplicableCouponException.EXCEPTION;
        }
        return Money.wons(discount);
    }

변경로직

  • 위와 동일

@cofls6581 cofls6581 added For: API [이슈 대상] 외부 API Type: Feature [이슈 목적] 새로운 기능 추가 labels Jan 26, 2023
@cofls6581 cofls6581 requested a review from ImNM as a code owner January 26, 2023 10:59
@cofls6581 cofls6581 self-assigned this Jan 26, 2023
Copy link
Member

@ImNM ImNM left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

굿~

public class RecoveryCouponService {
private final IssuedCouponAdaptor issuedCouponAdaptor;

@RedissonLock(LockName = "쿠폰회복", identifier = "couponId")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

락 이름이
쿠폰 사용이랑 쿠폰 회복이랑 같아야합니다.

동일한 공유 자원에 접근하는데 ( 쿠폰 사용 여부 )
락의 이름이 두개면
통로가 두개여서 두 길로 접근하는 경우랑 똑같으니깐유!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

아 전에 민준이랑 얘기하던 거 기억난다. 고쳐서 올렸어유~~

Comment on lines 81 to 83
public void recovery() {
usageStatus = false;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이부분을 나중에 테스팅한다고 가정했을 때
테스트 가능하게 할려면
usageStatus 가 이미 false 였을 때
회복불가능한 쿠폰이라고 오류를 뿜어줘야
동시성 테스팅이 가능할 것 같아요

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

분산락 일단 걸어두긴해서 동시성 테스트 여기도 들어가겠네요. 수정해서 올렸습니다! 굳굳

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 222 Code Smells

12.7% 12.7% Coverage
1.2% 1.2% Duplication

Copy link
Member

@gengminy gengminy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@cofls6581 cofls6581 merged commit 1c4e9e2 into dev Jan 26, 2023
@ImNM ImNM deleted the feature/197-recovery-user-coupon branch January 26, 2023 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
For: API [이슈 대상] 외부 API Type: Feature [이슈 목적] 새로운 기능 추가
Projects
None yet
Development

Successfully merging this pull request may close these issues.

🚀 [feature] 쿠폰 복구 로직 구현
3 participants