_rspErr(1, 'hero_id参数错误'); return; } if (empty($heroMeta['itemid'])) { $this->_rspErr(2, 'hero.item_id配置错误'); return; } if (!in_array($buyType, array(0, 1))) { $this->_rspErr(1, 'buy_type参数错误'); return; } $shopMeta = mt\Shop::get(mt\Shop::HERO_SHOP_ID); if (!$shopMeta) { $this->_rspErr(2, '配置表错误1'); return; } $goodsInfo = mt\Shop::getGoodsInfo($shopMeta, $heroMeta['itemid']); if (empty($goodsInfo)) { $this->_rspErr(2, '配置表错误2'); return; } if (Hero::find($heroId)) { $this->_rspErr(3, '你已经有该英雄'); return; } $costItems = array( 'item_id' => $goodsInfo['costItemId'], 'item_num' => $goodsInfo['costItemNum'], ); $lackItem = null; if (!$this->_hasEnoughItems($costItems, $lackItem)) { $this->_rspErr(3, '道具不足'); return; } $this->_decItems($costItems); Hero::addHero($heroMeta); $awardService = new services\AwardService(); $heroDb = Hero::find($heroId); if ($heroDb) { $awardService->addHero(Hero::toDto($heroDb)); } $this->rspData(array( 'award' => $awardService->toData() )); } public function outsideBuy() { } public function getOutsidePriceInfo() { $items = array(); { $types = array(mt\Item::HERO_TYPE, mt\Item::HERO_SKIN_TYPE, mt\Item::GUN_SKIN_TYPE); mt\Item::filter(function ($meta) use(&$items, &$types) { if (in_array($meta['type'], $types)) { array_push($items, $meta); } return true; }); } $priceList = array(); array_walk($items, function ($val) use(&$priceList) { array_push($priceList, mt\Item::getPriceInfo($val)); }); $this->_rspData(array( 'price_list' => $priceList )); } }