Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class WeeklyRankingScheduler {
/**
* 매주 월요일 00:00시 지난 주 랭킹 계산
*/
@Scheduled(cron = "0 23 17 * * THU", zone = "Asia/Seoul")
@Scheduled(cron = "0 0 0 * * MON", zone = "Asia/Seoul")
public void calculateWeeklyRankingBatch() {

log.info("스케줄러 작동");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import com.example.green.domain.pointshop.item.entity.vo.ItemCode;
import com.example.green.domain.pointshop.item.entity.vo.ItemMedia;
import com.example.green.domain.pointshop.item.entity.vo.ItemPrice;
import com.example.green.domain.pointshop.item.entity.vo.ItemStock;
import com.example.green.domain.pointshop.item.repository.PointItemOrderRepository;
import com.example.green.domain.pointshop.item.repository.PointItemQueryRepository;
import com.example.green.domain.pointshop.item.service.PointItemQueryService;
Expand Down Expand Up @@ -83,8 +82,7 @@ public NoContent updatePointItem(
new ItemCode(updatePointItemRequest.code()),
new ItemBasicInfo(updatePointItemRequest.name(), updatePointItemRequest.description()),
new ItemMedia(updatePointItemRequest.thumbnailUrl()),
new ItemPrice(updatePointItemRequest.price()),
new ItemStock(updatePointItemRequest.stock())
new ItemPrice(updatePointItemRequest.price())
);

pointItemService.updatePointItem(command, pointItemId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.example.green.domain.pointshop.item.entity.vo.ItemCode;
import com.example.green.domain.pointshop.item.entity.vo.ItemMedia;
import com.example.green.domain.pointshop.item.entity.vo.ItemPrice;
import com.example.green.domain.pointshop.item.entity.vo.ItemStock;
import com.example.green.domain.pointshop.item.service.command.PointItemCreateCommand;

import io.swagger.v3.oas.annotations.media.Schema;
Expand Down Expand Up @@ -35,18 +34,14 @@ public record CreatePointItemRequest(
String thumbnailUrl,
@NotNull(message = "아이템 상품 가격은 필수입니다.")
@Schema(description = "아이템 상품 가격", example = "10000")
BigDecimal price,
@NotNull(message = "아이템 상품 재고는 필수입니다")
@Schema(description = "아이템 상품 재고", example = "2")
Integer stock
BigDecimal price
) {
public PointItemCreateCommand toCommand() {
return new PointItemCreateCommand(
new ItemCode(code),
new ItemBasicInfo(name, description),
new ItemMedia(thumbnailUrl),
new ItemPrice(price),
new ItemStock(stock)
new ItemPrice(price)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ public record UpdatePointItemRequest(

@NotNull(message = "아이템 가격은 필수입니다.")
@Schema(description = "아이템 가격", example = "10000")
BigDecimal price,

@NotNull(message = "아이템 수량은 필수입니다")
@Schema(description = "아이템 수량", example = "10")
Integer stock
BigDecimal price
) {
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,14 @@ public class PointItemClientResponse {
@Column(nullable = false)
private BigDecimal remainPoint;

@Column(nullable = false)
private Integer stock;

public PointItemClientResponse(
String itemName,
String description,
String thumbnail,
BigDecimal price,
BigDecimal enablePoint,
BigDecimal decreasePoint,
BigDecimal remainPoint,
Integer stock
BigDecimal remainPoint
) {
validateEmptyString(itemName, REQUIRED_ITEM_NAME);
validateEmptyString(description, REQUIRED_ITEM_DESCRIPTION);
Expand All @@ -57,7 +53,6 @@ public PointItemClientResponse(
validateNullData(enablePoint, REQUIRED_ENABLE_POINT);
validateNullData(decreasePoint, REQUIRED_DECREASE_POINT);
validateNullData(remainPoint, REQUIRED_REMAIN_POINT);
validateNullData(stock, REQUIRED_ITEM_STOCK);

this.itemName = itemName;
this.description = description;
Expand All @@ -66,7 +61,6 @@ public PointItemClientResponse(
this.enablePoint = enablePoint;
this.decreasePoint = decreasePoint;
this.remainPoint = remainPoint;
this.stock = stock;
}

public static PointItemClientResponse from(PointItem pointItem, BigDecimal enablePoint, BigDecimal decreasePoint,
Expand All @@ -78,8 +72,7 @@ public static PointItemClientResponse from(PointItem pointItem, BigDecimal enabl
pointItem.getItemPrice().getItemPrice(),
enablePoint,
decreasePoint,
remainPoint,
pointItem.getItemStock().getStock()
remainPoint
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
import com.example.green.domain.pointshop.item.entity.vo.ItemDisplayStatus;
import com.example.green.domain.pointshop.item.entity.vo.ItemMedia;
import com.example.green.domain.pointshop.item.entity.vo.ItemPrice;
import com.example.green.domain.pointshop.item.entity.vo.ItemStock;
import com.example.green.domain.pointshop.item.exception.PointItemException;
import com.example.green.domain.pointshop.product.entity.vo.SellingStatus;

import jakarta.persistence.AttributeOverride;
import jakarta.persistence.Column;
Expand Down Expand Up @@ -60,46 +57,32 @@ public class PointItem extends BaseEntity {
@Embedded
private ItemPrice itemPrice;

@Embedded
private ItemStock itemStock;

@Column(nullable = false)
@Enumerated(EnumType.STRING)
private SellingStatus sellingStatus;

@Column(nullable = false)
@Enumerated(EnumType.STRING)
private ItemDisplayStatus displayStatus;

@Builder
public PointItem(ItemCode itemCode, ItemBasicInfo itemBasicInfo, ItemMedia itemMedia, ItemPrice itemPrice,
ItemStock itemStock) {
validatePointItem(itemCode, itemBasicInfo, itemMedia, itemPrice, itemStock);
public PointItem(ItemCode itemCode, ItemBasicInfo itemBasicInfo, ItemMedia itemMedia, ItemPrice itemPrice
) {
validatePointItem(itemCode, itemBasicInfo, itemMedia, itemPrice);
this.itemCode = itemCode;
this.itemBasicInfo = itemBasicInfo;
this.itemMedia = itemMedia;
this.itemPrice = itemPrice;
this.itemStock = itemStock;
this.sellingStatus = SellingStatus.EXCHANGEABLE;
this.displayStatus = ItemDisplayStatus.DISPLAY;
}

public static PointItem create(ItemCode itemCode, ItemBasicInfo itemBasicInfo, ItemMedia itemMedia,
ItemPrice itemPrice, ItemStock itemStock) {
return new PointItem(itemCode, itemBasicInfo, itemMedia, itemPrice, itemStock);
ItemPrice itemPrice) {
return new PointItem(itemCode, itemBasicInfo, itemMedia, itemPrice);
}

private static void validatePointItem(ItemCode itemCode, ItemBasicInfo itemBasicInfo, ItemMedia itemMedia,
ItemPrice itemPrice, ItemStock itemStock) {
ItemPrice itemPrice) {
validateNullData(itemCode, REQUIRED_ITEM_CODE);
validateNullData(itemBasicInfo, REQUIRED_ITEM_BASIC_INFO);
validateNullData(itemMedia, REQUIRED_ITEM_MEDIA);
validateNullData(itemPrice, REQUIRED_ITEM_PRICE);
validateNullData(itemStock, REQUIRED_ITEM_STOCK);
if (itemStock.isSoldOut()) {
throw new PointItemException(INVALID_ITEM_STOCK_CREATION);
}

}

public void updateItemCode(ItemCode itemCode) {
Expand All @@ -122,24 +105,6 @@ public void updateItemPrice(ItemPrice itemPrice) {
this.itemPrice = itemPrice;
}

public void updateItemStock(ItemStock itemStock) {
validateNullData(itemStock, REQUIRED_ITEM_STOCK);
this.itemStock = itemStock;
this.sellingStatus = updateSellingStatus();
}

public void decreaseStock(int amount) {
this.itemStock = this.itemStock.decreaseStock(amount);
this.sellingStatus = updateSellingStatus();
}

private SellingStatus updateSellingStatus() {
if (this.itemStock.isSoldOut()) {
return SellingStatus.SOLD_OUT;
}
return SellingStatus.EXCHANGEABLE;
}

public boolean isNewImage(ItemMedia media) {
return !this.itemMedia.equals(media);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ public List<ExcelField> getFields() {
ExcelField.of("아이템 코드", singleBackGroundColor, FieldFormat.TEXT),
ExcelField.of("아이템명", singleBackGroundColor, FieldFormat.TEXT),
ExcelField.of("아이템 포인트", singleBackGroundColor, FieldFormat.POINT),
ExcelField.of("수량", singleBackGroundColor, FieldFormat.NUMBER),
ExcelField.of("판매 상태", singleBackGroundColor, FieldFormat.TEXT),
ExcelField.of("전시 여부", singleBackGroundColor, FieldFormat.TEXT),
ExcelField.of("등록일", singleBackGroundColor, FieldFormat.DATE)
);
Expand All @@ -48,8 +46,6 @@ public Object[] extractRowData(PointItemSearchResponse data) {
data.getCode(),
data.getName(),
data.getPointPrice(),
data.getStockQuantity(),
data.getSellingStatus().getValue(),
data.getDisplayStatus().getValue(),
data.getCreatedDate()
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ public static QBean<PointItemSearchResponse> toSearchItemResponse(QPointItem qPo
qPointItem.itemCode.code.as("code"),
qPointItem.itemBasicInfo.itemName.as("name"),
qPointItem.itemPrice.itemPrice.as("pointPrice"),
qPointItem.itemStock.stock.as("stockQuantity"),
qPointItem.sellingStatus,
qPointItem.displayStatus,
qPointItem.createdDate
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ public List<PointItemResponse> findItemByCursor(BooleanExpression expression, in
qPointItem.id,
qPointItem.itemBasicInfo.itemName,
qPointItem.itemMedia.itemThumbNailUrl,
qPointItem.itemPrice.itemPrice,
qPointItem.sellingStatus
qPointItem.itemPrice.itemPrice
))
.from(qPointItem)
.where(expression)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public class PointItemOrderService {
private final PointItemOrderRepository pointItemOrderRepository;
private final PointItemRepository pointItemRepository;
private final PlantGrowthItemRepository plantGrowthItemRepository;
private final PointItemService pointItemService;
private final PointClient pointClient;
private final MemberRepository memberRepository;
private final TimeUtils timeUtils;
Expand Down Expand Up @@ -64,8 +63,6 @@ public OrderPointItemResponse orderPointItem(OrderPointItemCommand command,
throw new PointItemException(PointItemExceptionMessage.NOT_POSSIBLE_BUY_ITEM);
}

pointItemService.decreaseItemStock(itemId, amount);

BigDecimal remainPoint = currentPoint.subtract(totalPoint);

pointClient.spendPoints(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ public Long create(PointItemCreateCommand createCommand) {
createCommand.itemCode(),
createCommand.info(),
createCommand.media(),
createCommand.price(),
createCommand.stock()
createCommand.price()
);

PointItem savedPointItem = pointItemRepository.save(pointItem);
Expand All @@ -55,7 +54,6 @@ public void updatePointItem(PointItemUpdateCommand command, Long pointItemId) {
pointItem.updateItemBasicInfo(command.info());
pointItem.updateItemMedia(command.media());
pointItem.updateItemPrice(command.price());
pointItem.updateItemStock(command.stock());

processSideEffect(command, pointItem);
}
Expand Down Expand Up @@ -106,9 +104,4 @@ public void hideItemDisplay(Long pointItemId) {
pointItemQueryService.getPointItem(pointItemId).hideItemDisplay();
}

public void decreaseItemStock(Long pointItemId, int amount) {
PointItem pointItem = pointItemQueryService.getPointItem(pointItemId);
pointItem.decreaseStock(amount);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,12 @@
import com.example.green.domain.pointshop.item.entity.vo.ItemCode;
import com.example.green.domain.pointshop.item.entity.vo.ItemMedia;
import com.example.green.domain.pointshop.item.entity.vo.ItemPrice;
import com.example.green.domain.pointshop.item.entity.vo.ItemStock;

public record PointItemCreateCommand(
ItemCode itemCode,
ItemBasicInfo info,
ItemMedia media,
ItemPrice price,
ItemStock stock
ItemPrice price
) {
}

Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
import com.example.green.domain.pointshop.item.entity.vo.ItemCode;
import com.example.green.domain.pointshop.item.entity.vo.ItemMedia;
import com.example.green.domain.pointshop.item.entity.vo.ItemPrice;
import com.example.green.domain.pointshop.item.entity.vo.ItemStock;

public record PointItemUpdateCommand(
ItemCode itemCode,
ItemBasicInfo info,
ItemMedia media,
ItemPrice price,
ItemStock stock
ItemPrice price
) {
}
9 changes: 9 additions & 0 deletions src/main/resources/db/migration/v13__migrate_point_item.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
-- selling_status 컬럼 삭제
ALTER TABLE point_item
DROP
COLUMN IF EXISTS selling_status;

-- stock 컬럼 삭제
ALTER TABLE point_item
DROP
COLUMN IF EXISTS stock;
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@ public static CreatePointItemRequest createPointItemRequest() {
"맑은 뭉게 구름",
"하늘에서 포근한 구름이 내려와 식물을 감싸요. 몽글몽글 기분 좋은 하루!",
"https://thumbnail.url/rainbow-pot.jpg",
BigDecimal.valueOf(450),
10
BigDecimal.valueOf(450)
);
}

Expand All @@ -24,8 +23,7 @@ public static UpdatePointItemRequest updatePointItemRequest() {
"행운의 네잎클로버",
"행운의 네잎클로버가 싱그럽게 피어나요. 오늘 하루도 행운 가득!",
"https://thumbnail.url/clover.jpg",
BigDecimal.valueOf(600),
20
BigDecimal.valueOf(600)
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import com.example.green.domain.pointshop.item.entity.vo.ItemCode;
import com.example.green.domain.pointshop.item.entity.vo.ItemMedia;
import com.example.green.domain.pointshop.item.entity.vo.ItemPrice;
import com.example.green.domain.pointshop.item.entity.vo.ItemStock;
import com.example.green.domain.pointshop.item.repository.PointItemRepository;
import com.example.green.domain.pointshop.item.service.PointItemOrderService;
import com.example.green.domain.pointshop.item.service.command.OrderPointItemCommand;
Expand Down Expand Up @@ -51,9 +50,8 @@ class PointItemOrderServiceControllerTest extends BaseControllerUnitTest {
ItemBasicInfo itemBasicInfo = new ItemBasicInfo("무지개", "행운의 네잎클로버가 싱그럽게 피어나요. 오늘 하루도 행운 가득");
ItemMedia itemMedia = new ItemMedia("https://thumbnail.url/rainbow-pot.jpg");
ItemPrice itemPrice = new ItemPrice(BigDecimal.valueOf(400));
ItemStock itemStock = new ItemStock(10);

PointItem pointItem = new PointItem(itemCode, itemBasicInfo, itemMedia, itemPrice, itemStock);
PointItem pointItem = new PointItem(itemCode, itemBasicInfo, itemMedia, itemPrice);

when(pointItemRepository.findById(itemId)).thenReturn(Optional.of(pointItem));

Expand Down
Loading