This commit is contained in:
aozhiwei 2024-07-31 13:57:49 +08:00
parent 82ebb29620
commit c8bd67d489
2 changed files with 58 additions and 2 deletions

View File

@ -1981,10 +1981,10 @@ DROP TABLE IF EXISTS `t_box_alloc`;
CREATE TABLE `t_box_alloc` (
`idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id',
`room_uuid` varchar(60) NOT NULL COMMENT '公告标题',
`account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id',
`account_id` varchar(60) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT 'account_id',
`used_num` int(11) NOT NULL DEFAULT '0' COMMENT '已消耗的箱子数',
`box_num` int(11) NOT NULL DEFAULT '0' COMMENT '分配的箱子数',
`return_account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'return_account_id',
`return_account_id` varchar(60) CHARACTER SET utf8 NOT NULL DEFAULT '' COMMENT 'return_account_id',
`return_time` int(11) NOT NULL DEFAULT '0' COMMENT '返回时间',
`createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',

View File

@ -19,6 +19,7 @@ require_once('mt/RankSeason.php');
require_once('mt/Robot.php');
require_once('mt/Skill.php');
require_once('mt/MapMode.php');
require_once('mt/Parameter.php');
use phpcommon\SqlHelper;
use models\Hero;
@ -1196,6 +1197,56 @@ class BattleController extends BaseAuthedController {
{
error_log(json_encode($_REQUEST));
$roomUuid = getReqVal('room_uuid', '');
$row = SqlHelper::ormSelectOne(
$this->_getSelfMysql(),
't_box_alloc',
array(
'room_uuid' => $roomUuid,
)
);
$boxNum = 0;
if (!empty($row)) {
if ($row['createtime'] > myself()->_getNowDaySeconds()) {
$boxNum = $row['box_num'];
}
myself()->_rspData(array(
'box_num' => $boxNum
));
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(),
)
);
myself()->_rspData(array(
'box_num' => $boxNum
));
return;
}
public function requestReturnBoxNum()
@ -1206,4 +1257,9 @@ class BattleController extends BaseAuthedController {
$allocBoxNum = getReqVal('alloc_box_num', 0);
}
private function getAlreadyAllocBoxNum()
{
}
}