feat,wip: 경매장 API 작성
This commit is contained in:
@@ -14,6 +14,9 @@ use sammo\RandUtil;
|
||||
|
||||
class AuctionUniqueItem extends Auction
|
||||
{
|
||||
|
||||
static AuctionType $auctionType = AuctionType::UniqueItem;
|
||||
|
||||
static public function genObfuscatedName(int $id): string
|
||||
{
|
||||
$db = DB::db();
|
||||
@@ -131,7 +134,7 @@ class AuctionUniqueItem extends Auction
|
||||
}
|
||||
$auction = new static($auctionID, $general);
|
||||
try {
|
||||
$auction->bid($startAmount);
|
||||
$auction->bid($startAmount, false);
|
||||
} catch (\Exception $e) {
|
||||
//실패해선 안된다.
|
||||
$msg = $e->getMessage();
|
||||
@@ -147,7 +150,7 @@ class AuctionUniqueItem extends Auction
|
||||
// 유니크 옥션의 개최자는 운영자이므로 할 일이 없다.
|
||||
}
|
||||
|
||||
public function bid(int $amount, bool $tryExtendCloseDate = false): ?string
|
||||
public function bid(int $amount, bool $tryExtendCloseDate): ?string
|
||||
{
|
||||
|
||||
$db = DB::db();
|
||||
@@ -157,10 +160,21 @@ class AuctionUniqueItem extends Auction
|
||||
AuctionType::UniqueItem->value
|
||||
) ?? []);
|
||||
|
||||
$auctionIDList = [];
|
||||
foreach($openUniqueAuctions as $auction){
|
||||
$auctionIDList[] = $auction->id;
|
||||
}
|
||||
$db = DB::db();
|
||||
$rawHighestBids = Util::convertArrayToDict($db->queryFirstRow(
|
||||
'SELECT * FROM ng_auction_bid WHERE auction_id IN %i ORDER BY `amount` DESC LIMIT 1',
|
||||
$this->info->id
|
||||
$rawHighestBids = Util::convertArrayToDict($db->query(
|
||||
'SELECT bid.* FROM `ng_auction_bid` bid INNER JOIN (
|
||||
SELECT `auction_id`, MAX(`amount`) as `max_amount`
|
||||
FROM `ng_auction_bid`
|
||||
WHERE `auction_id` IN %li
|
||||
GROUP BY `auction_id`
|
||||
ORDER BY `amount`
|
||||
) AS max_bid
|
||||
ON bid.`auction_id` = max_bid.`auction_id` AND bid.`amount` = max_bid.`max_amount`',
|
||||
$auctionIDList,
|
||||
) ?? [], 'auction_id');
|
||||
/** @var array<int,AuctionBidItem> */
|
||||
$highestBids = Util::mapWithKey(
|
||||
|
||||
Reference in New Issue
Block a user