[fix] Statistics

This commit is contained in:
Lkeme 2020-06-26 20:52:46 +08:00
parent 551f8f1f34
commit 746d75cf89
2 changed files with 21 additions and 3 deletions

View File

@ -169,7 +169,10 @@ class Statistics
$results = 0;
is_null($second_key) ? self::initKeyValue($target, $key) : self::initKeyValue($target, $key, 0, $second_key);
foreach ($target as $item) {
is_null($second_key) ? $results += intval($item[$key]) : $results += intval($item[$key][$second_key]);
$skip = is_null($second_key) ? isset($item[$key]) : $item[$key][$second_key];
if ($skip) {
is_null($second_key) ? $results += intval($item[$key]) : $results += intval($item[$key][$second_key]);
}
}
return $results;
}
@ -236,7 +239,18 @@ class Statistics
array_push($tr_list_profit, $td);
}
}
return [$tr_list_count, $tr_list_profit];
return [self::unique_arr($tr_list_count), self::unique_arr($tr_list_profit)];
}
/**
* @use 二维数组去重
* @param $result
* @return array
*/
private static function unique_arr(array $result): array
{
return array_unique($result, SORT_REGULAR);
}
/**

View File

@ -109,10 +109,14 @@ class StormRaffle extends BaseRaffle
for ($i = 1; $i < $num; $i++) {
$raw = Curl::post('app', $url, Sign::common($payload));
if (strpos((string)$raw, 'html') !== false) {
Log::notice(self::formatInfo($raffle['raffle_id'], $num, '由于触发哔哩哔哩安全风控策略,该次访问请求被拒绝'));
Log::notice(self::formatInfo($raffle['raffle_id'], $num, '触发哔哩哔哩安全风控策略(412)'));
break;
}
$de_raw = json_decode($raw, true);
// {"code":-412,"message":"请求被拦截","ttl":1,"data":null}
if ($de_raw['code'] == -412) {
Log::notice(self::formatInfo($raffle['raffle_id'], $num, '触发哔哩哔哩安全风控策略(-412)'));
}
if ($de_raw['code'] == 429 || $de_raw['code'] == -429) {
Log::notice(self::formatInfo($raffle['raffle_id'], $num, '节奏风暴未实名或异常验证码'));
break;