Skip to content

Commit

Permalink
Merge pull request #64 from lotteon2/refactor
Browse files Browse the repository at this point in the history
✏️ 가게사장의 쿠폰확인 시 발급수량도 함께 전달
  • Loading branch information
nowgnas authored Jan 17, 2024
2 parents e30608c + df281a4 commit bc61896
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,22 +59,19 @@ public void downloadAllCoupons(@PathVariable Long storeId,
@GetMapping("/{storeId}/coupons/product")
public CommonResponse<CouponsForUserResponse> storeCouponsForUser(@PathVariable Long storeId,
@RequestHeader(value = "userId", required = false) Long userId) {
LocalDate now = LocalDate.now();
return CommonResponse.success(couponFacade.getAllStoreCouponsForUser(userId, storeId, now));
return CommonResponse.success(couponFacade.getAllStoreCouponsForUser(userId, storeId));
}

@PostMapping("/{storeId}/coupons/payment")
public CommonResponse<CouponsForUserResponse> couponsInPaymentStep(@PathVariable Long storeId,
@RequestHeader(value = "userId") Long userId,
@RequestBody TotalAmountRequest totalAmountRequest) {
LocalDate now = LocalDate.now();
return CommonResponse.success(couponFacade.getAvailableCouponsInPayment(totalAmountRequest, userId, storeId, now));
return CommonResponse.success(couponFacade.getAvailableCouponsInPayment(totalAmountRequest, userId, storeId));
}

@GetMapping("/coupons/my")
public CommonResponse<CouponsForUserResponse> myCoupons(@RequestHeader(value = "userId") Long userId) {
LocalDate now = LocalDate.now();
return CommonResponse.success(couponFacade.getMyValidCoupons(userId, now));
return CommonResponse.success(couponFacade.getMyValidCoupons(userId));
}

@GetMapping("/coupons/{couponId}/members")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,19 @@ public class CouponForOwnerDto {
private String couponName;
private Long minPrice;
private Long discountPrice;
private Integer limitCount;
private Integer unusedCount;
private LocalDate startDate;
private LocalDate endDate;

@QueryProjection
public CouponForOwnerDto(Long key, String couponCode, String couponName, Long minPrice, Long discountPrice, Integer unusedCount, LocalDate startDate, LocalDate endDate) {
public CouponForOwnerDto(Long key, String couponCode, String couponName, Long minPrice, Long discountPrice, Integer limitCount, Integer unusedCount, LocalDate startDate, LocalDate endDate) {
this.key = key;
this.couponCode = couponCode;
this.couponName = couponName;
this.minPrice = minPrice;
this.discountPrice = discountPrice;
this.limitCount = limitCount;
this.unusedCount = unusedCount;
this.startDate = startDate;
this.endDate = endDate;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,16 +73,19 @@ public void downloadAllCoupons(Long userId, Long storeId, String nickname, Strin
couponService.downloadAllCoupons(userId, storeId, nickname, phoneNumber, now);
}

public CouponsForUserResponse getAllStoreCouponsForUser(Long userId, Long storeId, LocalDate now) {
public CouponsForUserResponse getAllStoreCouponsForUser(Long userId, Long storeId) {
LocalDate now = LocalDate.now();
return CouponsForUserResponse.from(couponService.getAllStoreCouponsForUser(userId, storeId, now));
}

public CouponsForUserResponse getAvailableCouponsInPayment(TotalAmountRequest totalAmountRequest,
Long userId, Long storeId, LocalDate now) {
Long userId, Long storeId) {
LocalDate now = LocalDate.now();
return CouponsForUserResponse.from(couponService.getAvailableCouponsInPayment(totalAmountRequest, userId, storeId, now));
}

public CouponsForUserResponse getMyValidCoupons(Long userId, LocalDate now) {
public CouponsForUserResponse getMyValidCoupons(Long userId) {
LocalDate now = LocalDate.now();
return CouponsForUserResponse.from(couponService.getMyValidCoupons(userId, now));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ public interface CouponRepositoryCustom {
List<CouponWithIssueStatusDto> findStoreCouponsForUser(Long userId, Long storeId, LocalDate now);
List<CouponWithAvailabilityDto> findAvailableCoupons(Long totalAmount, Long userId, Long storeId, LocalDate now);
List<CouponDto> findMyValidCoupons(Long userId, LocalDate now);

Integer findMyValidCouponCount(Long userId, LocalDate now);
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public List<CouponForOwnerDto> findAllDtoByStoreId(Long storeId, LocalDate now)
coupon.couponName,
coupon.minPrice,
coupon.discountPrice,
coupon.limitCount,
coupon.limitCount.subtract(
JPAExpressions
.select(issuedCoupon.count())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ public List<LikedStoreInfoResponse> simpleInfos(List<Long> storeIds){
return storeService.simpleInfos(storeIds).stream()
.map(kr.bb.store.domain.store.controller.response.LikedStoreInfoResponse::toCommonDto)
.collect(Collectors.toList());

}

public List<SettlementStoreInfoResponse> storeInfoForSettlement(List<Long> storeIds) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/kr/bb/store/util/RedisCacheInitializer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ public class RedisCacheInitializer implements ApplicationRunner {
@CacheEvict(value = {"store-list-with-paging"}, allEntries = true)
@Override
public void run(ApplicationArguments args) throws Exception {
log.info("Some Cache Initialized");
log.info("store-list Cache Initialized");
}
}

0 comments on commit bc61896

Please sign in to comment.