From 5b4e6113d10ed8a473b3b42f1f085c90bbea74f7 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Thu, 11 Jul 2024 16:44:23 +0800 Subject: [PATCH] 1 --- sql/gamedb.sql | 16 +++++ sql/gamedb2006_migrate_240710_01.sql | 25 +++++++ sql/gamedb2006_migrate_240711_01.sql | 18 +++++ .../controller/InGameMallController.class.php | 9 +-- webapp/models/InGameMall.php | 4 +- webapp/models/ServerTaskBattleCount.php | 70 +++++++++++++++++++ webapp/services/LootService.php | 21 ++++-- 7 files changed, 153 insertions(+), 10 deletions(-) create mode 100644 sql/gamedb2006_migrate_240710_01.sql create mode 100644 sql/gamedb2006_migrate_240711_01.sql create mode 100644 webapp/models/ServerTaskBattleCount.php diff --git a/sql/gamedb.sql b/sql/gamedb.sql index d1e87f76..5d77f7b5 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -1442,6 +1442,7 @@ CREATE TABLE `t_ingame_mall` ( `item_id` int(11) NOT NULL DEFAULT '0' COMMENT '物品itemId', `item_num` bigint NOT NULL DEFAULT '0' COMMENT '物品数量', `price` bigint NOT NULL DEFAULT '0' COMMENT '价格', + `unit_price` decimal(10, 2) NOT NULL DEFAULT '0' COMMENT '单价', `status` int(11) NOT NULL DEFAULT '0' COMMENT 'status', `buyer` varchar(60) NOT NULL DEFAULT '' COMMENT '购买成功者', `buy_ok_time` int(11) NOT NULL DEFAULT '0' COMMENT '购买成功时间', @@ -1867,3 +1868,18 @@ CREATE TABLE `t_gold_bullion_return` ( UNIQUE KEY `idx_token_id_net_id` (`token_id`, `net_id`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; + + +DROP TABLE IF EXISTS `t_server_task_battle_count`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_server_task_battle_count` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id', + `period` int(11) NOT NULL DEFAULT '0' COMMENT '周期', + `state` int(11) NOT NULL DEFAULT '0' COMMENT '1:总计数 2:循环计数', + `val` bigint(20) NOT NULL DEFAULT '0' COMMENT 'val', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`) +) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; \ No newline at end of file diff --git a/sql/gamedb2006_migrate_240710_01.sql b/sql/gamedb2006_migrate_240710_01.sql new file mode 100644 index 00000000..b4ab6462 --- /dev/null +++ b/sql/gamedb2006_migrate_240710_01.sql @@ -0,0 +1,25 @@ +begin; + +DROP TABLE IF EXISTS `t_hero_skin`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_hero_skin` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id', + `skin_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤id', + `hero_id` int(11) NOT NULL DEFAULT '0' COMMENT '英雄id', + `skin_state` int(11) NOT NULL DEFAULT '0' COMMENT '英雄皮肤状态 0=封装,1=解封', + `get_from` int(11) NOT NULL DEFAULT '0' COMMENT '获得方式 0 = 系统赠送 1 = 金币购买', + `consume_num` int(11) NOT NULL DEFAULT '0' COMMENT '消耗货币的具体数量', + `try_expire_at` int(11) NOT NULL DEFAULT '0' COMMENT '试用截止时间', + `rand_attr` mediumblob COMMENT '随机属性', + `wealth_attr` mediumblob COMMENT '财富值属性', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `account_id_skinid` (`account_id`, `skin_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +insert into version (version) values(2024052101); + +commit; diff --git a/sql/gamedb2006_migrate_240711_01.sql b/sql/gamedb2006_migrate_240711_01.sql new file mode 100644 index 00000000..47ea0300 --- /dev/null +++ b/sql/gamedb2006_migrate_240711_01.sql @@ -0,0 +1,18 @@ +begin; + +alter table t_ingame_mall add column `unit_price` decimal(10, 2) NOT NULL DEFAULT '0' COMMENT '单价'; + +CREATE TABLE `t_server_task_battle_count` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'account_id', + `period` int(11) NOT NULL DEFAULT '0' COMMENT '周期', + `state` int(11) NOT NULL DEFAULT '0' COMMENT '1:总计数 2:循环计数', + `val` bigint(20) NOT NULL DEFAULT '0' COMMENT 'val', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`) +) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +insert into version (version) values(2024052101); + +commit; diff --git a/webapp/controller/InGameMallController.class.php b/webapp/controller/InGameMallController.class.php index 7f75380f..0213905a 100644 --- a/webapp/controller/InGameMallController.class.php +++ b/webapp/controller/InGameMallController.class.php @@ -83,7 +83,7 @@ class InGameMallController extends BaseAuthedController { break; case 2: { - $orderBy = 'ORDER BY length(price) ' . $orderAsc . ', price ' . $orderAsc; + $orderBy = 'ORDER BY length(unit_price) ' . $orderAsc . ', unit_price ' . $orderAsc; } break; } @@ -557,7 +557,8 @@ EOD; myself()->_rspErr(1, 'Not the seller'); return; } - InGameMall::modifyPrice($orderId, $priceBn); + $unitPrice = $priceBn / $goodsDb['item_num']; + InGameMall::modifyPrice($orderId, $priceBn,$unitPrice); myself()->_rspOk(); } @@ -576,7 +577,7 @@ EOD; break; case 2: { - $orderBy = 'ORDER BY length(price) ' . $orderAsc . ', price ' . $orderAsc; + $orderBy = 'ORDER BY length(unit_price) ' . $orderAsc . ', unit_price ' . $orderAsc; } break; } @@ -622,7 +623,7 @@ EOD; break; case 2: { - $orderBy = 'ORDER BY length(price) ' . $orderAsc . ', price ' . $orderAsc; + $orderBy = 'ORDER BY length(unit_price) ' . $orderAsc . ', unit_price ' . $orderAsc; } break; } diff --git a/webapp/models/InGameMall.php b/webapp/models/InGameMall.php index 7c8384ae..d985ec37 100644 --- a/webapp/models/InGameMall.php +++ b/webapp/models/InGameMall.php @@ -46,13 +46,14 @@ class InGameMall extends BaseModel { 'item_num' => $itemNum, 'price' => $price, 'order1' => $orderField, + 'unit_price' => $price/$itemNum, 'last_modify_price_time' => myself()->_getNowTime(), 'createtime' => myself()->_getNowTime(), 'modifytime' => myself()->_getNowTime(), )); } - public static function modifyPrice($orderId, $price) + public static function modifyPrice($orderId, $price,$unitPrice) { SqlHelper::update (myself()->_getMysql(''), @@ -62,6 +63,7 @@ class InGameMall extends BaseModel { ), array( 'price' => $price, + 'unit_price' => $unitPrice, 'last_modify_price_time' => myself()->_getNowTime(), ) ); diff --git a/webapp/models/ServerTaskBattleCount.php b/webapp/models/ServerTaskBattleCount.php new file mode 100644 index 00000000..32a9fc9a --- /dev/null +++ b/webapp/models/ServerTaskBattleCount.php @@ -0,0 +1,70 @@ +_getSelfMysql(), + 't_server_task_battle_count', + array( + 'account_id' => myself()->_getAccountId(), + 'period' => $period, + 'state' => $state, + ) + ); + return array( + 'val' => $row ? $row['val'] : $defVal, + 'modifytime' => $row ? $row['modifytime'] : myself()->_getNowTime(), + ); + } + + private static function internalSetV($period,$state, $val) + { + SqlHelper::upsert + (myself()->_getSelfMysql(), + 't_server_task_battle_count', + array( + 'account_id' => myself()->_getAccountId(), + 'period' => $period, + 'state' => $state + ), + array( + 'val' => $val, + 'modifytime' => myself()->_getNowTime() + ), + array( + 'account_id' => myself()->_getAccountId(), + 'period' => $period, + 'state' => $state, + 'val' => $val, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ) + ); + } +} \ No newline at end of file diff --git a/webapp/services/LootService.php b/webapp/services/LootService.php index afac35a0..fd3962c5 100644 --- a/webapp/services/LootService.php +++ b/webapp/services/LootService.php @@ -4,7 +4,10 @@ namespace services; require_once('mt/LootConfig.php'); +require_once('mt/ServerTaskTime.php'); +require_once('models/ServerTaskBattleCount.php'); +use models\ServerTaskBattleCount; use mt; class LootService @@ -75,8 +78,13 @@ class LootService } private static function disposeDropContent4($lootMeta,&$depth,&$items) { - $totalTimes = myself()->_getV(TN_TOTAL_LOOT_TIMES,0); - $recycleTimes = myself()->_getV(TN_TOTAL_LOOT_TIMES,1); + $serverTaskMeta = mt\ServerTaskTime::getCurrentTime(); + $period = $serverTaskMeta?$serverTaskMeta['id']:0; + +// $totalTimes = myself()->_getV(TN_TOTAL_LOOT_TIMES,0); + $totalTimes = ServerTaskBattleCount::getV($period,ServerTaskBattleCount::TOTAL_COUNT); +// $recycleTimes = myself()->_getV(TN_TOTAL_LOOT_TIMES,1); + $recycleTimes = ServerTaskBattleCount::getV(0,ServerTaskBattleCount::LOOP_COUNT); $contentArr = explode("|",$lootMeta['content']); $initTimes = $contentArr[0]; $po = $contentArr[1]; @@ -89,12 +97,15 @@ class LootService } $p = min($po + ($recycleTimes-1) * $pd,$pm) * 100 ; $rnd = rand(1,100); - myself()->_incV(TN_TOTAL_LOOT_TIMES,0,1); +// myself()->_incV(TN_TOTAL_LOOT_TIMES,0,1); + ServerTaskBattleCount::incV($period,ServerTaskBattleCount::TOTAL_COUNT,1); if ($rnd <= $p){ - myself()->_setV(TN_TOTAL_LOOT_TIMES,1,1); +// myself()->_setV(TN_TOTAL_LOOT_TIMES,1,1); + ServerTaskBattleCount::setV(0,ServerTaskBattleCount::LOOP_COUNT,1); self::disposeLootIndex($index1,$depth,$items); }else{ - myself()->_incV(TN_TOTAL_LOOT_TIMES,1,1); +// myself()->_incV(TN_TOTAL_LOOT_TIMES,1,1); + ServerTaskBattleCount::incV(0,ServerTaskBattleCount::LOOP_COUNT,1); self::disposeLootIndex($index2,$depth,$items); } }