diff --git a/sql/gamedb.sql b/sql/gamedb.sql index fb8ae18..02a2862 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -343,6 +343,7 @@ CREATE TABLE `recharge` ( `idx` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '自增id', `accountid` varchar(60) COLLATE utf8_bin NOT NULL DEFAULT '' COMMENT '账号id', `first_data` mediumblob 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 '创建时间', `modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', diff --git a/webapp/controller/RechargeController.class.php b/webapp/controller/RechargeController.class.php index f3e7e7d..a08b99e 100644 --- a/webapp/controller/RechargeController.class.php +++ b/webapp/controller/RechargeController.class.php @@ -126,8 +126,8 @@ class RechargeController $diamond_present = 0; $shopgoods_conf = metatable\getShopGoodsConf(); + $goodsid = 0; if ($shopgoods_conf) { - $goodsid = 0; for ($i = 1; $i <= count($shopgoods_conf); $i++) { if ($diamonds < $shopgoods_conf[$i]['item_num']) { continue; @@ -138,52 +138,56 @@ class RechargeController $goodsid = $shopgoods_conf[$i]['shop_id']; } } + } - if ($goodsid > 0 && $diamond_present > 0) { - $rechargerow = $conn->execQueryOne( - 'SELECT first_data FROM recharge WHERE accountid=:accountid;', - array( - ':accountid' => $account_id - ) - ); - if (!$rechargerow) { - $ret = $conn->execScript( - 'INSERT INTO recharge(accountid, first_data, present_diamond, create_time, modify_time) ' . - ' VALUES(:account_id, :first_data, :present_diamond, :create_time, :modify_time) ' . - ' ON DUPLICATE KEY UPDATE accountid=:account_id, first_data=:first_data, present_diamond=:present_diamond, modify_time=:modify_time;', - array( - ':account_id' => $account_id, - ':first_data' => $goodsid, - ':present_diamond' => $diamond_present, - ':create_time' => time(), - ':modify_time' => time() - ) - ); - } else { - $firstlist = explode(',', $rechargerow['first_data']); - $firstrecharge = true; - for ($i = 0; $i < count($firstlist); $i++) { - if ($firstlist[$i] == $goodsid) { - $firstrecharge = false; - } - } + $rechargerow = $conn->execQueryOne( + 'SELECT first_data FROM recharge WHERE accountid=:accountid;', + array( + ':accountid' => $account_id + ) + ); - if ($firstrecharge) { - $ret = $conn->execScript( - 'UPDATE recharge SET first_data=:first_data, present_diamond=:present_diamond, modify_time=:modify_time' . - ' WHERE accountid=:accountid;', - array( - ':accountid' => $account_id, - ':first_data' => $rechargerow['first_data'] . ',' . $goodsid, - ':present_diamond' => $rechargerow['present_diamond'] + $diamond_present, - ':modify_time' => time() - ) - ); - } else { - $diamond_present = 0; - } + if (!$rechargerow) { + $ret = $conn->execScript( + 'INSERT INTO recharge(accountid, first_data, recharge_diamond, present_diamond, create_time, modify_time) ' . + ' VALUES(:account_id, :first_data, :recharge_diamond, :present_diamond, :create_time, :modify_time) ' . + ' ON DUPLICATE KEY UPDATE accountid=:account_id, first_data=:first_data, recharge_diamond=:recharge_diamond, present_diamond=:present_diamond, modify_time=:modify_time;', + array( + ':account_id' => $account_id, + ':first_data' => $goodsid, + ':recharge_diamond' => $diamonds, + ':present_diamond' => $diamond_present, + ':create_time' => time(), + ':modify_time' => time() + ) + ); + } else { + $firstlist = explode(',', $rechargerow['first_data']); + $firstrecharge = true; + for ($i = 0; $i < count($firstlist); $i++) { + if ($firstlist[$i] == $goodsid) { + $firstrecharge = false; } } + + $firstdata = $rechargerow['first_data']; + if ($firstrecharge) { + $firstdata = $rechargerow['first_data'] . ',' . $goodsid; + } else { + $diamond_present = 0; + } + + $ret = $conn->execScript( + 'UPDATE recharge SET first_data=:first_data, recharge_diamond:=recharge_diamond, present_diamond=:present_diamond, modify_time=:modify_time' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':first_data' => $firstdata, + ':recharge_diamond' => $rechargerow['recharge_diamond'] + $diamonds, + ':present_diamond' => $rechargerow['present_diamond'] + $diamond_present, + ':modify_time' => time() + ) + ); } $diamond_num = $userrow['diamond_num'] + $diamonds + $diamond_present;