免广告券

This commit is contained in:
yangduo 2025-01-15 15:15:52 +08:00
parent 921148d632
commit 01f5495096
4 changed files with 100 additions and 0 deletions

View File

@ -345,6 +345,8 @@ CREATE TABLE `recharge` (
`first_data` mediumblob COMMENT '首充数据',
`daily_purchase` mediumblob COMMENT '每日特惠礼包',
`vip_info` mediumblob COMMENT '月卡信息',
`activity` mediumblob COMMENT '充值活动信息',
`adfree` int(11) NOT NULL DEFAULT '0' COMMENT '免广告券',
`recharge_diamond` int(11) NOT NULL DEFAULT '0' COMMENT '累计充值钻石',
`present_diamond` int(11) NOT NULL DEFAULT '0' COMMENT '充值赠送钻石总量',
`create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间',

View File

@ -106,6 +106,8 @@ class AddReward {
$item_list = $this->addEquip($item['item_id'], $account_id);
} else if ($i['type'] == 16) {
$this->addSpoilsItem($item['item_id'], $item['item_num'], $account_id);
} else if ($i['type'] == 17) {
$this->addAdfree($item['item_id'], $item['item_num'], $account_id);
} else {
$price = $i['diamond'];
if ($time != 0) {
@ -355,6 +357,46 @@ class AddReward {
}
}
protected function addAdfree($item_id, $item_num, $accountid)
{
$conn = $this->getMysql($accountid);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
die();
}
$row = $conn->execQueryOne('SELECT adfree FROM recharge WHERE accountid=:accountid;',
array(
':accountid' => $accountid
));
$ret = false;
$nowtime = time();
if (!$row) {
$ret = $conn->execScript(
'INSERT INTO recharge(accountid, adree, create_time, modify_time) ' .
' VALUES(:account_id, :adfree, :create_time, :modify_time) ' .
' ON DUPLICATE KEY UPDATE accountid=:account_id, adfree=adfree+:adfree, modify_time=:modify_time;',
array(
':account_id' => $accountid,
':adfree' => $item_num,
':create_time' => $nowtime,
':modify_time' => $nowtime,
)
);
} else {
$ret = $conn->execScript('UPDATE recharge SET adfree=adfree+:adfree, modify_time=:modify_time ' .
' WHERE accountid=:accountid;',
array(
':accountid' => $accountid,
':adfree' => $item_num + $row['adfree'],
':modify_time' => $nowtime,
));
}
if (!$ret) {
die();
}
}
//添加道具
protected function addItem($item_id, $time, $accountid, $price, $t)
{

View File

@ -337,6 +337,54 @@ class RechargeController
echo $user_purchase_str;
}
public function adFree()
{
$account_id = $_REQUEST['account_id'];
//登录校验
$login = loginVerify($account_id, $_REQUEST['session_id']);
if (!$login) {
phpcommon\sendError(ERR_USER_BASE + 1, 'session无效');
return;
}
$conn = $this->getMysql($account_id);
if (!$conn) {
phpcommon\sendError(ERR_USER_BASE + 1, '没有这个玩家');
return;
}
$rechargerow = $conn->execQueryOne(
'SELECT * FROM recharge WHERE accountid=:accountid;',
array(
':accountid' => $account_id
)
);
if (!$rechargerow || $rechargerow['adfree'] < 1) {
phpcommon\sendError(ERR_USER_BASE + 2, '券不足');
return;
}
$ret = $conn->execScript(
'UPDATE recharge SET adfree=adfree-1 WHERE accountid=:accountid;',
array(
':accountid' => $account_id,
':modify_time' => time(),
)
);
if(!$ret) {
phpcommon\sendError(ERR_INTERNAL + 1, '系统繁忙');
return;
}
echo json_encode(array(
'errcode' => 0,
'errmsg' => '',
'adfree' => $rechargerow['adfree'] - 1,
));
}
protected function checkPurchaseLimit($conn, $account_id, $productid)
{
$prod_conf = metatable\getShopGoodsById($productid);

View File

@ -283,6 +283,7 @@ class RoleController
'blobdata' => '',
'cpa_times' => 0,
'daily_diamond_times' => 0,
'adfree' => 0,
));
} else {
if ($avatar_url != '') {
@ -375,6 +376,12 @@ class RoleController
':accountid' => $account_id
)
);
$rechargerow = $conn->execQueryOne(
'SELECT * FROM recharge WHERE accountid=:accountid;',
array(
':accountid' => $account_id
)
);
echo json_encode(array(
'errcode' => 0,
@ -434,6 +441,7 @@ class RoleController
'blobdata' => $blobdata,
'cpa_times' => $cpa_times,
'daily_diamond_times' => $daily_diamond_times,
'adfree' => $rechargerow ? $rechargerow['adfree'] : 0,
));
}
}