diff --git a/doc/Shop.py b/doc/Shop.py index e7cc26bc..622d90a9 100644 --- a/doc/Shop.py +++ b/doc/Shop.py @@ -232,5 +232,20 @@ class Shop(object): _common.RspHead(), ['!result', [_common.BlindBoxResult()], '盲盒结果列表'], ] - } + }, + { + 'name': 'getChestItems', + 'desc': '获取宝箱可能出现的物品列表', + 'group': 'Shop', + 'url': 'webapp/index.php?c=Shop&a=getChestItems', + 'params': [ + _common.ReqHead(), + ['goods_id', 0, '宝箱物品id item_id'], + ], + 'response': [ + _common.RspHead(), + ['!items', [0], '宝箱物品列表'], + ] + }, + ] diff --git a/webapp/controller/ShopController.class.php b/webapp/controller/ShopController.class.php index dae2a03d..96778349 100644 --- a/webapp/controller/ShopController.class.php +++ b/webapp/controller/ShopController.class.php @@ -1233,14 +1233,32 @@ class ShopController extends BaseAuthedController { $goods_id = getReqVal('goods_id', 0); - if ($goods_id < 900001 || $goods_id > 900004) { + $meta = mt\Item::get($goods_id); + if ($meta['type'] != mt\Item::CHEST_BOX_TYPE) { $this->_rspErr(2, 'goods_id is invalid'); return; } - - $meta = mt\Item::get($goods_id); $chestType = $meta['sub_type']; $itemStore = mt\ShopChest::getRandomItemListByChestType($chestType); + $record = array(); + foreach ($itemStore as $key => $value) { + foreach ($value as $k => $v) { + $record[$v['item_id']] += 1; + } + } + + error_log("getChestItems start " . json_encode( + array( + 'goods_id' => $goods_id, + 'items' => array_keys($record), + ) + )); + + $this->_rspData( + array( + 'items' => array_keys($record), + ) + ); } private function buyGoodsFree() diff --git a/webapp/mt/Item.php b/webapp/mt/Item.php index e88e82ad..61306b22 100644 --- a/webapp/mt/Item.php +++ b/webapp/mt/Item.php @@ -97,6 +97,8 @@ class Item { const EMOJI_TYPE = 20; const RANDOM_BOX_TYPE = 21; + const CHEST_BOX_TYPE = 23; + const FUNC_RENAME_CARD_SUBTYPE = 1; const MATERIAL_CHIP_SUBTYPE = 3; const DRUG_TILI_SUBTYPE = 4;