From 98b1abbd12eb662d07a2073fba33f9a4000967bb Mon Sep 17 00:00:00 2001 From: yangduo Date: Tue, 31 Dec 2024 16:22:36 +0800 Subject: [PATCH] recharge present --- sql/gamedb.sql | 11 ++++ .../controller/RechargeController.class.php | 61 ++++++++++++++++++- 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 95c12f9..9b0e018 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -337,4 +337,15 @@ CREATE TABLE `draw` ( PRIMARY KEY (`idx`), UNIQUE KEY `accountid_drawid` (`accountid`, `id`) ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +DROP TABLE IF EXISTS `recharge`; +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 '首充数据', + `create_time` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modify_time` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `accountid` (`accountid`) +) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; -- Dump completed on 2015-08-19 18:51:22 diff --git a/webapp/controller/RechargeController.class.php b/webapp/controller/RechargeController.class.php index 3f598b1..ecfb80d 100644 --- a/webapp/controller/RechargeController.class.php +++ b/webapp/controller/RechargeController.class.php @@ -121,7 +121,63 @@ class RechargeController{ return; } - $diamond_num = $userrow['diamond_num'] + $diamonds; + $diamond_present = 0; + $shopgoods_conf = metatable\getShopGoodsConf(); + if ($shopgoods_conf) { + $goodsid = 0; + for ($i = 1; $i <= count($shopgoods_conf); $i++) { + if ($diamonds < $shopgoods_conf[$i]['item_num']) { + continue; + } + + if ($shopgoods_conf[$i]['first_present'] > $diamond_present) { + $diamond_present = $shopgoods_conf[$i]['first_present']; + $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, create_time, modify_time) ' . + ' VALUES(:account_id, :first_data, :create_time, :modify_time) ' . + ' ON DUPLICATE KEY UPDATE accountid=:account_id, first_data=:first_data, modify_time=:modify_time;', + array( + ':account_id' => $account_id, + ':first_data' => $goodsid, + ':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; + } + } + + if ($firstrecharge) { + $ret = $conn->execScript('UPDATE recharge SET first_data=:first_data, modify_time=:modify_time' . + ' WHERE accountid=:accountid;', + array( + ':accountid' => $account_id, + ':first_data' => $rechargerow['first_data'].','.$goodsid, + ':modify_time' => time() + )); + } else { + $diamond_present = 0; + } + } + } + } + + $diamond_num = $userrow['diamond_num'] + $diamonds + $diamond_present; $ret = $conn->execScript('UPDATE user SET diamond_num=:diamond_num' . ' WHERE accountid=:accountid;', @@ -139,7 +195,8 @@ class RechargeController{ 'errcode' => $response['errcode'], 'errmsg'=> $response['errmsg'], 'order_id' => $response['order_id'], - 'diamond_nums' => $diamond_num + 'diamond_nums' => $diamond_num, + 'diamond_present' => $diamond_present )); } }