Skip to content

Commit

Permalink
Merge pull request #330 from deokisys/develop
Browse files Browse the repository at this point in the history
Fix tradelist fail, myitems
  • Loading branch information
deokisys authored Dec 19, 2019
2 parents 8849532 + 405e03b commit 0841c70
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 16 deletions.
13 changes: 9 additions & 4 deletions client/src/components/Organism/TradeListBox/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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}
/>
<TradeContents isHover={isHover}>
Expand Down Expand Up @@ -82,7 +85,7 @@ const Component = props => {
/>
<ReportButton userId={props.targetId} productId={props.id} text={"구매자 신고"} />
</div>
) : (
) : props.status === "구매" ? (
<div>
{rateCheck || props.buyerCheck ? (
"평가완료"
Expand All @@ -102,6 +105,8 @@ const Component = props => {
/>
<ReportButton userId={props.targetId} productId={props.id} text={"판매자 신고"} />
</div>
) : (
undefined
)}
</TradeContents>
</div>
Expand Down
17 changes: 12 additions & 5 deletions client/src/pages/TradeList/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion server/src/controllers/api/LogController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
21 changes: 19 additions & 2 deletions server/src/repositories/LogRepository.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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"],
Expand Down
7 changes: 4 additions & 3 deletions server/src/repositories/ProductRepository.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
Not,
IsNull,
MoreThan,
MoreThanOrEqual
MoreThanOrEqual,
LessThan
} from "typeorm";
import { ProductsDTO } from "../dto/ProductDTO";
import { Products } from "../models/Products";
Expand Down Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion server/src/services/LogService.ts
Original file line number Diff line number Diff line change
@@ -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()
Expand All @@ -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);
}
}

0 comments on commit 0841c70

Please sign in to comment.