This commit is contained in:
aozhiwei 2024-10-14 11:15:39 +08:00
parent 23e6ae1e4c
commit a3c7ba330b
2 changed files with 25 additions and 2 deletions

View File

@ -48,6 +48,26 @@ class ShopGoods
return getXVal($shopData['goodsHash'], $goodsId, null);
}
public static function getRandDailyHeroGoodsIds($shopId, $num)
{
$goodsMetaList = self::getGoodsList($shopId);
$goodsIds = array();
foreach ($goodsMetaList as $goodsMeta) {
if ($goodsMeta['is_close']) {
continue;
}
array_push($goodsIds, $goodsMeta['goods_id']);
}
shuffle($goodsIds);
$result = array();
for ($i = 0; $i < $num; ++$i) {
if ($i < count($goodIds)) {
array_push($result, $goodsIds[$i]);
}
}
return $result;
}
protected static function mustBeShopGoodsHash()
{
if (!self::$shopGoodsHash) {

View File

@ -165,9 +165,12 @@ class ShopService {
return self::$dailyHeroHash[myself()->_getAccountId()];
}
$r = myself()->_getSelfRedis();
$data = $r->get('shop.daily.shop:' . myself()->_getAccountId());
$key = 'shop.daily.shop:' . myself()->_getAccountId();
$data = $r->get($key);
if (empty($data)) {
$num = myself()->_callMtStatic('Parameter', 'getByName', 'SHOP_TYPE2_SLOT');
$data = mt\ShopGoods::getRandDailyHeroGoodsIds(mt\Shop::DAILY_HERO_SHOP, min(50, $num));
$r->setPx($key, json_encode($data), 1000 * 3600 * 24);
} else {
$data = json_decode($data, true);
}