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 @@