This commit is contained in:
aozhiwei 2024-10-09 15:03:03 +08:00
parent 8ae383cea8
commit 209b7ba3ff
2 changed files with 6 additions and 63 deletions

View File

@ -1309,15 +1309,7 @@ class BattleController extends BaseAuthedController {
$r->setPx(DEC_BATTLE_TICKET . $roomUuid, 1, 1000 * 3600);
}
public function requestAllocBoxNumNew() {
$boxNum = services\BattleBoxService::allocBox('');
myself()->_rspData(array(
'box_num' => $boxNum
));
}
public function requestAllocBoxNum()
{
public function requestAllocBoxNum() {
if (!myself()->_switchIsOpen('bigEventBoxDrop')) {
myself()->_rspData(array(
'box_num' => 0
@ -1332,7 +1324,6 @@ class BattleController extends BaseAuthedController {
'room_uuid' => $roomUuid,
)
);
$boxNum = 0;
if (!empty($row)) {
if ($row['createtime'] > myself()->_getNowDaySeconds()) {
$boxNum = $row['box_num'];
@ -1342,40 +1333,10 @@ class BattleController extends BaseAuthedController {
));
return;
}
$alreadyAllocBoxNum = $this->getAlreadyAllocBoxNum();
$dailyMaxNum = mt\Parameter::getVal('battle_event_loot_daily_max', 0);
$allocableNum = intval($dailyMaxNum - $alreadyAllocBoxNum);
$lstVal = mt\Parameter::getListValue('battle_event_loot_per_game');
if ($allocableNum <= 0 || empty($lstVal) || count($lstVal) < 2) {
myself()->_rspData(array(
'box_num' => 0
));
return;
}
$rnd = rand($lstVal[0], $lstVal[1]);
if ($rnd <= 0) {
myself()->_rspData(array(
'box_num' => 0
));
return;
}
$boxNum = min($rnd, $allocableNum);
SqlHelper::insert(
$this->_getSelfMysql(),
't_box_alloc',
array(
'room_uuid' => $roomUuid,
'account_id' => myself()->_getAccountId(),
'box_num' => $boxNum,
'createtime' => myself()->_getNowTime(),
'modifytime' => myself()->_getNowTime(),
)
);
$this->incAlreadyAllocBoxNum($boxNum);
$boxNum = services\BattleBoxService::allocBox($roomUuid);
myself()->_rspData(array(
'box_num' => $boxNum
));
return;
}
public function requestReturnBoxNum()
@ -1406,28 +1367,10 @@ class BattleController extends BaseAuthedController {
'return_time' => myself()->_getNowTime(),
)
);
$this->incAlreadyAllocBoxNum(-max(0, $allocBoxNum - $usedNum));
services\BattleBoxService::incAlreadyAllocBoxNum($row['phase'],
$row['createtime'],
-max(0, $allocBoxNum - $usedNum));
myself()->_rspOk();
}
private function getAlreadyAllocBoxNum()
{
$key = 'box_daily_already_alloc_num:' . myself()->_getNowDaySeconds();
$r = $this->_getRedis($key);
$num = $r->get($key);
return empty($num) ? 0 : $num;
}
private function incAlreadyAllocBoxNum($val)
{
$key = 'box_daily_already_alloc_num:' . myself()->_getNowDaySeconds();
$r = $this->_getRedis($key);
$num = intval($r->get($key));
if (empty($num)) {
$r->setPx($key, $val, 1000 * 3600 * 24 * 7);
} else {
$r->setPx($key, $num + $val, 1000 * 3600 * 24 * 7);
}
}
}

View File

@ -223,7 +223,7 @@ class BattleBoxService {
return empty($num) ? 0 : $num;
}
private static function incAlreadyAllocNum($phase, $time, $val)
public static function incAlreadyAllocNum($phase, $time, $val)
{
$key = self::DAILY_PHASE_ALREADY_ALLOC_NUM_KEY . $phase . ':' . $time;
$r = myself()->_getRedis($key);