Skip to content

Commit

Permalink
feat: 그룹 상세 조회에서 개별 매장 상세 조회 기능 구현 (#205)
Browse files Browse the repository at this point in the history
* feat: 장바구니 추가 기능 구현

* feat: 장바구니 조회 기능 구현

* feat: 상품 주문과 식권 사용 기능 구현

* style: 포인트트랜잭션 레포지토리명 변경

* deploy: 재배포

* deploy: 재배포2

* deploy: 로그인 로직 수정에 따른 재배포

* deploy: 로그인 로직 수정에 따른 재배포2

* feat: 식권 사용 기능 구현

* feat: yml 수정 사항 반영

* feat: 식권 사용 로직 수정

* feat: 주문 로직 수정 완료

* fix: 장바구니에 아무것도 없을 때 주문 시 active 되는 현상 수정

* feat: 주문 완료 시 리턴 값 수정

* feat: 내 그룹 조회 기능 구현

* feat: 기본 프로필 이미지 url 추가

* feat: 그룹 멤버 전체 조회 기능 구현

* feat: 1인당 사용 가능 금액 설정 컬럼 추가

* feat: 내 지갑 조회 기능 구현

* feat: 선결제 기능 구현

* feat: 유저 홈 화면 조회 기능 구현

* feat: 그룹 상세 조회 기능 구현

* feat: 가게 상세 조회 쿼리 수정

* deploy: 변경사항 반영을 위한 커밋

* deploy: 수정 사항 반영 재배포

* deploy: rds 교체로 인한 재배포

* deploy: rds 교체로 인한 재배포2

* feat: 홈 화면 소속팀 조회 쿼리 제대로 안되던 현상 해결, 대표이미지 반환 추가

* feat: 그룹 상세 조회 응답 컬럼명 변경

* feat: memberLimit 컬럼 삭제

* feat: 선결제 시 기존 결제 내역과 멱등성 문제 해결

* fix: 팀 상세 조회 시 이미지 쿼리가 의미 없이 join 되던 쿼리 수정

* feat: 가게 검색 기능 대폭 수정

* feat: 프론트 요구사 반영

* feat: searchcondition 삭제

* feat: 팀타입 desription 리턴 하도록 수정

* feat: 카테고리별 팀 조회 시 팀 생성일 컬럼 추가

* feat: 매장찾기_상세 페이지 조회 기능 구현

* feat: 비밀 코드 조회 기능 엔드 포인트 수정

* fix: conflict fix

* hotfix: 서버 복구

* hotfix: 서버 복구2

* feat: Barobill api 연동

* fix: 홈 화면에 같은 데이터가 중복되는 현상 수정

* infra: ElastiCache 연결을 위한 docker-compose 설정

* infra: cicd script 수정

* infra: cicd script ec2 주소 설정

* infra: cicd script 수정2

* infra: cicd script 수정3

* infra: cicd script 수정4

* infra: cicd script 수정5

* infra: cicd script 수정6

* infra: cicd script 수정7

* infra: cicd script 수정7

* infra: cicd script 수정8

* infra: cicd script 수정9

* infra: cicd script 수정10

* infra: cicd script 수정11

* infra: cicd script 수정12

* infra: cicd script 수정13

* infra: cicd script 수정14

* infra: cicd script 수정15

* infra: cicd script 수정16

* infra: cicd script 수정17

* infra: cicd script 수정18

* infra: cicd script 수정19

* infra: cicd script 수정20

* infra: cicd script 수정21

* infra: cicd script 수정22

* fix: 보유금액이 선결제 금액보다 작을 경우 상태값 변경(200->400)

* feat: 홈화면 가게 별 선결제 디데이 추가, 쿼리문 조정

* feat: 주문하기 로직 정상화

* feat: 장바구니에 다른 가게 물건이 있는지 검증 구현

* feat: 장바구니 비우기 기능 구현

* deploy: cd retry

* feat: 매장 상세 페이지 조회 메뉴 정렬 조건 추가

* feat: 세금명세서 역발행 기능 추가

* feat: 거래 타입명 변경

* feat: pointTransaction 금액 음수(-) 표시 추가

* feat: 세금계산서 역발행 요청 기능 구현

* feat: 팀 조회 시 진행 상태값 반환 추가

* feat: 그룹 상세 조회 path storeId 추가

* feat: 그룹 조회 시 팀 id 조회 추가

* feat: 그룹 상세 조회에서 개별 매장 상세 조회 기능 구현
  • Loading branch information
LEEJaeHyeok97 authored Dec 6, 2024
1 parent b1450b3 commit 235ecfa
Show file tree
Hide file tree
Showing 8 changed files with 180 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -153,16 +153,19 @@ public OrderResponse order(String userProviderId, OrderRequest orderRequest) {
})
.sum();

PointTransaction pointTransaction = PointTransaction
.builder()
.transactionType(TransactionType.FOOD_PURCHASE)
.transactionedPoint(totalAmount * -1)
.team(team)
.user(user)
.store(store)
.build();

pointTransactionRepository.save(pointTransaction);
for (OrderRequest.OrderItemRequest item : orderRequest.items()) {
PointTransaction pointTransaction = PointTransaction
.builder()
.transactionType(TransactionType.FOOD_PURCHASE)
.transactionedPoint(totalAmount * -1)
.team(team)
.user(user)
.store(store)
.menuId(item.menuId())
.build();

pointTransactionRepository.save(pointTransaction);
}

StoreTeam storeTeam = storeTeamRepository.findByStoreIdAndTeamId(store.getId(), team.getId())
.orElseThrow(() -> new IllegalArgumentException("유효하지 않은 가게 id와 팀 id 입니다."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ public class PointTransaction extends BaseEntity {
@Column(name = "transaction_type")
private TransactionType transactionType;

@Column(name = "menu_id")
private Long menuId;

@Column(name = "transactioned_point")
private Integer transactionedPoint;

Expand All @@ -50,9 +53,11 @@ public class PointTransaction extends BaseEntity {


@Builder
public PointTransaction(TransactionType transactionType, Integer transactionedPoint, Team team, User user,
public PointTransaction(TransactionType transactionType, Long menuId, Integer transactionedPoint, Team team,
User user,
Store store) {
this.transactionType = transactionType;
this.menuId = menuId;
this.transactionedPoint = transactionedPoint;
this.team = team;
this.user = user;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.jangburich.domain.store.domain.Store;
import com.jangburich.domain.store.repository.StoreRepository;
import com.jangburich.domain.team.dto.response.IndividualStoreDetailsResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -131,25 +132,22 @@ public List<MyTeamResponse> getMyTeamByCategory(String userId, String category)
return myTeamResponses;
}

public MyTeamDetailsResponse getTeamDetailsById(String userId, Long teamId, Long storeId) {
public MyTeamDetailsResponse getTeamDetailsById(String userId, Long teamId) {
User user = userRepository.findByProviderId(userId)
.orElseThrow(() -> new NullPointerException("사용자를 찾을 수 없습니다."));

Team team = teamRepository.findById(teamId)
.orElseThrow(() -> new IllegalArgumentException("해당 팀을 찾을 수 없습니다."));

Store store = storeRepository.findById(storeId)
.orElseThrow(() -> new IllegalArgumentException("해당 가게를 찾을 수 없습니다."));

if (!team.getTeamLeader().getUser_id().equals(user.getUserId())) {
// 일반 구성원
return teamRepository.findMyTeamDetailsAsMember(user.getUserId(),
teamId, storeId);
teamId);
}
// 팀 리더일 때

return teamRepository.findMyTeamDetailsAsLeader(user.getUserId(),
teamId, storeId);
teamId);
}

public List<TeamMemberResponse> getTeamMembers(String userId, Long teamId) {
Expand Down Expand Up @@ -198,4 +196,20 @@ public TeamCodeResponse getTeamsWithSecretCode(String secretCode) {

return teamCodeResponse;
}

public IndividualStoreDetailsResponse getIndividualStoreDetails(String userId, Long teamId, Long storeId) {
User user = userRepository.findByProviderId(userId)
.orElseThrow(() -> new NullPointerException("사용자를 찾을 수 없습니다."));

Team team = teamRepository.findById(teamId)
.orElseThrow(() -> new IllegalArgumentException("해당하는 팀을 찾을 수 없습니다."));

Store store = storeRepository.findById(storeId)
.orElseThrow(() -> new IllegalArgumentException("해당하는 가게를 찾을 수 없습니다."));

IndividualStoreDetailsResponse individualStoreDetails = teamRepository.findIndividualStoreDetails(
user.getUserId(), team.getId(), store.getId());

return individualStoreDetails;
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.jangburich.domain.team.domain.repository;

import com.jangburich.domain.team.dto.response.IndividualStoreDetailsResponse;
import com.jangburich.domain.team.dto.response.MyTeamDetailsResponse;

public interface TeamQueryDslRepository {
MyTeamDetailsResponse findMyTeamDetailsAsMember(Long userId, Long teamId, Long storeId);
MyTeamDetailsResponse findMyTeamDetailsAsMember(Long userId, Long teamId);

MyTeamDetailsResponse findMyTeamDetailsAsLeader(Long userId, Long teamId, Long storeId);
MyTeamDetailsResponse findMyTeamDetailsAsLeader(Long userId, Long teamId);

IndividualStoreDetailsResponse findIndividualStoreDetails(Long userId, Long teamId, Long storeId);
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@

import com.jangburich.domain.common.Status;
import com.jangburich.domain.point.domain.TransactionType;
import com.jangburich.domain.store.domain.QStoreTeam;
import com.jangburich.domain.team.dto.response.IndividualStoreDetailsResponse;
import com.jangburich.domain.team.dto.response.MyPaymentHistory;
import com.jangburich.domain.team.dto.response.MyTeamDetailsResponse;
import com.jangburich.domain.team.dto.response.PrepayedStore;
import com.jangburich.domain.team.dto.response.QIndividualStoreDetailsResponse;
import com.jangburich.domain.team.dto.response.QMyPaymentHistory;
import com.jangburich.domain.team.dto.response.QMyTeamDetailsResponse;
import com.jangburich.domain.team.dto.response.QPrepayedStore;
import com.jangburich.domain.team.dto.response.QTodayPayment;
Expand Down Expand Up @@ -40,7 +45,7 @@ public class TeamQueryDslRepositoryImpl implements TeamQueryDslRepository {
LocalDateTime endOfDay = currentDate.plusDays(1).atStartOfDay().minusNanos(1);

@Override
public MyTeamDetailsResponse findMyTeamDetailsAsMember(Long userId, Long teamId, Long storeId) {
public MyTeamDetailsResponse findMyTeamDetailsAsMember(Long userId, Long teamId) {

List<PrepayedStore> prepayedStores = queryFactory
.select(new QPrepayedStore(
Expand All @@ -51,7 +56,7 @@ public MyTeamDetailsResponse findMyTeamDetailsAsMember(Long userId, Long teamId,
Expressions.constant(false)
))
.from(store)
.leftJoin(storeTeam).on(storeTeam.team.id.eq(storeId))
.leftJoin(storeTeam).on(storeTeam.team.id.eq(teamId))
.fetch();

List<String> images = queryFactory
Expand Down Expand Up @@ -109,7 +114,7 @@ public MyTeamDetailsResponse findMyTeamDetailsAsMember(Long userId, Long teamId,
}

@Override
public MyTeamDetailsResponse findMyTeamDetailsAsLeader(Long userId, Long teamId, Long storeId) {
public MyTeamDetailsResponse findMyTeamDetailsAsLeader(Long userId, Long teamId) {

List<PrepayedStore> prepayedStores = queryFactory
.select(new QPrepayedStore(
Expand All @@ -120,7 +125,7 @@ public MyTeamDetailsResponse findMyTeamDetailsAsLeader(Long userId, Long teamId,
Expressions.constant(false)
))
.from(store)
.leftJoin(storeTeam).on(storeTeam.team.id.eq(storeId))
.leftJoin(storeTeam).on(storeTeam.team.id.eq(teamId))
.fetch();

List<String> images = queryFactory
Expand Down Expand Up @@ -177,4 +182,64 @@ public MyTeamDetailsResponse findMyTeamDetailsAsLeader(Long userId, Long teamId,
.fetchOne();

}

@Override
public IndividualStoreDetailsResponse findIndividualStoreDetails(Long userId, Long teamId, Long storeId) {
LocalDateTime now = LocalDateTime.now();
LocalDateTime oneMonthAgo = now.minusMonths(1);

List<MyPaymentHistory> myPaymentHistories = queryFactory
.select(new QMyPaymentHistory(
Expressions.stringTemplate(
"DATE_FORMAT({0}, '%m.%d')", pointTransaction.createdAt
),
Expressions.stringTemplate(
"DATE_FORMAT({0}, '%H:%i')", pointTransaction.createdAt
),
menu.name,
menu.price
))
.from(pointTransaction)
.leftJoin(menu).on(pointTransaction.menuId.eq(menu.id))
.where(pointTransaction.store.id.eq(storeId),
pointTransaction.team.id.eq(teamId),
pointTransaction.user.userId.eq(userId),
pointTransaction.createdAt.between(oneMonthAgo, now))
.fetch();

Integer totalPrice = queryFactory
.select(pointTransaction.transactionedPoint.sum())
.from(pointTransaction)
.where(pointTransaction.store.id.eq(storeId),
pointTransaction.team.id.eq(teamId),
pointTransaction.user.userId.eq(userId),
pointTransaction.createdAt.between(oneMonthAgo, now))
.fetchOne();

return queryFactory
.selectDistinct(new QIndividualStoreDetailsResponse(
store.id,
store.name,
Expressions.constant(false),
storeTeam.remainPoint,
storeTeam.personalAllocatedPoint,
Expressions.constant(totalPrice),
Expressions.stringTemplate(
"DATE_FORMAT({0}, '%y.%m.%d')", oneMonthAgo
),
Expressions.stringTemplate(
"DATE_FORMAT({0}, '%y.%m.%d')", now
),
Expressions.constant(myPaymentHistories)
))
.from(storeTeam)
.leftJoin(store).on(storeTeam.store.id.eq(store.id))
.leftJoin(team).on(team.id.eq(storeTeam.team.id))
.leftJoin(pointTransaction).on(pointTransaction.store.id.eq(storeTeam.store.id),
pointTransaction.transactionType.eq(TransactionType.FOOD_PURCHASE),
pointTransaction.user.userId.eq(userId))
.where(storeTeam.store.id.eq(storeId),
storeTeam.team.id.eq(teamId))
.fetchOne();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package com.jangburich.domain.team.dto.response;

import com.querydsl.core.annotations.QueryProjection;
import java.util.List;

public record IndividualStoreDetailsResponse(
Long storeId,
String storeName,
boolean isLiked,
int remainingAmount,
int availableAmount,
int myUsedAmount,
String usageStartDate,
String usageEndDate,
List<MyPaymentHistory> myPaymentHistories
) {

@QueryProjection
public IndividualStoreDetailsResponse(Long storeId, String storeName, boolean isLiked, int remainingAmount,
int availableAmount, int myUsedAmount, String usageStartDate,
String usageEndDate,
List<MyPaymentHistory> myPaymentHistories) {
this.storeId = storeId;
this.storeName = storeName;
this.isLiked = isLiked;
this.remainingAmount = remainingAmount;
this.availableAmount = availableAmount;
this.myUsedAmount = myUsedAmount;
this.usageStartDate = usageStartDate;
this.usageEndDate = usageEndDate;
this.myPaymentHistories = myPaymentHistories;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.jangburich.domain.team.dto.response;

import com.querydsl.core.annotations.QueryProjection;

public record MyPaymentHistory(
String paymentDate,
String paymentTime,
String menuName,
int price
) {

@QueryProjection
public MyPaymentHistory(String paymentDate, String paymentTime, String menuName, int price) {
this.paymentDate = paymentDate;
this.paymentTime = paymentTime;
this.menuName = menuName;
this.price = price;
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.jangburich.domain.team.presentation;

import com.jangburich.domain.team.dto.response.IndividualStoreDetailsResponse;
import java.util.List;
import java.util.UUID;

Expand Down Expand Up @@ -65,14 +66,24 @@ public ResponseCustom<List<MyTeamResponse>> getMyTeamByCategory(
}

@Operation(summary = "그룹(팀) 상세 조회", description = "내가 속한 팀의 정보를 상세 조회합니다.")
@GetMapping("/{teamId}/{storeId}")
@GetMapping("/{teamId}")
public ResponseCustom<MyTeamDetailsResponse> getTeamDetailsById(
Authentication authentication,
@PathVariable Long teamId,
@PathVariable Long storeId
@PathVariable Long teamId
) {
return ResponseCustom.OK(
teamService.getTeamDetailsById(AuthenticationParser.parseUserId(authentication), teamId));
}

@Operation(summary = "그룹 상세 조회에서 개별 매장 상세 조회", description = "그룹 상세 조회에서 한 매장을 선택 시 조회되는 정보.")
@GetMapping("/{teamId}/{storeId}")
public ResponseCustom<IndividualStoreDetailsResponse> getIndividualStoreDetails(
Authentication authentication,
@PathVariable Long teamId,
@PathVariable Long storeId
) {
return ResponseCustom.OK(
teamService.getTeamDetailsById(AuthenticationParser.parseUserId(authentication), teamId, storeId));
teamService.getIndividualStoreDetails(AuthenticationParser.parseUserId(authentication), teamId, storeId));
}

@Operation(summary = "그룹(팀) 멤버 전체 조회", description = "그룹(팀)에 소속된 모든 멤버를 조회합니다.")
Expand Down

0 comments on commit 235ecfa

Please sign in to comment.