From 752377244da669b61a2592ef82257b03f76f90d4 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 31 Jul 2023 19:04:58 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 22 ++++++++++ webapp/models/InAppRecord.php | 81 +++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 webapp/models/InAppRecord.php diff --git a/sql/gamedb.sql b/sql/gamedb.sql index d1dfafc6..d1e0e910 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1278,6 +1278,28 @@ CREATE TABLE `t_user_honor` ( ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `t_inapp_record` +-- + +DROP TABLE IF EXISTS `t_inapp_record`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +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 '充值总额', + `buy_times` int(11) NOT NULL DEFAULT '0' COMMENT '充值次数', + `amount_ok` bigint 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 '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + KEY `account_id` (`account_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + -- -- Table structure for table `t_inapp_order` -- diff --git a/webapp/models/InAppRecord.php b/webapp/models/InAppRecord.php new file mode 100644 index 00000000..db4d1493 --- /dev/null +++ b/webapp/models/InAppRecord.php @@ -0,0 +1,81 @@ +_getSelfMysql(), + 't_inapp_record', + array( + 'account_id' => myself()->_getAccountId(), + 'daytime' => myself()->_getNowDaySeconds() + ) + ); + return $row; + } + + public static function addAmount($amount) + { + SqlHelper::upsert( + myself()->_getSelfMysql(), + 't_inapp_record', + array( + 'account_id' => myself()->_getAccountId(), + 'daytime' => myself()->_getNowDaySeconds() + ), + array( + 'amount' => function () use($amount) { + return 'amount + ' + $amount; + }, + 'buy_times' => function () { + return 'buy_times + 1'; + }, + 'modifytime' => myself()->_getNowTime(), + ), + array( + 'account_id' => myself()->_getAccountId(), + 'amount' => $amount, + 'buy_times' => 1, + 'daytime' => myself()->_getNowDaySeconds(), + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + } + + public static function addAmountOk($accountId, $amount) + { + SqlHelper::upsert( + myself()->_getMysql($accountId), + 't_inapp_record', + array( + 'account_id' => myself()->_getAccountId(), + 'daytime' => myself()->_getNowDaySeconds() + ), + array( + 'amount_ok' => function () use($amount) { + return 'amount_ok + ' + $amount; + }, + 'buy_ok_times' => function () use($amount) { + return 'buy_ok_times + 1'; + }, + 'modifytime' => myself()->_getNowTime(), + ), + array( + 'account_id' => myself()->_getAccountId(), + 'amount_ok' => $amount, + 'buy_ok_times' => 1, + 'daytime' => myself()->_getNowDaySeconds(), + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + } + +}