feat: 베팅시 유산포인트 로그에 추가
This commit is contained in:
@@ -10,10 +10,9 @@ use sammo\DTO\BettingItem;
|
|||||||
use sammo\Validator;
|
use sammo\Validator;
|
||||||
use sammo\GameConst;
|
use sammo\GameConst;
|
||||||
use sammo\KVStorage;
|
use sammo\KVStorage;
|
||||||
|
use sammo\UserLogger;
|
||||||
use sammo\Util;
|
use sammo\Util;
|
||||||
|
|
||||||
use function sammo\getAllNationStaticInfo;
|
|
||||||
|
|
||||||
class Bet extends \sammo\BaseAPI
|
class Bet extends \sammo\BaseAPI
|
||||||
{
|
{
|
||||||
public function validateArgs(): ?string
|
public function validateArgs(): ?string
|
||||||
@@ -56,7 +55,7 @@ class Bet extends \sammo\BaseAPI
|
|||||||
$bettingHelper = new Betting($bettingID);
|
$bettingHelper = new Betting($bettingID);
|
||||||
$bettingInfo = $bettingHelper->getInfo();
|
$bettingInfo = $bettingHelper->getInfo();
|
||||||
|
|
||||||
if($bettingInfo->finished){
|
if ($bettingInfo->finished) {
|
||||||
return '이미 종료된 베팅입니다';
|
return '이미 종료된 베팅입니다';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -64,15 +63,15 @@ class Bet extends \sammo\BaseAPI
|
|||||||
$yearMonth = Util::joinYearMonth($year, $month);
|
$yearMonth = Util::joinYearMonth($year, $month);
|
||||||
|
|
||||||
|
|
||||||
if($bettingInfo->closeYearMonth <= $yearMonth){
|
if ($bettingInfo->closeYearMonth <= $yearMonth) {
|
||||||
return '이미 마감된 베팅입니다';
|
return '이미 마감된 베팅입니다';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($bettingInfo->openYearMonth > $yearMonth){
|
if ($bettingInfo->openYearMonth > $yearMonth) {
|
||||||
return '아직 시작되지 않은 베팅입니다';
|
return '아직 시작되지 않은 베팅입니다';
|
||||||
}
|
}
|
||||||
|
|
||||||
if(count($bettingType) != $bettingInfo->selectCnt){
|
if (count($bettingType) != $bettingInfo->selectCnt) {
|
||||||
return '필요한 선택 수를 채우지 못했습니다.';
|
return '필요한 선택 수를 채우지 못했습니다.';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,19 +81,18 @@ class Bet extends \sammo\BaseAPI
|
|||||||
|
|
||||||
$prevBetAmount = $db->queryFirstField('SELECT sum(amount) FROM ng_betting WHERE betting_id = %i AND user_id = %i', $bettingID, $session->userID) ?? 0;
|
$prevBetAmount = $db->queryFirstField('SELECT sum(amount) FROM ng_betting WHERE betting_id = %i AND user_id = %i', $bettingID, $session->userID) ?? 0;
|
||||||
|
|
||||||
if($prevBetAmount + $amount > 1000){
|
if ($prevBetAmount + $amount > 1000) {
|
||||||
return (1000 - $prevBetAmount).' 포인트까지만 베팅 가능합니다.';
|
return (1000 - $prevBetAmount) . ' 포인트까지만 베팅 가능합니다.';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($bettingInfo->reqInheritancePoint){
|
if ($bettingInfo->reqInheritancePoint) {
|
||||||
$remainPoint = ($inheritStor->getValue('previous') ?? [0,0])[0];
|
$remainPoint = ($inheritStor->getValue('previous') ?? [0, 0])[0];
|
||||||
if($remainPoint < $amount){
|
if ($remainPoint < $amount) {
|
||||||
return '유산포인트가 충분하지 않습니다.';
|
return '유산포인트가 충분하지 않습니다.';
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
$remainPoint = $db->queryFirstField('SELECT gold FROM general WHERE no = %i', $session->generalID) ?? 0;
|
||||||
$remainPoint = $db->queryFirstField('SELECT gold FROM general WHERE no = %i', $session->generalID)??0;
|
if ($remainPoint < GameConst::$generalMinimumGold + $amount) {
|
||||||
if($remainPoint < GameConst::$generalMinimumGold + $amount){
|
|
||||||
return '금이 부족합니다.';
|
return '금이 부족합니다.';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -102,31 +100,34 @@ class Bet extends \sammo\BaseAPI
|
|||||||
$userID = $session->userID;
|
$userID = $session->userID;
|
||||||
|
|
||||||
$bettingItem = new BettingItem([
|
$bettingItem = new BettingItem([
|
||||||
'betting_id'=>$bettingID,
|
'betting_id' => $bettingID,
|
||||||
'general_id'=>$session->generalID,
|
'general_id' => $session->generalID,
|
||||||
'user_id'=>$userID,
|
'user_id' => $userID,
|
||||||
'betting_type'=>$bettingTypeKey,
|
'betting_type' => $bettingTypeKey,
|
||||||
'amount'=>$amount
|
'amount' => $amount
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$db->insertUpdate(
|
$db->insertUpdate(
|
||||||
'ng_betting',
|
'ng_betting',
|
||||||
$bettingItem->toArray(),
|
$bettingItem->toArray(),
|
||||||
['amount' => $db->sqleval('amount + %i', $amount)]
|
['amount' => $db->sqleval('amount + %i', $amount)]
|
||||||
); if($bettingInfo->reqInheritancePoint){
|
);
|
||||||
|
if ($bettingInfo->reqInheritancePoint) {
|
||||||
$inheritStor->setValue('previous', [$remainPoint - $amount, null]);
|
$inheritStor->setValue('previous', [$remainPoint - $amount, null]);
|
||||||
}
|
$userLogger = new UserLogger($userID);
|
||||||
else{
|
$userLogger->push("{$amount} 포인트를 베팅에 사용", "inheritPoint");
|
||||||
|
$userLogger->flush();
|
||||||
|
} else {
|
||||||
$db->update('general', [
|
$db->update('general', [
|
||||||
'gold' => $db->sqleval('gold - %i', $amount)
|
'gold' => $db->sqleval('gold - %i', $amount)
|
||||||
], 'no = %i', $session->generalID);
|
], 'no = %i', $session->generalID);
|
||||||
}
|
}
|
||||||
if(!$db->affected_rows){
|
if (!$db->affected_rows) {
|
||||||
return '베팅을 실패했습니다.';
|
return '베팅을 실패했습니다.';
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'result'=>true
|
'result' => true
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,8 +78,10 @@
|
|||||||
<div class="col-2 text-end">{{ amount.toLocaleString() }}</div>
|
<div class="col-2 text-end">{{ amount.toLocaleString() }}</div>
|
||||||
<div
|
<div
|
||||||
class="col-3 text-center"
|
class="col-3 text-center"
|
||||||
>{{ myBettings.has(betType) ? `(${myBettings.get(betType)?.toLocaleString()} -> ${((myBettings.get(betType)??0) * bettingAmount / amount).toLocaleString()})` : '' }}</div>
|
>{{ myBettings.has(betType) ? `(${myBettings.get(betType)?.toLocaleString()} -> ${((myBettings.get(betType) ?? 0) * bettingAmount / amount / ((info.isExclusive && info.selectCnt > 1) ? 1 : 2)).toLocaleString()})` : '' }}</div>
|
||||||
<div class="col-2 text-end">{{ (bettingAmount / amount).toFixed(1) }}배</div>
|
<div
|
||||||
|
class="col-2 text-end"
|
||||||
|
>{{ (bettingAmount / amount / ((info.isExclusive && info.selectCnt > 1) ? 1 : 2)).toFixed(1) }}배</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
@@ -130,10 +132,12 @@ type BettingInfo = {
|
|||||||
name: string;
|
name: string;
|
||||||
finished: boolean;
|
finished: boolean;
|
||||||
selectCnt: number;
|
selectCnt: number;
|
||||||
|
isExclusive?: boolean;
|
||||||
reqInheritancePoint: boolean;
|
reqInheritancePoint: boolean;
|
||||||
openYearMonth: number;
|
openYearMonth: number;
|
||||||
closeYearMonth: number;
|
closeYearMonth: number;
|
||||||
candidates: SelectItem[];
|
candidates: SelectItem[];
|
||||||
|
winner?: number[];
|
||||||
}
|
}
|
||||||
|
|
||||||
type BettingListResponse = ValidResponse & {
|
type BettingListResponse = ValidResponse & {
|
||||||
|
|||||||
Reference in New Issue
Block a user