From d1c7241a05a4782eebd3e885ffb0a12273faacef Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Tue, 20 Jun 2023 16:37:20 +0800 Subject: [PATCH] 1 --- webapp/controller/BattleController.class.php | 7 + .../controller/CallbackController.class.php | 2 +- webapp/models/Chip.php | 18 +- webapp/models/Gun.php | 8 +- webapp/models/Hero.php | 2 +- ...temMallBuyOk.php => GameItemMallBuyOk.php} | 2 +- .../services/callback/ShopAddItemService.php | 204 ++++++++++++++++++ 7 files changed, 216 insertions(+), 27 deletions(-) rename webapp/services/callback/{gameItemMallBuyOk.php => GameItemMallBuyOk.php} (98%) create mode 100644 webapp/services/callback/ShopAddItemService.php diff --git a/webapp/controller/BattleController.class.php b/webapp/controller/BattleController.class.php index 038a6f75..f6f897ed 100644 --- a/webapp/controller/BattleController.class.php +++ b/webapp/controller/BattleController.class.php @@ -11,6 +11,7 @@ require_once('models/BattleHistory.php'); require_once('models/User.php'); require_once('models/Parachute.php'); require_once('models/ChipPage.php'); +require_once('models/Battle.php'); require_once('services/BattleDataService.php'); require_once('services/TameBattleDataService.php'); require_once('services/FormulaService.php'); @@ -27,6 +28,7 @@ use models\BattleSettlement; use models\User; use models\Parachute; use models\ChipPage; +use models\Battle; class BattleController extends BaseAuthedController { @@ -240,6 +242,7 @@ class BattleController extends BaseAuthedController { 'hero_skin' => '', 'skill_id' => '', 'chip_page' => array(), + 'battle_times' => '', 'hero_dto' => '', 'weapon_dto1' => '', @@ -269,6 +272,10 @@ class BattleController extends BaseAuthedController { $info['weapon_uuid2'] = $userPresetInfo['presetInfo']['weapon_uid2']; $chipPageDb = ChipPage::find($userPresetInfo['presetInfo']['chip_page']); $info['chip_page'] = ChipPage::toDtoBattle($chipPageDb); + $battleDb = Battle::find($account_id); + $battleData = json_decode($battleDb['battle_data'], true); + $seasonBattleData = isset($battleData) ? getXVal($battleData, 'data', array()) : array(); + $info['battle_times'] = getXVal($seasonBattleData, 'total_battle_times', 0); }else{ $info['errcode'] = 51; diff --git a/webapp/controller/CallbackController.class.php b/webapp/controller/CallbackController.class.php index 3b509cc9..66287634 100644 --- a/webapp/controller/CallbackController.class.php +++ b/webapp/controller/CallbackController.class.php @@ -3,7 +3,7 @@ class CallbackController extends BaseController { private $handlers = array( - 'gameItemMallBuyOk' => 'gameItemMallBuyOk', + 'gameItemMallBuyOk' => 'GameItemMallBuyOk', ); public function dispatch() diff --git a/webapp/models/Chip.php b/webapp/models/Chip.php index 5ab4a3de..b476614f 100644 --- a/webapp/models/Chip.php +++ b/webapp/models/Chip.php @@ -231,23 +231,7 @@ class Chip extends BaseModel public static function internalAddItem($conn, $itemMeta, $accountId, $tokenId,$state) { - if (!$itemMeta) { - return; - } - if (myself()->_isVirtualItem($itemMeta['id'])) { - return; - } - $chipMeta = ChipAttr::getAttrByItemId($itemMeta['id']); - if (!$chipMeta){ - return; - } -// $randAttr = array(); -// if (mt\Item::isRoleChipItem($itemMeta)) { -// $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$grade); -// } -// if (mt\Item::isGunChipItem($itemMeta)) { -// $randAttr = mt\ChipAttr::generateAttrRandom($itemMeta,$grade); -// } + $randAttr = array(); $fieldsKv = array( 'item_id' => $itemMeta['id'], diff --git a/webapp/models/Gun.php b/webapp/models/Gun.php index ba32a7cd..45c2f18e 100644 --- a/webapp/models/Gun.php +++ b/webapp/models/Gun.php @@ -329,18 +329,12 @@ class Gun extends BaseModel { private static function internalAddGun($conn, $gunMeta, $accountId, $tokenId,$state) { $randAttr = array(); - { - $initQualityMeta = mt\GunQuality::getByQuality(1); - if ($initQualityMeta) { - $randAttr = mt\GunQuality::getRandAttr($initQualityMeta); - } - } $fieldsKv = array( 'gun_id' => $gunMeta['id'], 'gun_lv' => 1, 'quality' => 1, 'state' => $state, - 'durability' => FormulaService::Weapon_NFT_Maximum_Durability(1,FormulaService::Weapon_Advanced_Lucky_Value(1)), +// 'durability' => FormulaService::Weapon_NFT_Maximum_Durability(1,FormulaService::Weapon_Advanced_Lucky_Value(1)), 'rand_attr' => json_encode($randAttr), 'lock_type' => self::NO_LOCK, 'unlock_time' => 0, diff --git a/webapp/models/Hero.php b/webapp/models/Hero.php index a1a9caba..5146b4af 100644 --- a/webapp/models/Hero.php +++ b/webapp/models/Hero.php @@ -337,7 +337,7 @@ class Hero extends BaseModel { 'hero_id' => $heroMeta['id'], 'hero_lv' => 1, 'quality' => 1, - 'hero_tili' => FormulaService::Hero_NFT_Maximum_Physical_Strength(1,FormulaService::Hero_Advanced_Lucky_Value(1)), +// 'hero_tili' => FormulaService::Hero_NFT_Maximum_Physical_Strength(1,FormulaService::Hero_Advanced_Lucky_Value(1)), 'state' => $state, 'skill_lv1' => 1, 'skill_lv2' => 1, diff --git a/webapp/services/callback/gameItemMallBuyOk.php b/webapp/services/callback/GameItemMallBuyOk.php similarity index 98% rename from webapp/services/callback/gameItemMallBuyOk.php rename to webapp/services/callback/GameItemMallBuyOk.php index c5d6e2fd..3d85f7e6 100644 --- a/webapp/services/callback/gameItemMallBuyOk.php +++ b/webapp/services/callback/GameItemMallBuyOk.php @@ -8,7 +8,7 @@ require_once ('services/callback/BuyShopGoodsCbService.php'); use phpcommon\SqlHelper; -class gameItemMallBuyOk { +class GameItemMallBuyOk { public function process() { diff --git a/webapp/services/callback/ShopAddItemService.php b/webapp/services/callback/ShopAddItemService.php new file mode 100644 index 00000000..0bf95537 --- /dev/null +++ b/webapp/services/callback/ShopAddItemService.php @@ -0,0 +1,204 @@ +getAccountId($address); + $conn = myself()->_getMysql($address); + if (\mt\Item::isBagItem($itemMeta['type'], $itemMeta['sub_type'])) { + $this->internalAddBag($conn,$itemId,$itemNum,$accountId); + }else{ + for ($i = 0; $i < $itemNum; $i++) { + switch ($itemMeta['type']){ + case \mt\Item::HERO_TYPE : { + $this->internalAddHero($conn,$itemMeta,$accountId); + } + break; + case \mt\Item::GUN_TYPE : { + $this->internalAddGun($conn,$itemMeta,$accountId); + } + break; + case \mt\Item::CHIP_TYPE : { + $this->internalAddChip($conn,$itemMeta,$accountId); + } + break; + case \mt\Item::HERO_SKIN_TYPE : { + $this->internalAddHeroSkin($conn,$itemMeta,$accountId); + } + } + } + } + + + } + + private function getAccountId($address){ + + $row = SqlHelper::ormSelectOne + (myself()->_getMysql($address), + 't_user', + array( + 'address' => $address + ) + ); + + return $row['account_id']; + } + + private function internalAddHeroSkin($conn,$skinMeta,$accountId){ + + $heroId = 0; + if ($skinMeta['isdefaultskin'] == 1){ + $heroId = $skinMeta['playerid']; + } + SqlHelper::upsert( + $conn, + 't_hero_skin', + array( + 'account_id' => $accountId, + 'skin_id' => $skinMeta['id'] + ), + array(), + array( + 'account_id' => $accountId, + 'skin_id' => $skinMeta['id'], + 'skin_state' => 0, + 'get_from' => 0, + 'consume_num' => 0, + 'try_expire_at' => 0, + 'hero_id' => $heroId, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ) + ); + } + + private function internalAddHero($conn, $heroMeta, $accountId) + { + $skinItemMeta = \mt\Item::getMetaListByType(\mt\Item::HERO_SKIN_TYPE); + if ($skinItemMeta){ + foreach ($skinItemMeta as $value){ + if ($value['playerid'] == $heroMeta['id'] && $value['isdefaultskin'] == 1){ + $this->internalAddHeroSkin($conn,$value,$accountId); + } + } + } + $randAttr = array(); + $fieldsKv = array( + 'account_id' => $accountId, + 'hero_id' => $heroMeta['id'], + 'hero_lv' => 1, + 'quality' => 1, + 'state' => 0, + 'skill_lv1' => 1, + 'skill_lv2' => 1, + 'rand_attr' => json_encode($randAttr), + 'lock_type' => 0, + 'unlock_time' => 0, + 'unlock_trade_time' => 0, + 'activate' => 1, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ); + + SqlHelper::insert( + $conn, + 't_hero', + $fieldsKv + ); + } + + private function internalAddGun($conn, $gunMeta, $accountId) + { + $randAttr = array(); + $fieldsKv = array( + 'account_id' => $accountId, + 'gun_id' => $gunMeta['id'], + 'gun_lv' => 1, + 'quality' => 1, + 'state' => 0, + 'rand_attr' => json_encode($randAttr), + 'lock_type' => 0, + 'unlock_time' => 0, + 'unlock_trade_time' => 0, + 'activate' => 1, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ); + SqlHelper::insert( + $conn, + 't_gun', + $fieldsKv + ); + } + + private function internalAddChip($conn, $itemMeta, $accountId) + { + $randAttr = array(); + $fieldsKv = array( + 'account_id' => $accountId, + 'item_id' => $itemMeta['id'], + 'item_num' => 1, + 'state' => 0, + 'rand_attr' => json_encode($randAttr), + 'chip_grade' => 1, + 'chip_type' => $itemMeta['sub_type'], + 'activate' => 1, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ); + SqlHelper::insert + ($conn, + 't_chip', + $fieldsKv + ); + } + + private function internalAddBag($conn, $itemId, $itemNum, $accountId ) + { + if ($this->_isVirtualItem($itemId)) { + return; + } + SqlHelper::upsert + ($conn, + 't_bag', + array( + 'account_id' => $accountId, + 'item_id' => $itemId + ), + array( + 'item_num' => function () use($itemNum) { return "item_num + {$itemNum}";}, + 'modifytime' => myself()->_getNowTime(), + ), + array( + 'account_id' => $accountId, + 'item_id' => $itemId, + 'item_num' => $itemNum, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() + ) + ); + } + + private function _isVirtualItem($itemId) + { + return in_array($itemId, array(V_ITEM_GOLD, V_ITEM_DIAMOND, V_ITEM_EXP, V_ITEM_ACTIVE,V_ITEM_BCEG,V_ITEM_STAR)); + } + +} \ No newline at end of file