diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 9abb7230..f061f3a2 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -2194,7 +2194,7 @@ CREATE TABLE `t_rookie_task_value` ( ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; - +-- -- Table structure for table `t_hashrate_shop_buy_record` -- @@ -2219,3 +2219,39 @@ CREATE TABLE `t_hashrate_shop_buy_record` ( ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; +-- +-- Table structure for table `t_lucky_symbol` +-- + +DROP TABLE IF EXISTS `t_lucky_symbol`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_lucky_symbol` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', + `in_use_num` 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`), + UNIQUE 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_lucky_symbol_record` +-- + +DROP TABLE IF EXISTS `t_lucky_symbol_record`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_lucky_symbol_record` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `room_uuid` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'room_uuid', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `uk_room_uuid_account_id` (`room_uuid`, `account_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + diff --git a/sql/gamedb2006_migrate_241001_01.sql b/sql/gamedb2006_migrate_241001_01.sql index 2e07eb8e..ce5e0808 100644 --- a/sql/gamedb2006_migrate_241001_01.sql +++ b/sql/gamedb2006_migrate_241001_01.sql @@ -62,6 +62,7 @@ CREATE TABLE `t_hashrate_shop_buy_record` ( UNIQUE KEY `account_id_goods_id` (`account_id`, `goods_id`) ) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + CREATE TABLE `t_circuit_task_value` ( `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', @@ -73,6 +74,27 @@ CREATE TABLE `t_circuit_task_value` ( UNIQUE KEY `account_id_task` (`account_id`, `task_type`) ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +CREATE TABLE `t_lucky_symbol` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', + `in_use_num` 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`), + UNIQUE KEY `account_id` (`account_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +CREATE TABLE `t_lucky_symbol_record` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `room_uuid` varchar(60) CHARACTER SET utf8 NOT NULL COMMENT 'room_uuid', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id', + `createtime` int(11) NOT NULL DEFAULT '0' COMMENT '创建时间', + `modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '修改时间', + PRIMARY KEY (`idx`), + UNIQUE KEY `uk_room_uuid_account_id` (`room_uuid`, `account_id`) +) ENGINE=InnoDB AUTO_INCREMENT=10001 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + + insert into version (version) values(2024092401); commit; diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index f183eff4..e645d511 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -15,7 +15,7 @@ require_once('models/User.php'); require_once('models/RealtimeData.php'); require_once('models/ChipPage.php'); require_once('models/Chip.php'); - +require_once('models/LuckySymbol.php'); require_once('services/AwardService.php'); require_once('services/PropertyChgService.php'); @@ -31,6 +31,7 @@ use models\User; use models\RealtimeData; use models\ChipPage; use models\Chip; +use models\LuckySymbol; use services\LogService; class BagController extends BaseAuthedController { @@ -134,6 +135,11 @@ class BagController extends BaseAuthedController { $this->useSealDrug($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3); } break; + case mt\Item::LUCKY_SYMBOL_SUBTYPE: + { + $this->useSymbol($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3); + } + break; default: { $this->_rspErr(4, 'The prop function has not been realized yet'); @@ -880,4 +886,24 @@ class BagController extends BaseAuthedController { )); } + private function useSymbol($itemDb, $itemMeta, $itemNum, $param1, $param2, $param3) + { + if (LuckySymbol::hasLuckySymbol()) { + $this->_rspErr(201, "alreay use"); + return ; + } + $this->_decItems(array( + array( + 'item_id' => $itemMeta['id'], + 'item_num' => 1 + ) + )); + LuckySymbol::add(); + $this->propertyChgService->addBagChg(); + $this->_rspData(array( + 'award' => $this->awardService->toDto(), + 'property_chg' => $this->propertyChgService->toDto(), + )); + } + } diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index bcb0f006..dfed480d 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -986,11 +986,32 @@ class BattleController extends BaseAuthedController { { $data = array(); foreach ($member['battle_items'] as $item) { - $itemCount = Bag::getItemCount($item['item_id']); - array_push($data, array( - 'item_id' => $item['item_id'], - 'item_num' => $item['item_num'], - )); + $itemMeta = mt\Item::get($item['item_id']); + if ($itemMeta['type'] == mt\Item::FUNC_TYPE && + $itemMeta['sub_type'] == mt\Item::LUCKY_SYMBOL_SUBTYPE) { + $luckyRecord = myself()->_callModelStatic('LuckySymbolRecord', 'find', $roomUuid); + if (empty($luckyRecord)) { + if (myself()->_callModelStatic('LuckySymbol', 'hasLuckySymbol')) { + myself()->_callModelStatic('LuckySymbol', 'dec'); + myself()->_callModelStatic('LuckySymbolRecord', 'add', $roomUuid); + array_push($data, array( + 'item_id' => $item['item_id'], + 'item_num' => 1, + )); + } + } else { + array_push($data, array( + 'item_id' => $item['item_id'], + 'item_num' => 1, + )); + } + } else { + $itemCount = Bag::getItemCount($item['item_id']); + array_push($data, array( + 'item_id' => $item['item_id'], + 'item_num' => $item['item_num'], + )); + } } $info['items'] = $data; } diff --git a/webapp/controller/UserController.class.php b/webapp/controller/UserController.class.php index 66792b60..a3796dc7 100644 --- a/webapp/controller/UserController.class.php +++ b/webapp/controller/UserController.class.php @@ -377,6 +377,7 @@ class UserController extends BaseAuthedController { $userInfo['total_lucky'] = Hero::getAccountLuckyTemp(); $userInfo['admission_item_num'] = myself()->_getItemCount(900006, $userInfo); $userInfo['circuit_score'] = myself()->_callModelStatic('Circuit', 'getCurrentMyScore'); + $userInfo['has_lucky_symbol'] = myself()->_callModelStatic('LuckySymbol', 'hasLuckySymbol'); } $heroDb = Hero::findByAccountId(myself()->_getAccountId(), $userInfo['hero_uniid']); if (!$heroDb) { @@ -416,6 +417,7 @@ class UserController extends BaseAuthedController { $userInfo['total_lucky'] = Hero::getAccountLuckyTemp(); $userInfo['admission_item_num'] = myself()->_getItemCount(900006, $userInfo); $userInfo['circuit_score'] = myself()->_callModelStatic('Circuit', 'getCurrentMyScore'); + $userInfo['has_lucky_symbol'] = myself()->_callModelStatic('LuckySymbol', 'hasLuckySymbol'); } $heroDb = Hero::findByAccountId(myself()->_getAccountId(), $userInfo['hero_uniid']); if (!$heroDb) { @@ -456,6 +458,7 @@ class UserController extends BaseAuthedController { $userInfo['total_lucky'] = Hero::getAccountLuckyTemp(); $userInfo['admission_item_num'] = myself()->_getItemCount(900006, $userInfo); $userInfo['circuit_score'] = myself()->_callModelStatic('Circuit', 'getCurrentMyScore'); + $userInfo['has_lucky_symbol'] = myself()->_callModelStatic('LuckySymbol', 'hasLuckySymbol'); } $heroDb = Hero::findByAccountId(myself()->_getAccountId(), $heroUniId); if (!$heroDb) { diff --git a/webapp/models/LuckySymbol.php b/webapp/models/LuckySymbol.php new file mode 100644 index 00000000..01cb3ef3 --- /dev/null +++ b/webapp/models/LuckySymbol.php @@ -0,0 +1,59 @@ +_getSelfMysql(), + 't_lucky_symbol', + array( + 'account_id' => myself()->_getAccountId(), + ) + ); + $has = empty($row) ? false : $row['in_use_num'] > 0; + return $has ? 1 : 0; + } + + public static function dec() + { + SqlHelper::update + (myself()->_getSelfMysql(), + 't_lucky_symbol', + array( + 'account_id' => myself()->_getAccountId(), + ), + array( + 'in_use_num' => 0, + 'modifytime' => myself()->_getNowTime(), + ) + ); + } + + public static function add() + { + SqlHelper::upsert + (myself()->_getSelfMysql(), + 't_lucky_symbol', + array( + 'account_id' => myself()->_getAccountId(), + ), + array( + 'in_use_num' => function () { return "in_use_num + 1";}, + 'modifytime' => myself()->_getNowTime(), + ), + array( + 'account_id' => myself()->_getAccountId(), + 'in_use_num' => 1, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + } + +} diff --git a/webapp/models/LuckySymbolRecord.php b/webapp/models/LuckySymbolRecord.php new file mode 100644 index 00000000..c81d7429 --- /dev/null +++ b/webapp/models/LuckySymbolRecord.php @@ -0,0 +1,43 @@ +_getSelfMysql(), + 't_lucky_symbol_record', + array( + 'account_id' => myself()->_getAccountId(), + 'room_uuid' => $roomUuid, + ) + ); + return $row; + } + + public static function add($roomUuid) + { + SqlHelper::upsert + (myself()->_getSelfMysql(), + 't_lucky_symbol_record', + array( + 'account_id' => myself()->_getAccountId(), + 'room_uuid' => $roomUuid, + ), + array( + ), + array( + 'account_id' => myself()->_getAccountId(), + 'room_uuid' => $roomUuid, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + } + +} diff --git a/webapp/services/StakingVipService.php b/webapp/services/StakingVipService.php index 56915cf2..68dbf11a 100644 --- a/webapp/services/StakingVipService.php +++ b/webapp/services/StakingVipService.php @@ -20,7 +20,7 @@ class StakingVipService extends BaseService myself()->_getMarketMysql(), 't_vip_user', array( - 'account_address' => $accountAddr, + 'account_address' => strtolower($accountAddr), ) );