1
This commit is contained in:
parent
3e3ab9cb00
commit
fcb7c02a54
@ -96,6 +96,7 @@ CREATE TABLE `supplybox` (
|
||||
`box_id` int(11) NOT NULL COMMENT '补给箱id',
|
||||
`box_num` int(11) NOT NULL COMMENT '补给箱数量',
|
||||
`buy_times` int(11) NOT NULL COMMENT '购买次数',
|
||||
`last_buy_time` varchar(50) NOT NULL DEFAULT '最后一次购买',
|
||||
PRIMARY KEY (`idx`),
|
||||
KEY `accountid` (`accountid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
@ -206,10 +206,6 @@ class SupplyBoxController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 2, '没有这个宝箱');
|
||||
return;
|
||||
}
|
||||
if ($coin_num < 5) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
|
||||
return;
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT * FROM supplybox WHERE accountid=:account_id AND box_id=:box_id',
|
||||
array(
|
||||
':account_id' => $account_id,
|
||||
@ -220,32 +216,53 @@ class SupplyBoxController{
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
|
||||
return;
|
||||
}
|
||||
$ret = $conn->execScript('INSERT INTO supplybox(accountid, box_id, box_num, buy_times) ' .
|
||||
' VALUES(:accountid, :box_id, :box_num, :buy_times);',
|
||||
$ret = $conn->execScript('INSERT INTO supplybox(accountid, box_id, box_num, buy_times, last_buy_time) ' .
|
||||
' VALUES(:accountid, :box_id, :box_num, :buy_times, :last_buy_time);',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':box_id' => $box_id,
|
||||
':box_num' => 1,
|
||||
':buy_times' => 1
|
||||
':buy_times' => 1,
|
||||
':last_buy_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if ($coin_num < $s['price'] * pow($s['parameter'], ($row['box_num'] - 1))) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
|
||||
return;
|
||||
if (phpcommon\getdayseconds(time()) - phpcommon\getdayseconds($row['time']) > 0) {
|
||||
$ret = $conn->execScript('UPDATE supplybox SET buy_times=:buy_times, last_buy_time=:time ' .
|
||||
' WHERE accountid=:accountid AND box_id=:box_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':box_id' => $box_id,
|
||||
':buy_times' => 0,
|
||||
':time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
if ($coin_num < $s['price']) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if ($coin_num < $s['price'] * pow($s['parameter'], ($row['box_num'] - 1))) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 3, '金币不足');
|
||||
return;
|
||||
}
|
||||
}
|
||||
$box_num = $row['box_num'] + 1;
|
||||
$buy_times = $row['buy_times'] + 1;
|
||||
$ret = $conn->execScript('UPDATE supplybox SET box_num=:box_num, buy_times=:buy_times ' .
|
||||
$ret = $conn->execScript('UPDATE supplybox SET box_num=:box_num, buy_times=:buy_times, last_buy_time=:time ' .
|
||||
' WHERE accountid=:accountid AND box_id=:box_id;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':box_id' => $box_id,
|
||||
':box_num' => $box_num,
|
||||
':buy_times' => $buy_times
|
||||
':buy_times' => $buy_times,
|
||||
':time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
|
Loading…
x
Reference in New Issue
Block a user