From 72fd2e050713a93ac22bac40001e6513e8640508 Mon Sep 17 00:00:00 2001 From: qwerty1434 Date: Mon, 15 Jan 2024 19:56:42 +0900 Subject: [PATCH 1/7] =?UTF-8?q?:adhesive=5Fbandage:=20=EB=9D=84=EC=96=B4?= =?UTF-8?q?=EC=93=B0=EA=B8=B0=20=EC=A4=84=EB=B0=94=EA=BF=88=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../coupon/controller/CouponController.java | 3 --- .../coupon/controller/CouponFeignController.java | 1 - .../domain/coupon/entity/IssuedCouponId.java | 5 ----- .../store/domain/coupon/facade/CouponFacade.java | 1 - .../store/domain/coupon/handler/CouponIssuer.java | 3 +-- .../domain/coupon/service/CouponService.java | 4 ++-- .../bb/store/domain/store/facade/StoreFacade.java | 15 +++++++-------- .../store/domain/store/handler/GugunReader.java | 1 + .../store/domain/store/handler/StoreReader.java | 2 +- .../store/domain/store/service/StoreService.java | 4 +--- 10 files changed, 13 insertions(+), 26 deletions(-) diff --git a/src/main/java/kr/bb/store/domain/coupon/controller/CouponController.java b/src/main/java/kr/bb/store/domain/coupon/controller/CouponController.java index b9c73ce..e72ef10 100644 --- a/src/main/java/kr/bb/store/domain/coupon/controller/CouponController.java +++ b/src/main/java/kr/bb/store/domain/coupon/controller/CouponController.java @@ -59,7 +59,6 @@ public void downloadAllCoupons(@PathVariable Long storeId, @GetMapping("/{storeId}/coupons/product") public CommonResponse storeCouponsForUser(@PathVariable Long storeId, @RequestHeader(value = "userId", required = false) Long userId) { - LocalDate now = LocalDate.now(); return CommonResponse.success(couponFacade.getAllStoreCouponsForUser(userId, storeId, now)); } @@ -68,14 +67,12 @@ public CommonResponse storeCouponsForUser(@PathVariable public CommonResponse 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)); } @GetMapping("/coupons/my") public CommonResponse myCoupons(@RequestHeader(value = "userId") Long userId) { - LocalDate now = LocalDate.now(); return CommonResponse.success(couponFacade.getMyValidCoupons(userId, now)); } diff --git a/src/main/java/kr/bb/store/domain/coupon/controller/CouponFeignController.java b/src/main/java/kr/bb/store/domain/coupon/controller/CouponFeignController.java index 0193977..528bb43 100644 --- a/src/main/java/kr/bb/store/domain/coupon/controller/CouponFeignController.java +++ b/src/main/java/kr/bb/store/domain/coupon/controller/CouponFeignController.java @@ -23,7 +23,6 @@ public void useCoupon(@PathVariable Long couponId, @PathVariable Long userId) { @GetMapping("/count") public CommonResponse availableCouponCountOfUser(@RequestHeader(value = "userId") Long userId) { LocalDate now = LocalDate.now(); - return CommonResponse.success(couponService.getMyAvailableCouponCount(userId, now)); } } diff --git a/src/main/java/kr/bb/store/domain/coupon/entity/IssuedCouponId.java b/src/main/java/kr/bb/store/domain/coupon/entity/IssuedCouponId.java index 4ef60f6..e107d97 100644 --- a/src/main/java/kr/bb/store/domain/coupon/entity/IssuedCouponId.java +++ b/src/main/java/kr/bb/store/domain/coupon/entity/IssuedCouponId.java @@ -18,11 +18,6 @@ public class IssuedCouponId implements Serializable { private Long couponId; private Long userId; - - - - - @Override public boolean equals(Object o) { if (this == o) return true; diff --git a/src/main/java/kr/bb/store/domain/coupon/facade/CouponFacade.java b/src/main/java/kr/bb/store/domain/coupon/facade/CouponFacade.java index b016beb..d09cf86 100644 --- a/src/main/java/kr/bb/store/domain/coupon/facade/CouponFacade.java +++ b/src/main/java/kr/bb/store/domain/coupon/facade/CouponFacade.java @@ -64,7 +64,6 @@ public CouponsForOwnerResponse getAllStoreCoupons(Long storeId) { return CouponsForOwnerResponse.from(couponService.getAllStoreCoupons(storeId)); } - public void downloadCoupon(Long userId, Long couponId, String nickname, String phoneNumber, LocalDate now) { couponService.downloadCoupon(userId, couponId, nickname, phoneNumber, now); } diff --git a/src/main/java/kr/bb/store/domain/coupon/handler/CouponIssuer.java b/src/main/java/kr/bb/store/domain/coupon/handler/CouponIssuer.java index cd38886..1d7309e 100644 --- a/src/main/java/kr/bb/store/domain/coupon/handler/CouponIssuer.java +++ b/src/main/java/kr/bb/store/domain/coupon/handler/CouponIssuer.java @@ -61,8 +61,7 @@ public void issuePossibleCoupons(List coupons, Long userId, String nickn .filter(coupon -> { String redisKey = makeRedisKey(coupon); Integer limitCnt = coupon.getLimitCount(); - boolean issuable = (Boolean)redisLuaScriptExecutor.execute(script, redisKey, redisValue, limitCnt); - return issuable; + return (Boolean)redisLuaScriptExecutor.execute(script, redisKey, redisValue, limitCnt); }) .forEach(coupon -> issuedCouponRepository.save(makeIssuedCoupon(coupon,userId,nickname,phoneNumber))); } diff --git a/src/main/java/kr/bb/store/domain/coupon/service/CouponService.java b/src/main/java/kr/bb/store/domain/coupon/service/CouponService.java index fed9099..a17413b 100644 --- a/src/main/java/kr/bb/store/domain/coupon/service/CouponService.java +++ b/src/main/java/kr/bb/store/domain/coupon/service/CouponService.java @@ -15,13 +15,13 @@ import kr.bb.store.domain.store.handler.StoreReader; import kr.bb.store.util.RedisOperation; import lombok.RequiredArgsConstructor; -import lombok.extern.slf4j.Slf4j; import org.springframework.data.domain.Pageable; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.time.LocalDate; import java.util.List; +import java.util.Objects; import java.util.stream.Collectors; import static kr.bb.store.util.RedisUtils.makeRedisKey; @@ -134,7 +134,7 @@ public Integer getMyAvailableCouponCount(Long userId, LocalDate now) { public void validateCouponPrice(List validatePriceDtos) { validatePriceDtos.stream() - .filter(dto -> dto.getCouponId() != null) + .filter(dto -> Objects.nonNull(dto.getCouponId())) .forEach(dto -> { Coupon coupon = couponReader.read(dto.getCouponId()); Long receivedPaymentPrice = dto.getActualAmount(); diff --git a/src/main/java/kr/bb/store/domain/store/facade/StoreFacade.java b/src/main/java/kr/bb/store/domain/store/facade/StoreFacade.java index b4ca8aa..8d24d59 100644 --- a/src/main/java/kr/bb/store/domain/store/facade/StoreFacade.java +++ b/src/main/java/kr/bb/store/domain/store/facade/StoreFacade.java @@ -78,7 +78,7 @@ public SimpleStorePagingResponse getStoresWithLikes(Long userId, Pageable pageab .map(StoreListResponse::getStoreId) .collect(Collectors.toList()); - if(isNotGuest(userId)) { + if(isLoginUser(userId)) { Map storeLikes = storeLikeFeignClient.getStoreLikes(userId, storeIds).getData(); storePages.getContent().forEach(store -> store.setIsLiked(storeLikes.get(store.getStoreId()))); } @@ -92,7 +92,8 @@ public SimpleStorePagingResponse getStoresWithLikes(Long userId, Pageable pageab public StoreInfoUserResponse getStoreInfoForUser(Long userId, Long storeId) { String subscriptionProductId = productFeignClient.getSubscriptionProductId(storeId).getData() .getSubscriptionProductId(); - if(isNotGuest(userId)) { + + if(isLoginUser(userId)) { Map storeLikes = storeLikeFeignClient.getStoreLikes(userId, List.of(storeId)).getData(); Map storeSubscriptions = storeSubscriptionFeignClient .getStoreSubscriptions(userId, List.of(storeId)).getData(); @@ -100,8 +101,8 @@ public StoreInfoUserResponse getStoreInfoForUser(Long userId, Long storeId) { Boolean isSubscribed = storeSubscriptions.get(storeId); return storeService.getStoreInfoForUser(storeId, isLiked, isSubscribed, subscriptionProductId); } - return storeService.getStoreInfoForUser(storeId, false, false, subscriptionProductId); + return storeService.getStoreInfoForUser(storeId, false, false, subscriptionProductId); } public StoreInfoManagerResponse getStoreInfoForManager(Long storeId) { @@ -111,7 +112,7 @@ public StoreInfoManagerResponse getStoreInfoForManager(Long storeId) { public StoreListForMapResponse getNearbyStores(Long userId, Double lat, Double lon, Integer level) { StoreListForMapResponse nearbyStores = storeService.getNearbyStores(lat, lon, level); - if(isNotGuest(userId)) { + if(isLoginUser(userId)) { List storeIds = nearbyStores.getStoreIds(); Map storeLikes = storeLikeFeignClient.getStoreLikes(userId, storeIds).getData(); nearbyStores.setLikes(storeLikes); @@ -123,7 +124,7 @@ public StoreListForMapResponse getNearbyStores(Long userId, Double lat, Double l public StoreListForMapResponse getStoresWithRegion(Long userId, String sidoCode, String gugunCode) { StoreListForMapResponse storesWithRegion = storeService.getStoresWithRegion(sidoCode, gugunCode); - if(isNotGuest(userId)) { + if(isLoginUser(userId)) { List storeIds = storesWithRegion.getStoreIds(); Map storeLikes = storeLikeFeignClient.getStoreLikes(userId, storeIds).getData(); storesWithRegion.setLikes(storeLikes); @@ -180,7 +181,6 @@ public List storeInfoForSettlement(List store return storeService.storeInfoForSettlement(storeIds); } - public DeliveryPolicyDto getDeliveryPolicy(Long storeId) { return storeService.getDeliveryPolicy(storeId); } @@ -197,7 +197,6 @@ public StoreForAdminDtoResponse getStoresForAdmin(Pageable pageable, SortType so .collect(Collectors.toList()); return StoreForAdminDtoResponse.of(data, storesForAdmin.getTotalElements()); - } public List getAllSido() { @@ -208,7 +207,7 @@ public List getGuguns(String sidoCode) { return storeService.getGuguns(sidoCode); } - private boolean isNotGuest(Long userId) { + private boolean isLoginUser(Long userId) { return userId != null; } diff --git a/src/main/java/kr/bb/store/domain/store/handler/GugunReader.java b/src/main/java/kr/bb/store/domain/store/handler/GugunReader.java index 54eb4c6..ac35ef3 100644 --- a/src/main/java/kr/bb/store/domain/store/handler/GugunReader.java +++ b/src/main/java/kr/bb/store/domain/store/handler/GugunReader.java @@ -23,6 +23,7 @@ public Gugun readGugunCorrespondingSido(Sido sido, String gugunName) { } return gugun; } + public Gugun readGugunCorrespondingSidoWithCode(Sido sido, String gugunCode) { Gugun gugun = gugunRepository.findById(gugunCode) .orElseThrow(GugunNotFoundException::new); diff --git a/src/main/java/kr/bb/store/domain/store/handler/StoreReader.java b/src/main/java/kr/bb/store/domain/store/handler/StoreReader.java index 7375529..b9d295a 100644 --- a/src/main/java/kr/bb/store/domain/store/handler/StoreReader.java +++ b/src/main/java/kr/bb/store/domain/store/handler/StoreReader.java @@ -154,6 +154,6 @@ private Double levelToMeter(int level) { default: throw new IllegalArgumentException("정의되지 않은 레벨입니다"); } - } + } diff --git a/src/main/java/kr/bb/store/domain/store/service/StoreService.java b/src/main/java/kr/bb/store/domain/store/service/StoreService.java index 0f09f35..1a6288f 100644 --- a/src/main/java/kr/bb/store/domain/store/service/StoreService.java +++ b/src/main/java/kr/bb/store/domain/store/service/StoreService.java @@ -104,6 +104,7 @@ public StoreInfoManagerResponse getStoreInfoForManager(Long storeId) { public StoreListForMapResponse getNearbyStores(Double lat, Double lon, Integer level) { return storeReader.getNearbyStores(lat, lon, level); } + public StoreListForMapResponse getStoresWithRegion(String sidoCode, String gugunCode) { Sido sido = sidoReader.readSido(sidoCode); Gugun gugun = "".equals(gugunCode) ? null : gugunReader.readGugunCorrespondingSidoWithCode(sido, gugunCode); @@ -173,10 +174,8 @@ public List storeInfoForSettlement(List store .gugun(storeAddresses.get(id).getGugun().getName()) .build() ).collect(Collectors.toList()); - } - public DeliveryPolicyDto getDeliveryPolicy(Long storeId) { DeliveryPolicy deliveryPolicy = storeReader.findDeliveryPolicyByStoreId(storeId); return DeliveryPolicyDto.fromEntity(deliveryPolicy); @@ -210,7 +209,6 @@ public Page getStoresForAdmin(Pageable pageable, SortType sort, String si } } - public List getAllSido() { return sidoReader.readAll() .stream() From 88e89b90632479391d03f54d7ee959424cf5bf18 Mon Sep 17 00:00:00 2001 From: qwerty1434 Date: Tue, 16 Jan 2024 10:24:28 +0900 Subject: [PATCH 2/7] =?UTF-8?q?:pencil2:=20=EC=9E=AC=EA=B3=A0=EB=B6=80?= =?UTF-8?q?=EC=A1=B1=EC=8B=9C=20=EC=95=8C=EB=A6=BC=20=EB=A9=94=EC=8B=9C?= =?UTF-8?q?=EC=A7=80=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/kr/bb/store/domain/cargo/facade/CargoFacade.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/kr/bb/store/domain/cargo/facade/CargoFacade.java b/src/main/java/kr/bb/store/domain/cargo/facade/CargoFacade.java index c532b43..e17daeb 100644 --- a/src/main/java/kr/bb/store/domain/cargo/facade/CargoFacade.java +++ b/src/main/java/kr/bb/store/domain/cargo/facade/CargoFacade.java @@ -63,7 +63,7 @@ public void plusStocksWithLock(List stockChangeDtos) { } catch (Exception e) { Long userId = stockChangeDtos.get(0).getUserId(); String phoneNumber = stockChangeDtos.get(0).getPhoneNumber(); - orderStatusSQSPublisher.publish(userId, phoneNumber, NotificationKind.ORDER_FAIL); + orderStatusSQSPublisher.publish(userId, phoneNumber, NotificationKind.OUT_OF_STOCK); throw e; } @@ -76,7 +76,7 @@ public void minusStocksWithLock(List stockChangeDtos) { } catch (Exception e) { Long userId = stockChangeDtos.get(0).getUserId(); String phoneNumber = stockChangeDtos.get(0).getPhoneNumber(); - orderStatusSQSPublisher.publish(userId, phoneNumber, NotificationKind.ORDER_FAIL); + orderStatusSQSPublisher.publish(userId, phoneNumber, NotificationKind.OUT_OF_STOCK); throw e; } } From f1ab1f15b92ad6685aef96fe97fe5746b89a9239 Mon Sep 17 00:00:00 2001 From: qwerty1434 Date: Tue, 16 Jan 2024 10:26:39 +0900 Subject: [PATCH 3/7] =?UTF-8?q?:pencil2:=20=EA=B0=80=EA=B2=8C=EC=82=AC?= =?UTF-8?q?=EC=9E=A5=EC=9D=80=20=EC=9E=90=EC=8B=A0=EC=9D=98=20=EB=AC=B8?= =?UTF-8?q?=EC=9D=98=EC=A0=95=EB=B3=B4=EB=A7=8C=20=EC=A1=B0=ED=9A=8C=20?= =?UTF-8?q?=EA=B0=80=EB=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../question/repository/QuestionRepositoryCustomImpl.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/java/kr/bb/store/domain/question/repository/QuestionRepositoryCustomImpl.java b/src/main/java/kr/bb/store/domain/question/repository/QuestionRepositoryCustomImpl.java index 7826ddb..0b92398 100644 --- a/src/main/java/kr/bb/store/domain/question/repository/QuestionRepositoryCustomImpl.java +++ b/src/main/java/kr/bb/store/domain/question/repository/QuestionRepositoryCustomImpl.java @@ -39,7 +39,8 @@ public Page getQuestionsForStoreOwnerWithPaging(Long storeI .rightJoin(answer.question, question) .where( isReplied != null ? checkRepliedCondition(isReplied) : null, - question.isDeleted.isFalse() + question.isDeleted.isFalse(), + question.store.id.eq(storeId) ) .orderBy(question.createdAt.desc()) .limit(pageable.getPageSize()) @@ -52,7 +53,8 @@ public Page getQuestionsForStoreOwnerWithPaging(Long storeI .rightJoin(answer.question, question) .where( isReplied != null ? checkRepliedCondition(isReplied) : null, - question.isDeleted.isFalse() + question.isDeleted.isFalse(), + question.store.id.eq(storeId) ) .fetchOne(); return new PageImpl<>(contents,pageable,count); From 4ff13f256d2579ba609d312b6c5f3c221881c978 Mon Sep 17 00:00:00 2001 From: qwerty1434 Date: Tue, 16 Jan 2024 10:33:23 +0900 Subject: [PATCH 4/7] =?UTF-8?q?:pencil2:=20=EC=8B=9C=EC=9E=91=EC=9D=BC?= =?UTF-8?q?=EC=9D=B4=20=EB=8F=84=EB=9E=98=ED=95=98=EC=A7=80=20=EC=95=8A?= =?UTF-8?q?=EC=9D=80=20=EC=BF=A0=ED=8F=B0=EC=9D=80=20=EC=9C=A0=EC=A0=80?= =?UTF-8?q?=EC=97=90=EA=B2=8C=20=EB=85=B8=EC=B6=9C=EB=90=98=EC=A7=80=20?= =?UTF-8?q?=EC=95=8A=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../domain/coupon/repository/CouponRepositoryCustomImpl.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java b/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java index 0aa088c..09dbcd5 100644 --- a/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java +++ b/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java @@ -97,7 +97,8 @@ public List findStoreCouponsForUser(Long userId, Long .where( coupon.store.id.eq(storeId), isCouponUnexpired(now), - coupon.isDeleted.isFalse() + coupon.isDeleted.isFalse(), + coupon.startDate.loe(now) ) .fetch(); } From 66e3c8024a738d9a4060b1e70d898974b40bc583 Mon Sep 17 00:00:00 2001 From: qwerty1434 Date: Tue, 16 Jan 2024 11:30:41 +0900 Subject: [PATCH 5/7] =?UTF-8?q?:pencil2:=20=EC=A4=91=EB=B3=B5=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EA=B5=AC/=EA=B5=B0=EC=9D=B4=20=EC=A1=B4=EC=9E=AC?= =?UTF-8?q?=ED=95=B4=20Sido=EC=99=80=20=ED=95=A8=EA=BB=98=20=ED=8C=90?= =?UTF-8?q?=EB=B3=84=ED=95=98=EB=8F=84=EB=A1=9D=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bb/store/domain/store/entity/address/GugunRepository.java | 2 +- src/main/java/kr/bb/store/domain/store/handler/GugunReader.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/kr/bb/store/domain/store/entity/address/GugunRepository.java b/src/main/java/kr/bb/store/domain/store/entity/address/GugunRepository.java index 6887db1..584c1a0 100644 --- a/src/main/java/kr/bb/store/domain/store/entity/address/GugunRepository.java +++ b/src/main/java/kr/bb/store/domain/store/entity/address/GugunRepository.java @@ -8,5 +8,5 @@ public interface GugunRepository extends JpaRepository { List findGugunBySidoCode(String sidoCode); - Optional findByName(String name); + Optional findBySidoAndName(Sido sido, String name); } diff --git a/src/main/java/kr/bb/store/domain/store/handler/GugunReader.java b/src/main/java/kr/bb/store/domain/store/handler/GugunReader.java index ac35ef3..5aac9bb 100644 --- a/src/main/java/kr/bb/store/domain/store/handler/GugunReader.java +++ b/src/main/java/kr/bb/store/domain/store/handler/GugunReader.java @@ -16,7 +16,7 @@ public class GugunReader { private final GugunRepository gugunRepository; public Gugun readGugunCorrespondingSido(Sido sido, String gugunName) { - Gugun gugun = gugunRepository.findByName(gugunName) + Gugun gugun = gugunRepository.findBySidoAndName(sido, gugunName) .orElseThrow(GugunNotFoundException::new); if(!gugun.getSido().getCode().equals(sido.getCode())) { throw new InvalidParentException(); From 1f5fe917cd4c4ce2b7c88a185ef83322ab92a729 Mon Sep 17 00:00:00 2001 From: qwerty1434 Date: Tue, 16 Jan 2024 13:44:13 +0900 Subject: [PATCH 6/7] =?UTF-8?q?:pencil2:=20=EA=B0=80=EA=B2=8C=EC=82=AC?= =?UTF-8?q?=EC=9E=A5=EC=9D=98=20=EC=BF=A0=ED=8F=B0=EC=A0=95=EB=B3=B4=20?= =?UTF-8?q?=EC=9A=94=EC=B2=AD=20=EC=8B=9C=20=EB=A7=8C=EB=A3=8C=EC=9D=BC?= =?UTF-8?q?=EC=9D=B4=20=EC=A7=80=EB=82=9C=20=EC=BF=A0=ED=8F=B0=EC=9D=80=20?= =?UTF-8?q?=EB=B3=B4=EC=9D=B4=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- .../store/domain/coupon/facade/CouponFacade.java | 3 ++- .../domain/coupon/handler/CouponReader.java | 4 ++-- .../repository/CouponRepositoryCustom.java | 2 +- .../repository/CouponRepositoryCustomImpl.java | 16 +++------------- .../domain/coupon/service/CouponService.java | 4 ++-- .../domain/coupon/handler/CouponReaderTest.java | 6 +++--- 7 files changed, 14 insertions(+), 23 deletions(-) diff --git a/build.gradle b/build.gradle index b4e3b3a..4bd2ff8 100644 --- a/build.gradle +++ b/build.gradle @@ -74,7 +74,7 @@ dependencies { implementation 'org.springframework.cloud:spring-cloud-aws-messaging:2.2.4.RELEASE' implementation 'software.amazon.awssdk:sns:2.21.37' - implementation group: 'io.github.lotteon-maven', name: 'blooming-blooms-utils', version: '202401121522' + implementation group: 'io.github.lotteon-maven', name: 'blooming-blooms-utils', version: '202401160417' } dependencyManagement { diff --git a/src/main/java/kr/bb/store/domain/coupon/facade/CouponFacade.java b/src/main/java/kr/bb/store/domain/coupon/facade/CouponFacade.java index d09cf86..c3d2180 100644 --- a/src/main/java/kr/bb/store/domain/coupon/facade/CouponFacade.java +++ b/src/main/java/kr/bb/store/domain/coupon/facade/CouponFacade.java @@ -61,7 +61,8 @@ public void softDeleteCoupon(Long storeId, Long couponId) { } public CouponsForOwnerResponse getAllStoreCoupons(Long storeId) { - return CouponsForOwnerResponse.from(couponService.getAllStoreCoupons(storeId)); + LocalDate now = LocalDate.now(); + return CouponsForOwnerResponse.from(couponService.getAllStoreCoupons(storeId, now)); } public void downloadCoupon(Long userId, Long couponId, String nickname, String phoneNumber, LocalDate now) { diff --git a/src/main/java/kr/bb/store/domain/coupon/handler/CouponReader.java b/src/main/java/kr/bb/store/domain/coupon/handler/CouponReader.java index eeafa87..9be5fdb 100644 --- a/src/main/java/kr/bb/store/domain/coupon/handler/CouponReader.java +++ b/src/main/java/kr/bb/store/domain/coupon/handler/CouponReader.java @@ -22,8 +22,8 @@ public Coupon read(Long couponId) { return couponRepository.findById(couponId).orElseThrow(CouponNotFoundException::new); } - public List readCouponsForOwner(Long storeId) { - return couponRepository.findAllDtoByStoreId(storeId); + public List readCouponsForOwner(Long storeId, LocalDate now) { + return couponRepository.findAllDtoByStoreId(storeId, now); } public List readStoresAllValidateCoupon(Long storeId, LocalDate now) { diff --git a/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustom.java b/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustom.java index 0fa86cb..57affd4 100644 --- a/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustom.java +++ b/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustom.java @@ -10,7 +10,7 @@ import java.util.List; public interface CouponRepositoryCustom { - List findAllDtoByStoreId(Long storeId); + List findAllDtoByStoreId(Long storeId, LocalDate now); List findAllDownloadableCouponsByStoreId(Long storeId, LocalDate now); List findStoreCouponsForUser(Long userId, Long storeId, LocalDate now); List findAvailableCoupons(Long totalAmount, Long userId, Long storeId, LocalDate now); diff --git a/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java b/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java index 09dbcd5..2753160 100644 --- a/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java +++ b/src/main/java/kr/bb/store/domain/coupon/repository/CouponRepositoryCustomImpl.java @@ -21,7 +21,7 @@ public CouponRepositoryCustomImpl(EntityManager em) { } @Override - public List findAllDtoByStoreId(Long storeId) { + public List findAllDtoByStoreId(Long storeId, LocalDate now) { return queryFactory .select(new QCouponForOwnerDto( coupon.id, @@ -43,18 +43,8 @@ public List findAllDtoByStoreId(Long storeId) { .on(coupon.id.eq(issuedCoupon.id.couponId)) .where( coupon.store.id.eq(storeId), - coupon.isDeleted.isFalse() - ) - .groupBy( - coupon.store.id, - coupon.couponCode, - coupon.couponName, - coupon.minPrice, - coupon.discountPrice, - coupon.limitCount, - coupon.startDate, - coupon.endDate, - coupon.id + coupon.isDeleted.isFalse(), + coupon.endDate.loe(now) ) .fetch(); } diff --git a/src/main/java/kr/bb/store/domain/coupon/service/CouponService.java b/src/main/java/kr/bb/store/domain/coupon/service/CouponService.java index a17413b..5f59141 100644 --- a/src/main/java/kr/bb/store/domain/coupon/service/CouponService.java +++ b/src/main/java/kr/bb/store/domain/coupon/service/CouponService.java @@ -98,8 +98,8 @@ public void unUseAllCoupons(List couponIds, Long userId) { }); } - public List getAllStoreCoupons(Long storeId) { - return couponReader.readCouponsForOwner(storeId); + public List getAllStoreCoupons(Long storeId, LocalDate now) { + return couponReader.readCouponsForOwner(storeId, now); } public List getAllStoreCouponsForUser(Long userId, Long storeId, LocalDate now) { diff --git a/src/test/java/kr/bb/store/domain/coupon/handler/CouponReaderTest.java b/src/test/java/kr/bb/store/domain/coupon/handler/CouponReaderTest.java index 7c8b76c..9b965a7 100644 --- a/src/test/java/kr/bb/store/domain/coupon/handler/CouponReaderTest.java +++ b/src/test/java/kr/bb/store/domain/coupon/handler/CouponReaderTest.java @@ -51,7 +51,7 @@ void readCouponsForOwner() { couponRepository.saveAll(List.of(c1,c2)); // when - List result = couponReader.readCouponsForOwner(store.getId()); + List result = couponReader.readCouponsForOwner(store.getId(), LocalDate.now()); // then assertThat(result).hasSize(2); @@ -67,7 +67,7 @@ void couponCountWillEqualIfNobodyIssueTheCoupon() { couponRepository.save(c1); // when - List result = couponReader.readCouponsForOwner(store.getId()); + List result = couponReader.readCouponsForOwner(store.getId(), LocalDate.now()); // then assertThat(result.get(0).getUnusedCount()).isEqualTo(c1.getLimitCount()); @@ -87,7 +87,7 @@ void unUsedCountWillDecreaseWhenUserIssueCoupon() { issuedCouponRepository.save(createIssuedCoupon(c1, userId)); // when - List result = couponReader.readCouponsForOwner(store.getId()); + List result = couponReader.readCouponsForOwner(store.getId(), LocalDate.now()); // then assertThat(result.get(0).getUnusedCount()).isEqualTo(99); From bd5f58774aec2177ef95d740f9ba69c27b4a3859 Mon Sep 17 00:00:00 2001 From: qwerty1434 Date: Tue, 16 Jan 2024 13:44:35 +0900 Subject: [PATCH 7/7] =?UTF-8?q?:pencil2:=20=ED=8F=89=EC=A0=90=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EC=8B=9C=20dto=EB=A1=9C=20?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=84=B0=EB=A5=BC=20=EC=A3=BC=EA=B3=A0?= =?UTF-8?q?=EB=B0=9B=EA=B2=8C=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/kr/bb/store/domain/store/facade/StoreFacade.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/main/java/kr/bb/store/domain/store/facade/StoreFacade.java b/src/main/java/kr/bb/store/domain/store/facade/StoreFacade.java index 8d24d59..36708b0 100644 --- a/src/main/java/kr/bb/store/domain/store/facade/StoreFacade.java +++ b/src/main/java/kr/bb/store/domain/store/facade/StoreFacade.java @@ -3,6 +3,7 @@ import bloomingblooms.domain.flower.FlowerDto; import bloomingblooms.domain.notification.order.OrderType; import bloomingblooms.domain.order.ValidatePolicyDto; +import bloomingblooms.domain.store.StoreAverageDto; import bloomingblooms.domain.store.StoreInfoDto; import bloomingblooms.domain.store.StoreNameAndAddressDto; import bloomingblooms.domain.store.StorePolicy; @@ -47,8 +48,8 @@ public class StoreFacade { @KafkaListener(topics = "store-average-rating-update", groupId = "average-rating") @CacheEvict(cacheNames = "store-list-with-paging", allEntries = true) - public void updateAverageRating(Map averageRatings) { - storeService.updateAverageRating(averageRatings); + public void updateAverageRating(StoreAverageDto storeAverageDto) { + storeService.updateAverageRating(storeAverageDto.getAverage()); log.info("stores averageRating updated"); }