From 3b9c5598548401ccc2315bf6d51aed2df6272f35 Mon Sep 17 00:00:00 2001 From: hujiabin <519660157@qq.com> Date: Fri, 14 Jul 2023 16:15:45 +0800 Subject: [PATCH] 1 --- webapp/controller/HeroController.class.php | 22 +++++++++++++++++++++- webapp/models/HeroSkin.php | 13 ++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/webapp/controller/HeroController.class.php b/webapp/controller/HeroController.class.php index 24e82621..dbb56b03 100644 --- a/webapp/controller/HeroController.class.php +++ b/webapp/controller/HeroController.class.php @@ -36,6 +36,25 @@ use services\LogService; class HeroController extends BaseAuthedController { + public function test(){ + $heroUniId = getReqVal('hero_uniid', 0); + $heroDb = Hero::find($heroUniId); + if (!$heroDb) { + $this->_rspErr(100, 'param error or null'); + return; + } + if ($heroDb['hero_lv'] == 15){ + $this->_rspErr(100, 'param error or null'); + return; + } + $attrs = Hero::LvUpAddAttr($heroDb); + Hero::update($heroUniId, array( + 'hero_lv' => $heroDb['hero_lv'] + 1, + 'rand_attr' => json_encode($attrs['rand_attr']), + 'base_attr' => json_encode($attrs['base_attr']), + )); + } + public function heroList() { $heroList = array(); @@ -111,7 +130,8 @@ class HeroController extends BaseAuthedController { $this->_rspErr(1, "You don't have the hero yet"); return; } - if (!$heroSkinDb) { + $itemMeta = \mt\Item::get($skinId); + if ($itemMeta['isdefaultskin'] != 1 && !$heroSkinDb) { $this->_rspErr(2, "You don't have the skin yet"); return; } diff --git a/webapp/models/HeroSkin.php b/webapp/models/HeroSkin.php index 2d17a189..5cb12459 100644 --- a/webapp/models/HeroSkin.php +++ b/webapp/models/HeroSkin.php @@ -63,7 +63,7 @@ class HeroSkin extends BaseModel { 'hero_id'=>0 ) ); - SqlHelper::update( + SqlHelper::upsert( myself()->_getSelfMysql(), 't_hero_skin', array( @@ -72,6 +72,17 @@ class HeroSkin extends BaseModel { ), array( 'hero_id'=>$heroId + ), + array( + 'account_id' => myself()->_getAccountId(), + 'skin_id' => $skinId, + 'skin_state' => 0, + 'get_from' => 0, + 'consume_num' => 0, + 'try_expire_at' => 0, + 'hero_id' => $heroId, + 'createtime' => myself()->_getNowTime(), + 'modifytime' => myself()->_getNowTime() ) ); }