This commit is contained in:
aozhiwei 2019-09-02 18:03:01 +08:00
parent cb87921598
commit 21475decb1
4 changed files with 42 additions and 22 deletions

View File

@ -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 */;

View File

@ -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;

View File

@ -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(

View File

@ -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']
));
}
}