From 01f5495096a9979348d909ad5a5cdb042c4b2c02 Mon Sep 17 00:00:00 2001 From: yangduo Date: Wed, 15 Jan 2025 15:15:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=8D=E5=B9=BF=E5=91=8A=E5=88=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/gamedb.sql | 2 + webapp/classes/AddReward.php | 42 ++++++++++++++++ .../controller/RechargeController.class.php | 48 +++++++++++++++++++ webapp/controller/RoleController.class.php | 8 ++++ 4 files changed, 100 insertions(+) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 86c0df4..add864a 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -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 '创建时间', diff --git a/webapp/classes/AddReward.php b/webapp/classes/AddReward.php index fad278d..50888fd 100644 --- a/webapp/classes/AddReward.php +++ b/webapp/classes/AddReward.php @@ -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) { diff --git a/webapp/controller/RechargeController.class.php b/webapp/controller/RechargeController.class.php index 8d5919b..06efc64 100644 --- a/webapp/controller/RechargeController.class.php +++ b/webapp/controller/RechargeController.class.php @@ -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); diff --git a/webapp/controller/RoleController.class.php b/webapp/controller/RoleController.class.php index d36e8fd..c1ae4f9 100644 --- a/webapp/controller/RoleController.class.php +++ b/webapp/controller/RoleController.class.php @@ -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, )); } }