From 62982d7ffb1203ab6ae12abd544266f16c35c771 Mon Sep 17 00:00:00 2001 From: hide_d Date: Mon, 24 Jan 2022 05:41:24 +0900 Subject: [PATCH] =?UTF-8?q?feat(WIP):=20=EB=B2=A0=ED=8C=85=20=EC=83=81?= =?UTF-8?q?=EC=84=B8=20=EC=A0=95=EB=B3=B4=20=EB=B0=98=ED=99=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hwe/sammo/API/NationBetting/BetNation.php | 6 +- .../API/NationBetting/GetBettingDetail.php | 98 +++++++++++++++++++ .../API/NationBetting/GetBettingList.php | 4 +- 3 files changed, 103 insertions(+), 5 deletions(-) create mode 100644 hwe/sammo/API/NationBetting/GetBettingDetail.php diff --git a/hwe/sammo/API/NationBetting/BetNation.php b/hwe/sammo/API/NationBetting/BetNation.php index e3bf85b4..40f3b6f4 100644 --- a/hwe/sammo/API/NationBetting/BetNation.php +++ b/hwe/sammo/API/NationBetting/BetNation.php @@ -1,6 +1,6 @@ increaseVar('gold', -$amount); } - $db->insert('ng_betting', $bettingItem->toArray()); + $db->insertUpdate('ng_betting', $bettingItem->toArray()); if(!$db->affected_rows){ $general->flushUpdateValues(); return '베팅을 실패했습니다.'; diff --git a/hwe/sammo/API/NationBetting/GetBettingDetail.php b/hwe/sammo/API/NationBetting/GetBettingDetail.php new file mode 100644 index 00000000..e3a4d5e8 --- /dev/null +++ b/hwe/sammo/API/NationBetting/GetBettingDetail.php @@ -0,0 +1,98 @@ +args); + $v->rule('required', [ + 'betting_id', + ]) + ->rule('integer', 'betting_id'); + + if (!$v->validate()) { + return $v->errorStr(); + } + return null; + } + + public function getRequiredSessionMode(): int + { + return static::REQ_GAME_LOGIN | static::REQ_READ_ONLY; + } + + public function launch(Session $session, ?DateTimeInterface $modifiedSince, ?string $reqEtag) + { + $db = DB::db(); + + increaseRefresh("국가베팅장", 1); + /** @var int */ + $bettingID = $this->arg['betting_id']; + + $gameStor = KVStorage::getStorage($db, 'game_env'); + $nationBettingStor = KVStorage::getStorage($db, 'nation_betting'); + $rawBettingInfo = $nationBettingStor->getValue("id_{$bettingID}"); + if($rawBettingInfo === null){ + return '해당 베팅이 없습니다'; + } + + try{ + $bettingInfo = new NationBettingInfo($rawBettingInfo); + } + catch(\Error $e){ + return $e->getMessage(); + } + + [$year, $month] = $gameStor->getValuesAsArray(['year', 'month']); + + $bettingDetail = []; + + foreach ($db->queryAllLists( + 'SELECT betting_type, sum(amount) as sum_amount FROM ng_betting WHERE betting_id = %i GROUP BY betting_type', + $bettingID + ) as [$bettingType, $amount]) { + $bettingDetail[] = [$bettingType, $amount]; + } + + [$year, $month] = $gameStor->getValuesAsArray(['year', 'month']); + + $myBetting = []; + foreach($db->queryAllLists( + 'SELECT betting_type, sum(amount) as sum_amount FROM ng_betting WHERE betting_id = %i AND user_id = %i GROUP BY betting_type', + $bettingID, $session->userID + ) as [$bettingType, $amount]){ + $myBetting[] = [$bettingType, $amount]; + } + + $general = General::createGeneralObjFromDB($session->generalID, ['gold', 'aux'], 1); + + if($bettingInfo->reqInheritancePoint){ + $remainPoint = $general->getInheritancePoint('previous'); + } + else{ + $remainPoint = $general->getVar('gold'); + } + + return [ + 'result' => false, + 'bettingInfo' => $rawBettingInfo, + 'bettingDetail' => $bettingDetail, + 'myBetting' => $myBetting, + 'remainPoint' => $remainPoint, + 'year' => $year, + 'month' => $month, + ]; + } +} diff --git a/hwe/sammo/API/NationBetting/GetBettingList.php b/hwe/sammo/API/NationBetting/GetBettingList.php index efb400d1..8f3bf0b2 100644 --- a/hwe/sammo/API/NationBetting/GetBettingList.php +++ b/hwe/sammo/API/NationBetting/GetBettingList.php @@ -1,6 +1,6 @@