2026-06-15 22:42:59 +08:00
|
|
|
<?php
|
2026-06-16 04:58:56 +08:00
|
|
|
require_once __DIR__ . '/CloakJudgmentCache.php';
|
2026-06-15 22:42:59 +08:00
|
|
|
|
|
|
|
|
/**
|
2026-06-16 04:58:56 +08:00
|
|
|
* 二次风控缓存薄封装(委托 CloakJudgmentCache,保持既有调用点兼容)。
|
2026-06-15 22:42:59 +08:00
|
|
|
*/
|
|
|
|
|
class RiskSecondaryCache
|
|
|
|
|
{
|
2026-06-16 04:58:56 +08:00
|
|
|
const SESSION_KEY = 'cloak_judgment_cache';
|
2026-06-15 22:42:59 +08:00
|
|
|
|
|
|
|
|
/**
|
2026-06-16 04:58:56 +08:00
|
|
|
* @param array{result:string,reason?:string,fp_url?:string,ip?:string,country?:string} $payload
|
2026-06-15 22:42:59 +08:00
|
|
|
*/
|
|
|
|
|
public static function store(array $payload)
|
|
|
|
|
{
|
2026-06-16 04:58:56 +08:00
|
|
|
CloakJudgmentCache::storeFromByApiRisk($payload);
|
2026-06-15 22:42:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2026-06-16 04:58:56 +08:00
|
|
|
* 仅返回最终缓存(partial 不视为命中)。
|
|
|
|
|
*
|
|
|
|
|
* @param string|null $currentIp
|
2026-06-15 22:42:59 +08:00
|
|
|
* @return array|null
|
|
|
|
|
*/
|
|
|
|
|
public static function get($currentIp = null)
|
|
|
|
|
{
|
2026-06-16 04:58:56 +08:00
|
|
|
return CloakJudgmentCache::getFinal($currentIp);
|
2026-06-15 22:42:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function clear()
|
|
|
|
|
{
|
2026-06-16 04:58:56 +08:00
|
|
|
CloakJudgmentCache::clear();
|
2026-06-15 22:42:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param array $cached
|
|
|
|
|
*/
|
|
|
|
|
public static function applyToSession(array $cached)
|
|
|
|
|
{
|
2026-06-16 04:58:56 +08:00
|
|
|
CloakJudgmentCache::applyToSession($cached);
|
2026-06-15 22:42:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static function hitReason()
|
|
|
|
|
{
|
2026-06-16 04:58:56 +08:00
|
|
|
return CloakJudgmentCache::hitReason();
|
2026-06-15 22:42:59 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @param array $cached
|
|
|
|
|
* @return array{result:bool,reason:string,link:string}
|
|
|
|
|
*/
|
|
|
|
|
public static function toApiResponse(array $cached)
|
|
|
|
|
{
|
2026-06-16 04:58:56 +08:00
|
|
|
return CloakJudgmentCache::toApiResponse($cached);
|
2026-06-15 22:42:59 +08:00
|
|
|
}
|
|
|
|
|
}
|