This commit is contained in:
songliang 2023-06-29 14:41:37 +08:00
parent bd501f9356
commit a3c3a9ffc6
3 changed files with 39 additions and 4 deletions

View File

@ -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], '宝箱物品列表'],
]
},
]

View File

@ -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()

View File

@ -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;