diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index ac88fe74..19932e6c 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -62,7 +62,7 @@ class ShopController extends BaseAuthedController { public function buyGoods() { - $goodsUuid = getReqVal('goods_uuid', 0); + $goodsUuid = getReqVal('goods_id', 0); $tokenType = getReqVal('token_type', ''); $goodsNum = getReqVal('goods_num', 0); @@ -246,7 +246,7 @@ class ShopController extends BaseAuthedController { public function inappPurchase() { - $goodsUuid = getReqVal('goods_uuid', 0); + $goodsUuid = getReqVal('goods_id', 0); $goodsNum = getReqVal('goods_num', 0); $goods = mt\ShopGoods::getByGoodsUuid($goodsUuid); if (!$goods) { @@ -310,17 +310,20 @@ class ShopController extends BaseAuthedController { public function boxPreview() { - $id = getReqVal('id', 0); - $goods = mt\ShopGoods::get($id); $goodsId = $goods['goods_id']; - $shopId = $goods['shop_id']; - $meta = mt\Item::get($goodsId); - if ($meta['type'] != mt\Item::CHEST_BOX_TYPE) { + $goodsMeta = mt\ShopGoods::get($goodsId); + if (!$goodsMeta) { + myself()->_rspErr(1, 'goods not found'); + return; + } + + $itemMeta = mt\Item::get($goodsMeta['item_id']); + if ($itemMeta['type'] != mt\Item::CHEST_BOX_TYPE) { $this->_rspErr(2, 'goods_id is invalid'); return; } - $chestType = $meta['sub_type']; + $chestType = $itemMeta['sub_type']; $itemStore = mt\ShopChest::getRandomItemListByChestType($chestType); if (!$itemStore) { $this->_rspErr(2, 'goods_id is invalid'); @@ -343,11 +346,11 @@ class ShopController extends BaseAuthedController { $goods['free_num'] = 0; } - $free_num = $goods['free_num']; + $freeNum = $goods['free_num']; $this->_rspData( array( 'items' => array_keys($record), - 'free_num' => $free_num, + 'free_num' => $freeNum, ) ); } diff --git a/webapp/services/ShopService.php b/webapp/services/ShopService.php index 08cdbd3a..b926d30a 100644 --- a/webapp/services/ShopService.php +++ b/webapp/services/ShopService.php @@ -33,6 +33,7 @@ class ShopService { $goodsList = array(); foreach ($goodsMetaList as $goodsMeta) { $goodsDto = array( + 'goods_id' => $goodsMeta['goods_id'], 'goods_meta' => self::goodsMetaToInfo($goodsMeta), 'bought_times' => 0, 'free_num' => 0,