1
This commit is contained in:
parent
46028a3aaa
commit
d2c5cb2481
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user