diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 3896563..dd46086 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -412,6 +412,15 @@ CREATE TABLE `redpack_log` ( UNIQUE KEY `account_order_id_get_time` (`accountid`, `order_id` , `get_time`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +DROP TABLE IF EXISTS `orderidx`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `orderidx` ( + `idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + PRIMARY KEY (`idx`) +) 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/sql/gamedb2001_n_migrate_190902_01.sql b/sql/gamedb2001_n_migrate_190902_01.sql new file mode 100644 index 0000000..079cf78 --- /dev/null +++ b/sql/gamedb2001_n_migrate_190902_01.sql @@ -0,0 +1,15 @@ +begin; + +DROP TABLE IF EXISTS `orderidx`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `orderidx` ( + `idx` int(11) NOT NULL AUTO_INCREMENT COMMENT '自增id', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + PRIMARY KEY (`idx`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + + +insert into version (version) values(20190902); + +commit; diff --git a/webapp/controller/ActivityController.class.php b/webapp/controller/ActivityController.class.php index 41077e9..bfbdbc8 100644 --- a/webapp/controller/ActivityController.class.php +++ b/webapp/controller/ActivityController.class.php @@ -694,6 +694,12 @@ class ActivityController{ return $airReward_list; } + public function tempRedPack() + { + $this->getRedPack($_REQUEST['amount'], $_REQUEST['account_id']); + error_log('success'); + } + public function getRedBag() { $account_id = $_REQUEST['account_id']; @@ -760,23 +766,10 @@ class ActivityController{ return $conn; } - protected function getPayMysql($accountid) - { - $mysql_conf = getMysqlConfig(crc32($accountid)); - $conn = new phpcommon\Mysql(array( - 'host' => $mysql_conf['host'], - 'port' => $mysql_conf['port'], - 'user' => $mysql_conf['user'], - 'passwd' => $mysql_conf['passwd'], - 'dbname' => 'paydb' - )); - return $conn; - } - //redpack201908191405_xxxxx protected function getOrderId($accountid) { - $conn = $this->getPayMysql($accountid); + $conn = $this->getMysql($accountid); $orderid_pre = 'redpack' . strftime('%y%m%d%H%M%S'); $ret = $conn->execScript("INSERT INTO orderidx(createtime) VALUES(:createtime);", array( diff --git a/webapp/controller/TempController.class.php b/webapp/controller/TempController.class.php index 508e3c1..673f21a 100644 --- a/webapp/controller/TempController.class.php +++ b/webapp/controller/TempController.class.php @@ -22,18 +22,21 @@ class TempController{ { $type = $_REQUEST['type']; $red_conn = $this->getRedMysql(); - $rows = $red_conn->execQuery('SELECT * FROM redpack ' . - ' WHERE red_type=:red_type;', - //AND red_date=:red_date;', - array( - ':red_type' => $type, - //':red_date' => phpcommon\getdayseconds(time()) - )); + $rows = $red_conn->execQueryOne('SELECT * FROM redpack ' . + ' WHERE red_type=:red_type AND red_date=:red_date;', + array( + ':red_type' => $type, + ':red_date' => phpcommon\getdayseconds(time()) + )); error_log(json_encode($rows)); + if ($rows['red_sum'] + 0.3 > 100) { + phpcommon\sendError(ERR_USER_BASE + 3, '今日红包已领完'); + return; + } echo json_encode(array( 'errcode' => 0, 'errmsg' => '', - //'sum' => $row['red_sum'] + 'sum' => $rows['red_sum'] )); } }