From 1914112edfcbf10b17ba9052bd256e40dc51d6d7 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Wed, 2 Aug 2023 13:00:33 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 4 ++-- webapp/controller/ShopController.class.php | 16 ++++++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 93bdaa4b..5feac79f 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1307,9 +1307,9 @@ DROP TABLE IF EXISTS `t_inapp_record`; CREATE TABLE `t_inapp_record` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', - `amount` bigint NOT NULL DEFAULT '0' COMMENT '充值总额', + `amount` double NOT NULL DEFAULT '0' COMMENT '充值总额', `buy_times` int(11) NOT NULL DEFAULT '0' COMMENT '充值次数', - `amount_ok` bigint NOT NULL DEFAULT '0' COMMENT '充值成功总额', + `amount_ok` double NOT NULL DEFAULT '0' COMMENT '充值成功总额', `buy_ok_times` int(11) NOT NULL DEFAULT '0' COMMENT '充值成功次数', `daytime` int(11) NOT NULL DEFAULT '0' COMMENT '时间', `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index a7c4ef0c..8523c53f 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -237,6 +237,10 @@ class ShopController extends BaseAuthedController { $platform = getReqVal('platform', 0); $balance = $this->getInAppBalance(); + if ($balance <= 0) { + $this->_rspErr(2, "insufficient available balance"); + return; + } $goodsMeta = mt\ShopGoods::getByGoodsUuid($goodsId); if (!$goodsMeta) { $this->_rspErr(2, "inapp purchase failed"); @@ -258,8 +262,20 @@ class ShopController extends BaseAuthedController { $this->_rspErr(1, "error paramater platform"); return; } + $price = $goodsMeta['price']; + if (empty($price) || $pirce < 0.001) { + $this->_rspErr(1, "config error"); + return; + } $orderId = OrderId::gen(); + InAppOrder::add( + $orderId, + $platform, + $goodsId, + $price + ); + InAppRecord::addAmount($price); $this->_rspData(array( 'order_id' => $order_id, ));