From d2c5cb248148c40d4c17b0b8b252d63f26812262 Mon Sep 17 00:00:00 2001 From: aozhiwei Date: Mon, 29 Nov 2021 11:02:57 +0800 Subject: [PATCH] 1 --- webapp/controller/ShopController.class.php | 11 +++++++---- webapp/mt/Shop.php | 12 ++++++++---- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index 049bd9f..4ed163f 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -6,9 +6,12 @@ require_once('mt/Item.php'); require_once('mt/Parameter.php'); require_once('mt/Drop.php'); +require_once('models/Hero.php'); + require_once('services/AwardService.php'); use phpcommon\SqlHelper; +use models\Hero; class ShopController extends BaseAuthedController { @@ -17,7 +20,7 @@ class ShopController extends BaseAuthedController { $heroId = getReqVal('hero_id', 0); $buyType = getReqVal('buy_type', 0); $heroMeta = mt\Hero::get($heroId); - if ($heroMeta) { + if (!$heroMeta) { $this->_rspErr(1, 'hero_id参数错误'); return; } @@ -31,12 +34,12 @@ class ShopController extends BaseAuthedController { } $shopMeta = mt\Shop::get(mt\Shop::HERO_SHOP_ID); if (!$shopMeta) { - $this->_rspErr(2, '配置表错误'); + $this->_rspErr(2, '配置表错误1'); return; } $goodsInfo = mt\Shop::getGoodsInfo($shopMeta, $heroMeta['itemid']); if (empty($goodsInfo)) { - $this->_rspErr(2, '配置表错误'); + $this->_rspErr(2, '配置表错误2'); return; } if (Hero::find($heroId)) { @@ -48,7 +51,7 @@ class ShopController extends BaseAuthedController { 'item_num' => $goodsInfo['costItemNum'], ); $lackItem = null; - if (!$this->_hasEnoughItemsEx($costItems, $lackItem)) { + if (!$this->_hasEnoughItems($costItems, $lackItem)) { $this->_rspErr(3, '道具不足'); return; } diff --git a/webapp/mt/Shop.php b/webapp/mt/Shop.php index 29fef77..ecde5dd 100644 --- a/webapp/mt/Shop.php +++ b/webapp/mt/Shop.php @@ -7,10 +7,13 @@ use phpcommon; class Shop { const HERO_SHOP_ID = 1; + const HEROSKIN_SHOP_ID = 2; + const GUNSKIN1_SHOP_ID = 3; + const GUNSKIN2_SHOP_ID = 4; public static function get($id) { - getXVal(self::getMetaList(), $id); + return getXVal(self::getMetaList(), $id); } public static function getGoodsInfo($meta, $goodsId) @@ -18,13 +21,14 @@ class Shop { $goodsStrArr = explode("|", $meta['goods']); $priceStrArr = explode("|", $meta['price']); if (count($goodsStrArr) != count($priceStrArr)) { + echo '111'; return null; } $idx = -1; { $i = 0; array_filter($goodsStrArr, function($str) use(&$i, &$idx, $goodsId) { - if ($idx != -1) { + if ($idx == -1) { $strArr = explode(":", $str); if (count($strArr) >= 2) { if ($strArr[0] == $goodsId) { @@ -37,7 +41,7 @@ class Shop { return false; }); } - if ($idx <= 0) { + if ($idx < 0) { return null; } $info = array( @@ -65,7 +69,7 @@ class Shop { protected static function getMetaList() { if (!self::$metaList) { - self::$meta = getMetaTable('newshop@newshop.php'); + self::$metaList = getMetaTable('newshop@newshop.php'); } return self::$metaList; }