From a561a449d2ad5de2419ce06da0bc8f14b969baa0 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Wed, 9 Oct 2024 16:52:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E9=92=B1=E7=BD=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- doc/Activity.py | 8 +- doc/Bag.py | 17 ++- doc/SavingPot.py | 73 ++++++++++ sql/gamedb.sql | 18 +++ sql/gamedb2006_migrate_241001_01.sql | 11 ++ webapp/bootstrap/constant.php | 2 + .../controller/ActivityController.class.php | 4 +- webapp/controller/BagController.class.php | 71 ++++++++-- .../controller/BaseAuthedController.class.php | 5 + webapp/controller/HeroController.class.php | 3 + .../controller/SavingPotController.class.php | 128 +++++++++++++++++- webapp/models/Hero.php | 6 +- webapp/services/RoomBattleDataService.php | 2 +- 13 files changed, 320 insertions(+), 28 deletions(-) create mode 100644 doc/SavingPot.py diff --git a/doc/Activity.py b/doc/Activity.py index 14f12c98..6bf66e3e 100644 --- a/doc/Activity.py +++ b/doc/Activity.py @@ -35,10 +35,10 @@ class Activity(object): _common.RspHead(), ] },{ - 'name': 'getBindReward', + 'name': 'getBindRewardS', 'desc': '领取绑定奖励', 'group': 'Activity', - 'url': 'webapp/index.php?c=Activity&a=getBindReward', + 'surl': 'webapp/index.php?c=Activity&a=getBindRewardS', 'params': [ _common.ReqHead(), ], @@ -60,10 +60,10 @@ class Activity(object): ['!task_list',[_common.Mission()], '奖励信息'], ] },{ - 'name': 'commitInvitationTask', + 'name': 'commitInvitationTaskS', 'desc': '提交任务(领取奖励)', 'group': 'Activity', - 'url': 'webapp/index.php?c=Activity&a=commitInvitationTask', + 'surl': 'webapp/index.php?c=Activity&a=commitInvitationTaskS', 'params': [ _common.ReqHead(), ['mission_id', 0, '任务id'], diff --git a/doc/Bag.py b/doc/Bag.py index a74d6073..871153f5 100644 --- a/doc/Bag.py +++ b/doc/Bag.py @@ -26,7 +26,7 @@ class Bag(object): 'surl': 'webapp/index.php?c=Bag&a=useItemS', 'params': [ _common.ReqHead(), - ['item_uniid', 0, '道具唯一id'], + ['item_id', 0, '道具唯一id'], ['item_num', 0, '道具数量'], ['param1', '', '参数1(当使用的是改名卡时param1=新的角色名)'], ['param2', '', '参数2(当使用的是改名卡时param2=签名)'], @@ -37,6 +37,21 @@ class Bag(object): ['award', _common.Award(), '奖励信息'], ['property_chg', _common.PropertyChg(), '属性变更'], ] + },{ + 'name': 'openBoxByBindGoldS', + 'desc': '绑币开宝箱', + 'group': 'Bag', + 'surl': 'webapp/index.php?c=Bag&a=openBoxByBindGoldS', + 'params': [ + _common.ReqHead(), + ['item_id', 0, '道具唯一id'], + ['item_num', 0, '道具数量'], + ], + 'response': [ + _common.RspHead(), + ['award', _common.Award(), '奖励信息'], + ['property_chg', _common.PropertyChg(), '属性变更'], + ] }, { 'name': 'rename', diff --git a/doc/SavingPot.py b/doc/SavingPot.py new file mode 100644 index 00000000..ef4193c4 --- /dev/null +++ b/doc/SavingPot.py @@ -0,0 +1,73 @@ +# -*- coding: utf-8 -*- + +import _common + +class SavingPot(object): + + def __init__(self): + self.apis = [ + { + 'name': 'info', + 'desc': '存钱罐信息', + 'group': 'SavingPot', + 'url': 'webapp/index.php?c=SavingPot&a=info', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['!data', [Info()], '存钱罐信息'], + ] + },{ + 'name': 'smashOpenS', + 'desc': '砸开', + 'group': 'SavingPot', + 'surl': 'webapp/index.php?c=SavingPot&a=smashOpenS', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['award', _common.AwardItem(), '奖励'], + ['property_chg', _common.PropertyChg(), '属性变更'], + ] + },{ + 'name': 'drawGoldS', + 'desc': '取出', + 'group': 'SavingPot', + 'surl': 'webapp/index.php?c=SavingPot&a=drawGoldS', + 'params': [ + _common.ReqHead(), + ], + 'response': [ + _common.RspHead(), + ['award', _common.AwardItem(), '奖励'], + ['property_chg', _common.PropertyChg(), '属性变更'], + ] + },{ + 'name': 'getRecord', + 'desc': '获取记录', + 'group': 'SavingPot', + 'url': 'webapp/index.php?c=SavingPot&a=getRecord', + 'params': [ + _common.ReqHead(), + ['page', 0, '第几页数据'], + ], + 'response': [ + _common.RspHead(), + ['pagination', _common.Pagination(), '分页信息'], + ['!rows', [_common.InGameMallGoods()], '记录列表'] + ] + }, + + ] + + +class Info(object): + + def __init__(self): + self.fields = [ + ['bind_gold', 0, '绑定金币数'], + ['draw_state', 0, '1:今日已领取或砸开 0:反之'], + ['up_times', 0, '今日升阶次数'], + ] diff --git a/sql/gamedb.sql b/sql/gamedb.sql index 4835120d..2ed82841 100644 --- a/sql/gamedb.sql +++ b/sql/gamedb.sql @@ -2116,4 +2116,22 @@ CREATE TABLE `t_user_invitation_code_bind` ( PRIMARY KEY (`idx`), UNIQUE KEY `account_id` (`account_id`) ) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Table structure for table `t_user_bind_gold_record` +-- + +DROP TABLE IF EXISTS `t_user_bind_gold_record`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!40101 SET character_set_client = utf8 */; +CREATE TABLE `t_user_bind_gold_record` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', + `way` int(11) NOT NULL DEFAULT '0' COMMENT '1:draw 2:open', + `amount` 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`) +) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; /*!40101 SET character_set_client = @saved_cs_client */; \ No newline at end of file diff --git a/sql/gamedb2006_migrate_241001_01.sql b/sql/gamedb2006_migrate_241001_01.sql index 11bf203b..a9d1b65d 100644 --- a/sql/gamedb2006_migrate_241001_01.sql +++ b/sql/gamedb2006_migrate_241001_01.sql @@ -3,6 +3,17 @@ begin; alter table t_hero add column `gold_times` int(11) NOT NULL DEFAULT '0' COMMENT '打金次数'; alter table t_hero add column `gold_modifytime` int(11) NOT NULL DEFAULT '0' COMMENT '打金时间'; + +CREATE TABLE `t_user_bind_gold_record` ( + `idx` bigint NOT NULL AUTO_INCREMENT COMMENT '自增id', + `account_id` varchar(60) NOT NULL DEFAULT '' COMMENT '账号id(channel + "_" + gameid + "_" + openid)', + `way` int(11) NOT NULL DEFAULT '0' COMMENT '1:draw 2:open', + `amount` 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`) +) ENGINE=InnoDB AUTO_INCREMENT=10000 DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + insert into version (version) values(2024092401); commit; diff --git a/webapp/bootstrap/constant.php b/webapp/bootstrap/constant.php index 0d1b73f7..ec577b24 100644 --- a/webapp/bootstrap/constant.php +++ b/webapp/bootstrap/constant.php @@ -68,6 +68,8 @@ define('TN_DAILY_REFRESH_MISSION_TIMES', 9020); define('TN_DAILY_GOLD_MODE_BATTLE_TIMES', 9021); define('TN_DAILY_GATHER_GOLD', 9022); define('TN_DAILY_BIND_GOLD', 9023); +define('TN_DAILY_DRAW_BIND_GOLD_STATE', 9024); +define('TN_DAILY_TIER_N_HERO_TIMES', 9025); define('TN_WEEKLY_BEGIN', 10001); define('TN_WEEKLY_ACTIVE', 10002); diff --git a/webapp/controller/ActivityController.class.php b/webapp/controller/ActivityController.class.php index 96629bd8..2e0355b9 100644 --- a/webapp/controller/ActivityController.class.php +++ b/webapp/controller/ActivityController.class.php @@ -69,7 +69,7 @@ class ActivityController extends BaseAuthedController { $this->_rspOk(); } - public function getBindReward(){ + public function getBindRewardS(){ if (!UserInvitationCode::verifyAccountBind()){ $this->_rspErr(1, "Unbound user"); return; @@ -114,7 +114,7 @@ class ActivityController extends BaseAuthedController { )); } - public function commitInvitationTask(){ + public function commitInvitationTaskS(){ $missionId = getReqVal('mission_id', 0); $missionMeta = mt\Task::get($missionId); if (!$missionMeta) { diff --git a/webapp/controller/BagController.class.php b/webapp/controller/BagController.class.php index f000c29b..19635851 100644 --- a/webapp/controller/BagController.class.php +++ b/webapp/controller/BagController.class.php @@ -146,7 +146,20 @@ class BagController extends BaseAuthedController { $this->openTreasureBox($itemDb, $itemMeta, $itemNum); } else if ($itemMeta['type'] == mt\Item::BATTLE_REWARD_BOX) { myself()->_verifySwitch('bigEventBoxOpen'); - $this->openBattleBox($itemDb, $itemMeta, $itemNum); + $costItems = mt\Item::getUseCostItems($itemMeta); + if (count($costItems) > 0){ + foreach ($costItems as &$costItem){ + $costItem['item_num'] *= $itemNum; + } + $lackItem = null; + if (!$this->_hasEnoughItems($costItems, $lackItem)) { + $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); + return; + } + $this->_decItems($costItems); + + } + $this->openBattleBox($itemDb, $itemMeta, $itemNum,$costItems); } else { $this->_rspErr(4, 'The prop function has not been realized yet'); } @@ -385,18 +398,55 @@ class BagController extends BaseAuthedController { )); } - private function openBattleBox($itemDb,$itemMeta,$itemNum){ + public function openBoxByBindGoldS(){ + $itemId = getReqVal('item_id', 0); + $itemNum = getReqVal('item_num', 0); + + if ($itemNum < 0) { + $this->_rspErr(1, 'item_num must be greater than 0'); + return; + } + $itemDb = Bag::find($itemId); + if (!isset($itemDb) || $itemDb['item_num'] <= 0 || $itemDb['item_num']< $itemNum) { + $this->_rspErr(1, 'Not enough item'); + return; + } + $itemMeta = mt\Item::get($itemId); + if (!$itemMeta) { + $this->_rspErr(2, 'config error'); + return; + } + if ( $itemMeta['type'] != mt\Item::BATTLE_REWARD_BOX){ + $this->_rspErr(2, 'item error'); + return; + } $costItems = mt\Item::getUseCostItems($itemMeta); + $bindGold = 0; + $normal = \mt\Parameter::getVal('bind_to_normal',0); if (count($costItems) > 0){ - foreach ($costItems as &$costItem){ - $costItem['item_num'] *= $itemNum; - } - $lackItem = null; - if (!$this->_hasEnoughItems($costItems, $lackItem)) { - $this->_rspErr(3, $this->_getLackItemErrMsg($lackItem)); - return; + foreach ($costItems as $costItem){ + $bindGold = $costItem['item_num'] / $normal; } } + + $totalBindGold = $bindGold * $itemNum; + $myBindGold = $this->_getDailyV(TN_DAILY_BIND_GOLD, 0); + if ($totalBindGold > $myBindGold){ + $this->_rspErr(3, 'piggy bank Not enough'); + return; + } + $costItems = array( + array( + 'item_id' => V_ITEM_BIND_GOLD, + 'item_num' => $totalBindGold + ) + ); + $this->_decItems($costItems); + $this->openBattleBox($itemDb,$itemMeta,$itemNum,$costItems); + } + + private function openBattleBox($itemDb,$itemMeta,$itemNum,$costItems){ + if ($itemMeta['quality'] > 3){ $maxCec = \mt\Parameter::getVal('CEC_ServerDailyLootMax_Special',1500); $nameIndex = RealtimeData::CEC_NAME_INDEX2; @@ -429,9 +479,6 @@ class BagController extends BaseAuthedController { $hashItems[$item['item_id']] = $item; } } - if (count($costItems) > 0){ - $this->_decItems($costItems); - } $this->_decItems(array( array( 'item_id' => $itemMeta['id'], diff --git a/webapp/controller/BaseAuthedController.class.php b/webapp/controller/BaseAuthedController.class.php index 4f9f0e23..76449fec 100644 --- a/webapp/controller/BaseAuthedController.class.php +++ b/webapp/controller/BaseAuthedController.class.php @@ -500,6 +500,11 @@ class BaseAuthedController extends BaseController { )); } break; + case V_ITEM_BIND_GOLD: + { + $this->_decDailyV(TN_DAILY_BIND_GOLD, 0,$itemNum); + } + break; default: { } diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 564e2cb5..bc83034d 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -225,6 +225,9 @@ class HeroController extends BaseAuthedController { 'unseal_time' => $unseal_time_new, 'wealth_attr' => json_encode($attribute), ); + if ($heroDb['quality'] == 1){ + $this->_incDailyV(TN_DAILY_DRAW_BIND_GOLD_STATE, 0,1); + } if ($heroDb['quality'] + 1 > 4){ $randAttr = emptyReplace(json_decode($heroDb['rand_attr'], true), array()); $basicMeta = mt\BattleBasicAttribute::get($heroDb['hero_id']); diff --git a/webapp/controller/SavingPotController.class.php b/webapp/controller/SavingPotController.class.php index 2ef6f2db..8c0c3e1d 100644 --- a/webapp/controller/SavingPotController.class.php +++ b/webapp/controller/SavingPotController.class.php @@ -1,19 +1,137 @@ $this->_getDailyV(TN_DAILY_BIND_GOLD, 0), + 'draw_state' => $this->_getDailyV(TN_DAILY_DRAW_BIND_GOLD_STATE, 0), + 'up_times' => $this->_getDailyV(TN_DAILY_TIER_N_HERO_TIMES, 0), + ); + $this->_rspData(array( + 'data' => $info + )); + } + + public function smashOpenS(){ + $state = $this->_getDailyV(TN_DAILY_DRAW_BIND_GOLD_STATE, 0); + if ($state > 0){ + $this->_rspErr(1, "Run out today"); + return; + } + $bindGold = $this->_getDailyV(TN_DAILY_BIND_GOLD, 0); + if ($bindGold <= 0){ + $this->_rspErr(1, "piggy bank empty"); + return; + } + $rateRange = \mt\Parameter::getListValue('saving_withdraw_rate_range',0); + $rate = rand($rateRange[0]*100,$rateRange[1]*100)/100; + $normal = \mt\Parameter::getVal('bind_to_normal',0); + $gold = max(1,floor($bindGold * $rate * $normal)); + $items = array( + array( + "item_id" => V_ITEM_GOLD, + "item_num" => $gold, + ) + ); + $propertyChgService = new services\PropertyChgService(); + $awardService = new services\AwardService(); + $this->_addItems($items, $awardService,$propertyChgService); + $this->_setDailyV(TN_DAILY_DRAW_BIND_GOLD_STATE, 0,1); + SqlHelper::insert + (myself()->_getSelfMysql(), + 't_user_bind_gold_record', + array( + 'account_id' => myself()->_getAccountId(), + 'way' => 2, + 'amount' => $gold, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + $this->_rspData(array( + 'award' => $awardService->toDto(), + 'property_chg' => $propertyChgService->toDto(), + )); + } + + public function drawGoldS(){ + $state = $this->_getDailyV(TN_DAILY_DRAW_BIND_GOLD_STATE, 0); + if ($state > 0){ + $this->_rspErr(1, "Run out today"); + return; + } + $bindGold = $this->_getDailyV(TN_DAILY_BIND_GOLD, 0); + if ($bindGold <= 0){ + $this->_rspErr(1, "piggy bank empty"); + return; + } + $upTimes = $this->_getDailyV(TN_DAILY_TIER_N_HERO_TIMES, 0); + if ($upTimes < 1){ + $this->_rspErr(1, "No completion condition"); + return; + } + $normal = \mt\Parameter::getVal('bind_to_normal',0); + $gold = max(1,floor($bindGold * $normal)); + $items = array( + array( + "item_id" => V_ITEM_GOLD, + "item_num" => $gold, + ) + ); + $propertyChgService = new services\PropertyChgService(); + $awardService = new services\AwardService(); + $this->_addItems($items, $awardService,$propertyChgService); + $this->_setDailyV(TN_DAILY_DRAW_BIND_GOLD_STATE, 0,1); + SqlHelper::insert + (myself()->_getSelfMysql(), + 't_user_bind_gold_record', + array( + 'account_id' => myself()->_getAccountId(), + 'way' => 1, + 'amount' => $gold, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime(), + ) + ); + $this->_rspData(array( + 'award' => $awardService->toDto(), + 'property_chg' => $propertyChgService->toDto(), + )); + } + + public function getRecord(){ + $page = getReqVal('page', 0); + $out = array( + 'pagination' => array(), + 'rows' => array() + ); + SqlHelper::rawQueryPage( + myself()->_getSelfMysql(), + 'SELECT * FROM t_user_bind_gold_record ', + array(), + array( + 'page' => $page, + 'perPage' => 8, + 'orderBy' => "ORDER BY createtime DESC", + 'handle' => function ($row) use(&$out) { + array_push($out['rows'], $row); + } + ), + $out['pagination'] + ); + myself()->_rspData($out); } } \ No newline at end of file diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index 954501ea..1c33d0a3 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -221,7 +221,7 @@ class Hero extends BaseModel { 'valid_time' => max(0, 86400 * $heroAtteMeta['validTime']), 'is_old' => $row['is_old'], - "current_times" => myself()->_getDailyV(TN_DAILY_GOLD_MODE_BATTLE_TIMES,$row['idx']), + "current_times" => self::getDailyV($row['idx']), "total_times" => $heroAtteMeta['roundPerDay'], 'activate' => $row['activate'], ); @@ -322,7 +322,7 @@ class Hero extends BaseModel { 'valid_time' => max(0, 86400 * $heroAtteMeta['validTime']), 'is_old' => $row['is_old'], - "current_times" => myself()->_getDailyV(TN_DAILY_GOLD_MODE_BATTLE_TIMES,$row['idx']), + "current_times" => self::getDailyV($row['idx']), "total_times" => $heroAtteMeta['roundPerDay'], 'activate' => $row['activate'], ); @@ -368,7 +368,7 @@ class Hero extends BaseModel { 'ability' => self::abilityInfo($row), 'valid_time' => max(0, 86400 * $heroAtteMeta['validTime']), - "current_times" => myself()->_getDailyV(TN_DAILY_GOLD_MODE_BATTLE_TIMES,$row['idx']), + "current_times" => self::getDailyV($row['idx']), "total_times" => $heroAtteMeta['roundPerDay'], ); } diff --git a/webapp/services/RoomBattleDataService.php b/webapp/services/RoomBattleDataService.php index 804b43ed..654753c6 100644 --- a/webapp/services/RoomBattleDataService.php +++ b/webapp/services/RoomBattleDataService.php @@ -301,7 +301,7 @@ class RoomBattleDataService extends BaseService { } } }else{ - if ($heroTimes < 3 && $goldModeTimes < $rewardsMaxTimes){ + if ($heroTimes < $heroTimesMax && $goldModeTimes < $rewardsMaxTimes){ $items = LootService::dropOutItem($rewardMeta['boundGoldLoot']); foreach ($items as $item){ if ($item['item_id'] = V_ITEM_BIND_GOLD){