1
This commit is contained in:
parent
2371e713d1
commit
eb3ab5d87d
@ -1131,13 +1131,15 @@ DROP TABLE IF EXISTS `t_first_topup`;
|
||||
/*!40101 SET character_set_client = utf8 */;
|
||||
CREATE TABLE `t_first_topup` (
|
||||
`idx` bigint(20) NOT NULL AUTO_INCREMENT,
|
||||
`address` varchar(64) NOT NULL COMMENT '账户id',
|
||||
`createtime` int(11) NOT NULL COMMENT '首充时间',
|
||||
`account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id',
|
||||
`address` varchar(60) COMMENT 'address',
|
||||
`status1` int(11) NOT NULL DEFAULT '0' COMMENT '领取状态1 0 不能领取 1 可领取状态 2 已领取',
|
||||
`status2` int(11) NOT NULL DEFAULT '0' COMMENT '领取状态2',
|
||||
`status3` int(11) NOT NULL DEFAULT '0' COMMENT '领取状态3',
|
||||
`createtime` int(11) NOT NULL COMMENT '首充时间',
|
||||
`modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间',
|
||||
PRIMARY KEY (`idx`,`address`),
|
||||
UNIQUE KEY `address` (`address`)
|
||||
UNIQUE KEY `account_id` (`account_id`)
|
||||
) ENGINE=InnoDB AUTO_INCREMENT=11 DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
|
@ -25,8 +25,15 @@ class FirstTopupController extends BaseAuthedController {
|
||||
);
|
||||
return;
|
||||
}
|
||||
$complete = ($status[0] == 2 && $status[1] == 2 && $status[2] == 2) ? 1 : 0;
|
||||
if ($complete == 1 && myself()->_getV(TN_FIRST_TUPOP_STATUS, 0, 1) == 0) {
|
||||
FirstTopup::adjustStatus($dbInfo);
|
||||
$complete = 1;
|
||||
for ($i = 1; $i <= 3; ++$i) {
|
||||
if ($dbInfo['status' . $i] != 2) {
|
||||
$complete = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($complete == 1 && myself()->_getV(TN_FIRST_TUPOP_STATUS, 0) == 0) {
|
||||
myself()->_setV(TN_FIRST_TUPOP_STATUS, 0, 1);
|
||||
}
|
||||
$this->_rspData(
|
||||
@ -38,47 +45,6 @@ class FirstTopupController extends BaseAuthedController {
|
||||
);
|
||||
}
|
||||
|
||||
private function begin()
|
||||
{
|
||||
$conn = myself()->_getMysql('');
|
||||
|
||||
$address = myself()->_getAddress();
|
||||
if (!$address) {
|
||||
$this->_rspErr(1, 'you have not a web3 address');
|
||||
return;
|
||||
}
|
||||
|
||||
$exist = SqlHelper::selectOne(
|
||||
$conn,
|
||||
't_first_topup',
|
||||
array('address'),
|
||||
array('address' => myself()->_getAddress())
|
||||
);
|
||||
if ($exist) {
|
||||
$this->_rspErr(1, '首充奖励活动已经开启');
|
||||
return;
|
||||
}
|
||||
|
||||
// 开始首充奖励活动进程
|
||||
$chk = SqlHelper::insert(
|
||||
$conn,
|
||||
't_first_topup',
|
||||
array(
|
||||
'address' => myself()->_getAddress(),
|
||||
'createtime' => myself()->_getNowTime(),
|
||||
'status1' => 0,
|
||||
'status2' => 0,
|
||||
'status3' => 0,
|
||||
)
|
||||
);
|
||||
|
||||
if ($chk) {
|
||||
$this->_rspOk();
|
||||
} else {
|
||||
$this->_rspErr(1, '首充奖励活动开启失败');
|
||||
}
|
||||
}
|
||||
|
||||
public function get()
|
||||
{
|
||||
$group = getReqVal('group', 1);
|
||||
@ -139,45 +105,4 @@ class FirstTopupController extends BaseAuthedController {
|
||||
}
|
||||
}
|
||||
|
||||
private function getStatus($group, $time)
|
||||
{
|
||||
$beginDayTime = myself()->_getDaySeconds($time);
|
||||
$now = myself()->_getNowTime();
|
||||
|
||||
$diff = $now - ($beginDayTime + $group * 24 * 3600);
|
||||
if ($diff >= 0) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private function getStatusFromDB($conn)
|
||||
{
|
||||
// 从数据库中获取 status
|
||||
$row = SqlHelper::selectOne(
|
||||
$conn,
|
||||
't_first_topup',
|
||||
array('createtime', 'status1', 'status2', 'status3'),
|
||||
array('address' => myself()->_getAddress())
|
||||
);
|
||||
|
||||
$status = [0, 0, 0];
|
||||
|
||||
if ($row) {
|
||||
// 0 未领取 1 可领取 2 已领取
|
||||
$status = [(int)$row['status1'], (int)$row['status2'], (int)$row['status3']];
|
||||
$time = $row['createtime'];
|
||||
|
||||
for ($i = 0; $i < 3; $i++) {
|
||||
if ($status[$i] < 2) {
|
||||
// 检测是否到了可以领取的时间
|
||||
$status[$i] = $this->getStatus($i, $time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $status;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -50,4 +50,9 @@ class FirstTopup extends BaseModel {
|
||||
);
|
||||
}
|
||||
|
||||
public static function adjustStatus(&$dbInfo)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user