Skip to content

Commit

Permalink
hotfix: add expiredQuantity in getClothingSales
Browse files Browse the repository at this point in the history
  • Loading branch information
hyunihs committed Sep 13, 2024
1 parent 392a11a commit 72ff097
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,22 @@ public record GetSellingClothingSales(
@Schema(description = "ํŒ๋งค ์ง„ํ–‰ ์‹œ์ž‘์ผ", example = "2024.01.01") String salesStartDate,
@Schema(description = "๋‚จ์€ ํŒ๋งค ์ผ์ˆ˜", example= "90") Integer remainingSalesDays,
@Schema(description = "ํŒ๋งค ์ค‘์ธ ์˜๋ฅ˜ ์ˆ˜๋Ÿ‰", example = "43") Integer sellingQuantity,
@Schema(description = "๊ตฌ๋งค ํ™•์ • ๋Œ€๊ธฐ ์ˆ˜๋Ÿ‰", example = "7") Integer pendingQuantity,
@Schema(description = "๊ตฌ๋งค ํ™•์ • ์™„๋ฃŒ ์ˆ˜๋Ÿ‰", example = "36") Integer soldQuantity,
@Schema(description = "๊ตฌ๋งค ํ™•์ • ๋Œ€๊ธฐ ์ˆ˜๋Ÿ‰", example = "7") Integer confirmPendingQuantity,
@Schema(description = "ํŒ๋งค ์™„๋ฃŒ ์ˆ˜๋Ÿ‰", example = "36") Integer soldQuantity,
@Schema(description = "๊ธฐ๊ฐ„ ๋งŒ๋ฃŒ ์ˆ˜๋Ÿ‰", example = "0") Integer expiredQuantity,
@Schema(description = "์ด ํฌ์ธํŠธ", example = "2300") Long totalPoint
) {

public static GetSellingClothingSales of(ClothingSales clothingSales, String salesStartDate, int remainingSalesDays, int sellingQuantity, int pendingQuantity, int soldQuantity) {
public static GetSellingClothingSales of(ClothingSales clothingSales, String salesStartDate, int remainingSalesDays, int sellingQuantity, int confirmPendingQuantity, int soldQuantity, int expiredQuantity, long totalPoint) {
return new GetSellingClothingSales(
clothingSales.getId(),
clothingSales.getClothingSalesCount(),
salesStartDate,
remainingSalesDays,
sellingQuantity,
pendingQuantity,
confirmPendingQuantity,
soldQuantity,
clothingSales.getPoint());
expiredQuantity,
totalPoint);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ public BagCollect toEntity(User user, Integer clothingSalesCount) {
.bagQuantity(bagQuantity)
.initAddress(new Address(postalCode, mainAddress, detailAddress))
.clothingSalesCount(clothingSalesCount)
.point(0L)
.clothingSalesState(ClothingSalesStateType.BAG_INIT_REQUEST)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ public BoxCollect toEntity(User user, Integer clothingSalesCount) {
.address(new Address(postalCode, mainAddress, detailAddress))
.collectionDate(LocalDate.parse(collectionDate))
.clothingSalesCount(clothingSalesCount)
.point(0L)
.clothingSalesState(ClothingSalesStateType.BOX_COLLECT_REQUEST)
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class BagCollect extends ClothingSales{
private Integer bagQuantity;

@Column(name = "notify_count")
private int notifyCount = 0;
private int notifyCount;

public void updateNotifyCount(int notifyCount) {
this.notifyCount = notifyCount;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ public abstract class ClothingSales {
@Column(name = "clothing_sales_count")
private Integer clothingSalesCount;

@Column(name = "point")
private Long point;

@Column(name = "weight")
private Double weight;

Expand Down Expand Up @@ -81,9 +78,6 @@ public void updateImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}

public void updatePoint(long point) {
this.point = point;
}
public void updateWeight(double weight) {
this.weight = weight;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,15 @@ public GetSellingClothingSales getSellingClothingSales(Long clothingSalesId) {
private GetSellingClothingSales getSellingClothingSalesInfo(ClothingSales clothingSales) {
List<Product> productList = clothingSales.getProductList();
if(productList.isEmpty()) {
return GetSellingClothingSales.of(clothingSales, clothingSales.getSalesStartDate().format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), 0, 0, 0, 0);
return GetSellingClothingSales.of(clothingSales, clothingSales.getSalesStartDate().format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), 0, 0, 0, 0, 0, 0);
}

int remainingSalesDays = (int) ChronoUnit.DAYS.between(LocalDate.now(), clothingSales.getSalesStartDate().toLocalDate().plusDays(90));
int sellingQuantity = 0;
int pendingQuantity = 0;
int confirmPendingQuantity = 0;
int soldQuantity = 0;
int expiredQuantity = 0;
long totalPoint = 0;

for (Product product : productList) {
if (product.getProductState().equals(ProductStateType.SELLING)) {
Expand All @@ -154,12 +156,15 @@ private GetSellingClothingSales getSellingClothingSalesInfo(ClothingSales clothi
.orElseThrow(() -> new CustomException(INVALID_PRODUCT_ID));
if (productOrder.isConfirmed()) {
soldQuantity++;
totalPoint += product.getSettlement();
} else {
pendingQuantity++;
confirmPendingQuantity++;
}
} else if (product.getProductState().equals(ProductStateType.SELLING_END)) {
expiredQuantity++;
}
}
return GetSellingClothingSales.of(clothingSales, clothingSales.getSalesStartDate().format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), remainingSalesDays, sellingQuantity, pendingQuantity, soldQuantity);
return GetSellingClothingSales.of(clothingSales, clothingSales.getSalesStartDate().format(DateTimeFormatter.ofPattern("yyyy.MM.dd")), remainingSalesDays, sellingQuantity, confirmPendingQuantity, soldQuantity, expiredQuantity, totalPoint);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public void updateProductDiscountRate() {
}

private void handleExpiredSales(ClothingSales clothingSales) {
clothingSales.getProductList().forEach(p -> {
productService.changeSellingState(p, ProductStateType.SELLING_END);
});
clothingSales.getProductList().stream()
.filter(p -> p.getProductState() == ProductStateType.SELLING)
.forEach(p -> productService.changeSellingState(p, ProductStateType.SELLING_END));
ClothingSalesState clothingSalesState = ClothingSalesState.of(clothingSales.getId(), ClothingSalesStateType.SELLING_EXPIRED);
clothingSales.updateClothingSalesState(ClothingSalesStateType.SELLING_EXPIRED);
clothingSalesStateRepository.save(clothingSalesState);
Expand Down

0 comments on commit 72ff097

Please sign in to comment.