From 7d38cb35099d32b44582951103c418de7c64ca36 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Thu, 29 Aug 2019 13:48:51 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 18 +++++++++++ .../controller/ActivityController.class.php | 31 ++++++++++++++++--- .../ServerSwitchController.class.php | 24 +++++++++++++- webapp/controller/ShareController.class.php | 4 +-- 4 files changed, 69 insertions(+), 8 deletions(-) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index b1e5795..3896563 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -394,6 +394,24 @@ CREATE TABLE `redpack` ( PRIMARY KEY (`idx`), UNIQUE KEY `red_type_red_date` (`red_type`, `red_date`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + + +DROP TABLE IF EXISTS `redpack_log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `redpack_log` ( + `idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id', + `accountid` varchar(60) DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', + `order_id` varchar(60) DEFAULT '' COMMENT '订单id', + `get_time` int(11) NOT NULL DEFAULT '0' COMMENT '领取时间', + `coin_num` int(11) NOT NULL DEFAULT '0' COMMENT '金钱数量', + `custom_data` mediumblob COMMENT '其他字段', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `account_order_id_get_time` (`accountid`, `order_id` , `get_time`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + /*!40101 SET SQL_MODE=@OLD_SQL_MODE */; /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; /*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; diff --git a/webapp/controller/ActivityController.class.php b/webapp/controller/ActivityController.class.php index 6854569..4c0aeca 100644 --- a/webapp/controller/ActivityController.class.php +++ b/webapp/controller/ActivityController.class.php @@ -703,10 +703,19 @@ class ActivityController{ phpcommon\sendError(ERR_USER_BASE + 1, 'session无效'); return; } - $p = $this->getParameter(REDLIMIT); - $limit = $p['value']; + $p = array(); + $type = $_REQUEST['type']; + $item_list = array(); //随机奖励 - $item_list = $this->getRandomAirReward(24006); + if ($type == 1) { + $item_list = $this->getRandomAirReward(24006); + $p = $this->getParameter(REDLIMIT); + } + if ($type == 2) { + $item_list = $this->getRandomAirReward(24007); + $p = $this->getParameter(73); + } + $limit = $p['value']; foreach ($item_list as $item) { if ($item['item_id'] != 10004 ) { //增加奖励 @@ -718,7 +727,7 @@ class ActivityController{ $row = $red_conn->execQueryOne('SELECT red_sum FROM redpack ' . ' WHERE red_type=:red_type AND red_date=:red_date;', array( - ':red_type' => $_REQUEST['type'], + ':red_type' => $type, ':red_date' => phpcommon\getdayseconds(time()) )); if ($row['red_sum'] + $item['item_num'] > $limit) { @@ -728,7 +737,7 @@ class ActivityController{ //红包领取现金 $this->getRedPack($item['item_num'] * 100, $account_id); //更新红包数据 - $this->updateRedPack($item['item_num'], $_REQUEST['type']); + $this->updateRedPack($item['item_num'], $type); } } echo json_encode(array( @@ -866,6 +875,18 @@ class ActivityController{ phpcommon\sendError(ERR_USER_BASE + 2, '领取失败'); die(); } + //插入日志信息 + $ret = $conn->execScript('INSERT INTO redpack_log(accountid, order_id, get_time, custom_data, createtime, modifytime, coin_num) ' . + ' VALUES(:accountid, :order_id, :get_time, :custom_data, :createtime, :modifytime, :coin_num);', + array( + ':accountid' => $account_id, + ':order_id' => $partner_trade_no, + ':get_time' => time(), + ':custom_data' => $res, + ':coin_num' => $amount, + ':createtime' => time(), + ':modifytime' => time() + )); } //更新今日红包数据 diff --git a/webapp/controller/ServerSwitchController.class.php b/webapp/controller/ServerSwitchController.class.php index 5b03d40..d1172e5 100644 --- a/webapp/controller/ServerSwitchController.class.php +++ b/webapp/controller/ServerSwitchController.class.php @@ -2,6 +2,19 @@ class ServerSwitchController { + 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; + } + private function isForbidCity() { if (in_array(strtolower($_REQUEST['province']), @@ -36,8 +49,8 @@ class ServerSwitchController { )); die(); }*/ + error_log(json_encode($_REQUEST)); $payable = 0; - $recharge_times = isset($_REQUEST['recharge_times']) ? $_REQUEST['recharge_times'] : 0; /* 1:玩家进入第一天,战斗7次,开放充值(除北上广深成)。 2:玩家进入第二天,战斗7次,已充值玩家战斗2次(除北上广深成)。 @@ -45,6 +58,15 @@ class ServerSwitchController { */ if (phpcommon\isValidSessionId($_REQUEST['account_id'], $_REQUEST['session_id'])) { + $recharge_times = 0; + $conn = $this->getMysql($_REQUEST['account_id']); + $row = $conn->execQueryOne('SELECT recharge_times_total FROM user WHERE accountid=:accountid;', + array( + ':accountid' => $_REQUEST['account_id'] + )); + if ($row) { + $recharge_times = $row['recharge_times_total']; + } $register_time = phpcommon\extractRegisterTimeFromSessionId($_REQUEST['session_id']); $nowtime = time(); diff --git a/webapp/controller/ShareController.class.php b/webapp/controller/ShareController.class.php index 64a9072..70b418e 100644 --- a/webapp/controller/ShareController.class.php +++ b/webapp/controller/ShareController.class.php @@ -380,10 +380,10 @@ class ShareController{ $data = json_decode($response, true); $peo_num = $data['invitee_num']; $sh = $this->getShare($ach_id); - /*if ($peo_num < $sh['people']) { + if ($peo_num < $sh['people']) { phpcommon\sendError(ERR_USER_BASE + 4, '未达到人数要求'); return; - }*/ + } $item_list = array(); if ($ach_id != 6) { $array = $this->getExplode($sh['rewards']);