From dc09bfa3c483fdea1c891d26cdf3b25ff725ea85 Mon Sep 17 00:00:00 2001 From: wangwei01 Date: Thu, 11 Apr 2019 16:58:53 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 16 ++++ webapp/controller/HangController.class.php | 85 ++++++++++++++++++++++ webapp/controller/SignController.class.php | 20 ++++- 3 files changed, 117 insertions(+), 4 deletions(-) create mode 100644 webapp/controller/HangController.class.php diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 5371319..2d664fc 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -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 */; diff --git a/webapp/controller/HangController.class.php b/webapp/controller/HangController.class.php new file mode 100644 index 0000000..0a50d40 --- /dev/null +++ b/webapp/controller/HangController.class.php @@ -0,0 +1,85 @@ + $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() + )); + } +} +?> diff --git a/webapp/controller/SignController.class.php b/webapp/controller/SignController.class.php index eea5436..d02a60e 100644 --- a/webapp/controller/SignController.class.php +++ b/webapp/controller/SignController.class.php @@ -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(