feat,fix,wip: 버그 수정, 연장 시간 로직 변경
This commit is contained in:
+72
-22
@@ -21,7 +21,7 @@ abstract class Auction
|
||||
static AuctionType $auctionType;
|
||||
|
||||
public const COEFF_AUCTION_CLOSE_MINUTES = 24;
|
||||
public const COEFF_EXTENSION_MINUTES_PER_BID = 1 / 6;
|
||||
public const COEFF_EXTENSION_MINUTES_PER_BID = (1 / 6);
|
||||
public const COEFF_EXTENSION_MINUTES_LIMIT_BY_BID = 1;
|
||||
public const COEFF_EXTENSION_MINUTES_BY_EXTENSION_QUERY = 1;
|
||||
public const MIN_AUCTION_CLOSE_MINUTES = 30;
|
||||
@@ -157,32 +157,55 @@ abstract class Auction
|
||||
return null;
|
||||
}
|
||||
|
||||
public function extendLatestBidCloseDate(?DateTimeInterface $date): ?string
|
||||
{
|
||||
if ($date === null) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$turnTerm = $gameStor->getValue('turnterm');
|
||||
$date = $this->info->closeDate->add(TimeUtil::secondsToDateInterval(
|
||||
max(static::MIN_EXTENSION_MINUTES_PER_BID, $turnTerm * static::COEFF_EXTENSION_MINUTES_PER_BID) * 60
|
||||
));
|
||||
}
|
||||
else{
|
||||
$date = DateTimeImmutable::createFromInterface($date);
|
||||
}
|
||||
if ($this->info->detail->availableLatestBidCloseDate !== null && $date < $this->info->detail->availableLatestBidCloseDate) {
|
||||
return '기간보다 짧습니다.';
|
||||
}
|
||||
$this->info->detail->availableLatestBidCloseDate = $date;
|
||||
return null;
|
||||
}
|
||||
|
||||
public function extendCloseDate(DateTimeInterface $date, bool $force = false): ?string
|
||||
{
|
||||
if (!$force) {
|
||||
if ($this->info->remainCloseExtensionCnt === null) {
|
||||
if ($this->info->detail->remainCloseDateExtensionCnt === null) {
|
||||
return '연장할 수 없는 경매입니다.';
|
||||
}
|
||||
if ($this->info->remainCloseExtensionCnt === 0) {
|
||||
if ($this->info->detail->remainCloseDateExtensionCnt === 0) {
|
||||
return '더 이상 연장할 수 없습니다';
|
||||
}
|
||||
if ($this->info->remainCloseExtensionCnt > 0) {
|
||||
$this->info->remainCloseExtensionCnt--;
|
||||
if ($this->info->detail->remainCloseDateExtensionCnt > 0) {
|
||||
$this->info->detail->remainCloseDateExtensionCnt--;
|
||||
}
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$turnTerm = $gameStor->getValue('turnterm');
|
||||
if ($date < $this->info->closeDate) {
|
||||
return '종료 기간보다 짧습니다.';
|
||||
}
|
||||
|
||||
$closeDate = DateTimeImmutable::createFromInterface($date);
|
||||
$this->info->closeDate = $closeDate;
|
||||
$this->info->availableLatestBidCloseDate = $closeDate->add(TimeUtil::secondsToDateInterval(
|
||||
max(static::MIN_EXTENSION_MINUTES_PER_BID, $turnTerm * static::COEFF_EXTENSION_MINUTES_PER_BID) * 60
|
||||
));
|
||||
$db->update('ng_auction', $this->info->toArray('id'), 'id = %i', $this->info->id);
|
||||
return null;
|
||||
}
|
||||
|
||||
public function applyDB(): void
|
||||
{
|
||||
$db = DB::db();
|
||||
$db->update('ng_auction', $this->info->toArray('id'), 'id = %i', $this->info->id);
|
||||
}
|
||||
|
||||
public function refundBid(AuctionBidItem $bidItem, string $reason): void
|
||||
{
|
||||
if ($bidItem->auctionID !== $this->info->id) {
|
||||
@@ -190,7 +213,7 @@ abstract class Auction
|
||||
}
|
||||
|
||||
$db = DB::db();
|
||||
if ($bidItem->generalID === $this->general->generalID) {
|
||||
if ($bidItem->generalID === $this->general->getID()) {
|
||||
$oldBidder = $this->general;
|
||||
} else {
|
||||
$oldBidder = General::createGeneralObjFromDB($bidItem->generalID);
|
||||
@@ -198,10 +221,15 @@ abstract class Auction
|
||||
|
||||
if ($this->info->reqResource === ResourceType::inheritancePoint) {
|
||||
$oldBidder->increaseInheritancePoint(InheritanceKey::previous, $bidItem->amount);
|
||||
$oldBidder->increaseRankVar(RankColumn::inherit_point_spent_dynamic, -$bidItem->amount);
|
||||
} else {
|
||||
$oldBidder->increaseVar($this->info->reqResource->value, $bidItem->amount);
|
||||
}
|
||||
|
||||
if ($oldBidder instanceof DummyGeneral) {
|
||||
return;
|
||||
}
|
||||
|
||||
$staticNation = $oldBidder->getStaticNation();
|
||||
$src = new MessageTarget(0, '', 0, 'System', '#000000');
|
||||
$dest = new MessageTarget(
|
||||
@@ -258,7 +286,7 @@ abstract class Auction
|
||||
}
|
||||
|
||||
$myPrevBid = $this->getMyPrevBid();
|
||||
if($myPrevBid !== null && $highestBid->no !== $myPrevBid->no){
|
||||
if ($myPrevBid !== null && $highestBid->no !== $myPrevBid->no) {
|
||||
//이미 환불 받았으니 무효.
|
||||
$myPrevBid = null;
|
||||
}
|
||||
@@ -293,13 +321,14 @@ abstract class Auction
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$turnTerm = $gameStor->getValue('turnterm');
|
||||
|
||||
if ($this->info->availableLatestBidCloseDate !== null) {
|
||||
$extendedCloseDate = $this->info->closeDate->add(TimeUtil::secondsToDateInterval(
|
||||
if ($this->info->detail->availableLatestBidCloseDate !== null) {
|
||||
$extendedCloseDate = $now->add(TimeUtil::secondsToDateInterval(
|
||||
max(static::MIN_EXTENSION_MINUTES_PER_BID, $turnTerm * static::COEFF_EXTENSION_MINUTES_PER_BID) * 60
|
||||
));
|
||||
|
||||
if ($extendedCloseDate > $this->info->closeDate && $this->info->closeDate < $this->info->availableLatestBidCloseDate) {
|
||||
$this->extendCloseDate(min($extendedCloseDate, $this->info->availableLatestBidCloseDate));
|
||||
if ($extendedCloseDate > $this->info->closeDate && $this->info->closeDate < $this->info->detail->availableLatestBidCloseDate) {
|
||||
$this->extendCloseDate(min($extendedCloseDate, $this->info->detail->availableLatestBidCloseDate), true);
|
||||
$this->applyDB();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -332,11 +361,11 @@ abstract class Auction
|
||||
}
|
||||
|
||||
if (!$auctionInfo->detail->isReverse) {
|
||||
if ($auctionInfo->buyImmediatelyAmount !== null && $auctionInfo->buyImmediatelyAmount < $amount) {
|
||||
if ($auctionInfo->detail->finishBidAmount !== null && $auctionInfo->detail->finishBidAmount < $amount) {
|
||||
return '즉시판매가보다 높을 수 없습니다.';
|
||||
}
|
||||
} else {
|
||||
if ($auctionInfo->buyImmediatelyAmount !== null && $auctionInfo->buyImmediatelyAmount > $amount) {
|
||||
if ($auctionInfo->detail->finishBidAmount !== null && $auctionInfo->detail->finishBidAmount > $amount) {
|
||||
return '즉시판매가보다 낮을 수 없습니다.';
|
||||
}
|
||||
}
|
||||
@@ -363,7 +392,7 @@ abstract class Auction
|
||||
|
||||
|
||||
$myPrevBid = $this->getMyPrevBid();
|
||||
if($myPrevBid !== null && $highestBid->no !== $myPrevBid->no){
|
||||
if ($myPrevBid !== null && $highestBid->no !== $myPrevBid->no) {
|
||||
//이미 환불 받았으니 무효.
|
||||
$myPrevBid = null;
|
||||
}
|
||||
@@ -402,6 +431,17 @@ abstract class Auction
|
||||
|
||||
$general->increaseVar($resType->value, -$morePoint);
|
||||
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$turnTerm = $gameStor->getValue('turnterm');
|
||||
$extendedCloseDate = $now->add(TimeUtil::secondsToDateInterval(
|
||||
max(static::MIN_EXTENSION_MINUTES_PER_BID, $turnTerm * static::COEFF_EXTENSION_MINUTES_PER_BID) * 60
|
||||
));
|
||||
|
||||
if ($extendedCloseDate > $this->info->closeDate) {
|
||||
$this->extendCloseDate($extendedCloseDate, true);
|
||||
$this->applyDB();
|
||||
}
|
||||
|
||||
if ($highestBid !== null && $myPrevBid === null) {
|
||||
$this->refundBid($highestBid, "{$auctionInfo->id}번 {$auctionInfo->detail->title}에 상회입찰자가 나타났습니다.");
|
||||
}
|
||||
@@ -424,12 +464,18 @@ abstract class Auction
|
||||
}
|
||||
|
||||
if ($highestBid->aux->tryExtendCloseDate) {
|
||||
$db = DB::db();
|
||||
$gameStor = KVStorage::getStorage($db, 'game_env');
|
||||
$turnTerm = $gameStor->getValue('turnterm');
|
||||
|
||||
//연장 요청이 있었다.
|
||||
$extendedCloseDate = $this->info->closeDate->add(TimeUtil::secondsToDateInterval(
|
||||
max(static::MIN_EXTENSION_MINUTES_BY_EXTENSION_QUERY, $this->info->turnTerm * static::COEFF_EXTENSION_MINUTES_BY_EXTENSION_QUERY) * 60
|
||||
max(static::MIN_EXTENSION_MINUTES_BY_EXTENSION_QUERY, $turnTerm * static::COEFF_EXTENSION_MINUTES_BY_EXTENSION_QUERY) * 60
|
||||
));
|
||||
|
||||
if ($this->extendCloseDate($extendedCloseDate) === null) {
|
||||
$this->extendLatestBidCloseDate(null);
|
||||
$this->applyDB();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -441,6 +487,10 @@ abstract class Auction
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($bidder instanceof DummyGeneral) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$staticNation = $bidder->getStaticNation();
|
||||
$src = new MessageTarget(0, '', 0, 'System', '#000000');
|
||||
$dest = new MessageTarget(
|
||||
|
||||
Reference in New Issue
Block a user