1
This commit is contained in:
parent
a473ae2560
commit
dc09bfa3c4
@ -118,6 +118,22 @@ CREATE TABLE `sign` (
|
||||
PRIMARY KEY (`idx`),
|
||||
KEY `accountid` (`accountid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
|
||||
|
||||
--
|
||||
-- Table structure for table `hang`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `hang`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client*/;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `hang` (
|
||||
`idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id',
|
||||
`accountid` varchar(60) DEFAULT '' COMMENT '账号id',
|
||||
`hang_time` varchar(50) NOT NULL DEFAULT '领取时间',
|
||||
PRIMARY KEY (`idx`),
|
||||
KEY `accountid` (`accountid`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
|
||||
|
85
webapp/controller/HangController.class.php
Normal file
85
webapp/controller/HangController.class.php
Normal file
@ -0,0 +1,85 @@
|
||||
<?php
|
||||
|
||||
class HangController{
|
||||
|
||||
protected function getMysql($account_id)
|
||||
{
|
||||
$mysql_conf = getMysqlConfig(crc32($account_id));
|
||||
$conn = new phpcommon\Mysql(array(
|
||||
'host' => $mysql_conf['host'],
|
||||
'port' => $mysql_conf['port'],
|
||||
'user' => $mysql_conf['user'],
|
||||
'passwd' => $mysql_conf['passwd'],
|
||||
'dbname' => 'gamedb2001_' . $mysql_conf['instance_id']
|
||||
));
|
||||
return $conn;
|
||||
}
|
||||
|
||||
public function GetHangReward()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
$item_id = 0;
|
||||
$num = 0;
|
||||
$weight = $_REQUEST['weight'];
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
$row = $conn->execQueryOne('SELECT * FROM hang WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id
|
||||
));
|
||||
if (!$row) {
|
||||
$ret = $conn->execScript('INSERT INTO hang(accountid, hang_time) ' .
|
||||
' VALUES(:accountid, :hang_time);',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':hang_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$ret = $conn->execScript('UPDATE hang SET hang_time=:hang_time ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':hang_time' => time(),
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
$item_id = 1;
|
||||
$num = time() - $row['hang_time'];
|
||||
if ($weight != 0) {
|
||||
$num = $num * 3;
|
||||
}
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'item_id' => $item_id,
|
||||
'num' => $num,
|
||||
'time' => time()
|
||||
));
|
||||
}
|
||||
|
||||
public function GetTime()
|
||||
{
|
||||
$account_id = $_REQUEST['account_id'];
|
||||
$conn = $this->getMysql($account_id);
|
||||
if (!$conn) {
|
||||
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
|
||||
return;
|
||||
}
|
||||
echo json_encode(array(
|
||||
'errcode' => 0,
|
||||
'errmsg' => '',
|
||||
'time' => time()
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
@ -48,7 +48,7 @@ class SignController{
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':sign_days' => 1,
|
||||
':signable' => 1,
|
||||
':signable' => 0,
|
||||
':sign_time' => time()
|
||||
));
|
||||
if (!$ret) {
|
||||
@ -56,7 +56,7 @@ class SignController{
|
||||
return;
|
||||
}
|
||||
$sign_days = 1;
|
||||
$signable = 1;
|
||||
$signable = 0;
|
||||
//获得奖励
|
||||
$s = $this->getSign($sign_days + 90000);
|
||||
$item_id = $s['item_id'];
|
||||
@ -65,11 +65,13 @@ class SignController{
|
||||
if (phpcommon\getdayseconds(time()) - phpcommon\getdayseconds($row['sign_time']) > 0) {
|
||||
$sign_days = $row['sign_days'] + 1;
|
||||
$signable = 0;
|
||||
$ret = $conn->execScript('UPDATE sign SET sign_days=:sign_days, sign_time=:sign_time ' .
|
||||
$ret = $conn->execScript('UPDATE sign SET sign_days=:sign_days, sign_time=:sign_time, signable=:signable ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':sign_days' => $sign_days,
|
||||
':sign_time' => time()
|
||||
':sign_time' => time(),
|
||||
':signable' => $signable
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
@ -82,6 +84,16 @@ class SignController{
|
||||
} else {
|
||||
$sign_days = $row['sign_days'];
|
||||
$signable = 1;
|
||||
$ret = $conn->execScript('UPDATE sign SET signable=:signable ' .
|
||||
' WHERE accountid=:accountid;',
|
||||
array(
|
||||
':accountid' => $account_id,
|
||||
':signable' => $signable
|
||||
));
|
||||
if (!$ret) {
|
||||
die();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
echo json_encode(array(
|
||||
|
Loading…
x
Reference in New Issue
Block a user