From 427f4a0f61e76859d81dc5f7003a8d2151e2e368 Mon Sep 17 00:00:00 2001 From: deokisys Date: Thu, 19 Dec 2019 18:50:01 +0900 Subject: [PATCH 1/2] Fix failer products MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 실패한 상품 오류 수정 --- .../Organism/TradeListBox/index.jsx | 13 ++++++++---- client/src/pages/TradeList/index.jsx | 17 ++++++++++----- server/src/controllers/api/LogController.ts | 2 +- server/src/repositories/LogRepository.ts | 21 +++++++++++++++++-- server/src/services/LogService.ts | 4 +++- 5 files changed, 44 insertions(+), 13 deletions(-) diff --git a/client/src/components/Organism/TradeListBox/index.jsx b/client/src/components/Organism/TradeListBox/index.jsx index 125dc626..7d9e33a5 100644 --- a/client/src/components/Organism/TradeListBox/index.jsx +++ b/client/src/components/Organism/TradeListBox/index.jsx @@ -40,8 +40,9 @@ const OptionPriceCheck = styled.div` const Component = props => { const [isHover, setIsHover] = useState(false); const [rateCheck, setRateCheck] = useState(false); - let soldDate = toFormatDateTime(props.solddate); - + let soldDate = props.solddate + ? toFormatDateTime(props.solddate) + : toFormatDateTime(props.registdate); function doCheck() { setRateCheck(true); } @@ -53,7 +54,9 @@ const Component = props => { title={props.title} thumbnail={props.thumbnail} status={props.status} - price={convert2Price(props.soldprice)} + price={ + props.soldprice ? convert2Price(props.soldprice) : convert2Price(props.immediatePrice) + } time={soldseconds} /> @@ -82,7 +85,7 @@ const Component = props => { /> - ) : ( + ) : props.status === "판매" ? (
{rateCheck || props.buyerCheck ? ( "평가완료" @@ -102,6 +105,8 @@ const Component = props => { />
+ ) : ( + undefined )}
diff --git a/client/src/pages/TradeList/index.jsx b/client/src/pages/TradeList/index.jsx index c3ca5104..ebd52694 100644 --- a/client/src/pages/TradeList/index.jsx +++ b/client/src/pages/TradeList/index.jsx @@ -103,19 +103,26 @@ function TradeList() { .then(result => { let resultData = result[0].map(ele => { let hope_price_check = ele.hopePrice ? ele.hopePrice : undefined; + let sold_price_check = ele.soldPrice ? ele.soldPrice : undefined; + let sold_date_check = ele.soldDate ? ele.soldDate : undefined; + let buyer_id_check = ele.buyerId ? ele.buyerId : undefined; + return { id: ele.id, title: ele.title, thumbnail: ele.thumbnailUrl, - status: ele.seller.id === user.id ? "판매" : "구매", - soldprice: ele.soldPrice, - solddate: ele.soldDate, + status: ele.seller.id === user.id ? (sold_price_check ? "판매" : "판매실패") : "구매", + soldprice: sold_price_check, + solddate: sold_date_check, registdate: ele.registerDate, hopeprice: hope_price_check, - deviation: (((ele.soldPrice - hope_price_check) / hope_price_check) * 100).toFixed(2), + deviation: (((sold_price_check - hope_price_check) / hope_price_check) * 100).toFixed( + 2 + ), + immediatePrice: ele.immediatePrice, userId: user.id, - targetId: ele.seller.id === user.id ? ele.buyerId : ele.seller.id, + targetId: ele.seller.id === user.id ? buyer_id_check : ele.seller.id, sellerCheck: ele.sellerCheck, buyerCheck: ele.buyerCheck diff --git a/server/src/controllers/api/LogController.ts b/server/src/controllers/api/LogController.ts index 137a93b4..fc353d57 100644 --- a/server/src/controllers/api/LogController.ts +++ b/server/src/controllers/api/LogController.ts @@ -22,7 +22,7 @@ export class LogController { } else if (isSale) { return this.logService.findSellLog(userid, dayago, page, limit); } else { - return [[], [0]]; + return this.logService.findFailLog(userid, dayago, page, limit); } } } diff --git a/server/src/repositories/LogRepository.ts b/server/src/repositories/LogRepository.ts index 147d6214..6e823996 100644 --- a/server/src/repositories/LogRepository.ts +++ b/server/src/repositories/LogRepository.ts @@ -1,5 +1,5 @@ -import { EntityRepository, EntityManager, MoreThanOrEqual } from "typeorm"; -import { prevDay } from "../util/DateUtils"; +import { EntityRepository, EntityManager, MoreThanOrEqual, IsNull, Between } from "typeorm"; +import { prevDay, Today } from "../util/DateUtils"; import { Products } from "../models/Products"; @EntityRepository() @@ -38,6 +38,23 @@ export class LogRepository { }); } + public findFail(userid: number, dayago: number, page: number, limit: number) { + return this.em.findAndCount(Products, { + relations: ["seller"], + where: { + soldDate: IsNull(), + extensionDate: Between(prevDay(dayago), Today()), + seller: { id: userid } + }, + order: { + registerDate: "DESC" + }, + skip: (page - 1) * limit, + take: limit, + cache: true + }); + } + public findAll(userid: number, dayago: number, page: number, limit: number) { return this.em.findAndCount(Products, { relations: ["seller"], diff --git a/server/src/services/LogService.ts b/server/src/services/LogService.ts index 98e7d80b..4930a3d5 100644 --- a/server/src/services/LogService.ts +++ b/server/src/services/LogService.ts @@ -1,7 +1,6 @@ import { Service } from "typedi"; import { LogRepository } from "../repositories/LogRepository"; import { InjectRepository } from "typeorm-typedi-extensions"; -import { Products } from "../models/Products"; /** TODO: Transaction을 어떻게 처리해야 좋을까? */ @Service() @@ -19,4 +18,7 @@ export class LogService { public findAllLog(userid: number, dayago: number, page: number, limit: number) { return this.LogRepository.findAll(userid, dayago, page, limit); } + public findFailLog(userid: number, dayago: number, page: number, limit: number) { + return this.LogRepository.findFail(userid, dayago, page, limit); + } } From fb6051ac4a21ef1019cbd9e4a1d9e046a23fe274 Mon Sep 17 00:00:00 2001 From: deokisys Date: Thu, 19 Dec 2019 19:11:10 +0900 Subject: [PATCH 2/2] Fix bug buyproduct, myitems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 구매한 상품에대해 평가버튼이 나오도록 수정, 안팔리고 시간이 지난 상품이 경매중상품에 안나오도록 수정 --- client/src/components/Organism/TradeListBox/index.jsx | 2 +- server/src/repositories/ProductRepository.ts | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/client/src/components/Organism/TradeListBox/index.jsx b/client/src/components/Organism/TradeListBox/index.jsx index 7d9e33a5..93f0def0 100644 --- a/client/src/components/Organism/TradeListBox/index.jsx +++ b/client/src/components/Organism/TradeListBox/index.jsx @@ -85,7 +85,7 @@ const Component = props => { /> - ) : props.status === "판매" ? ( + ) : props.status === "구매" ? (
{rateCheck || props.buyerCheck ? ( "평가완료" diff --git a/server/src/repositories/ProductRepository.ts b/server/src/repositories/ProductRepository.ts index 98a4578d..259c429a 100644 --- a/server/src/repositories/ProductRepository.ts +++ b/server/src/repositories/ProductRepository.ts @@ -5,7 +5,8 @@ import { Not, IsNull, MoreThan, - MoreThanOrEqual + MoreThanOrEqual, + LessThan } from "typeorm"; import { ProductsDTO } from "../dto/ProductDTO"; import { Products } from "../models/Products"; @@ -50,8 +51,8 @@ export class ProductRepository { select: ["id", "title", "thumbnailUrl", "immediatePrice", "registerDate"], where: { seller: userId, - soldDate: null, - auctionDeadline: MoreThanOrEqual(new Date()) + soldDate: IsNull(), + extensionDate: MoreThan(Today()) }, order: { id: "DESC"